public class StandardDialRangeTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(StandardDialRangeTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public StandardDialRangeTests(String name) { super(name); } /** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { StandardDialRange r1 = new StandardDialRange(); StandardDialRange r2 = new StandardDialRange(); assertTrue(r1.equals(r2)); // lowerBound r1.setLowerBound(1.1); assertFalse(r1.equals(r2)); r2.setLowerBound(1.1); assertTrue(r1.equals(r2)); // upperBound r1.setUpperBound(11.1); assertFalse(r1.equals(r2)); r2.setUpperBound(11.1); assertTrue(r1.equals(r2)); // paint r1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertFalse(r1.equals(r2)); r2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); assertTrue(r1.equals(r2)); // check an inherited attribute r1.setVisible(false); assertFalse(r1.equals(r2)); r2.setVisible(false); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashCode() { StandardDialRange r1 = new StandardDialRange(); StandardDialRange r2 = new StandardDialRange(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { StandardDialRange r1 = new StandardDialRange(); StandardDialRange r2 = null; try { r2 = (StandardDialRange) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); r1.addChangeListener(l1); assertTrue(r1.hasListener(l1)); assertFalse(r2.hasListener(l1)); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { StandardDialRange r1 = new StandardDialRange(); StandardDialRange r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (StandardDialRange) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2)
public class GanttRendererTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(GanttRendererTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public GanttRendererTests(String name) { super(name); } /** * Check that the equals() method distinguishes all fields. */ public void testEquals() { GanttRenderer r1 = new GanttRenderer(); GanttRenderer r2 = new GanttRenderer(); assertEquals(r1, r2); r1.setCompletePaint(Color.yellow); assertFalse(r1.equals(r2)); r2.setCompletePaint(Color.yellow); assertTrue(r1.equals(r2)); r1.setIncompletePaint(Color.green); assertFalse(r1.equals(r2)); r2.setIncompletePaint(Color.green); assertTrue(r1.equals(r2)); r1.setStartPercent(0.11); assertFalse(r1.equals(r2)); r2.setStartPercent(0.11); assertTrue(r1.equals(r2)); r1.setEndPercent(0.88); assertFalse(r1.equals(r2)); r2.setEndPercent(0.88); assertTrue(r1.equals(r2)); } /** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { GanttRenderer r1 = new GanttRenderer(); GanttRenderer r2 = new GanttRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ public void testCloning() { GanttRenderer r1 = new GanttRenderer(); GanttRenderer r2 = null; try { r2 = (GanttRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2)); } /** * Check that this class implements PublicCloneable. */ public void testPublicCloneable() { GanttRenderer r1 = new GanttRenderer(); assertTrue(r1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { GanttRenderer r1 = new GanttRenderer(); r1.setCompletePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); r1.setIncompletePaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f, 1.0f, Color.blue)); GanttRenderer r2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); r2 = (GanttRenderer) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(r1, r2)
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/dial/junit/StandardDialRangeTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/category/junit/GanttRendererTests.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class StandardDialRangeTests extends TestCase {
1
public class GanttRendererTests 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(StandardDialRangeTests.class);
8
        return new TestSuite(GanttRendererTests.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 StandardDialRangeTests(String name) {
15
    public GanttRendererTests(String name) {
16
        super(name);
16
        super(name);
17
    }
17
    }
18
    /**
18
    /**
19
     * Confirm that the equals method can distinguish all the required fields.
19
     * Check that the equals() method distinguishes all fields.
20
     */
20
     */
21
    public void testEquals() {
21
    public void testEquals() {
22
        StandardDialRange r1 = new StandardDialRange();
22
        
23
        StandardDialRange
23
GanttRenderer r1 = new GanttRenderer();
24
 r2 = new StandardDialRange();
24
        GanttRenderer r2 = new GanttRenderer();
25
        assertTrue(r1.equals(r2));
25
        assertEquals(r1, r2);
26
        
27
        // lowerBound
28
        r1.setLowerBound(1.1
29
);
26
        r1.setCompletePaint(Color.yellow);
30
        assertFalse(r1.equals(r2));
27
        assertFalse(r1.equals(r2));
31
        r2.setLowerBound(1.1);
28
        r2.setCompletePaint(Color.yellow);
32
        assertTrue(r1.equals(r2));
29
        assertTrue(r1.equals(r2));
33
        
34
        // upperBound
35
        r1.setUpperBound(11.1
36
);
30
        r1.setIncompletePaint(Color.green);
37
        assertFalse(r1.equals(r2));
31
        assertFalse(r1.equals(r2));
38
        r2.setUpperBound(11.1);
32
        r2.setIncompletePaint(Color.green);
39
        assertTrue(r1.equals(r2));
33
        assertTrue(r1.equals(r2));
40
        
41
        // paint
42
        r1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, 
43
                Color.blue));
44
        assertFalse(r1.equals(r2));
45
        r2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, 
46
                Color.blue));
