182-3-5

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));
StandardDialFrame f1 = new StandardDialFrame(); StandardDialFrame f2 = null; try { f2 = (StandardDialFrame) f1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(f1 != f2); assertTrue(f1.getClass() == f2.getClass()); assertTrue(f1.equals(f2)); // check that the listener lists are independent MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); f1.addChangeListener(l1); assertTrue(f1.hasListener(l1)); assertFalse(f2.hasListener(l1));

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/plot/dial/junit/StandardDialFrameTests.java
Method name: `void testCloning()` |  | Method name: `void testCloning()`
Number of AST nodes: 11 |  | Number of AST nodes: 11

1

    StandardDialRange r1 = new StandardDialRange();↵

1

    StandardDialFrame f1 = new StandardDialFrame();↵

2

            StandardDialRange r2 = null;↵

2

            StandardDialFrame f2 = null;↵

3

            try {↵

3

            try {↵

4

                r2 = (StandardDialRange) r1.clone();↵

4

                f2 = (StandardDialFrame) f1.clone();↵

5

            }↵

5

            }↵

6

            catch (CloneNotSupportedException e) {↵

6

            catch (CloneNotSupportedException e) {↵

7

                e.printStackTrace();↵

7

                e.printStackTrace();↵

8

            }↵

8

            }↵

9

            assertTrue(r1 != r2);↵

9

            assertTrue(f1 != f2);↵

10

            assertTrue(r1.getClass() == r2.getClass());↵

10

            assertTrue(f1.getClass() == f2.getClass());↵

11

            assertTrue(r1.equals(r2));↵

11

            assertTrue(f1.equals(f2));↵

12

            ↵

12

            ↵

13

            // check that the listener lists are independent↵

13

            // check that the listener lists are independent↵

14

            MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();↵

14

            MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();↵

15

            r1.addChangeListener(l1);↵

15

            f1.addChangeListener(l1);↵

16

            assertTrue(r1.hasListener(l1));↵

16

            assertTrue(f1.hasListener(l1));↵

17

            assertFalse(r2.hasListener(l1));

17

            assertFalse(f2.hasListener(l1));

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 1
Number of non-refactorable cases | 0
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.1
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 47

1. {Refactorable}

   Mapping Summary
   Number of mapped statements | 11
   Number of unmapped statements in the first code fragment | 0
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 2.3
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   1

       StandardDialRange r1 = new StandardDialRange();

   1 | StandardDialRange r1 = new StandardDialRange();
   1 | StandardDialFrame f1 = new StandardDialFrame();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r1 | f1 | VARIABLE_NAME_MISMATCH

   1

       StandardDialFrame f1 = new StandardDialFrame();

   2

       StandardDialRange r2 = null;

   2 | StandardDialRange r2 = null;
   2 | StandardDialFrame f2 = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r2 | f2 | VARIABLE_NAME_MISMATCH

   2

       StandardDialFrame f2 = null;

   3

       try

   3

       try

   4

       r2 = (StandardDialRange)r1.clone();

   4 | r2 = (StandardDialRange)r1.clone();
   4 | f2 = (StandardDialFrame)f1.clone();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r2 | f2 | VARIABLE_NAME_MISMATCH
   r1 | f1 | VARIABLE_NAME_MISMATCH

   4

       f2 = (StandardDialFrame)f1.clone();

   5

       assertTrue(r1 != r2);

   5 | assertTrue(r1 != r2);
   5 | assertTrue(f1 != f2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r1 | f1 | VARIABLE_NAME_MISMATCH
   r2 | f2 | VARIABLE_NAME_MISMATCH

   5

       assertTrue(f1 != f2);

   6

       assertTrue(r1.getClass() == r2.getClass());

   6 | assertTrue(r1.getClass() == r2.getClass());
   6 | assertTrue(f1.getClass() == f2.getClass());

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r1 | f1 | VARIABLE_NAME_MISMATCH
   r2 | f2 | VARIABLE_NAME_MISMATCH

   6

       assertTrue(f1.getClass() == f2.getClass());

   7

       assertTrue(r1.equals(r2));

   7 | assertTrue(r1.equals(r2));
   7 | assertTrue(f1.equals(f2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r2 | f2 | VARIABLE_NAME_MISMATCH
   r1 | f1 | VARIABLE_NAME_MISMATCH

   7

       assertTrue(f1.equals(f2));

   8

       MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();

   8

       MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();

   9

       r1.addChangeListener(l1);

   9 | r1.addChangeListener(l1);
   9 | f1.addChangeListener(l1);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r1 | f1 | VARIABLE_NAME_MISMATCH

   9

       f1.addChangeListener(l1);

   10

       assertTrue(r1.hasListener(l1));

   10 | assertTrue(r1.hasListener(l1));
   10 | assertTrue(f1.hasListener(l1));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r1 | f1 | VARIABLE_NAME_MISMATCH

   10

       assertTrue(f1.hasListener(l1));

   11

       assertFalse(r2.hasListener(l1));

   11 | assertFalse(r2.hasListener(l1));
   11 | assertFalse(f2.hasListener(l1));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r2 | f2 | VARIABLE_NAME_MISMATCH

   11

       assertFalse(f2.hasListener(l1));

   Precondition Violations (0)
   Row | Violation
   --- | ---