115-1-6

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);
DefaultPieDataset d1 = new DefaultPieDataset(); d1.setValue("C1", new Double(234.2)); d1.setValue("C2", null); d1.setValue("C3", new Double(345.9)); d1.setValue("C4", new Double(452.7)); DefaultPieDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); d2 = (DefaultPieDataset) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(d1, d2);

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/general/junit/DefaultPieDatasetTests.java
Method name: `void testSerialization()` |  | Method name: `void testSerialization()`
Number of AST nodes: 15 |  | Number of AST nodes: 15

1

    KeyedObjects2D ko2D1 = new KeyedObjects2D();↵

2

            ko2D1.addObject(↵

1

    DefaultPieDataset d1 = new DefaultPieDataset();↵

3

    new Double(234.2), "Row1", "Col1");↵

2

            d1.setValue("C1", new Double(234.2)↵

4

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

5

            ko2D1.addObject(↵

3

    );↵

4

            d1.setValue("C2", null);↵

6

    new Double(345.9), "Row2", "Col1");↵

5

            d1.setValue("C3", new Double(345.9)↵

7

            ko2D1.addObject(↵

6

    );↵

8

    new Double(452.7), "Row2", "Col2");↵

7

            d1.setValue("C4", new Double(452.7)↵

9

            KeyedObjects2D ko2D↵

8

    );↵

10

    2 = null;↵

9

            DefaultPieDataset d2 = null;↵

11

            try {↵

10

            try {↵

12

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

11

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

13

                ObjectOutput out = new ObjectOutputStream(buffer);↵

12

                ObjectOutput out = new ObjectOutputStream(buffer);↵

14

                out.writeObject(ko2D1);↵

13

                out.writeObject(d1);↵

15

                out.close();↵

14

                out.close();↵

16

                ObjectInput in = new ObjectInputStream(↵

15

                ObjectInput in = new ObjectInputStream(↵

17

                        new ByteArrayInputStream(buffer.toByteArray())↵

16

                    new ByteArrayInputStream(buffer.toByteArray())↵

18

    );↵

17

                );↵

19

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

18

                d2 = (DefaultPieDataset) in.readObject();↵

20

                in.close();↵

19

                in.close();↵

21

            }↵

20

            }↵

22

            catch (Exception e) {↵

21

            catch (Exception e) {↵

23

                e.printStackTrace();↵

22

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

24

            }↵

23

            }↵

25

            assertEquals(ko2D1, ko2D2);

24

            assertEquals(d1, d2);

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