try { cfg.addInputStream( ConfigHelper.getResourceAsStream( resourceName ) ); fail(); } catch ( InvalidMappingException inv ) { assertEquals( inv.getType(), "input stream" ); assertEquals( inv.getPath(), null ); 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.addInputStream( ConfigHelper.getResourceAsStream( resourceName ) );
2
			cfg.addURL( ConfigHelper.findAsResource( resourceName ) );
3
			fail();
3
			fail();
4
		}
4
		}
5
		catch ( InvalidMappingException inv ) {
5
		catch ( InvalidMappingException inv ) {
6
			assertEquals( inv.getType(), "input stream" );
6
			assertEquals( inv.getType(), "URL" );
7
			assertEquals( inv.getPath(), null );
7
			assertTrue( inv.getPath().endsWith( "InvalidMapping.hbm.xml" ) );
8
			assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
8
			assertTrue( !( inv.getCause() instanceof MappingNotFoundException ) );
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.4
Clones locationClones are in the same method
Number of node comparisons9
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)544.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    21
    try
    21
    try
    30
    try
    Differences
    Expression1Expression2Difference
    "input stream""URL"LITERAL_VALUE_MISMATCH
    assertEqualsassertTrueMETHOD_INVOCATION_NAME_MISMATCH
    assertEquals(inv.getPath(),null)assertTrue(inv.getPath().endsWith("InvalidMapping.hbm.xml"))ARGUMENT_NUMBER_MISMATCH
    Preondition Violations
    Expression assertEquals(inv.getPath(),null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(inv.getPath().endsWith("InvalidMapping.hbm.xml")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(inv.getPath(),null) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(inv.getPath().endsWith("InvalidMapping.hbm.xml")) is a void method call, and thus it cannot be parameterized
    Expression assertEquals(inv.getPath(),null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertTrue(inv.getPath().endsWith("InvalidMapping.hbm.xml")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression assertEquals(inv.getPath(),null) is a void method call, and thus it cannot be parameterized
    Expression assertTrue(inv.getPath().endsWith("InvalidMapping.hbm.xml")) is a void method call, and thus it cannot be parameterized
    30
    try
    22
    cfg.addInputStream(ConfigHelper.getResourceAsStream(resourceName));
    22
    cfg.addInputStream(ConfigHelper.getResourceAsStream(resourceName));
    31
    cfg.addURL(ConfigHelper.findAsResource(resourceName));
    Differences
    Expression1Expression2Difference
    getResourceAsStreamfindAsResourceMETHOD_INVOCATION_NAME_MISMATCH
    java.io.InputStreamjava.net.URLVARIABLE_TYPE_MISMATCH
    addInputStreamaddURLMETHOD_INVOCATION_NAME_MISMATCH
    Preondition Violations
    Expression ConfigHelper.getResourceAsStream(resourceName) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Type java.io.InputStream of variable ConfigHelper.getResourceAsStream(resourceName) does not match with type java.net.URL of variable ConfigHelper.findAsResource(resourceName)
    • Make classes java.io.InputStream and java.net.URL extend a common superclass
    Expression cfg.addInputStream(ConfigHelper.getResourceAsStream(resourceName)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression cfg.addURL(ConfigHelper.findAsResource(resourceName)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression cfg.addInputStream(ConfigHelper.getResourceAsStream(resourceName)) is a void method call, and thus it cannot be parameterized
    Expression cfg.addURL(ConfigHelper.findAsResource(resourceName)) is a void method call, and thus it cannot be parameterized
    31
    cfg.addURL(ConfigHelper.findAsResource(resourceName));
    23
    fail();
    32
    fail();
    Precondition Violations (14)
    Row Violation
    1Expression assertEquals(inv.getPath(),null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression assertTrue(inv.getPath().endsWith("InvalidMapping.hbm.xml")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression assertEquals(inv.getPath(),null) is a void method call, and thus it cannot be parameterized
    4Expression assertTrue(inv.getPath().endsWith("InvalidMapping.hbm.xml")) is a void method call, and thus it cannot be parameterized
    5Expression assertEquals(inv.getPath(),null) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Expression assertTrue(inv.getPath().endsWith("InvalidMapping.hbm.xml")) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression assertEquals(inv.getPath(),null) is a void method call, and thus it cannot be parameterized
    8Expression assertTrue(inv.getPath().endsWith("InvalidMapping.hbm.xml")) is a void method call, and thus it cannot be parameterized
    9Expression ConfigHelper.getResourceAsStream(resourceName) is a method call throwing exception(s) that should be caught by a try block that will be extracted
    10Type java.io.InputStream of variable ConfigHelper.getResourceAsStream(resourceName) does not match with type java.net.URL of variable ConfigHelper.findAsResource(resourceName)
    11Expression cfg.addInputStream(ConfigHelper.getResourceAsStream(resourceName)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12Expression cfg.addURL(ConfigHelper.findAsResource(resourceName)) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    13Expression cfg.addInputStream(ConfigHelper.getResourceAsStream(resourceName)) is a void method call, and thus it cannot be parameterized
    14Expression cfg.addURL(ConfigHelper.findAsResource(resourceName)) is a void method call, and thus it cannot be parameterized