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 55 import org.openejb.test.TestManager; 56 57 63 public class StatelessContainerTxTests extends org.openejb.test.NamedTestCase{ 64 65 public final static String jndiEJBHomeEntry = "client/tests/stateless/ContainerManagedTransactionTests/EJBHome"; 66 67 protected ContainerTxStatelessHome ejbHome; 68 protected ContainerTxStatelessObject ejbObject; 69 70 protected EJBMetaData ejbMetaData; 71 protected HomeHandle ejbHomeHandle; 72 protected Handle ejbHandle; 73 protected Integer ejbPrimaryKey; 74 75 protected InitialContext initialContext; 76 77 public StatelessContainerTxTests(){ 78 super("Stateless.ContainerManagedTransaction."); 79 } 80 81 85 protected void setUp() throws Exception { 86 87 Properties properties = TestManager.getServer().getContextEnvironment(); 88 properties.put(Context.SECURITY_PRINCIPAL, "STATELESS_test00_CLIENT"); 89 properties.put(Context.SECURITY_CREDENTIALS, "STATELESS_test00_CLIENT"); 90 91 initialContext = new InitialContext (properties); 92 93 94 Object obj = initialContext.lookup(jndiEJBHomeEntry); 95 ejbHome = (ContainerTxStatelessHome)javax.rmi.PortableRemoteObject.narrow( obj, ContainerTxStatelessHome.class); 96 ejbObject = ejbHome.create(); 97 98 99 TestManager.getDatabase().createAccountTable(); 100 } 101 102 106 protected void tearDown() throws Exception { 107 108 TestManager.getDatabase().dropAccountTable(); 109 } 110 111 public void test01_txMandatory_withoutTx(){ 112 try{ 113 String expected = "ping"; 114 String actual = ejbObject.txMandatoryMethod( expected ); 115 assertEquals("The method invocation was invalid.", expected, actual); 116 } catch (Exception e){ 117 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 118 } 119 } 120 121 public void test02_txNever_withoutTx(){ 122 try{ 123 String expected = "ping"; 124 String actual = ejbObject.txNeverMethod( expected ); 125 assertEquals("The method invocation was invalid.", expected, actual); 126 } catch (Exception e){ 127 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 128 } 129 } 130 131 public void test03_txNotSupported_withoutTx(){ 132 try{ 133 String expected = "ping"; 134 String actual = ejbObject.txNotSupportedMethod( expected ); 135 assertEquals("The method invocation was invalid.", expected, actual); 136 } catch (Exception e){ 137 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 138 } 139 } 140 141 public void test04_txRequired_withoutTx(){ 142 try{ 143 String expected = "ping"; 144 String actual = ejbObject.txRequiredMethod( expected ); 145 assertEquals("The method invocation was invalid.", expected, actual); 146 } catch (Exception e){ 147 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 148 } 149 } 150 151 public void test05_txRequiresNew_withoutTx(){ 152 try{ 153 String expected = "ping"; 154 String actual = ejbObject.txRequiresNewMethod( expected ); 155 assertEquals("The method invocation was invalid.", expected, actual); 156 } catch (Exception e){ 157 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 158 } 159 } 160 161 public void test06_txSupports_withoutTx(){ 162 try{ 163 String expected = "ping"; 164 String actual = ejbObject.txSupportsMethod( expected ); 165 assertEquals("The method invocation was invalid.", expected, actual); 166 } catch (Exception e){ 167 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 168 } 169 } 170 171 public void test07_txMandatory_withTx(){ 172 try{ 173 String expected = "ping"; 174 String actual = ejbObject.txMandatoryMethod( expected ); 175 assertEquals("The method invocation was invalid.", expected, actual); 176 } catch (Exception e){ 177 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 178 } 179 } 180 181 public void test08_txNever_withTx(){ 182 try{ 183 String expected = "ping"; 184 String actual = ejbObject.txNeverMethod( expected ); 185 assertEquals("The method invocation was invalid.", expected, actual); 186 } catch (Exception e){ 187 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 188 } 189 } 190 191 public void test09_txNotSupported_withTx(){ 192 try{ 193 String expected = "ping"; 194 String actual = ejbObject.txNotSupportedMethod( expected ); 195 assertEquals("The method invocation was invalid.", expected, actual); 196 } catch (Exception e){ 197 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 198 } 199 } 200 201 public void test10_txRequired_withTx(){ 202 try{ 203 String expected = "ping"; 204 String actual = ejbObject.txRequiredMethod( expected ); 205 assertEquals("The method invocation was invalid.", expected, actual); 206 } catch (Exception e){ 207 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 208 } 209 } 210 211 public void test11_txRequiresNew_withTx(){ 212 try{ 213 String expected = "ping"; 214 String actual = ejbObject.txRequiresNewMethod( expected ); 215 assertEquals("The method invocation was invalid.", expected, actual); 216 } catch (Exception e){ 217 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 218 } 219 } 220 221 public void test12_txSupports_withTx(){ 222 try{ 223 String expected = "ping"; 224 String actual = ejbObject.txSupportsMethod( expected ); 225 assertEquals("The method invocation was invalid.", expected, actual); 226 } catch (Exception e){ 227 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 228 } 229 } 230 231 public void test01_txMandatory_withoutTx_appException(){ 232 try{ 233 String expected = "ping"; 234 String actual = ejbObject.txMandatoryMethod( expected ); 235 assertEquals("The method invocation was invalid.", expected, actual); 236 } catch (Exception e){ 237 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 238 } 239 } 240 241 public void test02_txNever_withoutTx_appException(){ 242 try{ 243 String expected = "ping"; 244 String actual = ejbObject.txNeverMethod( expected ); 245 assertEquals("The method invocation was invalid.", expected, actual); 246 } catch (Exception e){ 247 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 248 } 249 } 250 251 public void test03_txNotSupported_withoutTx_appException(){ 252 try{ 253 String expected = "ping"; 254 String actual = ejbObject.txNotSupportedMethod( expected ); 255 assertEquals("The method invocation was invalid.", expected, actual); 256 } catch (Exception e){ 257 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 258 } 259 } 260 261 public void test04_txRequired_withoutTx_appException(){ 262 try{ 263 String expected = "ping"; 264 String actual = ejbObject.txRequiredMethod( expected ); 265 assertEquals("The method invocation was invalid.", expected, actual); 266 } catch (Exception e){ 267 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 268 } 269 } 270 271 public void test05_txRequiresNew_withoutTx_appException(){ 272 try{ 273 String expected = "ping"; 274 String actual = ejbObject.txRequiresNewMethod( expected ); 275 assertEquals("The method invocation was invalid.", expected, actual); 276 } catch (Exception e){ 277 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 278 } 279 } 280 281 public void test06_txSupports_withoutTx_appException(){ 282 try{ 283 String expected = "ping"; 284 String actual = ejbObject.txSupportsMethod( expected ); 285 assertEquals("The method invocation was invalid.", expected, actual); 286 } catch (Exception e){ 287 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 288 } 289 } 290 291 public void test07_txMandatory_withTx_appException(){ 292 try{ 293 String expected = "ping"; 294 String actual = ejbObject.txMandatoryMethod( expected ); 295 assertEquals("The method invocation was invalid.", expected, actual); 296 } catch (Exception e){ 297 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 298 } 299 } 300 301 public void test08_txNever_withTx_appException(){ 302 try{ 303 String expected = "ping"; 304 String actual = ejbObject.txNeverMethod( expected ); 305 assertEquals("The method invocation was invalid.", expected, actual); 306 } catch (Exception e){ 307 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 308 } 309 } 310 311 public void test09_txNotSupported_withTx_appException(){ 312 try{ 313 String expected = "ping"; 314 String actual = ejbObject.txNotSupportedMethod( expected ); 315 assertEquals("The method invocation was invalid.", expected, actual); 316 } catch (Exception e){ 317 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 318 } 319 } 320 321 public void test10_txRequired_withTx_appException(){ 322 try{ 323 String expected = "ping"; 324 String actual = ejbObject.txRequiredMethod( expected ); 325 assertEquals("The method invocation was invalid.", expected, actual); 326 } catch (Exception e){ 327 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 328 } 329 } 330 331 public void test11_txRequiresNew_withTx_appException(){ 332 try{ 333 String expected = "ping"; 334 String actual = ejbObject.txRequiresNewMethod( expected ); 335 assertEquals("The method invocation was invalid.", expected, actual); 336 } catch (Exception e){ 337 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 338 } 339 } 340 341 public void test12_txSupports_withTx_appException(){ 342 try{ 343 String expected = "ping"; 344 String actual = ejbObject.txSupportsMethod( expected ); 345 assertEquals("The method invocation was invalid.", expected, actual); 346 } catch (Exception e){ 347 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 348 } 349 } 350 351 public void test01_txMandatory_withoutTx_sysException(){ 352 try{ 353 String expected = "ping"; 354 String actual = ejbObject.txMandatoryMethod( expected ); 355 assertEquals("The method invocation was invalid.", expected, actual); 356 } catch (Exception e){ 357 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 358 } 359 } 360 361 public void test02_txNever_withoutTx_sysException(){ 362 try{ 363 String expected = "ping"; 364 String actual = ejbObject.txNeverMethod( expected ); 365 assertEquals("The method invocation was invalid.", expected, actual); 366 } catch (Exception e){ 367 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 368 } 369 } 370 371 public void test03_txNotSupported_withoutTx_sysException(){ 372 try{ 373 String expected = "ping"; 374 String actual = ejbObject.txNotSupportedMethod( expected ); 375 assertEquals("The method invocation was invalid.", expected, actual); 376 } catch (Exception e){ 377 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 378 } 379 } 380 381 public void test04_txRequired_withoutTx_sysException(){ 382 try{ 383 String expected = "ping"; 384 String actual = ejbObject.txRequiredMethod( expected ); 385 assertEquals("The method invocation was invalid.", expected, actual); 386 } catch (Exception e){ 387 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 388 } 389 } 390 391 public void test05_txRequiresNew_withoutTx_sysException(){ 392 try{ 393 String expected = "ping"; 394 String actual = ejbObject.txRequiresNewMethod( expected ); 395 assertEquals("The method invocation was invalid.", expected, actual); 396 } catch (Exception e){ 397 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 398 } 399 } 400 401 public void test06_txSupports_withoutTx_sysException(){ 402 try{ 403 String expected = "ping"; 404 String actual = ejbObject.txSupportsMethod( expected ); 405 assertEquals("The method invocation was invalid.", expected, actual); 406 } catch (Exception e){ 407 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 408 } 409 } 410 411 public void test07_txMandatory_withTx_sysException(){ 412 try{ 413 String expected = "ping"; 414 String actual = ejbObject.txMandatoryMethod( expected ); 415 assertEquals("The method invocation was invalid.", expected, actual); 416 } catch (Exception e){ 417 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 418 } 419 } 420 421 public void test08_txNever_withTx_sysException(){ 422 try{ 423 String expected = "ping"; 424 String actual = ejbObject.txNeverMethod( expected ); 425 assertEquals("The method invocation was invalid.", expected, actual); 426 } catch (Exception e){ 427 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 428 } 429 } 430 431 public void test09_txNotSupported_withTx_sysException(){ 432 try{ 433 String expected = "ping"; 434 String actual = ejbObject.txNotSupportedMethod( expected ); 435 assertEquals("The method invocation was invalid.", expected, actual); 436 } catch (Exception e){ 437 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 438 } 439 } 440 441 public void test10_txRequired_withTx_sysException(){ 442 try{ 443 String expected = "ping"; 444 String actual = ejbObject.txRequiredMethod( expected ); 445 assertEquals("The method invocation was invalid.", expected, actual); 446 } catch (Exception e){ 447 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 448 } 449 } 450 451 public void test11_txRequiresNew_withTx_sysException(){ 452 try{ 453 String expected = "ping"; 454 String actual = ejbObject.txRequiresNewMethod( expected ); 455 assertEquals("The method invocation was invalid.", expected, actual); 456 } catch (Exception e){ 457 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 458 } 459 } 460 461 public void test12_txSupports_withTx_sysException(){ 462 try{ 463 String expected = "ping"; 464 String actual = ejbObject.txSupportsMethod( expected ); 465 assertEquals("The method invocation was invalid.", expected, actual); 466 } catch (Exception e){ 467 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 468 } 469 } 470 } 471 472 | Popular Tags |