String ls = System.getProperty("line.separator"); perms.setSecurityManager(); try { String s = System.setProperty("line.separator",ls); fail("Could perform an action that should have been forbidden."); } catch (SecurityException e){ // Was expected, test passes } finally { perms.restoreSecurityManager(); }
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/PermissionsTest.java File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java
Method name: void testOther() Method name: void testValidateWrongAlgorithm()
Number of AST nodes: 5 Number of AST nodes: 5
1
String ls = System.getProperty("line.separator");
1
String 
2
        perms.setSecurityManager();
2
name = "this-is-not-a-valid-algorithm-name";
3
        try {
4
            ModifiedSelector.AlgorithmName algoName
3
        try {
5
        
4
            String s = System.setProperty("line.separator",ls);
6
        
5
            fail("Could perform an action that should have been forbidden
7
= new ModifiedSelector.AlgorithmName();
8
            algoName.setValue(name);
6
.");
9
            fail("CacheSelector.AlgorithmName accepted invalid value.");
7
        } catch (SecurityException e){
10
        } catch (BuildException be) {
8
            // Was expected, test passes
11
            
9
        } finally {
10
            perms.restoreSecurityMan
12
assertEquals(name + " is not a legal value for this attribute",
11
ager();
13
                         be.getMessage());
12
        }
14
        }
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.1
Clones locationClones are in different classes having the same super class
Number of node comparisons1