public class BoxAndWhiskerToolTipGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(BoxAndWhiskerToolTipGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public BoxAndWhiskerToolTipGeneratorTests(String name) { super(name); } /** * A series of tests for the equals() method. */ public void testEquals() { // standard test BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator(); BoxAndWhiskerToolTipGenerator g2 = new BoxAndWhiskerToolTipGenerator(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); // tooltip format g1 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}", new DecimalFormat("0.0")); g2 = new BoxAndWhiskerToolTipGenerator("{1} {2}", new DecimalFormat("0.0")); assertFalse(g1.equals(g2)); g2 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}", new DecimalFormat("0.0")); assertTrue(g1.equals(g2)); // Y format g1 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}", new DecimalFormat("0.0")); g2 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}", new DecimalFormat("0.00")); assertFalse(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator(); BoxAndWhiskerToolTipGenerator g2 = new BoxAndWhiskerToolTipGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator(); BoxAndWhiskerToolTipGenerator g2 = null; try { g2 = (BoxAndWhiskerToolTipGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator(); BoxAndWhiskerToolTipGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (BoxAndWhiskerToolTipGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2)
public class IntervalCategoryLabelGeneratorTests extends TestCase { /** * Returns the tests as a test suite. * * @return The test suite. */ public static Test suite() { return new TestSuite(IntervalCategoryLabelGeneratorTests.class); } /** * Constructs a new set of tests. * * @param name the name of the tests. */ public IntervalCategoryLabelGeneratorTests(String name) { super(name); } /** * Tests the equals() method. */ public void testEquals() { IntervalCategoryItemLabelGenerator g1 = new IntervalCategoryItemLabelGenerator(); IntervalCategoryItemLabelGenerator g2 = new IntervalCategoryItemLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g2.equals(g1)); g1 = new IntervalCategoryItemLabelGenerator("{3} - {4}", new DecimalFormat("0.000")); assertFalse(g1.equals(g2)); g2 = new IntervalCategoryItemLabelGenerator("{3} - {4}", new DecimalFormat("0.000")); assertTrue(g1.equals(g2)); g1 = new IntervalCategoryItemLabelGenerator("{3} - {4}", new SimpleDateFormat("d-MMM")); assertFalse(g1.equals(g2)); g2 = new IntervalCategoryItemLabelGenerator("{3} - {4}", new SimpleDateFormat("d-MMM")); assertTrue(g1.equals(g2)); } /** * Simple check that hashCode is implemented. */ public void testHashCode() { IntervalCategoryItemLabelGenerator g1 = new IntervalCategoryItemLabelGenerator(); IntervalCategoryItemLabelGenerator g2 = new IntervalCategoryItemLabelGenerator(); assertTrue(g1.equals(g2)); assertTrue(g1.hashCode() == g2.hashCode()); } /** * Confirm that cloning works. */ public void testCloning() { IntervalCategoryItemLabelGenerator g1 = new IntervalCategoryItemLabelGenerator(); IntervalCategoryItemLabelGenerator g2 = null; try { g2 = (IntervalCategoryItemLabelGenerator) g1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(g1 != g2); assertTrue(g1.getClass() == g2.getClass()); assertTrue(g1.equals(g2)); } /** * Check to ensure that this class implements PublicCloneable. */ public void testPublicCloneable() { IntervalCategoryItemLabelGenerator g1 = new IntervalCategoryItemLabelGenerator(); assertTrue(g1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ public void testSerialization() { IntervalCategoryItemLabelGenerator g1 = new IntervalCategoryItemLabelGenerator("{3} - {4}", DateFormat.getInstance()); IntervalCategoryItemLabelGenerator g2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(g1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); g2 = (IntervalCategoryItemLabelGenerator) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(g1, g2)
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/labels/junit/BoxAndWhiskerToolTipGeneratorTests.java File path: /jfreechart-1.0.10/tests/org/jfree/chart/labels/junit/IntervalCategoryLabelGeneratorTests.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class BoxAndWhiskerToolTipGeneratorTests extends TestCase {
1
public class IntervalCategoryLabelGeneratorTests 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(BoxAndWhiskerToolTipGeneratorTests.class);
8
        return new TestSuite(IntervalCategoryLabelGeneratorTests.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 BoxAndWhiskerToolTipGeneratorTests(String name) {
15
    public IntervalCategoryLabelGeneratorTests(String name) {
16
        super(name);
16
        super(name);
17
    }
17
    }
18
    /**
18
    /**
19
     * A series of tests for the equals() method.
19
     * Tests the equals() method.
20
     */
20
     */
21
    public void testEquals() {
21
    public void testEquals() {
22
        // standard test
22
        
23
        BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator();
24
        BoxAndWhiskerToolTipGenerator g2 = new BoxAndWhiskerToolTip
23
IntervalCategoryItemLabelGenerator g1
24
                = new IntervalCategoryItemLabelGenerator();
25
        IntervalCategoryItemLabelGenerator g2
25
Generator();
26
                = new IntervalCategoryItemLabelGenerator();
26
        assertTrue(g1.equals(g2));
27
        assertTrue(g1.equals(g2));
27
        assertTrue(g2.equals(g1));
28
        assertTrue(g2.equals(g1));
28
        // tooltip format
29
        
29
        g1 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}",
30
                new DecimalFormat("0.0"));
31
        g2 = new BoxAndWhiskerToolTipGenerator("{1} {2}",
30
g1 = new IntervalCategoryItemLabelGenerator("{3} - {4}",
32
                new DecimalFormat("0.0"));
31
                new DecimalFormat("0.000"));
33
        assertFalse(g1.equals(g2));
32
        assertFalse(g1.equals(g2));
34
        g2 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}",
33
        g2 = new IntervalCategoryItemLabelGenerator("{3} - {4}",
35
                new DecimalFormat("0.0"));
34
                new DecimalFormat("0.000"));
36
        assertTrue(g1.equals(g2));
35
        assertTrue(g1.equals(g2));
37
        // Y format
36
        
38
        g1 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}",
37
g1 = new IntervalCategoryItemLabelGenerator("{3} - {4}",
39
                new DecimalFormat("0.0"));
38
                new 
40
        g2 = new BoxAndWhiskerToolTip
39
SimpleDateFormat("d-MMM"));
40
        assertFalse(g1.equals(g2));
41
Generator("{0} --> {1} {2}",
41
        g2 = new IntervalCategoryItemLabelGenerator("{3} - {4}",
42
                new DecimalFormat("0.00"));
42
                new SimpleDateFormat("d-MMM"));
43
        assertFalse(g1.equals(g2));
43
        assertTrue(g1.equals(g2));
44
    }
44
    }
45
    /**
45
    /**
46
     * Simple check that hashCode is implemented.
46
     * Simple check that hashCode is implemented.
47
     */
47
     */
48
    public void testHashCode() {
48
    public void testHashCode() {
49
        BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator();
49
        
50
        BoxAndWhiskerToolTipGenerator g2 = new BoxAndWhiskerToolTip
50
IntervalCategoryItemLabelGenerator g1
51
                = new IntervalCategoryItemLabelGenerator();
52
        IntervalCategoryItemLabelGenerator g2
51
Generator();
53
                = new IntervalCategoryItemLabelGenerator();
52
        assertTrue(g1.equals(g2));
54
        assertTrue(g1.equals(g2));
53
        assertTrue(g1.hashCode() == g2.hashCode());
55
        assertTrue(g1.hashCode() == g2.hashCode());
54
    }
56
    }
55
    /**
57
    /**
56
     * Confirm that cloning works.
58
     * Confirm that cloning works.
57
     */
59
     */
58
    public void testCloning() {
60
    public void testCloning() {
59
        BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator();
61
        
60
        BoxAndWhiskerToolTip
62
IntervalCategoryItemLabelGenerator g1
63
                = new IntervalCategoryItemLabelGenerator();
61
Generator g2 = null;
64
        IntervalCategoryItemLabelGenerator g2 = null;
62
        try {
65
        try {
63
            g2 = (BoxAndWhiskerToolTipGenerator) g1.clone();
66
            g2 = (IntervalCategoryItemLabelGenerator) g1.clone();
64
        }
67
        }
65
        catch (CloneNotSupportedException e) {
68
        catch (CloneNotSupportedException e) {
66
            e.printStackTrace();
69
            e.printStackTrace();
67
        }
70
        }
68
        assertTrue(g1 != g2);
71
        assertTrue(g1 != g2);
69
        assertTrue(g1.getClass() == g2.getClass());
72
        assertTrue(g1.getClass() == g2.getClass());
70
        assertTrue(g1.equals(g2));
73
        assertTrue(g1.equals(g2));
71
    }
74
    }
72
    /**
75
    /**
73
     * Check to ensure that this class implements PublicCloneable.
76
     * Check to ensure that this class implements PublicCloneable.
74
     */
77
     */
75
    public void testPublicCloneable() {
78
    public void testPublicCloneable() {
76
        BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTip
79
        IntervalCategoryItemLabelGenerator g1
77
Generator();
80
                = new IntervalCategoryItemLabelGenerator();
78
        assertTrue(g1 instanceof PublicCloneable);
81
        assertTrue(g1 instanceof PublicCloneable);
79
    }
82
    }
80
    /**
83
    /**
81
     * Serialize an instance, restore it, and check for equality.
84
     * Serialize an instance, restore it, and check for equality.
82
     */
85
     */
83
    public void testSerialization() {
86
    public void testSerialization() {
84
        BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator();
87
        
85
        BoxAndWhiskerToolTip
88
IntervalCategoryItemLabelGenerator g1
89
                = new IntervalCategoryItemLabelGenerator("{3} - {4}",
90
                DateFormat.getInstance());
86
Generator g2 = null;
91
        IntervalCategoryItemLabelGenerator g2 = null;
87
        try {
92
        try {
88
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
93
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
89
            ObjectOutput out = new ObjectOutputStream(buffer);
94
            ObjectOutput out = new ObjectOutputStream(buffer);
90
            out.writeObject(g1);
95
            out.writeObject(g1);
91
            out.close();
96
            out.close();
92
            ObjectInput in = new ObjectInputStream(
97
            ObjectInput in = new ObjectInputStream(
93
                    new ByteArrayInputStream(buffer.toByteArray()));
98
                    new ByteArrayInputStream(buffer.toByteArray()));
94
            g2 = (BoxAndWhiskerToolTipGenerator) in.readObject();
99
            g2 = (IntervalCategoryItemLabelGenerator) in.readObject();
95
            in.close();
100
            in.close();
96
        }
101
        }
97
        catch (Exception e) {
102
        catch (Exception e) {
98
            e.printStackTrace();
103
            e.printStackTrace();
99
        }
104
        }
100
        assertEquals(g1, g2)
105
        assertEquals(g1, g2)
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