Path p = new Path(project); project.addReference("dummy", p); p.setRefid(new Reference("dummy")); try { p.list(); fail("Can make Path a Reference to itself."); } catch (BuildException be) { assertEquals("This data type contains a circular reference.", be.getMessage()); } // dummy1 --> dummy2 --> dummy3 --> dummy1 Path p1 = new Path(project); project.addReference("dummy1", p1);
Mapper m = new Mapper(project); project.addReference("dummy", m); m.setRefid(new Reference("dummy")); try { m.getImplementation(); fail("Can make Mapper a Reference to itself."); } catch (BuildException be) { assertEquals("This data type contains a circular reference.", be.getMessage()); } // dummy1 --> dummy2 --> dummy3 --> dummy1 Mapper m1 = new Mapper(project); project.addReference("dummy1", m1);
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/PathTest.java File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/MapperTest.java
Method name: void testCircularReferenceCheck() Method name: void testCircularReferenceCheck()
Number of AST nodes: 8 Number of AST nodes: 8
1
Path p = new Path(project);
1
Mapper m = new Mapper(project);
2
        project.addReference("dummy", p);
2
        project.addReference("dummy", m);
3
        p.setRefid(new Reference("dummy"));
3
        m.setRefid(new Reference("dummy"));
4
        try {
4
        try {
5
            p.list();
5
            m.getImplementation();
6
            fail("Can make Path a Reference to itself.");
6
            fail("Can make Mapper a Reference to itself.");
7
        } catch (BuildException be) {
7
        } catch (BuildException be) {
8
            assertEquals("This data type contains a circular reference.",
8
            assertEquals("This data type contains a circular reference.",
9
                         be.getMessage());
9
                         be.getMessage());
10
        }
10
        }
11
        // dummy1 --> dummy2 --> dummy3 --> dummy1
11
        // dummy1 --> dummy2 --> dummy3 --> dummy1
12
        Path p1 = new Path(project);
12
        Mapper m1 = new Mapper(project);
13
        project.addReference("dummy1", p1);
13
        project.addReference("dummy1", m1);
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.4
Clones locationClones are in different classes having the same super class
Number of node comparisons20
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements7
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)34.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Path p = new Path(project);
    1
    Path p = new Path(project);
    1
    Mapper m = new Mapper(project);
    Differences
    Expression1Expression2Difference
    org.apache.tools.ant.types.Pathorg.apache.tools.ant.types.MapperSUBCLASS_TYPE_MISMATCH
    pmVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.Pathorg.apache.tools.ant.types.MapperSUBCLASS_TYPE_MISMATCH
    org.apache.tools.ant.types.Pathorg.apache.tools.ant.types.MapperSUBCLASS_TYPE_MISMATCH
    1
    Mapper m = new Mapper(project);
    2
    project.addReference("dummy", p);
    2
    project.addReference("dummy", p);
    2
    project.addReference("dummy", m);
    Differences
    Expression1Expression2Difference
    pmVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.Pathorg.apache.tools.ant.types.MapperSUBCLASS_TYPE_MISMATCH
    2
    project.addReference("dummy", m);
    3
    p.setRefid(new Reference("dummy"));
    3
    p.setRefid(new Reference("dummy"));
    3
    m.setRefid(new Reference("dummy"));
    Differences
    Expression1Expression2Difference
    pmVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.Pathorg.apache.tools.ant.types.MapperSUBCLASS_TYPE_MISMATCH
    3
    m.setRefid(new Reference("dummy"));
    4
    try
    4
    try
                                                      
    5
    m.getImplementation();
    Preondition Violations
    Unmatched statement m.getImplementation(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement m.getImplementation(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    5
    m.getImplementation();
    5
    p.list();
    5
    p.list();
    Preondition Violations
    Unmatched statement p.list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement p.list(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                            
    6
    fail("Can make Path a Reference to itself.");
    6
    fail("Can make Path a Reference to itself.");
    6
    fail("Can make Mapper a Reference to itself.");
    Differences
    Expression1Expression2Difference
    "Can make Path a Reference to itself.""Can make Mapper a Reference to itself."LITERAL_VALUE_MISMATCH
    6
    fail("Can make Mapper a Reference to itself.");
    7
    Path p1 = new Path(project);
    7
    Path p1 = new Path(project);
    7
    Mapper m1 = new Mapper(project);
    Differences
    Expression1Expression2Difference
    org.apache.tools.ant.types.Pathorg.apache.tools.ant.types.MapperSUBCLASS_TYPE_MISMATCH
    p1m1VARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.Pathorg.apache.tools.ant.types.MapperSUBCLASS_TYPE_MISMATCH
    org.apache.tools.ant.types.Pathorg.apache.tools.ant.types.MapperSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new Path(project) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new Mapper(project) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7
    Mapper m1 = new Mapper(project);
    8
    project.addReference("dummy1", p1);
    8
    project.addReference("dummy1", p1);
    8
    project.addReference("dummy1", m1);
    Differences
    Expression1Expression2Difference
    p1m1VARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.Pathorg.apache.tools.ant.types.MapperSUBCLASS_TYPE_MISMATCH
    8
    project.addReference("dummy1", m1);
    Precondition Violations (7)
    Row Violation
    1Unmatched statement m.getImplementation(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement m.getImplementation(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    3Unmatched statement p.list(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement p.list(); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    5Expression new Path(project) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression new Mapper(project) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Clone fragment #1 returns variables p, p1 , while Clone fragment #2 returns variables m, m1