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.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());
}
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: 4
|
|
Number of AST nodes: 4
|
|
1 | s.setDatetime("01/01/1969 01:01 AM");↵ | | 1 | s.setDatetime("this is not a date");↵
|
2 | try {↵ | | 2 | try {↵
|
3 | s.isSelected(basedir,filenames[0],files[0]);↵ | | 3 | s.isSelected(basedir,filenames[0],files[0]);↵
|
4 | fail("DateSelector did not check for Datetime being in the "↵ | | 4 | fail("DateSelector did not check for Datetime being in a "↵
|
5 | + "allowable range");↵ | | 5 | + "valid format");↵
|
6 | } catch (BuildException be2) {↵ | | 6 | } catch (BuildException be3) {↵
|
7 | assertEquals("Date of 01/01/1969 01:01 AM results in negative "↵ | | 7 | assertEquals("Date of ↵
|
8 | + "milliseconds value relative to epoch (January 1, "↵ | | |
|
9 | + "1970, 00:00:00 GMT)↵ | | 8 | this is not a date"↵
|
| | | 9 | + " Cannot be parsed correctly. It should be in"↵
|
10 | .", be2.getMessage());↵ | | 10 | + " MM/DD/YYYY HH:MM AM_PM format.", be3.getMessage());↵
|
11 | } | | 11 | }
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.3 |
Clones location | Clones are in the same method |
Number of node comparisons | 10 |
-
{Refactorable}
Mapping Summary
Number of mapped statements | 4 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 8.9 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
6 | s.setDatetime("01/01/1969 01:01 AM"); | | 11 | s.setDatetime("this is not a date"); |
7 | try | | 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"); | | 14 | fail("DateSelector did not check for Datetime being in a " + "valid format"); |
Precondition Violations (0)
Row |
Violation |