324-3-5

DefaultKeyedValuesDataset d1 = new DefaultKeyedValuesDataset(); d1.setValue("C1", new Double(234.2)); d1.setValue("C2", null); d1.setValue("C3", new Double(345.9)); d1.setValue("C4", new Double(452.7)); KeyedValuesDataset 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 = (KeyedValuesDataset) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(d1, d2);
DefaultKeyedValues2D kv2D1 = new DefaultKeyedValues2D(); kv2D1.addValue(new Double(234.2), "Row1", "Col1"); kv2D1.addValue(null, "Row1", "Col2"); kv2D1.addValue(new Double(345.9), "Row2", "Col1"); kv2D1.addValue(new Double(452.7), "Row2", "Col2"); DefaultKeyedValues2D kv2D2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(kv2D1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); kv2D2 = (DefaultKeyedValues2D) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(kv2D1, kv2D2);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/data/general/junit/DefaultKeyedValuesDatasetTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/junit/DefaultKeyedValues2DTests.java
Method name: `void testSerialization()` |  | Method name: `void testSerialization()`
Number of AST nodes: 15 |  | Number of AST nodes: 15

1

    DefaultKeyedValuesDataset d1 = new DefaultKeyedValuesDataset();↵

1

    DefaultKeyedValues2D kv2D1 = new DefaultKeyedValues2D();↵

2

            d1.setValue("C1", new Double(234.2));↵

2

            kv2D1.addValue(new Double(234.2)↵

3

            d1.setValue("C2", null);↵

4

            d1.setValue("C3", ↵

3

    , "Row1", "Col1");↵

4

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

5

    new Double(345.9));↵

5

            kv2D1.addValue(new Double(345.9)↵

6

            d1.setValue("C4", ↵

6

    , "Row2", "Col1");↵

7

    new Double(452.7));↵

7

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

8

            KeyedValuesDataset d2 = null;↵

8

            DefaultKeyedValues2D kv2D2 = null;↵

9

            try {↵

9

            try {↵

10

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

10

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

11

                ObjectOutput out = new ObjectOutputStream(buffer);↵

11

                ObjectOutput out = new ObjectOutputStream(buffer);↵

12

                out.writeObject(d1);↵

12

                out.writeObject(kv2D1);↵

13

                out.close();↵

13

                out.close();↵

14

                ObjectInput in = new ObjectInputStream(↵

14

                ObjectInput in = new ObjectInputStream(↵

15

                    new ByteArrayInputStream(buffer.toByteArray())↵

15

                        new ByteArrayInputStream(buffer.toByteArray())↵

16

                );↵

16

    );↵

17

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

17

                kv2D2 = (DefaultKeyedValues2D) in.readObject();↵

18

                in.close();↵

18

                in.close();↵

19

            }↵

19

            }↵

20

            catch (Exception e) {↵

20

            catch (Exception e) {↵

21

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

21

                e.printStackTrace();↵

22

            }↵

22

            }↵

23

            assertEquals(d1, d2);

23

            assertEquals(kv2D1, kv2D2);

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