392-15-16

TimeTableXYDataset d1 = new TimeTableXYDataset(); d1.add(new Year(1999), 123.4, "S1"); TimeTableXYDataset 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 = (TimeTableXYDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(d1.equals(d2));
DefaultOHLCDataset d1 = new DefaultOHLCDataset("Series 1", new OHLCDataItem[0]); DefaultOHLCDataset 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 = (DefaultOHLCDataset) 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/time/junit/TimeTableXYDatasetTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/DefaultOHLCDatasetTests.java
Method name: `void testSerialization()` |  | Method name: `void testSerialization()`
Number of AST nodes: 12 |  | Number of AST nodes: 11

1

    TimeTableXYDataset d1 = new TimeTableXYDataset();↵

1

    DefaultOHLCDataset d1 = new ↵

2

            d1.add(new Year(1999), 123.4, "S1");↵

3

            TimeTableXY↵

2

    DefaultOHLCDataset("Series 1",↵

3

                    new OHLCDataItem[0]);↵

4

    Dataset d2 = null;↵

4

            DefaultOHLCDataset d2 = null;↵

5

            try {↵

5

            try {↵

6

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

6

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

7

                ObjectOutput out = new ObjectOutputStream(buffer);↵

7

                ObjectOutput out = new ObjectOutputStream(buffer);↵

8

                out.writeObject(d1);↵

8

                out.writeObject(d1);↵

9

                out.close();↵

9

                out.close();↵

10

                ObjectInput in = new ObjectInputStream(↵

10

                ObjectInput in = new ObjectInputStream(↵

11

    new ByteArrayInputStream(↵

11

                    new ByteArrayInputStream(↵

12

                        buffer.toByteArray())↵

12

    buffer.toByteArray())↵

13

    );↵

13

                );↵

14

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

14

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

15

                in.close();↵

15

                in.close();↵

16

            }↵

16

            }↵

17

            catch (Exception e) {↵

17

            catch (Exception e) {↵

18

                e.printStackTrace();↵

18

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

19

            }↵

19

            }↵

20

            assertTrue(d1.equals(d2));

20

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