try { cfg.addResource( resourceName ); fail(); } catch ( InvalidMappingException inv ) { assertEquals( inv.getType(), "resource" ); assertEquals( inv.getPath(), resourceName ); assertClassAssignability( inv.getCause().getClass(), DuplicateMappingException.class ); }
try { cfg.addFile( file ); fail(); } catch ( InvalidMappingException inv ) { assertEquals( inv.getType(), "file" ); assertEquals( inv.getPath(), file.getPath() ); 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 testDuplicateMapping() Method name: void testInvalidMapping()
Number of AST nodes: 3 Number of AST nodes: 3
1
try {
1
try {
2
			cfg.addResource( resourceName );
2
			cfg.addFile( file );
3
			fail();
3
			fail();
4
		}
4
		}
5
		catch ( InvalidMappingException inv ) {
5
		catch ( InvalidMappingException inv ) {
6
			assertEquals( inv.getType(), "resource" );
6
			assertEquals( inv.getType(), "file" );
7
			assertEquals( inv.getPath(), resourceName );
7
			assertEquals( inv.getPath(), 
8
			assertClassAssignability( inv.getCause().getClass(), DuplicateMapping
8
file.getPath() );
9
Exception.class );
9
			assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
10
		}
10
		}
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.4
Clones locationClones are declared in the same 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)5.2
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    4
    try
    4
    try
    18
    try
    Differences
    Expression1Expression2Difference
    "resource""file"LITERAL_VALUE_MISMATCH
    resourceNamefile.getPath()TYPE_COMPATIBLE_REPLACEMENT
    assertClassAssignabilityassertTrueMETHOD_INVOCATION_NAME_MISMATCH
    assertClassAssignability(inv.getCause().getClass(),DuplicateMappingException.class)assertTrue(!(inv.getCause() instanceof MappingNotFoundException))ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertClassAssignability(inv.getCause().getClass(),DuplicateMappingException.class) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(!(inv.getCause() instanceof MappingNotFoundException)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertClassAssignability(inv.getCause().getClass(),DuplicateMappingException.class) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(!(inv.getCause() instanceof MappingNotFoundException)) is a void method call, and thus it cannot be parameterized
    Expression assertClassAssignability(inv.getCause().getClass(),DuplicateMappingException.class) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(!(inv.getCause() instanceof MappingNotFoundException)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertClassAssignability(inv.getCause().getClass(),DuplicateMappingException.class) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(!(inv.getCause() instanceof MappingNotFoundException)) is a void method call, and thus it cannot be parameterized
    18
    try
    5
    cfg.addResource(resourceName);
    5
    cfg.addResource(resourceName);
    Preondition Violations
    Unmatched statement cfg.addResource(resourceName); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement cfg.addResource(resourceName); 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
                                                                      
                                                
    19
    cfg.addFile(file);
    Preondition Violations
    Unmatched statement cfg.addFile(file); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    Unmatched statement cfg.addFile(file); 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
    19
    cfg.addFile(file);
    6
    fail();
    20
    fail();
    Precondition Violations (12)
    Row Violation
    1Expression assertClassAssignability(inv.getCause().getClass(),DuplicateMappingException.class) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression assertTrue(!(inv.getCause() instanceof MappingNotFoundException)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression assertClassAssignability(inv.getCause().getClass(),DuplicateMappingException.class) is a void method call, and thus it cannot be parameterized
    4Expression assertTrue(!(inv.getCause() instanceof MappingNotFoundException)) is a void method call, and thus it cannot be parameterized
    5Expression assertClassAssignability(inv.getCause().getClass(),DuplicateMappingException.class) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression assertTrue(!(inv.getCause() instanceof MappingNotFoundException)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression assertClassAssignability(inv.getCause().getClass(),DuplicateMappingException.class) is a void method call, and thus it cannot be parameterized
    8Expression assertTrue(!(inv.getCause() instanceof MappingNotFoundException)) is a void method call, and thus it cannot be parameterized
    9Unmatched statement cfg.addResource(resourceName); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    10Unmatched statement cfg.addResource(resourceName); 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
    11Unmatched statement cfg.addFile(file); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
    12Unmatched statement cfg.addFile(file); 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