324-1-2

DefaultPieDataset data = new DefaultPieDataset(); data.setValue("Type 1", 54.5); data.setValue("Type 2", 23.9); data.setValue("Type 3", 45.8); JFreeChart c1 = ChartFactory.createPieChart3D("Test", data, true, true, true); JFreeChart 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 = (JFreeChart) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2);
DefaultKeyedValues2DDataset d1 = new DefaultKeyedValues2DDataset(); d1.addValue(new Double(234.2), "Row1", "Col1"); d1.addValue(null, "Row1", "Col2"); d1.addValue(new Double(345.9), "Row2", "Col1"); d1.addValue(new Double(452.7), "Row2", "Col2"); DefaultKeyedValues2DDataset 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 = (DefaultKeyedValues2DDataset) 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/chart/junit/JFreeChartTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/general/junit/DefaultKeyedValues2DDatasetTests.java
Method name: `void testSerialization2()` |  | Method name: `void testSerialization()`
Number of AST nodes: 15 |  | Number of AST nodes: 15

1

    DefaultPieDataset data = new DefaultPieDataset();↵

1

    DefaultKeyedValues2DDataset d1 = new DefaultKeyedValues2DDataset();↵

2

            data.setValue("Type 1", 54.5);↵

2

            d1.addValue(new Double(234.2), "Row1", "Col1");↵

3

            data.setValue("Type 2", 23.9);↵

3

            d1.addValue(null, "Row1", "Col2");↵

4

            data.setValue("Type 3", 45.8);↵

4

            d1.addValue(new Double(345.9), "Row2", "Col1");↵

5

            JFreeChart c1 = ChartFactory.createPieChart3D("Test", data, true, true,↵

5

            ↵

6

                    true);↵

6

    d1.addValue(new Double(452.7), "Row2", "Col2");↵

7

            JFreeChart c2 = null;↵

7

            DefaultKeyedValues2DDataset d2 = null;↵

8

            try {↵

8

            try {↵

9

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

9

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

10

                ObjectOutput out = new ObjectOutputStream(buffer);↵

10

                ObjectOutput out = new ObjectOutputStream(buffer);↵

11

                out.writeObject(c1);↵

11

                out.writeObject(d1);↵

12

                out.close();↵

12

                out.close();↵

13

                ObjectInput in = new ObjectInputStream(↵

13

                ObjectInput in = new ObjectInputStream(↵

14

    new ByteArrayInputStream(↵

14

                    new ByteArrayInputStream(↵

15

                        buffer.toByteArray())↵

15

    buffer.toByteArray())↵

16

    );↵

16

                );↵

17

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

17

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

18

                in.close();↵

18

                in.close();↵

19

            }↵

19

            }↵

20

            catch (Exception e) {↵

20

            catch (Exception e) {↵

21

                e.printStackTrace();↵

21

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

22

            }↵

22

            }↵

23

            assertEquals(c1, c2);

23

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