392-2-4

CategoryLineAnnotation a1 = new CategoryLineAnnotation( "Category 1", 1.0, "Category 2", 2.0, Color.red, new BasicStroke(1.0f)); CategoryLineAnnotation 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 = (CategoryLineAnnotation) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(a1, a2);
XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, Math.PI); XYPointerAnnotation 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 = (XYPointerAnnotation) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(a1, a2);

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

1

    CategoryLineAnnotation a1 = new CategoryLineAnnotation(↵

1

    XYPointerAnnotation a1 = new ↵

2

                "Category 1", 1.0, "Category 2", 2.0, Color.red,↵

2

    XYPointerAnnotation("Label", 10.0, ↵

3

                new BasicStroke(1.0f)↵

3

    20.0,↵

4

    );↵

4

                    Math.PI);↵

5

            CategoryLineAnnotation a2 = null;↵

5

            XYPointerAnnotation a2 = null;↵

6

            try {↵

6

            try {↵

7

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

7

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

8

                ObjectOutput out = new ObjectOutputStream(buffer);↵

8

                ObjectOutput out = new ObjectOutputStream(buffer);↵

9

                out.writeObject(a1);↵

9

                out.writeObject(a1);↵

10

                out.close();↵

10

                out.close();↵

11

                ObjectInput in = new ObjectInputStream(↵

11

                ObjectInput in = new ObjectInputStream(↵

12

                    new ByteArrayInputStream(↵

12

    new ByteArrayInputStream(↵

13

    buffer.toByteArray())↵

13

                        buffer.toByteArray())↵

14

                );↵

14

    );↵

15

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

15

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

16

                in.close();↵

16

                in.close();↵

17

            }↵

17

            }↵

18

            catch (Exception e) {↵

18

            catch (Exception e) {↵

19

                e.printStackTrace();↵

19

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

20

            }↵

20

            }↵

21

            assertEquals(a1, a2);

21

            assertEquals(a1, a2);

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