1 | public void testProxiedInvocationException() {↵ | | 1 | public void testProxiedInvocationException() {↵
|
2 | if ( ! ( Environment.getBytecodeProvider() instanceof org.hibernate.bytecode.cglib.BytecodeProviderImpl ) ) {↵ | | 2 | if ( !( Environment.getBytecodeProvider() instanceof org.hibernate.bytecode.javassist.BytecodeProviderImpl ) ) {↵
|
3 | // because of the scoping :(↵ | | 3 | // because of the scoping :(↵
|
4 | reportSkip( ↵ | | 4 | reportSkip(↵
|
5 | "env not configured for cglib provider", "bytecode-provider InvocationTargetException handling" ↵ | | 5 | "env not configured for javassist provider", "bytecode-provider InvocationTargetException handling"↵
|
6 | );↵ | | 6 | );↵
|
7 | return;↵ | | 7 | return;↵
|
8 | }↵ | | 8 | }↵
|
9 | Session s = openSession();↵ | | 9 | Session s = openSession();↵
|
10 | s.beginTransaction();↵ | | 10 | s.beginTransaction();↵
|
11 | Bean bean = new Bean();↵ | | 11 | Bean bean = new Bean();↵
|
12 | bean.setSomeString( "my-bean" );↵ | | 12 | bean.setSomeString( "my-bean" );↵
|
13 | s.save( bean );↵ | | 13 | s.save( bean );↵
|
14 | s.getTransaction().commit();↵ | | 14 | s.getTransaction().commit();↵
|
15 | s.close();↵ | | 15 | s.close();↵
|
|
16 | s = openSession();↵ | | 16 | s = openSession();↵
|
17 | s.beginTransaction();↵ | | 17 | s.beginTransaction();↵
|
18 | bean = ( Bean ) s.load( Bean.class, bean.getSomeString() );↵ | | 18 | bean = ( Bean ) s.load( Bean.class, bean.getSomeString() );↵
|
19 | assertFalse( Hibernate.isInitialized( bean ) );↵ | | 19 | assertFalse( Hibernate.isInitialized( bean ) );↵
|
20 | try {↵ | | 20 | try {↵
|
21 | bean.throwException();↵ | | 21 | bean.throwException();↵
|
22 | fail( "exception not thrown" );↵ | | 22 | fail( "exception not thrown" );↵
|
23 | }↵ | | 23 | }↵
|
24 | catch ( ParseException e ) {↵ | | 24 | catch ( ParseException e ) {↵
|
25 | // expected behavior↵ | | 25 | // expected behavior↵
|
26 | }↵ | | 26 | }↵
|
27 | catch( Throwable t ) {↵ | | 27 | catch ( Throwable t ) {↵
|
28 | fail( "unexpected exception type : " + t );↵ | | 28 | fail( "unexpected exception type : " + t );↵
|
29 | }↵ | | 29 | }↵
|
|
30 | s.delete( bean );↵ | | 30 | s.delete( bean );↵
|
31 | s.getTransaction().commit();↵ | | 31 | s.getTransaction().commit();↵
|
32 | s.close();↵ | | 32 | s.close();↵
|
33 | | | 33 |
|