115-1-7

KeyedObjects2D ko2D1 = new KeyedObjects2D(); ko2D1.addObject(new Double(234.2), "Row1", "Col1"); ko2D1.addObject(null, "Row1", "Col2"); ko2D1.addObject(new Double(345.9), "Row2", "Col1"); ko2D1.addObject(new Double(452.7), "Row2", "Col2"); KeyedObjects2D ko2D2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(ko2D1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); ko2D2 = (KeyedObjects2D) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(ko2D1, ko2D2);
DefaultKeyedValues v1 = new DefaultKeyedValues(); v1.addValue("Key 1", new Double(23)); v1.addValue("Key 2", null); v1.addValue("Key 3", new Double(42)); DefaultKeyedValues v2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(v1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); v2 = (DefaultKeyedValues) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(v1, v2);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/KeyedObjects2DTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/DefaultKeyedValuesTests.java
Method name: `void testSerialization()` |  | Method name: `void testSerialization()`
Number of AST nodes: 15 |  | Number of AST nodes: 14

1

    KeyedObjects2D ko2D1 = new KeyedObjects2D();↵

1

    DefaultKeyedValues v1 = new DefaultKeyedValues();↵

2

            ko2D1.addObject(new Double(234.2), "Row1", "Col1");↵

2

            v1.addValue("Key 1", new Double(23));↵

3

            ko2D1.addObject(null, "Row1", "Col2");↵

3

            v1.addValue("Key 2", null);↵

4

            ko2D1.addObject(new Double(345.9), "Row2", "Col1");↵

4

            v1.add↵

5

            ko2D1.addObject(new Double(452.7), "Row2", "Col2");↵

5

    Value("Key 3", new Double(42));↵

6

            KeyedObjects2D ko2D2 = null;↵

6

            DefaultKeyedValues v2 = null;↵

7

            try {↵

7

            try {↵

8

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

8

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

9

                ObjectOutput out = new ObjectOutputStream(buffer);↵

9

                ObjectOutput out = new ObjectOutputStream(buffer);↵

10

                out.writeObject(ko2D1);↵

10

                out.writeObject(v1);↵

11

                out.close();↵

11

                out.close();↵

12

                ObjectInput in = new ObjectInputStream(↵

12

                ObjectInput in = new ObjectInputStream(↵

13

                        new ByteArrayInputStream(buffer.toByteArray())↵

13

                    new ByteArrayInputStream(buffer.toByteArray())↵

14

    );↵

14

                );↵

15

                ko2D2 = (KeyedObjects2D) in.readObject();↵

15

                v2 = (DefaultKeyedValues) 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(ko2D1, ko2D2);

21

            assertEquals(v1, v2);

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.2
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 1