114-5-10

LegendItem item1 = new LegendItem("Item", "Description", "ToolTip", "URL", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.red); LegendItem item2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(item1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); item2 = (LegendItem) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(item1, item2);
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);

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

1

    LegendItem item1 = new LegendItem("Item", "Description",↵

2

                    "ToolTip", "URL",↵

3

                    new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.red);↵

4

            LegendItem item↵

1

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

2

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

5

    2 = null;↵

3

            CompositeTitle t2 = null;↵

6

            try {↵

4

            try {↵

7

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

5

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

8

                ObjectOutput out = new ObjectOutputStream(buffer);↵

6

                ObjectOutput out = new ObjectOutputStream(buffer);↵

9

                out.writeObject(item1);↵

7

                out.writeObject(t1);↵

10

                out.close();↵

8

                out.close();↵

11

                ObjectInput in = new ObjectInputStream(↵

9

                ObjectInput in = new ObjectInputStream(↵

12

                        new ByteArrayInputStream(buffer.toByteArray())↵

10

                    new ByteArrayInputStream(buffer.toByteArray())↵

13

    );↵

11

                );↵

14

                item2 = (LegendItem) in.readObject();↵

12

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

15

                in.close();↵

13

                in.close();↵

16

            }↵

14

            }↵

17

            catch (Exception e) {↵

15

            catch (Exception e) {↵

18

                e.printStackTrace();↵

16

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

19

            }↵

17

            }↵

20

            assertEquals(item1, item2);

18

            assertEquals(t1, t2);

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