1 45 package org.openejb.test.stateless; 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 StatelessBeanTxTests extends org.openejb.test.NamedTestCase{ 67 68 public final static String jndiEJBHomeEntry = "client/tests/stateless/BeanManagedTransactionTests/EJBHome"; 69 70 protected BeanTxStatelessHome ejbHome; 71 protected BeanTxStatelessObject 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 StatelessBeanTxTests(){ 81 super("Stateless.BeanManagedTransaction."); 82 } 83 84 88 protected void setUp() throws Exception { 89 90 Properties properties = TestManager.getServer().getContextEnvironment(); 91 properties.put(Context.SECURITY_PRINCIPAL, "STATELESS_test00_CLIENT"); 92 properties.put(Context.SECURITY_CREDENTIALS, "STATELESS_test00_CLIENT"); 93 94 initialContext = new InitialContext (properties); 95 96 97 Object obj = initialContext.lookup(jndiEJBHomeEntry); 98 ejbHome = (BeanTxStatelessHome)javax.rmi.PortableRemoteObject.narrow( obj, BeanTxStatelessHome.class); 99 ejbObject = ejbHome.create(); 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 292 308 public void TODO_test09_beginWithNoCommit(){ 309 try{ 310 311 } catch (Exception e){ 312 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 313 } 314 } 315 316 357 public void TODO_test10_scenario1_NoneNone(){ 358 try{ 359 360 } catch (Exception e){ 361 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 362 } 363 } 364 365 406 public void TODO_test11_scenario2_T1None(){ 407 try{ 408 409 } catch (Exception e){ 410 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 411 } 412 } 413 414 } 415 416 | Popular Tags |