try { Source result = catalog.resolve("i/dont/exist.dtd", null); String expected = toURLString(new File(project.getBaseDir() + "/i/dont/exist.dtd")); // // These shenanigans are necessary b/c Norm Walsh's resolver // has a different idea of how file URLs are created on windoze // ie file://c:/foo instead of file:///c:/foo // String resultStr = new URL(((SAXSource)result).getInputSource().getSystemId()).getFile(); assertTrue("Empty catalog should return input", expected.endsWith(resultStr)); } catch (Exception e) { fail("resolve() failed!" + e.toString()); }
try { Source result = catalog.resolve("i/dont/exist.dtd", null); String expected = toURLString(new File(project.getBaseDir().toURL() + "/i/dont/exist.dtd")); String resultStr = new URL(((SAXSource)result).getInputSource().getSystemId()).getFile(); assertTrue("Nonexistent Catalog entry return input", expected.endsWith(resultStr)); } catch (Exception e) { fail("resolve() failed!" + e.toString()); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java
Method name: void testEmptyCatalog() Method name: void testNonExistentEntry()
Number of AST nodes: 5 Number of AST nodes: 5
1
try {
1
try {
2
           Source result = catalog.resolve("i/dont/exist.dtd", null);
2
            Source result = catalog.resolve("i/dont/exist.dtd", null);
3
           String expected = toURLString(new File(project.getBaseDir() +
3
            String expected = toURLString(new File(project.getBaseDir().toURL() +
4
                                                  "/i/dont/exist.dtd"));
4
                                                   "/i/dont/exist.dtd"));
5
           //
5
 
6
           // These shenanigans are necessary b/c Norm Walsh's resolver
7
           // has a different idea of how file URLs are created on windoze
8
           // ie file://c:/foo instead of file:///c:/foo
9
           //
10
           String resultStr = new URL(((SAXSource)result).getInputSource().getSystemId()).getFile();
6
           String resultStr = new URL(((SAXSource)result).getInputSource().getSystemId()).getFile();
11
           assertTrue("Empty catalog should return input",
7
            assertTrue("Nonexistent Catalog entry return input",
12
                      expected.endsWith(resultStr));
8
                       expected.endsWith(resultStr));
13
       } catch (Exception e) {
9
        } catch (Exception e) {
14
           fail("resolve() failed!" + e.toString());
10
            fail("resolve() failed!" + e.toString());
15
       }
11
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.2
Clones locationClones are declared in the same class
Number of node comparisons25
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    4
    try
    7
    try
    5
    Source result = catalog.resolve("i/dont/exist.dtd", null);
    8
    Source result = catalog.resolve("i/dont/exist.dtd", null);
    6
    String expected = toURLString(new File(project.getBaseDir() + "/i/dont/exist.dtd"));
    6
    String expected = toURLString(new File(project.getBaseDir() + "/i/dont/exist.dtd"));
    Preondition Violations
    Unmatched statement String expected=toURLString(new File(project.getBaseDir() + "/i/dont/exist.dtd")); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                                                                                                                                              
                                                                                                                                                                                              
    9
    String expected = toURLString(new File(project.getBaseDir().toURL() + "/i/dont/exist.dtd"));
    Preondition Violations
    Unmatched statement String expected=toURLString(new File(project.getBaseDir().toURL() + "/i/dont/exist.dtd")); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    9
    String expected = toURLString(new File(project.getBaseDir().toURL() + "/i/dont/exist.dtd"));
    7
    String resultStr = new URL(((SAXSource)result).getInputSource().getSystemId()).getFile();
    10
    String resultStr = new URL(((SAXSource)result).getInputSource().getSystemId()).getFile();
    8
    assertTrue("Empty catalog should return input", expected.endsWith(resultStr));
    8
    assertTrue("Empty catalog should return input", expected.endsWith(resultStr));
    11
    assertTrue("Nonexistent Catalog entry return input", expected.endsWith(resultStr));
    Differences
    Expression1Expression2Difference
    "Empty catalog should return input""Nonexistent Catalog entry return input"LITERAL_VALUE_MISMATCH
    11
    assertTrue("Nonexistent Catalog entry return input", expected.endsWith(resultStr));
    Precondition Violations (2)
    Row Violation
    1Unmatched statement String expected=toURLString(new File(project.getBaseDir() + "/i/dont/exist.dtd")); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    2Unmatched statement String expected=toURLString(new File(project.getBaseDir().toURL() + "/i/dont/exist.dtd")); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted