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