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-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/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 testValidateWrongComparator()
Number of AST nodes: 5 Number of AST nodes: 5
1
String ls = System.getProperty("line.separator");
1
String name = "this-is-not-a-valid-comparator-name";
2
        perms.setSecurityManager();
2
        
3
        try {
4
            String s = System.setProperty("line.separator",ls);
5
            fail("Could perform an action that should have been forbidden
3
try {
4
            ModifiedSelector.ComparatorName compName
5
                = new ModifiedSelector.ComparatorName();
6
            compName.setValue(name);
6
.");
7
            fail("ModifiedSelector.ComparatorName accepted invalid value.");
7
        } catch (SecurityException e){
8
        } catch (BuildException be) {
8
            // Was expected, test passes
9
            
9
        } finally {
10
            perms.restoreSecurityMan
10
assertEquals(name + " is not a legal value for this attribute",
11
ager();
11
                         be.getMessage());
12
        }
12
        }
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