Commit db76c70e authored by Jakob Schöttl's avatar Jakob Schöttl
Browse files

Remove unncessary clone method and related tests

parent 3f189de9
......@@ -22,12 +22,4 @@ public abstract class Attributes extends DefaultSealable implements Cloneable {
public Attributes() {}
public Attributes cloneAttributes() {
try {
return (Attributes) super.clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException("This should never happen because the base class Attributes is Cloneable.");
}
}
}
package org.vadere.state.attributes;
import static org.junit.Assert.*;
import org.junit.Test;
public class TestAttributesCloneable {
private static class SimpleAttributes extends Attributes {
int id = 1;
}
private static class NestedAttributes extends Attributes {
int id = 1;
SimpleAttributes c = new SimpleAttributes();
SimpleCloneable d = new SimpleCloneable();
}
private static class SimpleCloneable implements Cloneable {
int id = 1;
}
private static class NotCloneableClass {
@Override
public Object clone() throws CloneNotSupportedException {
......@@ -27,30 +11,6 @@ public class TestAttributesCloneable {
}
}
@Test
public void testSimpleCloneable() {
try {
SimpleAttributes a = new SimpleAttributes();
SimpleAttributes b = (SimpleAttributes) a.cloneAttributes();
assertEquals(a.id, b.id);
} catch (Exception e) {
fail("clone should not throw exception");
}
}
@Test
public void testExtendedCloneable() {
try {
NestedAttributes a = new NestedAttributes();
NestedAttributes b = (NestedAttributes) a.cloneAttributes();
assertEquals(a.id, b.id);
assertEquals(a.c.id, b.c.id);
assertEquals(a.d.id, b.d.id);
} catch (Exception e) {
fail("clone should not throw exception");
}
}
@Test(expected=CloneNotSupportedException.class)
public void testNotCloneableClass() throws CloneNotSupportedException {
new NotCloneableClass().clone();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment