408-1-15

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);
Quarter q1 = new Quarter(4, 1999); Quarter q2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(q1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); q2 = (Quarter) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(q1, q2);

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/data/time/junit/QuarterTests.java
Method name: `void testSerialization()` |  | Method name: `void testSerialization()`
Number of AST nodes: 11 |  | Number of AST nodes: 11

1

    CategoryLineAnnotation a1 = new CategoryLineAnnotation(↵

2

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

3

                new BasicStroke(1.0f));↵

4

            CategoryLineAnnotation a↵

1

    Quarter q1 = new Quarter(4, 1999);↵

5

    2 = null;↵

2

            Quarter q2 = null;↵

6

            try {↵

3

            try {↵

7

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

4

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

8

                ObjectOutput out = new ObjectOutputStream(buffer);↵

5

                ObjectOutput out = new ObjectOutputStream(buffer);↵

9

                out.writeObject(a1);↵

6

                out.writeObject(q1);↵

10

                out.close();↵

7

                out.close();↵

11

                ObjectInput in = new ObjectInputStream(↵

8

                ObjectInput in = new ObjectInputStream(↵

12

                    new ByteArrayInputStream(buffer.toByteArray())↵

9

                    new ByteArrayInputStream(buffer.toByteArray())↵

13

                );↵

10

                );↵

14

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

11

                q2 = (Quarter) in.readObject();↵

15

                in.close();↵

12

                in.close();↵

16

            }↵

13

            }↵

17

            catch (Exception e) {↵

14

            catch (Exception e) {↵

18

                e.printStackTrace();↵

15

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

19

            }↵

16

            }↵

20

            assertEquals(a1, a2);

17

            assertEquals(q1, q2);

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