Map elemMap = getExpectedNestedElements(); Enumeration e = ih.getNestedElements(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); Class expect = (Class) elemMap.get(name); assertNotNull("Support for "+name+" in IntrospectioNHelperTest?", expect); assertEquals("Return type of "+name, expect, ih.getElementType(name)); elemMap.remove(name); }
Map attrMap = getExpectedAttributes(); Enumeration e = ih.getAttributes(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); Class expect = (Class) attrMap.get(name); assertNotNull("Support for "+name+" in IntrospectionHelperTest?", expect); assertEquals("Type of "+name, expect, ih.getAttributeType(name)); attrMap.remove(name); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java
Method name: void testGetNestedElements() Method name: void testGetAttributes()
Number of AST nodes: 8 Number of AST nodes: 8
1
Map elemMap = getExpectedNestedElements();
1
Map attrMap = getExpectedAttributes();
2
        Enumeration e = ih.getNestedElements();
2
        Enumeration e = ih.getAttributes();
3
        while (e.hasMoreElements()) {
3
        while (e.hasMoreElements()) {
4
            String name = (String) e.nextElement();
4
            String name = (String) e.nextElement();
5
            Class expect = (Class) elemMap.get(name);
5
            Class expect = (Class) attrMap.get(name);
6
            assertNotNull("Support for "+name+" in IntrospectioNHelperTest?",
6
            assertNotNull("Support for "+name+" in IntrospectionHelperTest?",
7
                          expect);
7
                          expect);
8
            assertEquals("Return type of "+name, expect, ih.getElementType(name));
8
            assertEquals("Type of "+name, expect, ih.getAttributeType(name));
9
            elemMap.remove(name);
9
            attrMap.remove(name);
10
        }
10
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.1
Clones locationClones are declared in the same class
Number of node comparisons40
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)38.4
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Map elemMap = getExpectedNestedElements();
    1
    Map elemMap = getExpectedNestedElements();
    1
    Map attrMap = getExpectedAttributes();
    Differences
    Expression1Expression2Difference
    elemMapattrMapVARIABLE_NAME_MISMATCH
    getExpectedNestedElementsgetExpectedAttributesMETHOD_INVOCATION_NAME_MISMATCH
    1
    Map attrMap = getExpectedAttributes();
    2
    Enumeration e = ih.getNestedElements();
    2
    Enumeration e = ih.getNestedElements();
    2
    Enumeration e = ih.getAttributes();
    Differences
    Expression1Expression2Difference
    getNestedElementsgetAttributesMETHOD_INVOCATION_NAME_MISMATCH
    2
    Enumeration e = ih.getAttributes();
    3
    while (e.hasMoreElements())
    3
    while (e.hasMoreElements())
    4
    String name = (String)e.nextElement();
    4
    String name = (String)e.nextElement();
    5
    Class expect = (Class)elemMap.get(name);
    5
    Class expect = (Class)elemMap.get(name);
    5
    Class expect = (Class)attrMap.get(name);
    Differences
    Expression1Expression2Difference
    elemMapattrMapVARIABLE_NAME_MISMATCH
    5
    Class expect = (Class)attrMap.get(name);
    6
    assertNotNull("Support for " + name + " in IntrospectioNHelperTest?", expect);
    6
    assertNotNull("Support for " + name + " in IntrospectioNHelperTest?", expect);
    6
    assertNotNull("Support for " + name + " in IntrospectionHelperTest?", expect);
    Differences
    Expression1Expression2Difference
    " in IntrospectioNHelperTest?"" in IntrospectionHelperTest?"LITERAL_VALUE_MISMATCH
    6
    assertNotNull("Support for " + name + " in IntrospectionHelperTest?", expect);
    7
    assertEquals("Return type of " + name, expect, ih.getElementType(name));
    7
    assertEquals("Return type of " + name, expect, ih.getElementType(name));
    7
    assertEquals("Type of " + name, expect, ih.getAttributeType(name));
    Differences
    Expression1Expression2Difference
    "Return type of ""Type of "LITERAL_VALUE_MISMATCH
    getElementTypegetAttributeTypeMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression ih.getElementType(name) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression ih.getAttributeType(name) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7
    assertEquals("Type of " + name, expect, ih.getAttributeType(name));
    8
    elemMap.remove(name);
    8
    elemMap.remove(name);
    8
    attrMap.remove(name);
    Differences
    Expression1Expression2Difference
    elemMapattrMapVARIABLE_NAME_MISMATCH
    8
    attrMap.remove(name);
    Precondition Violations (2)
    Row Violation
    1Expression ih.getElementType(name) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression ih.getAttributeType(name) cannot be parameterized, because it has dependencies to/from statements that will be extracted