1 25 26 package org.objectweb.jonas.jtests.clients.exception; 27 28 import java.rmi.RemoteException ; 29 30 import javax.transaction.Status ; 31 import javax.transaction.TransactionRolledbackException ; 32 33 import org.objectweb.jonas.jtests.beans.beanexc.AccountS; 34 import org.objectweb.jonas.jtests.beans.beanexc.AppException; 35 import org.objectweb.jonas.jtests.util.JTestCase; 36 37 41 public abstract class A_Catcher extends JTestCase { 42 43 public A_Catcher(String name) { 44 super(name); 45 } 46 47 protected void setUp() { 48 super.setUp(); 49 useBeans("beanexc", true); 50 } 51 52 56 public abstract AccountS getAccountS(int i); 57 58 62 67 public void testApplicationNoTx() throws Exception { 68 AccountS acs = getAccountS(83); 69 try { 70 acs.doAppException_3(); 71 fail("No AppException"); 72 } catch (AppException e) { 73 } 74 } 75 76 81 public void testApplicationNotTx() throws Exception { 82 AccountS acs = getAccountS(83); 83 utx.begin(); 84 try { 85 acs.doAppException_3(); 86 fail("No AppException"); 87 } catch (AppException e) { 88 assertTrue(utx.getStatus() == Status.STATUS_ACTIVE); 89 } finally { 90 utx.rollback(); 91 } 92 } 93 94 100 public void testApplicationContTx1() throws Exception { 101 AccountS acs = getAccountS(82); 102 try { 103 acs.doAppException_2(false); 105 fail("No AppException"); 106 } catch (AppException e) { 107 108 } 109 } 110 111 117 public void testApplicationContTxRb1() throws Exception { 118 AccountS acs = getAccountS(82); 119 try { 120 acs.doAppException_2(true); 122 fail("No AppException"); 123 } catch (AppException e) { 124 } 125 } 126 127 133 public void testApplicationCallerTx1() throws Exception { 134 AccountS acs = getAccountS(81); 135 utx.begin(); 136 try { 137 acs.doAppException_1(); 138 fail("No AppException"); 139 } catch (AppException e) { 140 assertTrue(utx.getStatus() == Status.STATUS_ACTIVE); 141 } finally { 142 utx.rollback(); 143 } 144 } 145 146 150 156 public void testUncheckedCallerTx() throws Exception { 157 AccountS acs = getAccountS(85); 158 utx.begin(); 159 try { 160 acs.doUncheckedException_1(); 161 fail("No RemoteException"); 162 } catch (RemoteException e) { 163 assertTrue((e.detail instanceof TransactionRolledbackException ) 164 || (e instanceof TransactionRolledbackException )); 165 } finally { 166 utx.rollback(); 167 } 168 } 169 170 175 public void testUncheckedContTx() throws Exception { 176 AccountS acs = getAccountS(84); 177 try { 178 acs.doUncheckedException_2(); fail("No RemoteException"); 180 } catch (RemoteException e) { 181 } 182 183 } 184 185 190 public void testUncheckedNoTx() throws Exception { 191 AccountS acs = getAccountS(84); 192 try { 193 acs.doUncheckedException_3(); fail("No RemoteException"); 195 } catch (RemoteException e) { 196 } 197 } 198 199 203 208 public void testEJBContTx() throws Exception { 209 AccountS acs = getAccountS(84); 210 try { 211 acs.doEJBException_1(); fail("No RemoteException"); 213 } catch (RemoteException e) { 214 } 215 } 216 217 221 227 public void testRemoteCallerTx() throws Exception { 228 AccountS acs = getAccountS(86); 229 utx.begin(); 230 acs.ping(); try { 232 acs.doRemoteException_1(); fail("No RemoteException"); 234 } catch (RemoteException e) { 235 assertTrue((e.detail instanceof TransactionRolledbackException ) 236 || (e instanceof TransactionRolledbackException )); 237 } finally { 238 utx.rollback(); 239 } 240 } 241 242 } | Popular Tags |