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-algorithm-name"; try { ModifiedSelector.AlgorithmName algoName = new ModifiedSelector.AlgorithmName(); algoName.setValue(name); fail("CacheSelector.AlgorithmName 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 testValidateWrongAlgorithm()
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-algorithm-name";
2
        try {
2
        try {
3
            ModifiedSelector.CacheName cacheName
3
            ModifiedSelector.AlgorithmName algoName
4
 = new ModifiedSelector.CacheName();
4
                = new ModifiedSelector.AlgorithmName();
5
            cacheName.setValue(name);
5
            algoName.setValue(name);
6
            fail("CacheSelector.CacheName accepted invalid value.");
6
            fail("CacheSelector.AlgorithmName 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.3
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-algorithm-name";
    Differences
    Expression1Expression2Difference
    "this-is-not-a-valid-cache-name""this-is-not-a-valid-algorithm-name"LITERAL_VALUE_MISMATCH
    1
    String name = "this-is-not-a-valid-algorithm-name";
    2
    try
    2
    try
    3
    ModifiedSelector.CacheName cacheName = new ModifiedSelector.CacheName();
    3
    ModifiedSelector.CacheName cacheName = new ModifiedSelector.CacheName();
    3
    ModifiedSelector.AlgorithmName algoName = new ModifiedSelector.AlgorithmName();
    Differences
    Expression1Expression2Difference
    CacheNameAlgorithmNameVARIABLE_NAME_MISMATCH
    cacheNamealgoNameVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector.CacheNameorg.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector.AlgorithmNameSUBCLASS_TYPE_MISMATCH
    CacheNameAlgorithmNameVARIABLE_NAME_MISMATCH
    3
    ModifiedSelector.AlgorithmName algoName = new ModifiedSelector.AlgorithmName();
    4
    cacheName.setValue(name);
    4
    cacheName.setValue(name);
    4
    algoName.setValue(name);
    Differences
    Expression1Expression2Difference
    cacheNamealgoNameVARIABLE_NAME_MISMATCH
    org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector.CacheNameorg.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector.AlgorithmNameSUBCLASS_TYPE_MISMATCH
    4
    algoName.setValue(name);
    5
    fail("CacheSelector.CacheName accepted invalid value.");
    5
    fail("CacheSelector.CacheName accepted invalid value.");
    5
    fail("CacheSelector.AlgorithmName accepted invalid value.");
    Differences
    Expression1Expression2Difference
    "CacheSelector.CacheName accepted invalid value.""CacheSelector.AlgorithmName accepted invalid value."LITERAL_VALUE_MISMATCH
    5
    fail("CacheSelector.AlgorithmName accepted invalid value.");
    Precondition Violations (0)
    Row Violation