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