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 |
|