Configuration cfg = new Configuration(); assertNotNull( cfg.getEventListeners().getDeleteEventListeners() ); try { cfg.setListeners( "delete", new Object[] { } ); fail( "should have thrown ClassCastException" ); } catch ( ClassCastException ex ) { // expected }
Configuration cfg = new Configuration(); assertNotNull( cfg.getEventListeners().getDeleteEventListeners() ); try { cfg.setListener( null, new DeleteListenerForTest() ); fail( "should have thrown MappingException" ); } catch ( MappingException ex ) { // expected }
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/cfg/ListenerTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/cfg/ListenerTest.java
Method name: void testSetListenersEmptyClassObjectArray() Method name: void testSetListenerNullType()
Number of AST nodes: 5 Number of AST nodes: 5
1
Configuration cfg = new Configuration();
1
Configuration cfg = new Configuration();
2
		assertNotNull( cfg.getEventListeners().getDeleteEventListeners() );
2
		assertNotNull( cfg.getEventListeners().getDeleteEventListeners() );
3
		try {
3
		try {
4
			cfg.setListeners( "delete", new Object[] { } );
4
			cfg.setListener( null, new DeleteListenerForTest() );
5
			fail( "should have thrown ClassCastException" );
5
			fail( "should have thrown MappingException" );
6
		}
6
		}
7
		catch ( ClassCastException ex ) {
7
		catch ( MappingException ex ) {
8
			// expected
8
			// expected
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.1
Clones locationClones are declared in the same class
Number of node comparisons11
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)2.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Configuration cfg = new Configuration();
    1
    Configuration cfg = new Configuration();
    2
    assertNotNull(cfg.getEventListeners().getDeleteEventListeners());
    2
    assertNotNull(cfg.getEventListeners().getDeleteEventListeners());
    3
    try
    3
    try
    3
    try
    Differences
    Expression1Expression2Difference
    java.lang.ClassCastExceptionorg.hibernate.MappingExceptionSUBCLASS_TYPE_MISMATCH
    java.lang.ClassCastExceptionorg.hibernate.MappingExceptionSUBCLASS_TYPE_MISMATCH
    3
    try
    4
    cfg.setListeners("delete", new Object[] {});
    4
    cfg.setListeners("delete", new Object[] {});
    5
    fail("should have thrown MappingException");
    Differences
    Expression1Expression2Difference
    setListenersfailMETHOD_INVOCATION_NAME_MISMATCH
    cfg.setListeners("delete",new Object[]{})fail("should have thrown MappingException")ARGUMENT_NUMBER_MISMATCH
    cfgMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression cfg.setListeners("delete",new Object[]{}) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression cfg.setListeners("delete",new Object[]{}) is a void method call, and thus it cannot be parameterized
    Expression fail("should have thrown MappingException") is a void method call, and thus it cannot be parameterized
    Expression cfg.setListeners("delete",new Object[]{}) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression cfg.setListeners("delete",new Object[]{}) is a void method call, and thus it cannot be parameterized
    Expression fail("should have thrown MappingException") is a void method call, and thus it cannot be parameterized
    5
    fail("should have thrown MappingException");
    5
    fail("should have thrown ClassCastException");
    5
    fail("should have thrown ClassCastException");
    4
    cfg.setListener(null, new DeleteListenerForTest());
    Differences
    Expression1Expression2Difference
    failsetListenerMETHOD_INVOCATION_NAME_MISMATCH
    fail("should have thrown ClassCastException")cfg.setListener(null,new DeleteListenerForTest())ARGUMENT_NUMBER_MISMATCH
    cfgMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression cfg.setListener(null,new DeleteListenerForTest()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression fail("should have thrown ClassCastException") is a void method call, and thus it cannot be parameterized
    Expression cfg.setListener(null,new DeleteListenerForTest()) is a void method call, and thus it cannot be parameterized
    Expression cfg.setListener(null,new DeleteListenerForTest()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression fail("should have thrown ClassCastException") is a void method call, and thus it cannot be parameterized
    Expression cfg.setListener(null,new DeleteListenerForTest()) is a void method call, and thus it cannot be parameterized
    4
    cfg.setListener(null, new DeleteListenerForTest());
    Precondition Violations (12)
    Row Violation
    1Expression cfg.setListeners("delete",new Object[]{}) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression cfg.setListeners("delete",new Object[]{}) is a void method call, and thus it cannot be parameterized
    3Expression fail("should have thrown MappingException") is a void method call, and thus it cannot be parameterized
    4Expression cfg.setListeners("delete",new Object[]{}) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression cfg.setListeners("delete",new Object[]{}) is a void method call, and thus it cannot be parameterized
    6Expression fail("should have thrown MappingException") is a void method call, and thus it cannot be parameterized
    7Expression cfg.setListener(null,new DeleteListenerForTest()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression fail("should have thrown ClassCastException") is a void method call, and thus it cannot be parameterized
    9Expression cfg.setListener(null,new DeleteListenerForTest()) is a void method call, and thus it cannot be parameterized
    10Expression cfg.setListener(null,new DeleteListenerForTest()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    11Expression fail("should have thrown ClassCastException") is a void method call, and thus it cannot be parameterized
    12Expression cfg.setListener(null,new DeleteListenerForTest()) is a void method call, and thus it cannot be parameterized