public class InvocationTargetExceptionTest extends FunctionalTestCase { public InvocationTargetExceptionTest(String name) { super( name ); } public String[] getMappings() { return new String[] { "bytecode/Bean.hbm.xml" }; } public static TestSuite suite() { return new FunctionalTestClassTestSuite( InvocationTargetExceptionTest.class ); } public void testProxiedInvocationException() { if ( ! ( Environment.getBytecodeProvider() instanceof org.hibernate.bytecode.cglib.BytecodeProviderImpl ) ) { // because of the scoping :( reportSkip( "env not configured for cglib provider", "bytecode-provider InvocationTargetException handling" ); return; } Session s = openSession(); s.beginTransaction(); Bean bean = new Bean(); bean.setSomeString( "my-bean" ); s.save( bean ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); bean = ( Bean ) s.load( Bean.class, bean.getSomeString() ); assertFalse( Hibernate.isInitialized( bean ) ); try { bean.throwException(); fail( "exception not thrown" ); } catch ( ParseException e ) { // expected behavior } catch( Throwable t ) { fail( "unexpected exception type : " + t ); } s.delete( bean ); s.getTransaction().commit(); s.close();
public class InvocationTargetExceptionTest extends FunctionalTestCase { public InvocationTargetExceptionTest(String name) { super( name ); } public String[] getMappings() { return new String[] { "bytecode/Bean.hbm.xml" }; } public static TestSuite suite() { return new FunctionalTestClassTestSuite( InvocationTargetExceptionTest.class ); } public void testProxiedInvocationException() { if ( !( Environment.getBytecodeProvider() instanceof org.hibernate.bytecode.javassist.BytecodeProviderImpl ) ) { // because of the scoping :( reportSkip( "env not configured for javassist provider", "bytecode-provider InvocationTargetException handling" ); return; } Session s = openSession(); s.beginTransaction(); Bean bean = new Bean(); bean.setSomeString( "my-bean" ); s.save( bean ); s.getTransaction().commit(); s.close(); s = openSession(); s.beginTransaction(); bean = ( Bean ) s.load( Bean.class, bean.getSomeString() ); assertFalse( Hibernate.isInitialized( bean ) ); try { bean.throwException(); fail( "exception not thrown" ); } catch ( ParseException e ) { // expected behavior } catch ( Throwable t ) { fail( "unexpected exception type : " + t ); } s.delete( bean ); s.getTransaction().commit(); s.close();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/bytecode/cglib/InvocationTargetExceptionTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/bytecode/javassist/InvocationTargetExceptionTest.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class InvocationTargetExceptionTest extends FunctionalTestCase {
1
public class InvocationTargetExceptionTest extends FunctionalTestCase {
2
	public InvocationTargetExceptionTest(String name) {
2
	public InvocationTargetExceptionTest(String name) {
3
		super( name );
3
		super( name );
4
	}
4
	}
5
	public String[] getMappings() {
5
	public String[] getMappings() {
6
		return new String[] { "bytecode/Bean.hbm.xml" };
6
		return new String[] { "bytecode/Bean.hbm.xml" };
7
	}
7
	}
8
	public static TestSuite suite() {
8
	public static TestSuite suite() {
9
		return new FunctionalTestClassTestSuite( InvocationTargetExceptionTest.class );
9
		return new FunctionalTestClassTestSuite( InvocationTargetExceptionTest.class );
10
	}
10
	}
11
	public void testProxiedInvocationException() {
11
	public void testProxiedInvocationException() {
12
		if ( ! ( Environment.getBytecodeProvider() instanceof org.hibernate.bytecode.cglib.BytecodeProviderImpl ) ) {
12
		if ( !( Environment.getBytecodeProvider() instanceof org.hibernate.bytecode.javassist.BytecodeProviderImpl ) ) {
13
			// because of the scoping :(
13
			// because of the scoping :(
14
			reportSkip( 
14
			reportSkip(
15
"env not configured for cglib provider", "bytecode-provider InvocationTargetException handling" 
15
					"env not configured for javassist provider", "bytecode-provider InvocationTargetException handling"
16
);
16
			);
17
			return;
17
			return;
18
		}
18
		}
19
		Session s = openSession();
19
		Session s = openSession();
20
		s.beginTransaction();
20
		s.beginTransaction();
21
		Bean bean = new Bean();
21
		Bean bean = new Bean();
22
		bean.setSomeString( "my-bean" );
22
		bean.setSomeString( "my-bean" );
23
		s.save( bean );
23
		s.save( bean );
24
		s.getTransaction().commit();
24
		s.getTransaction().commit();
25
		s.close();
25
		s.close();
26
		s = openSession();
26
		s = openSession();
27
		s.beginTransaction();
27
		s.beginTransaction();
28
		bean = ( Bean ) s.load( Bean.class, bean.getSomeString() );
28
		bean = ( Bean ) s.load( Bean.class, bean.getSomeString() );
29
		assertFalse( Hibernate.isInitialized( bean ) );
29
		assertFalse( Hibernate.isInitialized( bean ) );
30
		try {
30
		try {
31
			bean.throwException();
31
			bean.throwException();
32
			fail( "exception not thrown" );
32
			fail( "exception not thrown" );
33
		}
33
		}
34
		catch ( ParseException e ) {
34
		catch ( ParseException e ) {
35
			// expected behavior
35
			// expected behavior
36
		}
36
		}
37
		catch( Throwable t ) {
37
		catch ( Throwable t ) {
38
			fail( "unexpected exception type : " + t );
38
			fail( "unexpected exception type : " + t );
39
		}
39
		}
40
		s.delete( bean );
40
		s.delete( bean );
41
		s.getTransaction().commit();
41
		s.getTransaction().commit();
42
		s.close();
42
		s.close();
43
	
43
	
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0