String name = "this-is-not-a-valid-cache-name"; try { ModifiedSelector.CacheName cacheName = new ModifiedSelector.CacheName(); cacheName.setValue(name); fail("CacheSelector.CacheName accepted invalid value."); } catch (BuildException be) { assertEquals(name + " is not a legal value for this attribute", be.getMessage()); }
String name = "this-is-not-a-valid-comparator-name"; try { ModifiedSelector.ComparatorName compName = new ModifiedSelector.ComparatorName(); compName.setValue(name); fail("ModifiedSelector.ComparatorName accepted invalid value."); } catch (BuildException be) { assertEquals(name + " is not a legal value for this attribute", be.getMessage()); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java
Method name: void testValidateWrongCache() Method name: void testValidateWrongComparator()
Number of AST nodes: 5 Number of AST nodes: 5
1
String name = "this-is-not-a-valid-cache-name";
1
String name = "this-is-not-a-valid-comparator-name";
2
        try {
2
        try {
3
            ModifiedSelector.CacheName cacheName
3
            ModifiedSelector.ComparatorName compName
4
 = new ModifiedSelector.CacheName();
4
                = new ModifiedSelector.ComparatorName();
5
            cacheName.setValue(name);
5
            compName.setValue(name);
6
            fail("CacheSelector.CacheName accepted invalid value.");
6
            fail("ModifiedSelector.ComparatorName accepted invalid value.");
7
        } catch (BuildException be) {
7
        } catch (BuildException be) {
8
            assertEquals(name + " is not a legal value for this attribute",
8
            assertEquals(name + " is not a legal value for this attribute",
9
                         be.getMessage());
9
                         be.getMessage());
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.2
Clones locationClones are declared in the same class
Number of node comparisons17
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    String name = "this-is-not-a-valid-cache-name";
    1
    String name = "this-is-not-a-valid-cache-name";
    1
    String name = "this-is-not-a-valid-comparator-name";
    Differences
    Expression1Expression2Difference
    "this-is-not-a-valid-cache-name""this-is-not-a-valid-comparator-name"LITERAL_VALUE_MISMATCH
    1
    String name = "this-is-not-a-valid-comparator-name";
    2
    try
    2
    try
    3
    ModifiedSelector.CacheName cacheName = new ModifiedSelector.CacheName();
    3
    ModifiedSelector.CacheName cacheName = new ModifiedSelector.CacheName();
    3
    ModifiedSelector.ComparatorName compName = new ModifiedSelector.ComparatorName();
    Differences
    Expression1Expression2Difference
    CacheNameComparatorNameVARIABLE_NAME_MISMATCH
    cacheNamecompNameVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector.CacheNameorg.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector.ComparatorNameSUBCLASS_TYPE_MISMATCH
    CacheNameComparatorNameVARIABLE_NAME_MISMATCH
    3
    ModifiedSelector.ComparatorName compName = new ModifiedSelector.ComparatorName();
    4
    cacheName.setValue(name);
    4
    cacheName.setValue(name);
    4
    compName.setValue(name);
    Differences
    Expression1Expression2Difference
    cacheNamecompNameVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector.CacheNameorg.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector.ComparatorNameSUBCLASS_TYPE_MISMATCH
    4
    compName.setValue(name);
    5
    fail("CacheSelector.CacheName accepted invalid value.");
    5
    fail("CacheSelector.CacheName accepted invalid value.");
    5
    fail("ModifiedSelector.ComparatorName accepted invalid value.");
    Differences
    Expression1Expression2Difference
    "CacheSelector.CacheName accepted invalid value.""ModifiedSelector.ComparatorName accepted invalid value."LITERAL_VALUE_MISMATCH
    5
    fail("ModifiedSelector.ComparatorName accepted invalid value.");
    Precondition Violations (0)
    Row Violation