326-1-2

DefaultCategoryDataset dataset = new DefaultCategoryDataset(); CategoryAxis domainAxis = new CategoryAxis("Domain"); NumberAxis rangeAxis = new NumberAxis("Range"); BarRenderer renderer = new BarRenderer(); CategoryPlot p1 = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); p1.setOrientation(PlotOrientation.HORIZONTAL); CategoryPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (CategoryPlot) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertTrue(p1.equals(p2));
DefaultCategoryDataset data = new DefaultCategoryDataset(); CategoryAxis domainAxis = new CategoryAxis("Domain"); NumberAxis rangeAxis = new NumberAxis("Range"); BarRenderer renderer = new BarRenderer(); CategoryPlot p1 = new CategoryPlot(data, domainAxis, rangeAxis, renderer); p1.setOrientation(PlotOrientation.VERTICAL); CategoryPlot p2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); p2 = (CategoryPlot) in.readObject(); in.close(); } catch (Exception e) { fail(e.toString()); } assertEquals(p1, p2);

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/CategoryPlotTests.java |  | File path: /jfreechart-1.0.10/tests/org/jfree/chart/plot/junit/CategoryPlotTests.java
Method name: `void testSerialization()` |  | Method name: `void testSerialization2()`
Number of AST nodes: 16 |  | Number of AST nodes: 16

1

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();↵

1

    DefaultCategoryDataset data = new DefaultCategoryDataset();↵

2

            CategoryAxis domainAxis = new CategoryAxis("Domain");↵

2

            CategoryAxis domainAxis = new CategoryAxis("Domain");↵

3

            NumberAxis rangeAxis = new NumberAxis("Range");↵

3

            NumberAxis rangeAxis = new NumberAxis("Range");↵

4

            BarRenderer renderer = new BarRenderer();↵

4

            BarRenderer renderer = new BarRenderer();↵

5

            CategoryPlot p1 = new CategoryPlot(dataset, domainAxis, rangeAxis,↵

5

            CategoryPlot p1 = new CategoryPlot(data, domainAxis, rangeAxis,↵

6

                    renderer);↵

6

                    renderer);↵

7

            p1.setOrientation(PlotOrientation.HORIZONTAL);↵

7

            p1.setOrientation(PlotOrientation.VERTICAL);↵

8

            CategoryPlot p2 = null;↵

8

            CategoryPlot p2 = 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(p1);↵

12

                out.writeObject(p1);↵

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

                p2 = (CategoryPlot) in.readObject();↵

16

                p2 = (CategoryPlot) in.readObject();↵

17

                in.close();↵

17

                in.close();↵

18

            }↵

18

            }↵

19

            catch (Exception e) {↵

19

            catch (Exception e) {↵

20

                e.printStackTrace();↵

20

                fail(e.toString());↵

21

            }↵

21

            }↵

22

            assertTrue(p1.equals(p2));

22

            assertEquals(p1, p2);

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 0
Number of non-refactorable cases | 1
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.1
Clones location | Clones are declared in the same class
Number of node comparisons | 90

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 16
   Number of unmapped statements in the first code fragment | 0
   Number of unmapped statements in the second code fragment | 0
   Time elapsed for statement mapping (ms) | 4.0
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   1

       DefaultCategoryDataset dataset = new DefaultCategoryDataset();

   1 | DefaultCategoryDataset dataset = new DefaultCategoryDataset();
   1 | DefaultCategoryDataset data = new DefaultCategoryDataset();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   dataset | data | VARIABLE_NAME_MISMATCH

   1

       DefaultCategoryDataset data = new DefaultCategoryDataset();

   2

       CategoryAxis domainAxis = new CategoryAxis("Domain");

   2

       CategoryAxis domainAxis = new CategoryAxis("Domain");

   3

       NumberAxis rangeAxis = new NumberAxis("Range");

   3

       NumberAxis rangeAxis = new NumberAxis("Range");

   4

       BarRenderer renderer = new BarRenderer();

   4

       BarRenderer renderer = new BarRenderer();

   5

       CategoryPlot p1 = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer);

   5 | CategoryPlot p1 = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer);
   5 | CategoryPlot p1 = new CategoryPlot(data, domainAxis, rangeAxis, renderer);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   dataset | data | VARIABLE_NAME_MISMATCH

   5

       CategoryPlot p1 = new CategoryPlot(data, domainAxis, rangeAxis, renderer);

   6

       p1.setOrientation(PlotOrientation.HORIZONTAL);

   6 | p1.setOrientation(PlotOrientation.HORIZONTAL);
   6 | p1.setOrientation(PlotOrientation.VERTICAL);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   HORIZONTAL | VERTICAL | VARIABLE_NAME_MISMATCH

   6

       p1.setOrientation(PlotOrientation.VERTICAL);

   7

       CategoryPlot p2 = null;

   7

       CategoryPlot p2 = null;

   8

       try

   8 | try
   8 | try

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   printStackTrace | fail | METHOD_INVOCATION_NAME_MISMATCH
   e.printStackTrace() | fail(e.toString()) | ARGUMENT_NUMBER_MISMATCH
   e |  | MISSING_METHOD_INVOCATION_EXPRESSION

   Preondition Violations
   Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
   Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
   Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
   Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized

   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(p1);

   11

       out.writeObject(p1);

   12

       out.close();

   12

       out.close();

   13

       ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));

   13

       ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));

   14

       p2 = (CategoryPlot)in.readObject();

   14

       p2 = (CategoryPlot)in.readObject();

   15

       in.close();

   15

       in.close();

   16

       assertTrue(p1.equals(p2));

   16 | assertTrue(p1.equals(p2));
   16 | assertEquals(p1, p2);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   assertTrue | assertEquals | METHOD_INVOCATION_NAME_MISMATCH
   assertTrue(p1.equals(p2)) | assertEquals(p1,p2) | ARGUMENT_NUMBER_MISMATCH

   Preondition Violations
   Expression assertTrue(p1.equals(p2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertEquals(p1,p2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertTrue(p1.equals(p2)) is a void method call, and thus it cannot be parameterized
   Expression assertEquals(p1,p2) is a void method call, and thus it cannot be parameterized
   Expression assertTrue(p1.equals(p2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertEquals(p1,p2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression assertTrue(p1.equals(p2)) is a void method call, and thus it cannot be parameterized
   Expression assertEquals(p1,p2) is a void method call, and thus it cannot be parameterized

   16

       assertEquals(p1, p2);

   Precondition Violations (12)
   Row | Violation
   --- | ---
   1 | Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
   2 | Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
   3 | Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
   4 | Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
   5 | Expression assertTrue(p1.equals(p2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   6 | Expression assertEquals(p1,p2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   7 | Expression assertTrue(p1.equals(p2)) is a void method call, and thus it cannot be parameterized
   8 | Expression assertEquals(p1,p2) is a void method call, and thus it cannot be parameterized
   9 | Expression assertTrue(p1.equals(p2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   10 | Expression assertEquals(p1,p2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   11 | Expression assertTrue(p1.equals(p2)) is a void method call, and thus it cannot be parameterized
   12 | Expression assertEquals(p1,p2) is a void method call, and thus it cannot be parameterized