try {
cfg.addResource( resourceName, getClass().getClassLoader() );
fail();
}
catch ( InvalidMappingException inv ) {
assertEquals( inv.getType(), "resource" );
assertEquals( inv.getPath(), resourceName );
assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
}
try {
cfg.addURL( ConfigHelper.findAsResource( resourceName ) );
fail();
}
catch ( InvalidMappingException inv ) {
assertEquals( inv.getType(), "URL" );
assertTrue( inv.getPath().endsWith( "InvalidMapping.hbm.xml" ) );
assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
}
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/mappingexception/MappingExceptionTest.java
|
|
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/mappingexception/MappingExceptionTest.java
|
Method name: void testInvalidMapping()
|
|
Method name: void testInvalidMapping()
|
Number of AST nodes: 3
|
|
Number of AST nodes: 3
|
|
1 | try {↵ | | 1 | try {↵
|
2 | cfg.addResource( resourceName, getClass().getClassLoader() );↵ | | 2 | cfg.addURL( ConfigHelper.findAsResource( resourceName ) );↵
|
3 | fail();↵ | | 3 | fail();↵
|
4 | }↵ | | 4 | }↵
|
5 | catch ( InvalidMappingException inv ) {↵ | | 5 | catch ( InvalidMappingException inv ) {↵
|
6 | assertEquals( inv.getType(), "resource" );↵ | | 6 | assertEquals( inv.getType(), "URL" );↵
|
7 | assertEquals( inv.getPath(), resourceName );↵ | | 7 | assertTrue( inv.getPath().endsWith( "InvalidMapping.hbm.xml" ) );↵
|
8 | assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );↵ | | 8 | assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );↵
|
9 | } | | 9 | }
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.4 |
Clones location | Clones are in the same method |
Number of node comparisons | 9 |
-
{Non-refactorable}
Mapping Summary
Number of mapped statements | 3 |
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) | 2.8 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
27 | try | | 30 | try |
28 | cfg.addResource(resourceName, getClass().getClassLoader()); | | 31 | cfg.addURL(ConfigHelper.findAsResource(resourceName)); |
29 | | | 32 | |
Precondition Violations (8)
Row |
Violation |
1 | Expression assertEquals(inv.getPath(),resourceName) is a void method call, and thus it cannot be parameterized |
2 | Expression assertTrue(inv.getPath().endsWith("InvalidMapping.hbm.xml")) is a void method call, and thus it cannot be parameterized |
3 | Expression assertEquals(inv.getPath(),resourceName) is a void method call, and thus it cannot be parameterized |
4 | Expression assertTrue(inv.getPath().endsWith("InvalidMapping.hbm.xml")) is a void method call, and thus it cannot be parameterized |
5 | Expression cfg.addResource(resourceName,getClass().getClassLoader()) is a method call throwing exception(s) that should be caught by a try block that will be extracted |
6 | Expression cfg.addURL(ConfigHelper.findAsResource(resourceName)) is a method call throwing exception(s) that should be caught by a try block that will be extracted |
7 | Expression cfg.addResource(resourceName,getClass().getClassLoader()) is a method call throwing exception(s) that should be caught by a try block that will be extracted |
8 | Expression cfg.addURL(ConfigHelper.findAsResource(resourceName)) is a method call throwing exception(s) that should be caught by a try block that will be extracted |