public class PlumNeedleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(PlumNeedleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public PlumNeedleTests(String name) { super(name); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { PlumNeedle n1 = new PlumNeedle(); PlumNeedle n2 = new PlumNeedle(); assertTrue(n1.equals(n2)); assertTrue(n2.equals(n1)); } /** * Check that cloning works. */ public void testCloning() { PlumNeedle n1 = new PlumNeedle(); PlumNeedle n2 = null; try { n2 = (PlumNeedle) n1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(n1 != n2); assertTrue(n1.getClass() == n2.getClass()); assertTrue(n1.equals(n2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { PlumNeedle n1 = new PlumNeedle(); PlumNeedle n2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(n1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); n2 = (PlumNeedle) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(n1.equals(n2))
public class ShipNeedleTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(ShipNeedleTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public ShipNeedleTests(String name) { super(name); } /** * Check that the equals() method can distinguish all fields. */ public void testEquals() { ShipNeedle n1 = new ShipNeedle(); ShipNeedle n2 = new ShipNeedle(); assertTrue(n1.equals(n2)); assertTrue(n2.equals(n1)); } /** * Check that cloning works. */ public void testCloning() { ShipNeedle n1 = new ShipNeedle(); ShipNeedle n2 = null; try { n2 = (ShipNeedle) n1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); System.err.println("Failed to clone."); } assertTrue(n1 != n2); assertTrue(n1.getClass() == n2.getClass()); assertTrue(n1.equals(n2)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { ShipNeedle n1 = new ShipNeedle(); ShipNeedle n2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(n1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); n2 = (ShipNeedle) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(n1.equals(n2))
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/needle/junit/PlumNeedleTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/needle/junit/ShipNeedleTests.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class PlumNeedleTests extends TestCase {
1
public class ShipNeedleTests extends TestCase {
2
    
3
    /**
2
    /**
4
     * Returns the tests as a test suite.
3
     * Returns the tests as a test suite.
5
     *
4
     *
6
     * @return The test suite.
5
     * @return The test suite.
7
     */
6
     */
8
    public static Test suite() {
7
    public static Test suite() {
9
        return new TestSuite(PlumNeedleTests.class);
8
        return new TestSuite(ShipNeedleTests.class);
10
    }
9
    }
11
    /**
10
    /**
12
     * Constructs a new set of tests.
11
     * Constructs a new set of tests.
13
     *
12
     *
14
     * @param name  the name of the tests.
13
     * @param name  the name of the tests.
15
     */
14
     */
16
    public PlumNeedleTests(String name) {
15
    public ShipNeedleTests(String name) {
17
        super(name);
16
        super(name);
18
    }
17
    }
19
    /**
18
    /**
20
     * Check that the equals() method can distinguish all fields.
19
     * Check that the equals() method can distinguish all fields.
21
     */
20
     */
22
    public void testEquals() {
21
    public void testEquals() {
23
       PlumNeedle n1 = new PlumNeedle();
22
       ShipNeedle n1 = new ShipNeedle();
24
       PlumNeedle n2 = new PlumNeedle();
23
       ShipNeedle n2 = new ShipNeedle();
25
       assertTrue(n1.equals(n2));
24
       assertTrue(n1.equals(n2));
26
       assertTrue(n2.equals(n1));
25
       assertTrue(n2.equals(n1));
27
    }
26
    }
28
    /**
27
    /**
29
     * Check that cloning works.
28
     * Check that cloning works.
30
     */
29
     */
31
    public void testCloning() {
30
    public void testCloning() {
32
        PlumNeedle n1 = new PlumNeedle();
31
        ShipNeedle n1 = new ShipNeedle();
33
        PlumNeedle n2 = null;
32
        ShipNeedle n2 = null;
34
        try {
33
        try {
35
            n2 = (PlumNeedle) n1.clone();
34
            n2 = (ShipNeedle) n1.clone();
36
        }
35
        }
37
        catch (CloneNotSupportedException e) {
36
        catch (CloneNotSupportedException e) {
38
            e.printStackTrace();
37
            e.printStackTrace();
39
            System.err.println("Failed to clone.");
38
            System.err.println("Failed to clone.");
40
        }
39
        }
41
        assertTrue(n1 != n2);
40
        assertTrue(n1 != n2);
42
        assertTrue(n1.getClass() == n2.getClass());
41
        assertTrue(n1.getClass() == n2.getClass());
43
        assertTrue(n1.equals(n2));
42
        assertTrue(n1.equals(n2));
44
    }
43
    }
45
    /**
44
    /**
46
     * Serialize an instance, restore it, and check for equality.
45
     * Serialize an instance, restore it, and check for equality.
47
     */
46
     */
48
    public void testSerialization() {
47
    public void testSerialization() {
49
        PlumNeedle n1 = new PlumNeedle();
48
        ShipNeedle n1 = new ShipNeedle();
50
        PlumNeedle n2 = null;
49
        ShipNeedle n2 = null;
51
        try {
50
        try {
52
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
51
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
53
            ObjectOutput out = new ObjectOutputStream(buffer);
52
            ObjectOutput out = new ObjectOutputStream(buffer);
54
            out.writeObject(n1);
53
            out.writeObject(n1);
55
            out.close();
54
            out.close();
56
            ObjectInput in = new ObjectInputStream(
55
            ObjectInput in = new ObjectInputStream(
57
                new ByteArrayInputStream(buffer.toByteArray())
56
                new ByteArrayInputStream(buffer.toByteArray())
58
            );
57
            );
59
            n2 = (PlumNeedle) in.readObject();
58
            n2 = (ShipNeedle) in.readObject();
60
            in.close();
59
            in.close();
61
        }
60
        }
62
        catch (Exception e) {
61
        catch (Exception e) {
63
            e.printStackTrace();
62
            e.printStackTrace();
64
        }
63
        }
65
        assertTrue(n1.equals(n2))
64
        assertTrue(n1.equals(n2))
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0