Map elemMap = getExpectedNestedElements(); Map actualMap = ih.getNestedElementMap(); for (Iterator i = actualMap.entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); String elemName = (String) entry.getKey(); Class elemClass = (Class) elemMap.get(elemName); assertNotNull("Support for " + elemName + " in IntrospectionHelperTest?", elemClass); assertEquals("Type of " + elemName, elemClass, entry.getValue()); elemMap.remove(elemName); } assertTrue("Found all", elemMap.isEmpty()); // Check it's a read-only map. try { actualMap.clear(); } catch (UnsupportedOperationException e) {}
Map attrMap = getExpectedAttributes(); Map actualMap = ih.getAttributeMap(); for (Iterator i = actualMap.entrySet().iterator(); i.hasNext();) { Map.Entry entry = (Map.Entry) i.next(); String attrName = (String) entry.getKey(); Class attrClass = (Class) attrMap.get(attrName); assertNotNull("Support for " + attrName + " in IntrospectionHelperTest?", attrClass); assertEquals("Type of " + attrName, attrClass, entry.getValue()); attrMap.remove(attrName); } attrMap.remove("name"); assertTrue("Found all", attrMap.isEmpty()); // Check it's a read-only map. try { actualMap.clear(); } catch (UnsupportedOperationException e) {}
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 testGetNestedElementMap() Method name: void testGetAttributeMap()
Number of AST nodes: 12 Number of AST nodes: 13
1
Map elemMap = getExpectedNestedElements();
1
Map attrMap = getExpectedAttributes();
2
        Map actualMap = ih.getNestedElementMap();
2
        Map actualMap = ih.getAttributeMap();
3
        for (Iterator i = actualMap.entrySet().iterator(); i.hasNext();) {
3
        for (Iterator i = actualMap.entrySet().iterator(); i.hasNext();) {
4
            Map.Entry entry = (Map.Entry) i.next();
4
            Map.Entry entry = (Map.Entry) i.next();
5
            String elemName = (String) entry.getKey();
5
            String attrName = (String) entry.getKey();
6
            Class elemClass = (Class) elemMap.get(elemName);
6
            Class attrClass = (Class) attrMap.get(attrName);
7
            assertNotNull("Support for " + elemName +
7
            assertNotNull("Support for " + attrName +
8
                          " in IntrospectionHelperTest?", elemClass);
8
                          " in IntrospectionHelperTest?", attrClass);
9
            assertEquals("Type of " + elemName, elemClass, entry.getValue());
9
            assertEquals("Type of " + attrName, attrClass, entry.getValue());
10
            elemMap.remove(elemName);
10
            attrMap.remove(attrName);
11
        }
11
        }
12
        attrMap.remove("name");
12
        assertTrue("Found all", elemMap.isEmpty());
13
        assertTrue("Found all", attrMap.isEmpty());
13
        // Check it's a read-only map.
14
        // Check it's a read-only map.
14
        try {
15
        try {
15
            actualMap.clear();
16
            actualMap.clear();
16
        } catch (UnsupportedOperationException e) {}
17
        } catch (UnsupportedOperationException e) {}
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 declared in the same class
Number of node comparisons76
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements12
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)18.4
    Clone typeType 3
    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
    Map actualMap = ih.getNestedElementMap();
    2
    Map actualMap = ih.getNestedElementMap();
    2
    Map actualMap = ih.getAttributeMap();
    Differences
    Expression1Expression2Difference
    getNestedElementMapgetAttributeMapMETHOD_INVOCATION_NAME_MISMATCH
    2
    Map actualMap = ih.getAttributeMap();
    3
    for (Iterator i = actualMap.entrySet().iterator(); i.hasNext(); )
    3
    for (Iterator i = actualMap.entrySet().iterator(); i.hasNext(); )
    4
    Map.Entry entry = (Map.Entry)i.next();
    4
    Map.Entry entry = (Map.Entry)i.next();
    5
    String elemName = (String)entry.getKey();
    5
    String elemName = (String)entry.getKey();
    5
    String attrName = (String)entry.getKey();
    Differences
    Expression1Expression2Difference
    elemNameattrNameVARIABLE_NAME_MISMATCH
    5
    String attrName = (String)entry.getKey();
    6
    Class elemClass = (Class)elemMap.get(elemName);
    6
    Class elemClass = (Class)elemMap.get(elemName);
    6
    Class attrClass = (Class)attrMap.get(attrName);
    Differences
    Expression1Expression2Difference
    elemClassattrClassVARIABLE_NAME_MISMATCH
    elemNameattrNameVARIABLE_NAME_MISMATCH
    elemMapattrMapVARIABLE_NAME_MISMATCH
    6
    Class attrClass = (Class)attrMap.get(attrName);
    7
    assertNotNull("Support for " + elemName + " in IntrospectionHelperTest?", elemClass);
    7
    assertNotNull("Support for " + elemName + " in IntrospectionHelperTest?", elemClass);
    7
    assertNotNull("Support for " + attrName + " in IntrospectionHelperTest?", attrClass);
    Differences
    Expression1Expression2Difference
    elemNameattrNameVARIABLE_NAME_MISMATCH
    elemClassattrClassVARIABLE_NAME_MISMATCH
    7
    assertNotNull("Support for " + attrName + " in IntrospectionHelperTest?", attrClass);
    8
    assertEquals("Type of " + elemName, elemClass, entry.getValue());
    8
    assertEquals("Type of " + elemName, elemClass, entry.getValue());
    8
    assertEquals("Type of " + attrName, attrClass, entry.getValue());
    Differences
    Expression1Expression2Difference
    elemNameattrNameVARIABLE_NAME_MISMATCH
    elemClassattrClassVARIABLE_NAME_MISMATCH
    8
    assertEquals("Type of " + attrName, attrClass, entry.getValue());
    9
    elemMap.remove(elemName);
    9
    elemMap.remove(elemName);
    9
    attrMap.remove(attrName);
    Differences
    Expression1Expression2Difference
    elemNameattrNameVARIABLE_NAME_MISMATCH
    elemMapattrMapVARIABLE_NAME_MISMATCH
    9
    attrMap.remove(attrName);
                                                          
    10
    attrMap.remove("name");
    Preondition Violations
    Unmatched statement attrMap.remove("name"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10
    attrMap.remove("name");
    10
    assertTrue("Found all", elemMap.isEmpty());
    10
    assertTrue("Found all", elemMap.isEmpty());
    11
    assertTrue("Found all", attrMap.isEmpty());
    Differences
    Expression1Expression2Difference
    elemMapattrMapVARIABLE_NAME_MISMATCH
    11
    assertTrue("Found all", attrMap.isEmpty());
    11
    try
    12
    try
    12
    actualMap.clear();
    13
    actualMap.clear();
    Precondition Violations (2)
    Row Violation
    1Unmatched statement attrMap.remove("name"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Clone fragment #1 returns variables , while Clone fragment #2 returns variables attrMap