47
        assertTrue(r1.equals(r2));
48
        
49
        // check an inherited attribute
50
        r1.setVisible(false
34
        r1.setStartPercent(0.11);
35
        assertFalse(r1.equals(r2));
36
        r2.setStartPercent(0.11);
37
        assertTrue(r1.equals(r2));
51
);
38
        r1.setEndPercent(0.88);
52
        assertFalse(r1.equals(r2));
39
        assertFalse(r1.equals(r2));
53
        r2.setVisible(false);
40
        r2.setEndPercent(0.88);
54
        assertTrue(r1.equals(r2));
41
        assertTrue(r1.equals(r2));
55
    }
42
    }
56
    
57
    /**
43
    /**
58
     * Two objects that are equal are required to return the same hashCode. 
44
     * Two objects that are equal are required to return the same hashCode.
59
     */
45
     */
60
    public void testHashCode() {
46
    public void testHashcode() {
61
        StandardDialRange r1 = new StandardDialRange();
47
        GanttRenderer r1 = new GanttRenderer();
62
        StandardDialRange r2 = new StandardDialRange();
48
        GanttRenderer r2 = new GanttRenderer();
63
        assertTrue(r1.equals(r2));
49
        assertTrue(r1.equals(r2));
64
        int h1 = r1.hashCode();
50
        int h1 = r1.hashCode();
65
        int h2 = r2.hashCode();
51
        int h2 = r2.hashCode();
66
        assertEquals(h1, h2);
52
        assertEquals(h1, h2);
67
    }
53
    }
68
    /**
54
    /**
69
     * Confirm that cloning works.
55
     * Confirm that cloning works.
70
     */
56
     */
71
    public void testCloning() {
57
    public void testCloning() {
72
        StandardDialRange r1 = new StandardDialRange();
58
        GanttRenderer r1 = new GanttRenderer();
73
        StandardDialRange r2 = null;
59
        GanttRenderer r2 = null;
74
        try {
60
        try {
75
            r2 = (StandardDialRange) r1.clone();
61
            r2 = (GanttRenderer) r1.clone();
76
        }
62
        }
77
        catch (CloneNotSupportedException e) {
63
        catch (CloneNotSupportedException e) {
78
            e.printStackTrace();
64
            e.printStackTrace();
79
        }
65
        }
80
        assertTrue(r1 != r2);
66
        assertTrue(r1 != r2);
81
        assertTrue(r1.getClass() == r2.getClass());
67
        assertTrue(r1.getClass() == r2.getClass());
82
        assertTrue(r1.equals(r2));
68
        assertTrue(r1.equals(r2));
83
    
69
    }
84
    
70
    /**
85
        // check that the listener lists are independent
71
     * Check that th
86
        MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
87
        r1.addChangeList
72
is class implements PublicCloneable.
73
     */
74
    public void testPublicCloneable() {
88
ener(l1);
75
        GanttRender
89
        assertTrue(r1.hasListener(l1));
90
        assertFalse(r2.hasListener(l1)
76
er r1 = new GanttRenderer();
91
);
77
        assertTrue(r1 instanceof PublicCloneable);
92
    }
78
    }
93
    /**
79
    /**
94
     * Serialize an instance, restore it, and check for equality.
80
     * Serialize an instance, restore it, and check for equality.
95
     */
81
     */
96
    public void testSerialization() {
82
    public void testSerialization() {
97
        StandardDialRange r1 = new StandardDialRange();
83
        
98
        StandardDialRange
84
GanttRenderer r1 = new GanttRenderer();
85
        r1.setCompletePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f,
86
                4.0f, Color.blue));
87
        r1.setIncompletePaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f,
88
                1.0f, Color.blue));
99
 r2 = null;
89
        GanttRenderer r2 = null;
100
        try {
90
        try {
101
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
91
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
102
            ObjectOutput out = new ObjectOutputStream(buffer);
92
            ObjectOutput out = new ObjectOutputStream(buffer);
103
            out.writeObject(r1);
93
            out.writeObject(r1);
104
            out.close();
94
            out.close();
105
            ObjectInput in = new ObjectInputStream(
95
            ObjectInput in = new ObjectInputStream(
106
                    new ByteArrayInputStream(buffer.toByteArray()));
96
                    new ByteArrayInputStream(buffer.toByteArray()));
107
            r2 = (StandardDialRange) in.readObject();
97
            r2 = (GanttRenderer) in.readObject();
108
            in.close();
98
            in.close();
109
        }
99
        }
110
        catch (Exception e) {
100
        catch (Exception e) {
111
            e.printStackTrace();
101
            e.printStackTrace();
112
        }
102
        }
113
        assertEquals(r1, r2)
103
        assertEquals(r1, r2)
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