114-4-10

DefaultBoxAndWhiskerXYDataset d1 = new DefaultBoxAndWhiskerXYDataset( "Series"); d1.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList())); DefaultBoxAndWhiskerXYDataset 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 = (DefaultBoxAndWhiskerXYDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); // test independence d1.add(new Date(2L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, new ArrayList())); assertFalse(d1.equals(d2));
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/data/statistics/junit/DefaultBoxAndWhiskerXYDatasetTests.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: 14 |  | Number of AST nodes: 12

1

    DefaultBoxAndWhiskerXYDataset d1 = new DefaultBoxAndWhiskerXYDataset(↵

2

                    "Series");↵

3

            d1.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, ↵

4

                    6.0, 7.0, 8.0, new ArrayList()));↵

5

            DefaultBoxAndWhiskerXYDataset d2 = null;↵

6

            ↵

1

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

2

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

3

            CompositeTitle t2 = null;↵

7

            try {↵

4

            try {↵

8

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

5

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

9

                ObjectOutput out = new ObjectOutputStream(buffer);↵

6

                ObjectOutput out = new ObjectOutputStream(buffer);↵

10

                out.writeObject(d1);↵

7

                out.writeObject(t1);↵

11

                out.close();↵

8

                out.close();↵

12

                ObjectInput in = new ObjectInputStream(↵

9

                ObjectInput in = new ObjectInputStream(↵

13

    new ByteArrayInputStream(↵

10

                    new ByteArrayInputStream(↵

14

                        buffer.toByteArray())↵

11

    buffer.toByteArray())↵

15

    );↵

12

                );↵

16

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

13

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

17

                in.close();↵

14

                in.close();↵

18

            }↵

15

            }↵

19

            catch (Exception e) {↵

16

            catch (Exception e) {↵

20

                e.printStackTrace();↵

17

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

21

            }↵

18

            }↵

22

            assertEquals(d1, d2);↵

19

            assertEquals(↵

23

            // test independence↵

24

            d1.add(new Date(2L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, ↵

25

                    6.0, 7.0, 8.0, new ArrayList()));↵

26

            assertFalse(d1.equals(d2));

20

    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