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