1 45 package org.openejb.test.stateful; 46 47 import java.util.Properties ; 48 49 import javax.ejb.EJBMetaData ; 50 import javax.ejb.Handle ; 51 import javax.ejb.HomeHandle ; 52 import javax.naming.Context ; 53 import javax.naming.InitialContext ; 54 import javax.transaction.RollbackException ; 55 56 import org.openejb.test.TestManager; 57 import org.openejb.test.object.Account; 58 import org.openejb.test.object.Transaction; 59 60 66 public class StatefulBeanTxTests extends org.openejb.test.NamedTestCase{ 67 68 public final static String jndiEJBHomeEntry = "client/tests/stateful/BeanManagedTransactionTests/EJBHome"; 69 70 protected BeanTxStatefulHome ejbHome; 71 protected BeanTxStatefulObject ejbObject; 72 73 protected EJBMetaData ejbMetaData; 74 protected HomeHandle ejbHomeHandle; 75 protected Handle ejbHandle; 76 protected Integer ejbPrimaryKey; 77 78 protected InitialContext initialContext; 79 80 public StatefulBeanTxTests(){ 81 super("Stateful.BeanManagedTransaction."); 82 } 83 84 88 protected void setUp() throws Exception { 89 90 Properties properties = TestManager.getServer().getContextEnvironment(); 91 properties.put(Context.SECURITY_PRINCIPAL, "STATEFUL_test00_CLIENT"); 92 properties.put(Context.SECURITY_CREDENTIALS, "STATEFUL_test00_CLIENT"); 93 94 initialContext = new InitialContext (properties); 95 96 97 Object obj = initialContext.lookup(jndiEJBHomeEntry); 98 ejbHome = (BeanTxStatefulHome)javax.rmi.PortableRemoteObject.narrow( obj, BeanTxStatefulHome.class); 99 ejbObject = ejbHome.create("Transaction Bean"); 100 101 102 TestManager.getDatabase().createAccountTable(); 103 } 104 105 109 protected void tearDown() throws Exception { 110 111 TestManager.getDatabase().dropAccountTable(); 112 } 113 114 115 132 public void test01_EJBContext_getUserTransaction(){ 133 try{ 134 Transaction t = ejbObject.getUserTransaction(); 135 assertNotNull("UserTransaction is null.", t); 136 } catch (Exception e){ 137 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 138 } 139 } 140 141 159 public void test02_java_comp_UserTransaction(){ 160 try{ 161 Transaction t = ejbObject.jndiUserTransaction(); 162 assertNotNull("UserTransaction is null. Could not retreive a UserTransaction from the bean's JNDI namespace.", t); 163 } catch (Exception e){ 164 fail("Could not retreive a UserTransaction from the bean's JNDI namespace. Received Exception "+e.getClass()+ " : "+e.getMessage()); 165 } 166 } 167 168 180 public void TODO_test03_EJBContext_setRollbackOnly(){ 181 try{ 182 183 } catch (Exception e){ 184 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 185 } 186 } 187 188 200 public void TODO_test04_EJBContext_getRollbackOnly(){ 201 try{ 202 203 } catch (Exception e){ 204 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 205 } 206 } 207 208 211 public void test05_singleTransactionCommit(){ 212 try{ 213 Account expected = new Account("123-45-6789","Joe","Cool",40000); 214 Account actual = new Account(); 215 216 ejbObject.openAccount(expected, new Boolean (false)); 217 actual = ejbObject.retreiveAccount( expected.getSsn() ); 218 219 assertNotNull( "The transaction was not commited. The record is null", actual ); 220 assertEquals( "The transaction was not commited cleanly.", expected, actual ); 221 } catch (RollbackException re){ 222 fail("Transaction was rolledback. Received Exception "+re.getClass()+ " : "+re.getMessage()); 223 } catch (Exception e){ 224 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 225 } 226 } 227 228 233 public void BUG_test06_singleTransactionRollback(){ 234 Account expected = new Account("234-56-7890","Charlie","Brown", 20000); 235 Account actual = new Account(); 236 237 try{ 240 ejbObject.openAccount(expected, new Boolean (true)); 241 fail( "A javax.transaction.RollbackException should have been thrown." ); 242 } catch (RollbackException re){ 243 } catch (Exception e){ 245 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 246 } 247 248 } 256 257 258 265 public void TODO_test07_serialTransactions(){ 266 try{ 267 268 } catch (Exception e){ 269 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 270 } 271 } 272 273 283 public void TODO_test08_nestedTransactions(){ 284 try{ 285 286 } catch (Exception e){ 287 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 288 } 289 } 290 291 304 public void TODO_test09_methodSpanningTransactions(){ 305 try{ 306 307 } catch (Exception e){ 308 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 309 } 310 } 311 312 353 public void TODO_test10_scenario1_NoneNone(){ 354 try{ 355 356 } catch (Exception e){ 357 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 358 } 359 } 360 361 402 public void TODO_test11_scenario2_T1None(){ 403 try{ 404 405 } catch (Exception e){ 406 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 407 } 408 } 409 410 450 public void TODO_test12_scenario3_NoneT2(){ 451 try{ 452 453 } catch (Exception e){ 454 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 455 } 456 } 457 458 500 public void TODO_test13_scenario4_T1T2(){ 501 try{ 502 503 } catch (Exception e){ 504 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 505 } 506 } 507 } 508 | Popular Tags |