362-6-8

StrokeMap m1 = new StrokeMap(); m1.put("K1", new BasicStroke(1.1f)); m1.put("K2", new BasicStroke(2.2f)); StrokeMap m2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); m2 = (StrokeMap) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(m1, m2);
TimePeriodValue tpv1 = new TimePeriodValue(new Day(30, 7, 2003), 55.75); TimePeriodValue tpv2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(tpv1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); tpv2 = (TimePeriodValue) in.readObject(); in.close(); } catch (Exception e) { System.out.println(e.toString()); } assertEquals(tpv1, tpv2);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/junit/StrokeMapTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/data/time/junit/TimePeriodValueTests.java
Method name: `void testSerialization2()` |  | Method name: `void testSerialization()`
Number of AST nodes: 13 |  | Number of AST nodes: 11

1

    StrokeMap m1 = new StrokeMap();↵

2

            m1.put("K1", new BasicStroke(1.1f));↵

3

            m1.put("K2", new BasicStroke(2.2f));↵

4

            StrokeMap m↵

1

    TimePeriodValue tpv1 = new TimePeriodValue(new Day(30, 7, 2003), 55.75);↵

5

    2 = null;↵

2

            TimePeriodValue tpv2 = null;↵

6

            try {↵

3

            try {↵

7

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

4

                ByteArrayOutputStream buffer = new ByteArrayOutputStream();↵

8

                ObjectOutput out = new ObjectOutputStream(buffer);↵

5

                ObjectOutput out = new ObjectOutputStream(buffer);↵

9

                out.writeObject(m1);↵

6

                out.writeObject(tpv1);↵

10

                out.close();↵

7

                out.close();↵

11

                ObjectInput in = new ObjectInputStream(↵

8

                ObjectInput in = new ObjectInputStream(↵

12

    new ByteArrayInputStream(↵

9

                    new ByteArrayInputStream(↵

13

                        buffer.toByteArray())↵

10

    buffer.toByteArray())↵

14

    );↵

11

                );↵

15

                m2 = (StrokeMap) in.readObject();↵

12

                tpv2 = (TimePeriodValue) in.readObject();↵

16

                in.close();↵

13

                in.close();↵

17

            }↵

14

            }↵

18

            catch (Exception e) {↵

15

            catch (Exception e) {↵

19

                e.printStackTrace();↵

16

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

20

            }↵

17

            }↵

21

            assertEquals(m1, m2);

18

            assertEquals(tpv1, tpv2);

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