346-1-4

Stroke stroke = new BasicStroke(2.0f); XYLineAnnotation a1 = new XYLineAnnotation( 10.0, 20.0, 100.0, 200.0, stroke, Color.blue ); XYLineAnnotation 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 = (XYLineAnnotation) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(a1, a2);
RingPlot p1 = new RingPlot(null); GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.red); p1.setSeparatorPaint(gp); RingPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (RingPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(p1, p2);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/annotations/junit/XYLineAnnotationTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/RingPlotTests.java
Method name: `void testSerialization()` |  | Method name: `void testSerialization()`
Number of AST nodes: 12 |  | Number of AST nodes: 13

1

    Stroke stroke = new BasicStroke(2.0f);↵

2

            XYLineAnnotation a1 = new XYLineAnnotation(↵

3

                10.0, 20.0, 100↵

1

    RingPlot p1 = new RingPlot(null);↵

2

            GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.yellow,↵

4

    .0, 200.0, stroke, Color.blue↵

3

                    3.0f, 4.0f, Color.red);↵

5

            );↵

4

            ↵

6

            XYLineAnnotation a↵

5

    p1.setSeparatorPaint(gp);↵

7

    2 = null;↵

6

            RingPlot p2 = null;↵

8

            try {↵

7

            try {↵

9

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

8

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

10

                ObjectOutput out = new ObjectOutputStream(buffer);↵

9

                ObjectOutput out = new ObjectOutputStream(buffer);↵

11

                out.writeObject(a1);↵

10

                out.writeObject(p1);↵

12

                out.close();↵

11

                out.close();↵

13

                ObjectInput in = new ObjectInputStream(↵

12

                ObjectInput in = new ObjectInputStream(↵

14

                    new ByteArrayInputStream(buffer.toByteArray())↵

13

                        new ByteArrayInputStream(buffer.toByteArray())↵

15

                );↵

14

    );↵

16

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

15

                p2 = (RingPlot) in.readObject();↵

17

                in.close();↵

16

                in.close();↵

18

            }↵

17

            }↵

19

            catch (Exception e) {↵

18

            catch (Exception e) {↵

20

                System.out.println(e.toString());↵

19

                e.printStackTrace();↵

21

            }↵

20

            }↵

22

            assertEquals(a1, a2);

21

            assertEquals(p1, p2);

See real code fragment |  | See real code fragment

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