try { f.setRefid(new Reference("dummyref")); fail("Can add reference to " + f.getDataTypeName() + " with nested patternset element."); } catch (BuildException be) { assertEquals("You must not specify nested elements when " + "using refid", be.getMessage()); }
try { f.setSrc(new File("example.tar")); fail("can add src to " + f.getDataTypeName() + " when a dir is already present"); } catch (BuildException be) { assertEquals("Cannot set both dir and src attributes",be.getMessage()); }
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/AbstractFileSetTest.java File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/TarFileSetTest.java
Method name: void testEmptyElementIfIsReference() Method name: void testAttributes()
Number of AST nodes: 3 Number of AST nodes: 3
1
try {
1
try {
2
            f.setRefid(new Reference("dummyref"));
2
            f.setSrc(new File("example.tar"));
3
            fail("Can add reference to "
3
            fail("can add src to "
4
                 + f.getDataTypeName()
4
                    + f.getDataTypeName()
5
                 + " with nested patternset element.");
5
                    + " when a dir is already present");
6
        } catch (BuildException be) {
6
        } catch (BuildException be) {
7
            assertEquals("You must not specify nested elements when "
7
            assertEquals("
8
                         + "using refid", be.getMessage());
8
Cannot set both dir and src attributes",be.getMessage());
9
        }
9
        }
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 in different classes having the same super class
Number of node comparisons9
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements2
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.8
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    8
    try
    8
    try
    8
    try
    Differences
    Expression1Expression2Difference
    "You must not specify nested elements when " + "using refid""Cannot set both dir and src attributes"TYPE_COMPATIBLE_REPLACEMENT
    8
    try
                                                                              
    9
    f.setSrc(new File("example.tar"));
    9
    f.setRefid(new Reference("dummyref"));
    9
    f.setRefid(new Reference("dummyref"));
    Preondition Violations
    Unmatched statement f.setRefid(new Reference("dummyref")); 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
                                                                                      
    10
    fail("Can add reference to " + f.getDataTypeName() + " with nested patternset element.");
    10
    fail("Can add reference to " + f.getDataTypeName() + " with nested patternset element.");
    10
    fail("can add src to " + f.getDataTypeName() + " when a dir is already present");
    Differences
    Expression1Expression2Difference
    " with nested patternset element."" when a dir is already present"LITERAL_VALUE_MISMATCH
    "Can add reference to ""can add src to "LITERAL_VALUE_MISMATCH
    org.apache.tools.ant.types.AbstractFileSetorg.apache.tools.ant.types.TarFileSetSUBCLASS_TYPE_MISMATCH
    10
    fail("can add src to " + f.getDataTypeName() + " when a dir is already present");
    Precondition Violations (1)
    Row Violation
    1Unmatched statement f.setRefid(new Reference("dummyref")); 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