230-3-4

XYLine3DRenderer r1 = new XYLine3DRenderer(); r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); XYLine3DRenderer r2 = null; try { r2 = (XYLine3DRenderer) r1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(r1 != r2); assertTrue(r1.getClass() == r2.getClass()); assertTrue(r1.equals(r2));
CategoryMarker m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(1.1f)); CategoryMarker m2 = null; try { m2 = (CategoryMarker) m1.clone(); } catch (CloneNotSupportedException e) { e.printStackTrace(); } assertTrue(m1 != m2); assertTrue(m1.getClass() == m2.getClass()); assertTrue(m1.equals(m2));

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/xy/junit/XYLine3DRendererTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/CategoryMarkerTests.java
Method name: `void testCloning()` |  | Method name: `void testCloning()`
Number of AST nodes: 8 |  | Number of AST nodes: 7

1

    XYLine3DRenderer r1 = new XYLine3DRenderer();↵

1

    CategoryMarker m1 = new ↵

2

            r1.setWallPaint(new GradientPaint(1.0f, ↵

2

    CategoryMarker("A", new GradientPaint(1.0f, ↵

3

    2.0f, Color.red, 3.0f, 4.0f,↵

3

                    2.0f, Color.white, 3.0f, 4.0f, Color.yellow), ↵

4

                    Color.blue));↵

4

                    ↵

5

            XYLine3DRender↵

5

    new BasicStroke(1.1f));↵

6

    er r2 = null;↵

6

            CategoryMarker m2 = null;↵

7

            try {↵

7

            try {↵

8

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

8

                m2 = (CategoryMarker) m1.clone();↵

9

            }↵

9

            }↵

10

            catch (CloneNotSupportedException e) {↵

10

            catch (CloneNotSupportedException e) {↵

11

                e.printStackTrace();↵

11

                e.printStackTrace();↵

12

            }↵

12

            }↵

13

            assertTrue(r1 != r2);↵

13

            assertTrue(m1 != m2);↵

14

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

14

            assertTrue(m1.getClass() == m2.getClass());↵

15

            assertTrue(r1.equals(r2));

15

            assertTrue(m1.equals(m2));

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 0
Number of non-refactorable cases | 1
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 | 34

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 3
   Number of unmapped statements in the first code fragment | 5
   Number of unmapped statements in the second code fragment | 4
   Time elapsed for statement mapping (ms) | 3.3
   Clone type | Type 3

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

   1

       CategoryMarker m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), new BasicStroke(1.1f));

   1

       XYLine3DRenderer r1 = new XYLine3DRenderer();

   2

       CategoryMarker m2 = null;

   2

       r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue));

   3

       XYLine3DRenderer r2 = null;

   4

       try

   3

       try

   4 | m2 = (CategoryMarker)m1.clone();

   Preondition Violations
   Unmatched statement m2=(CategoryMarker)m1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted

   4

       m2 = (CategoryMarker)m1.clone();

   5

       r2 = (XYLine3DRenderer)r1.clone();

   5 | r2 = (XYLine3DRenderer)r1.clone();

   Preondition Violations
   Unmatched statement r2=(XYLine3DRenderer)r1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted

   6

       assertTrue(m1.getClass() == m2.getClass());

   6

       assertTrue(r1 != r2);

   7

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

   7 | assertTrue(r1.getClass() == r2.getClass());
   7 | assertTrue(m1.equals(m2));

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r1.getClass() == r2.getClass() | m1.equals(m2) | TYPE_COMPATIBLE_REPLACEMENT

   7

       assertTrue(m1.equals(m2));

   8

       assertTrue(r1.equals(r2));

   8 | assertTrue(r1.equals(r2));
   5 | assertTrue(m1 != m2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r1.equals(r2) | m1 != m2 | TYPE_COMPATIBLE_REPLACEMENT

   5

       assertTrue(m1 != m2);

   Precondition Violations (2)
   Row | Violation
   --- | ---
   1 | Unmatched statement m2=(CategoryMarker)m1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
   2 | Unmatched statement r2=(XYLine3DRenderer)r1.clone(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted