145-3-5

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);
XYShapeAnnotation a1 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.red, Color.blue); XYShapeAnnotation a2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); a2 = (XYShapeAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/renderer/category/junit/GanttRendererTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/annotations/junit/XYShapeAnnotationTests.java
Method name: `void testSerialization()` |  | Method name: `void testSerialization()`
Number of AST nodes: 13 |  | Number of AST nodes: 11

1

    GanttRenderer r1 = new GanttRenderer();↵

2

            r1.setCompletePaint(new GradientPaint↵

1

    XYShapeAnnotation a1 = new XYShapeAnnotation(↵

3

    (1.0f, 2.0f, Color.red, 3.0f,↵

2

                    new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0),↵

4

                    4.0f, Color.blue));↵

3

                    ↵

5

            r1.setIncompletePaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f,↵

6

                    1.0f, Color.blue));↵

4

    new BasicStroke(1.2f), Color.red, Color.blue);↵

7

            GanttRenderer r2 = null;↵

5

            XYShapeAnnotation a2 = null;↵

8

            try {↵

6

            try {↵

9

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

7

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

10

                ObjectOutput out = new ObjectOutputStream(buffer);↵

8

                ObjectOutput out = new ObjectOutputStream(buffer);↵

11

                out.writeObject(r1);↵

9

                out.writeObject(a1);↵

12

                out.close();↵

10

                out.close();↵

13

                ObjectInput in = new ObjectInputStream(↵

11

                ObjectInput in = new ObjectInputStream(↵

14

                        new ByteArrayInputStream(buffer.toByteArray()));↵

12

                        new ByteArrayInputStream(buffer.toByteArray()));↵

15

                r2 = (GanttRenderer) in.readObject();↵

13

                a2 = (XYShapeAnnotation) in.readObject();↵

16

                in.close();↵

14

                in.close();↵

17

            }↵

15

            }↵

18

            catch (Exception e) {↵

16

            catch (Exception e) {↵

19

                e.printStackTrace();↵

17

                e.printStackTrace();↵

20

            }↵

18

            }↵

21

            assertEquals(r1, r2);

19

            assertEquals(a1, a2);

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 | 75

1. {Non-refactorable}

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

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

   1

       GanttRenderer r1 = new GanttRenderer();

   1 | GanttRenderer r1 = new GanttRenderer();
   1 | XYShapeAnnotation a1 = new XYShapeAnnotation(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.red, Color.blue);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r1 | a1 | VARIABLE_NAME_MISMATCH
   new GanttRenderer() | new XYShapeAnnotation(new Rectangle2D.Double(1.0,2.0,3.0,4.0),new BasicStroke(1.2f),Color.red,Color.blue) | ARGUMENT_NUMBER_MISMATCH

   1

       XYShapeAnnotation a1 = new XYShapeAnnotation(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.red, Color.blue);

   2

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

   3

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

   4

       GanttRenderer r2 = null;

   4 | GanttRenderer r2 = null;
   2 | XYShapeAnnotation a2 = null;

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

   2

       XYShapeAnnotation a2 = null;

   5

       try

   3

       try

   6

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   4

       ByteArrayOutputStream buffer = new ByteArrayOutputStream();

   7

       ObjectOutput out = new ObjectOutputStream(buffer);

   5

       ObjectOutput out = new ObjectOutputStream(buffer);

   8

       out.writeObject(r1);

   8 | out.writeObject(r1);
   6 | out.writeObject(a1);

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

   6

       out.writeObject(a1);

   9

       out.close();

   7

       out.close();

   10

       ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));

   8

       ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));

   11

       r2 = (GanttRenderer)in.readObject();

   11 | r2 = (GanttRenderer)in.readObject();
   9 | a2 = (XYShapeAnnotation)in.readObject();

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

   9

       a2 = (XYShapeAnnotation)in.readObject();

   12

       in.close();

   10

       in.close();

   13

       assertEquals(r1, r2);

   13 | assertEquals(r1, r2);
   11 | assertEquals(a1, a2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   r1 | a1 | VARIABLE_NAME_MISMATCH
   r2 | a2 | VARIABLE_NAME_MISMATCH

   11

       assertEquals(a1, a2);

   Precondition Violations (1)
   Row | Violation
   --- | ---
   1 | Clone fragment #1 returns variables r1 , while Clone fragment #2 returns variables