try { s.isSelected(basedir,filenames[0],files[0]); fail("DateSelector did not check for required fields"); } catch (BuildException be1) { assertEquals("You must provide a datetime or the number of " + "milliseconds.", be1.getMessage()); } s = (DateSelector)getInstance(); s.setDatetime("01/01/1969 01:01 AM"); try { s.isSelected(basedir,filenames[0],files[0]); fail("DateSelector did not check for Datetime being in the " + "allowable range"); } catch (BuildException be2) { assertEquals("Date of 01/01/1969 01:01 AM results in negative " + "milliseconds value relative to epoch (January 1, " + "1970, 00:00:00 GMT).", be2.getMessage()); } s = (DateSelector)getInstance();
try { s.isSelected(basedir,filenames[0],files[0]); fail("DateSelector did not check for Datetime being in the " + "allowable range"); } catch (BuildException be2) { assertEquals("Date of 01/01/1969 01:01 AM results in negative " + "milliseconds value relative to epoch (January 1, " + "1970, 00:00:00 GMT).", be2.getMessage()); } s = (DateSelector)getInstance(); s.setDatetime("this is not a date"); try { s.isSelected(basedir,filenames[0],files[0]); fail("DateSelector did not check for Datetime being in a " + "valid format"); } catch (BuildException be3) { assertEquals("Date of this is not a date" + " Cannot be parsed correctly. It should be in" + " MM/DD/YYYY HH:MM AM_PM format.", be3.getMessage()); } s = (DateSelector)getInstance();
Clone fragments detected by clone detection tool
File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java File path: /apache-ant-1.7.0/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java
Method name: void testValidate() Method name: void testValidate()
Number of AST nodes: 9 Number of AST nodes: 9
1
try {
1
try {
2
            s.isSelected(basedir,filenames[0],files[0]);
2
            s.isSelected(basedir,filenames[0],files[0]);
3
            fail("DateSelector did not check for required fields
3
            fail("DateSelector did not check for Datetime being in the "
4
");
4
                    + "allowable range");
5
        } catch (BuildException be1) {
5
        } catch (BuildException be2) {
6
            assertEquals("You must provide a date
6
            assertEquals("Date of 01/01/1969 01:01 AM results in negative "
7
time or the number of "
7
                    + "milliseconds value relative to epoch (January 1, "
8
                    + "milliseconds.", be1.getMessage());
8
                    + "1970, 00:00:00 GMT).", be2.getMessage());
9
        }
9
        }
10
        s = (DateSelector)getInstance();
10
        s = (DateSelector)getInstance();
11
        s.setDatetime("01/01/1969 01:01 AM");
11
        s.setDatetime("this is not a date");
12
        try {
12
        try {
13
            s.isSelected(basedir,filenames[0],files[0]);
13
            s.isSelected(basedir,filenames[0],files[0]);
14
            fail("DateSelector did not check for Datetime being in the "
14
            fail("DateSelector did not check for Datetime being in a "
15
                    + "allowable range");
15
                    + "valid format");
16
        } catch (BuildException be2) {
16
        } catch (BuildException be3) {
17
            assertEquals("Date of 01/01/1969 01:01 AM results in negative "
17
            assertEquals("Date of 
18
                    + "milliseconds value relative to epoch (January 1, "
19
                    + "1970, 00:00:00 GMT)
18
this is not a date"
19
                        + " Cannot be parsed correctly. It should be in"
20
.", be2.getMessage());
20
                        + " MM/DD/YYYY HH:MM AM_PM format.", be3.getMessage());
21
        }
21
        }
22
        s = (DateSelector)getInstance();
22
        s = (DateSelector)getInstance();
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.5
Clones locationClones are in the same method
Number of node comparisons34
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)1.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    2
    try
    2
    try
    7
    try
    Differences
    Expression1Expression2Difference
    be1be2VARIABLE_NAME_MISMATCH
    "You must provide a datetime or the number of ""Date of 01/01/1969 01:01 AM results in negative "LITERAL_VALUE_MISMATCH
    "milliseconds.""milliseconds value relative to epoch (January 1, "LITERAL_VALUE_MISMATCH
    "You must provide a datetime or the number of " + "milliseconds.""Date of 01/01/1969 01:01 AM results in negative " + "milliseconds value relative to epoch (January 1, " + "1970, 00:00:00 GMT)."INFIX_EXTENDED_OPERAND_NUMBER_MISMATCH
    be1be2VARIABLE_NAME_MISMATCH
    7
    try
    3
    s.isSelected(basedir, filenames[0], files[0]);
    8
    s.isSelected(basedir, filenames[0], files[0]);
    4
    fail("DateSelector did not check for required fields");
    4
    fail("DateSelector did not check for required fields");
    9
    fail("DateSelector did not check for Datetime being in the " + "allowable range");
    Differences
    Expression1Expression2Difference
    "DateSelector did not check for required fields""DateSelector did not check for Datetime being in the " + "allowable range"TYPE_COMPATIBLE_REPLACEMENT
    9
    fail("DateSelector did not check for Datetime being in the " + "allowable range");
    5
    s = (DateSelector)getInstance();
    10
    s = (DateSelector)getInstance();
    6
    s.setDatetime("01/01/1969 01:01 AM");
    6
    s.setDatetime("01/01/1969 01:01 AM");
    11
    s.setDatetime("this is not a date");
    Differences
    Expression1Expression2Difference
    "01/01/1969 01:01 AM""this is not a date"LITERAL_VALUE_MISMATCH
    11
    s.setDatetime("this is not a date");
    7
    try
    7
    try
    12
    try
    Differences
    Expression1Expression2Difference
    be2be3VARIABLE_NAME_MISMATCH
    "1970, 00:00:00 GMT)."" MM/DD/YYYY HH:MM AM_PM format."LITERAL_VALUE_MISMATCH
    "Date of 01/01/1969 01:01 AM results in negative ""Date of this is not a date"LITERAL_VALUE_MISMATCH
    "milliseconds value relative to epoch (January 1, "" Cannot be parsed correctly. It should be in"LITERAL_VALUE_MISMATCH
    be2be3VARIABLE_NAME_MISMATCH
    12
    try
    8
    s.isSelected(basedir, filenames[0], files[0]);
    13
    s.isSelected(basedir, filenames[0], files[0]);
    9
    fail("DateSelector did not check for Datetime being in the " + "allowable range");
    9
    fail("DateSelector did not check for Datetime being in the " + "allowable range");
    14
    fail("DateSelector did not check for Datetime being in a " + "valid format");
    Differences
    Expression1Expression2Difference
    "DateSelector did not check for Datetime being in the ""DateSelector did not check for Datetime being in a "LITERAL_VALUE_MISMATCH
    "allowable range""valid format"LITERAL_VALUE_MISMATCH
    14
    fail("DateSelector did not check for Datetime being in a " + "valid format");
    10
    s = (DateSelector)getInstance();
    10
    s = (DateSelector)getInstance();
                                                                        
    15
    s = (DateSelector)getInstance();
    Preondition Violations
    Unmatched statement s=(DateSelector)getInstance(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15
    s = (DateSelector)getInstance();
    Precondition Violations (2)
    Row Violation
    1Unmatched statement s=(DateSelector)getInstance(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Clone fragment #1 returns variables s , while Clone fragment #2 returns variables