366-1-2

CompositeTitle t1 = new CompositeTitle(new BlockContainer()); t1.getContainer().add(new TextTitle("T1")); CompositeTitle t2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); t2 = (CompositeTitle) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(t1, t2);
KeyedObjects ko1 = new KeyedObjects(); ko1.addObject("Key 1", "Object 1"); ko1.addObject("Key 2", null); ko1.addObject("Key 3", "Object 2"); KeyedObjects ko2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(ko1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); ko2 = (KeyedObjects) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(ko1, ko2);

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

1

    CompositeTitle t1 = new CompositeTitle(new BlockContainer());↵

2

            t1.getContainer().add(new TextTitle("T1")↵

1

    KeyedObjects ko1 = new KeyedObjects();↵

2

            ko1.addObject("Key 1", "Object 1");↵

3

            ko1.addObject("Key 2", null);↵

3

    );↵

4

            ko1.addObject("Key 3", "Object 2");↵

4

            CompositeTitle t2 = null;↵

5

            KeyedObjects ko2 = null;↵

5

            try {↵

6

            try {↵

6

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

7

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

7

                ObjectOutput out = new ObjectOutputStream(buffer);↵

8

                ObjectOutput out = new ObjectOutputStream(buffer);↵

8

                out.writeObject(t1);↵

9

                out.writeObject(ko1);↵

9

                out.close();↵

10

                out.close();↵

10

                ObjectInput in = new ObjectInputStream(↵

11

                ObjectInput in = new ObjectInputStream(↵

11

                    new ByteArrayInputStream(buffer.toByteArray())↵

12

                        new ByteArrayInputStream(buffer.toByteArray())↵

12

                );↵

13

    );↵

13

                t2 = (CompositeTitle) in.readObject();↵

14

                ko2 = (KeyedObjects) in.readObject();↵

14

                in.close();↵

15

                in.close();↵

15

            }↵

16

            }↵

16

            catch (Exception e) {↵

17

            catch (Exception e) {↵

17

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

18

                e.printStackTrace();↵

18

            }↵

19

            }↵

19

            assertEquals(t1, t2);

20

            assertEquals(ko1, ko2);

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