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);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.2
Clones locationClones are declared in the same class
Number of node comparisons77
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements16
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)61.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    1
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    1
    DefaultCategoryDataset data = new DefaultCategoryDataset();
    Differences
    Expression1Expression2Difference
    datasetdataVARIABLE_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
    Expression1Expression2Difference
    datasetdataVARIABLE_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
    Expression1Expression2Difference
    HORIZONTALVERTICALVARIABLE_NAME_MISMATCH
    6
    p1.setOrientation(PlotOrientation.VERTICAL);
    7
    CategoryPlot p2 = null;
    7
    CategoryPlot p2 = null;
    8
    try
    8
    try
    8
    try
    Differences
    Expression1Expression2Difference
    printStackTracefailMETHOD_INVOCATION_NAME_MISMATCH
    e.printStackTrace()fail(e.toString())TYPE_COMPATIBLE_REPLACEMENT
    e.printStackTrace()fail(e.toString())ARGUMENT_NUMBER_MISMATCH
    eMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    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() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    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
    Expression1Expression2Difference
    assertTrueassertEqualsMETHOD_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 (16)
    Row Violation
    1Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    4Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
    5Expression e.printStackTrace() cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression fail(e.toString()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression e.printStackTrace() is a void method call, and thus it cannot be parameterized
    8Expression fail(e.toString()) is a void method call, and thus it cannot be parameterized
    9Expression assertTrue(p1.equals(p2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression assertEquals(p1,p2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression assertTrue(p1.equals(p2)) is a void method call, and thus it cannot be parameterized
    12Expression assertEquals(p1,p2) is a void method call, and thus it cannot be parameterized
    13Expression assertTrue(p1.equals(p2)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression assertEquals(p1,p2) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Expression assertTrue(p1.equals(p2)) is a void method call, and thus it cannot be parameterized
    16Expression assertEquals(p1,p2) is a void method call, and thus it cannot be parameterized