364-5-6

double start = 10.0; double end = 20.0; HistogramBin b1 = new HistogramBin(start, end); HistogramBin b2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); b2 = (HistogramBin) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(b1, b2);
XYSeries s1 = new XYSeries("Series"); s1.add(1.0, 1.1); XYSeriesCollection c1 = new XYSeriesCollection(); c1.addSeries(s1); XYSeriesCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); c2 = (XYSeriesCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/statistics/junit/HistogramBinTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/xy/junit/XYSeriesCollectionTests.java
Method name: `void testSerialization()` |  | Method name: `void testSerialization()`
Number of AST nodes: 13 |  | Number of AST nodes: 14

1

    double start = 10.0;↵

2

            double end = 20.0;↵

3

            HistogramBi↵

1

    XYSeries s1 = new XYSeries("Series");↵

2

            s1.add(1.0, 1.1);↵

4

    n b1 = new HistogramBin(start, end);↵

3

            XYSeriesCollection c1 = new ↵

5

            HistogramBi↵

4

    XYSeriesCollection();↵

5

            c1.addSeries(s1);↵

6

    n b2 = null;↵

6

            XYSeriesCollection c2 = null;↵

7

            try {↵

7

            try {↵

8

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

8

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

9

                ObjectOutput out = new ObjectOutputStream(buffer);↵

9

                ObjectOutput out = new ObjectOutputStream(buffer);↵

10

                out.writeObject(b1);↵

10

                out.writeObject(c1);↵

11

                out.close();↵

11

                out.close();↵

12

                ObjectInput in = new ObjectInputStream(↵

12

                ObjectInput in = new ObjectInputStream(↵

13

                    new ByteArrayInputStream(buffer.toByteArray())↵

13

                        new ByteArrayInputStream(buffer.toByteArray())↵

14

                );↵

14

    );↵

15

                b2 = (HistogramBin) in.readObject();↵

15

                c2 = (XYSeriesCollection) in.readObject();↵

16

                in.close();↵

16

                in.close();↵

17

            }↵

17

            }↵

18

            catch (Exception e) {↵

18

            catch (Exception e) {↵

19

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

19

                e.printStackTrace();↵

20

            }↵

20

            }↵

21

            assertEquals(b1, b2);

21

            assertEquals(c1, c2);

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