115-2-24

DefaultKeyedValues2D kv2D1 = new DefaultKeyedValues2D(); kv2D1.addValue(new Double(234.2), "Row1", "Col1"); kv2D1.addValue(null, "Row1", "Col2"); kv2D1.addValue(new Double(345.9), "Row2", "Col1"); kv2D1.addValue(new Double(452.7), "Row2", "Col2"); DefaultKeyedValues2D kv2D2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(kv2D1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); kv2D2 = (DefaultKeyedValues2D) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(kv2D1, kv2D2);
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/data/junit/DefaultKeyedValues2DTests.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: 15 |  | Number of AST nodes: 11

1

    DefaultKeyedValues2D kv2D1 = new DefaultKeyedValues2D();↵

2

            kv2D1.addValue(new Double(234.2), "Row1", "Col1");↵

3

            kv2D1.addValue(null, "Row1", "Col2");↵

4

            kv2D1.addValue(new Double(345.9), "Row2", "Col1");↵

5

            kv2D1.addValue(new Double(452.7), "Row2", "Col2"↵

1

    XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0,↵

6

    );↵

2

                    Math.PI);↵

7

            DefaultKeyedValues2D kv2D2 = null;↵

3

            XYPointerAnnotation a2 = null;↵

8

            try {↵

4

            try {↵

9

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

5

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

10

                ObjectOutput out = new ObjectOutputStream(buffer);↵

6

                ObjectOutput out = new ObjectOutputStream(buffer);↵

11

                out.writeObject(kv2D1);↵

7

                out.writeObject(a1);↵

12

                out.close();↵

8

                out.close();↵

13

                ObjectInput in = new ObjectInputStream(↵

9

                ObjectInput in = new ObjectInputStream(↵

14

                        new ByteArrayInputStream(↵

10

    new ByteArrayInputStream(↵

15

    buffer.toByteArray()));↵

11

                        buffer.toByteArray()));↵

16

                kv2D2 = (DefaultKeyedValues2D) in.readObject();↵

12

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

17

                in.close();↵

13

                in.close();↵

18

            }↵

14

            }↵

19

            catch (Exception e) {↵

15

            catch (Exception e) {↵

20

                e.printStackTrace();↵

16

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

21

            }↵

17

            }↵

22

            assertEquals(kv2D1, kv2D2);

18

            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