1 44 package org.openejb.test.stateful; 45 46 import javax.ejb.EJBHome ; 47 import javax.ejb.EJBMetaData ; 48 import javax.ejb.EJBObject ; 49 import javax.ejb.Handle ; 50 51 import org.openejb.test.object.ObjectGraph; 52 53 58 public class StatefulRmiIiopTests extends StatefulTestClient{ 59 60 protected RmiIiopStatefulHome ejbHome; 61 protected RmiIiopStatefulObject ejbObject; 62 63 public StatefulRmiIiopTests(){ 64 super("RMI_IIOP."); 65 } 66 67 protected void setUp() throws Exception { 68 super.setUp(); 69 Object obj = initialContext.lookup("client/tests/stateful/RMI-over-IIOP/EJBHome"); 70 ejbHome = (RmiIiopStatefulHome)javax.rmi.PortableRemoteObject.narrow( obj, RmiIiopStatefulHome.class); 71 ejbObject = ejbHome.create("RMI-IIOP TestBean"); 72 } 73 74 75 76 77 78 public void test01_returnStringObject() { 79 try{ 80 String expected = new String ("1"); 81 String actual = ejbObject.returnStringObject(expected); 82 assertEquals(expected, actual); 83 } catch (Exception e){ 84 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 85 } 86 } 87 88 public void test02_returnStringObjectArray() { 89 try{ 90 String [] expected = {"1","2","3"}; 91 String [] actual = ejbObject.returnStringObjectArray(expected); 92 93 assertNotNull("The array returned is null", actual); 94 assertEquals(expected.length, actual.length); 95 for (int i=0; i < actual.length; i++){ 96 assertEquals("Array values are not equal at index "+i ,expected[i], actual[i]); 97 } 98 } catch (Exception e){ 99 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 100 } 101 } 102 103 104 105 106 107 108 public void test03_returnCharacterObject() { 109 try{ 110 Character expected = new Character ('1'); 111 Character actual = ejbObject.returnCharacterObject(expected); 112 assertEquals(expected, actual); 113 } catch (Exception e){ 114 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 115 } 116 } 117 118 public void test04_returnCharacterPrimitive() { 119 try{ 120 char expected = '1'; 121 char actual = ejbObject.returnCharacterPrimitive(expected); 122 assertEquals(expected, actual); 123 } catch (Exception e){ 124 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 125 } 126 } 127 128 public void test05_returnCharacterObjectArray() { 129 try{ 130 Character [] expected = {new Character ('1'),new Character ('2'),new Character ('3')}; 131 Character [] actual = ejbObject.returnCharacterObjectArray(expected); 132 133 assertNotNull("The array returned is null", actual); 134 assertEquals(expected.length, actual.length); 135 for (int i=0; i < actual.length; i++){ 136 assertEquals("Array values are not equal at index "+i ,expected[i], actual[i]); 137 } 138 } catch (Exception e){ 139 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 140 } 141 } 142 143 public void test06_returnCharacterPrimitiveArray() { 144 try{ 145 char[] expected = {'1','2','3'}; 146 char[] actual = ejbObject.returnCharacterPrimitiveArray(expected); 147 148 assertNotNull("The array returned is null", actual); 149 assertEquals(expected.length, actual.length); 150 for (int i=0; i < actual.length; i++){ 151 assertEquals("Array values are not equal at index "+i ,expected[i], actual[i]); 152 } 153 } catch (Exception e){ 154 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 155 } 156 } 157 158 159 160 161 162 163 public void test07_returnBooleanObject() { 164 try{ 165 Boolean expected = new Boolean (true); 166 Boolean actual = ejbObject.returnBooleanObject(expected); 167 assertEquals(expected, actual); 168 } catch (Exception e){ 169 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 170 } 171 } 172 173 public void test08_returnBooleanPrimitive() { 174 try{ 175 boolean expected = true; 176 boolean actual = ejbObject.returnBooleanPrimitive(expected); 177 assertEquals(""+expected, ""+actual); 178 } catch (Exception e){ 179 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 180 } 181 } 182 183 public void test09_returnBooleanObjectArray() { 184 try{ 185 Boolean [] expected = {new Boolean (true),new Boolean (false),new Boolean (true)}; 186 Boolean [] actual = ejbObject.returnBooleanObjectArray(expected); 187 188 assertNotNull("The array returned is null", actual); 189 assertEquals(expected.length, actual.length); 190 for (int i=0; i < actual.length; i++){ 191 assertEquals("Array values are not equal at index "+i ,expected[i], actual[i]); 192 } 193 } catch (Exception e){ 194 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 195 } 196 } 197 198 public void test10_returnBooleanPrimitiveArray() { 199 try{ 200 boolean[] expected = {false,true,true}; 201 boolean[] actual = ejbObject.returnBooleanPrimitiveArray(expected); 202 203 assertNotNull("The array returned is null", actual); 204 assertEquals(expected.length, actual.length); 205 for (int i=0; i < actual.length; i++){ 206 assertEquals("Array values are not equal at index "+i ,expected[i], actual[i]); 207 } 208 } catch (Exception e){ 209 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 210 } 211 } 212 213 214 215 216 217 218 public void test11_returnByteObject() { 219 try{ 220 Byte expected = new Byte ("1"); 221 Byte actual = ejbObject.returnByteObject(expected); 222 assertEquals(expected, actual); 223 } catch (Exception e){ 224 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 225 } 226 } 227 228 public void test12_returnBytePrimitive() { 229 try{ 230 byte expected = (byte)1; 231 byte actual = ejbObject.returnBytePrimitive(expected); 232 assertEquals(expected, actual); 233 } catch (Exception e){ 234 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 235 } 236 } 237 238 public void test13_returnByteObjectArray() { 239 try{ 240 Byte [] expected = {new Byte ("1"),new Byte ("2"),new Byte ("3")}; 241 Byte [] actual = ejbObject.returnByteObjectArray(expected); 242 243 assertNotNull("The array returned is null", actual); 244 assertEquals(expected.length, actual.length); 245 for (int i=0; i < actual.length; i++){ 246 assertEquals("Array values are not equal at index "+i ,expected[i], actual[i]); 247 } 248 } catch (Exception e){ 249 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 250 } 251 } 252 253 public void test14_returnBytePrimitiveArray() { 254 try{ 255 byte[] expected = {(byte)1,(byte)2,(byte)3}; 256 byte[] actual = ejbObject.returnBytePrimitiveArray(expected); 257 258 assertNotNull("The array returned is null", actual); 259 assertEquals(expected.length, actual.length); 260 for (int i=0; i < actual.length; i++){ 261 assertEquals("Array values are not equal at index "+i ,expected[i], actual[i]); 262 } 263 } catch (Exception e){ 264 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 265 } 266 } 267 268 269 270 271 272 273 public void test15_returnShortObject() { 274 try{ 275 Short expected = new Short ("1"); 276 Short actual = ejbObject.returnShortObject(expected); 277 assertEquals(expected, actual); 278 } catch (Exception e){ 279 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 280 } 281 } 282 283 public void test16_returnShortPrimitive() { 284 try{ 285 short expected = (short)1; 286 short actual = ejbObject.returnShortPrimitive(expected); 287 assertEquals(expected, actual); 288 } catch (Exception e){ 289 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 290 } 291 } 292 293 public void test17_returnShortObjectArray() { 294 try{ 295 Short [] expected = {new Short ("1"),new Short ("2"),new Short ("3")}; 296 Short [] actual = ejbObject.returnShortObjectArray(expected); 297 298 assertNotNull("The array returned is null", actual); 299 assertEquals(expected.length, actual.length); 300 for (int i=0; i < actual.length; i++){ 301 assertEquals("Array values are not equal at index "+i ,expected[i], actual[i]); 302 } 303 } catch (Exception e){ 304 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 305 } 306 } 307 308 public void test18_returnShortPrimitiveArray() { 309 try{ 310 short[] expected = {(short)1,(short)2,(short)3}; 311 short[] actual = ejbObject.returnShortPrimitiveArray(expected); 312 313 assertNotNull("The array returned is null", actual); 314 assertEquals(expected.length, actual.length); 315 for (int i=0; i < actual.length; i++){ 316 assertEquals("Array values are not equal at index "+i ,expected[i], actual[i]); 317 } 318 } catch (Exception e){ 319 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 320 } 321 } 322 323 324 325 326 327 328 public void test19_returnIntegerObject() { 329 try{ 330 Integer expected = new Integer (1); 331 Integer actual = ejbObject.returnIntegerObject(expected); 332 assertEquals(expected, actual); 333 } catch (Exception e){ 334 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 335 } 336 } 337 338 public void test20_returnIntegerPrimitive() { 339 try{ 340 int expected = 1; 341 int actual = ejbObject.returnIntegerPrimitive(expected); 342 assertEquals(expected, actual); 343 } catch (Exception e){ 344 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 345 } 346 } 347 348 public void test21_returnIntegerObjectArray() { 349 try{ 350 Integer [] expected = {new Integer (1),new Integer (2),new Integer (3)}; 351 Integer [] actual = ejbObject.returnIntegerObjectArray(expected); 352 353 assertNotNull("The array returned is null", actual); 354 assertEquals(expected.length, actual.length); 355 for (int i=0; i < actual.length; i++){ 356 assertEquals("Array values are not equal at index "+i ,expected[i], actual[i]); 357 } 358 } catch (Exception e){ 359 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 360 } 361 } 362 363 public void test22_returnIntegerPrimitiveArray() { 364 try{ 365 int[] expected = {1,2,3}; 366 int[] actual = ejbObject.returnIntegerPrimitiveArray(expected); 367 368 assertNotNull("The array returned is null", actual); 369 assertEquals(expected.length, actual.length); 370 for (int i=0; i < actual.length; i++){ 371 assertEquals("Array values are not equal at index "+i ,expected[i], actual[i]); 372 } 373 } catch (Exception e){ 374 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 375 } 376 } 377 378 379 380 381 382 383 public void test23_returnLongObject() { 384 try{ 385 Long expected = new Long ("1"); 386 Long actual = ejbObject.returnLongObject(expected); 387 assertEquals(expected, actual); 388 } catch (Exception e){ 389 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 390 } 391 } 392 393 public void test24_returnLongPrimitive() { 394 try{ 395 long expected = 1; 396 long actual = ejbObject.returnLongPrimitive(expected); 397 assertEquals(expected, actual); 398 } catch (Exception e){ 399 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 400 } 401 } 402 403 public void test25_returnLongObjectArray() { 404 try{ 405 Long [] expected = {new Long ("1"),new Long ("2"),new Long ("3")}; 406 Long [] actual = ejbObject.returnLongObjectArray(expected); 407 408 assertNotNull("The array returned is null", actual); 409 assertEquals(expected.length, actual.length); 410 for (int i=0; i < actual.length; i++){ 411 assertEquals("Array values are not equal at index "+i ,expected[i], actual[i]); 412 } 413 } catch (Exception e){ 414 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 415 } 416 } 417 418 public void test26_returnLongPrimitiveArray() { 419 try{ 420 long[] expected = {1,2,3}; 421 long[] actual = ejbObject.returnLongPrimitiveArray(expected); 422 423 assertNotNull("The array returned is null", actual); 424 assertEquals(expected.length, actual.length); 425 for (int i=0; i < actual.length; i++){ 426 assertEquals("Array values are not equal at index "+i ,expected[i], actual[i]); 427 } 428 } catch (Exception e){ 429 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 430 } 431 } 432 433 434 435 436 437 438 public void test27_returnFloatObject() { 439 try{ 440 Float expected = new Float ("1.3"); 441 Float actual = ejbObject.returnFloatObject(expected); 442 assertEquals(expected, actual); 443 } catch (Exception e){ 444 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 445 } 446 } 447 448 public void test28_returnFloatPrimitive() { 449 try{ 450 float expected = 1.2F; 451 float actual = ejbObject.returnFloatPrimitive(expected); 452 assertEquals(expected, actual, 0.00D); 453 } catch (Exception e){ 454 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 455 } 456 } 457 458 public void test29_returnFloatObjectArray() { 459 try{ 460 Float [] expected = {new Float ("1.1"),new Float ("2.2"),new Float ("3.3")}; 461 Float [] actual = ejbObject.returnFloatObjectArray(expected); 462 463 assertNotNull("The array returned is null", actual); 464 assertEquals(expected.length, actual.length); 465 for (int i=0; i < actual.length; i++){ 466 assertEquals("Array values are not equal at index "+i ,expected[i], actual[i]); 467 } 468 } catch (Exception e){ 469 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 470 } 471 } 472 473 public void test30_returnFloatPrimitiveArray() { 474 try{ 475 float[] expected = {1.2F,2.3F,3.4F}; 476 float[] actual = ejbObject.returnFloatPrimitiveArray(expected); 477 478 assertNotNull("The array returned is null", actual); 479 assertEquals(expected.length, actual.length); 480 for (int i=0; i < actual.length; i++){ 481 assertEquals("Array values are not equal at index "+i , expected[i], actual[i], 0.0D); 482 } 483 } catch (Exception e){ 484 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 485 } 486 } 487 488 489 490 491 492 493 public void test31_returnDoubleObject() { 494 try{ 495 Double expected = new Double ("1.1"); 496 Double actual = ejbObject.returnDoubleObject(expected); 497 assertEquals(expected, actual); 498 } catch (Exception e){ 499 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 500 } 501 } 502 503 public void test32_returnDoublePrimitive() { 504 try{ 505 double expected = 1.2; 506 double actual = ejbObject.returnDoublePrimitive(expected); 507 assertEquals(expected, actual, 0.0D); 508 } catch (Exception e){ 509 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 510 } 511 } 512 513 public void test33_returnDoubleObjectArray() { 514 try{ 515 Double [] expected = {new Double ("1.3"),new Double ("2.4"),new Double ("3.5")}; 516 Double [] actual = ejbObject.returnDoubleObjectArray(expected); 517 518 assertNotNull("The array returned is null", actual); 519 assertEquals(expected.length, actual.length); 520 for (int i=0; i < actual.length; i++){ 521 assertEquals("Array values are not equal at index "+i ,expected[i], actual[i]); 522 } 523 } catch (Exception e){ 524 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 525 } 526 } 527 528 public void test34_returnDoublePrimitiveArray() { 529 try{ 530 double[] expected = {1.4,2.5,3.6}; 531 double[] actual = ejbObject.returnDoublePrimitiveArray(expected); 532 533 assertNotNull("The array returned is null", actual); 534 assertEquals(expected.length, actual.length); 535 for (int i=0; i < actual.length; i++){ 536 assertEquals("Array values are not equal at index "+i ,expected[i], actual[i],0.0D); 537 } 538 } catch (Exception e){ 539 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 540 } 541 } 542 543 544 545 546 547 548 public void test35_returnEJBHome() { 549 try{ 550 Object obj = initialContext.lookup("client/tests/stateful/EncBean"); 551 EncStatefulHome expected = (EncStatefulHome)javax.rmi.PortableRemoteObject.narrow( obj, EncStatefulHome.class); 552 assertNotNull("The EJBHome returned from JNDI is null", expected); 553 554 EncStatefulHome actual = (EncStatefulHome)javax.rmi.PortableRemoteObject.narrow(ejbObject.returnEJBHome(expected), EncStatefulHome.class); 555 assertNotNull("The EJBHome returned is null", actual); 556 557 } catch (Exception e){ 558 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 559 } 560 } 561 562 public void test36_returnEJBHome2() { 563 try{ 564 EncStatefulHome actual = (EncStatefulHome)javax.rmi.PortableRemoteObject.narrow(ejbObject.returnEJBHome(), EncStatefulHome.class); 565 assertNotNull("The EJBHome returned is null", actual); 566 567 } catch (Exception e){ 568 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 569 } 570 } 571 572 public void test37_returnNestedEJBHome() { 573 try{ 574 Object obj = initialContext.lookup("client/tests/stateful/EncBean"); 575 EncStatefulHome expected = (EncStatefulHome)javax.rmi.PortableRemoteObject.narrow( obj, EncStatefulHome.class); 576 assertNotNull("The EJBHome returned from JNDI is null", expected); 577 578 ObjectGraph graph = ejbObject.returnObjectGraph(new ObjectGraph(expected)); 579 assertNotNull("The ObjectGraph is null", graph); 580 581 EncStatefulHome actual = (EncStatefulHome)javax.rmi.PortableRemoteObject.narrow(graph.getObject(), EncStatefulHome.class); 582 assertNotNull("The EJBHome returned is null", actual); 583 } catch (Exception e){ 584 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 585 } 586 } 587 588 public void test38_returnNestedEJBHome2() { 589 try{ 590 ObjectGraph graph = ejbObject.returnNestedEJBHome(); 591 assertNotNull("The ObjectGraph is null", graph); 592 593 EncStatefulHome actual = (EncStatefulHome)javax.rmi.PortableRemoteObject.narrow(graph.getObject(), EncStatefulHome.class); 594 assertNotNull("The EJBHome returned is null", actual); 595 } catch (Exception e){ 596 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 597 } 598 } 599 600 public void test39_returnEJBHomeArray() { 601 try{ 602 603 EncStatefulHome expected[] = new EncStatefulHome[3]; 604 for (int i=0; i < expected.length; i++){ 605 Object obj = initialContext.lookup("client/tests/stateful/EncBean"); 606 expected[i] = (EncStatefulHome)javax.rmi.PortableRemoteObject.narrow( obj, EncStatefulHome.class); 607 assertNotNull("The EJBHome returned from JNDI is null", expected[i]); 608 } 609 610 EJBHome [] actual = ejbObject.returnEJBHomeArray(expected); 611 assertNotNull("The EJBHome array returned is null", actual); 612 assertEquals(expected.length, actual.length); 613 614 } catch (Exception e){ 615 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 616 } 617 } 618 619 620 621 622 623 624 public void test40_returnEJBObject() { 625 try{ 626 Object obj = initialContext.lookup("client/tests/stateful/EncBean"); 627 EncStatefulHome home = (EncStatefulHome)javax.rmi.PortableRemoteObject.narrow( obj, EncStatefulHome.class); 628 assertNotNull("The EJBHome returned from JNDI is null", home); 629 630 EncStatefulObject expected = home.create("test_40 StatefulBean"); 631 assertNotNull("The EJBObject created is null", expected); 632 633 EncStatefulObject actual = (EncStatefulObject)javax.rmi.PortableRemoteObject.narrow(ejbObject.returnEJBObject(expected), EncStatefulObject.class); 634 assertNotNull("The EJBObject returned is null", actual); 635 636 assertTrue("The EJBObejcts are not identical", expected.isIdentical(actual)); 637 } catch (Exception e){ 638 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 639 } 640 } 641 642 public void test41_returnEJBObject2() { 643 try{ 644 EncStatefulObject actual = (EncStatefulObject)javax.rmi.PortableRemoteObject.narrow(ejbObject.returnEJBObject(), EncStatefulObject.class); 645 assertNotNull("The EJBObject returned is null", actual); 646 647 } catch (Exception e){ 648 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 649 } 650 } 651 652 public void test42_returnNestedEJBObject() { 653 try{ 654 Object obj = initialContext.lookup("client/tests/stateful/EncBean"); 655 EncStatefulHome home = (EncStatefulHome)javax.rmi.PortableRemoteObject.narrow( obj, EncStatefulHome.class); 656 assertNotNull("The EJBHome returned from JNDI is null", home); 657 658 EncStatefulObject expected = home.create("test_42 StatefulBean"); 659 assertNotNull("The EJBObject created is null", expected); 660 661 ObjectGraph graph = ejbObject.returnObjectGraph(new ObjectGraph(expected)); 662 assertNotNull("The ObjectGraph is null", graph); 663 664 EncStatefulObject actual = (EncStatefulObject)javax.rmi.PortableRemoteObject.narrow(graph.getObject(), EncStatefulObject.class); 665 assertNotNull("The EJBObject returned is null", actual); 666 667 assertTrue("The EJBObejcts are not identical", expected.isIdentical(actual)); 668 } catch (Exception e){ 669 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 670 } 671 } 672 673 public void test43_returnNestedEJBObject2() { 674 try{ 675 ObjectGraph graph = ejbObject.returnNestedEJBObject(); 676 assertNotNull("The ObjectGraph is null", graph); 677 678 EncStatefulObject actual = (EncStatefulObject)javax.rmi.PortableRemoteObject.narrow(graph.getObject(), EncStatefulObject.class); 679 assertNotNull("The EJBHome returned is null", actual); 680 } catch (Exception e){ 681 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 682 } 683 } 684 685 public void test44_returnEJBObjectArray() { 686 try{ 687 Object obj = initialContext.lookup("client/tests/stateful/EncBean"); 688 EncStatefulHome home = (EncStatefulHome)javax.rmi.PortableRemoteObject.narrow( obj, EncStatefulHome.class); 689 assertNotNull("The EJBHome returned from JNDI is null", home); 690 691 EncStatefulObject expected[] = new EncStatefulObject[3]; 692 for (int i=0; i < expected.length; i++){ 693 expected[i] = home.create("test_44 StatefulBean"); 694 assertNotNull("The EJBObject created is null", expected[i]); 695 } 696 697 EJBObject [] actual = ejbObject.returnEJBObjectArray(expected); 698 assertNotNull("The EJBObject array returned is null", actual); 699 assertEquals(expected.length, actual.length); 700 701 for (int i=0; i < actual.length; i++){ 702 assertTrue("The EJBObejcts are not identical", expected[i].isIdentical(actual[i])); 703 } 704 705 } catch (Exception e){ 706 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 707 } 708 } 709 710 711 712 713 714 public void test45_returnEJBMetaData() { 715 try{ 716 Object obj = initialContext.lookup("client/tests/stateful/EncBean"); 717 EncStatefulHome home = (EncStatefulHome)javax.rmi.PortableRemoteObject.narrow( obj, EncStatefulHome.class); 718 assertNotNull("The EJBHome returned from JNDI is null", home); 719 720 EJBMetaData expected = home.getEJBMetaData(); 721 assertNotNull("The EJBMetaData returned is null", expected); 722 723 EJBMetaData actual = ejbObject.returnEJBMetaData(expected); 724 assertNotNull("The EJBMetaData returned is null", actual); 725 assertEquals(expected.getHomeInterfaceClass(), actual.getHomeInterfaceClass()); 726 assertEquals(expected.getRemoteInterfaceClass(), actual.getRemoteInterfaceClass()); 727 } catch (Exception e){ 728 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 729 } 730 } 731 732 public void test46_returnEJBMetaData() { 733 try{ 734 EJBMetaData actual = ejbObject.returnEJBMetaData(); 735 assertNotNull("The EJBMetaData returned is null", actual); 736 assertEquals(actual.getHomeInterfaceClass(), actual.getHomeInterfaceClass()); 737 assertEquals(actual.getRemoteInterfaceClass(), actual.getRemoteInterfaceClass()); 738 } catch (Exception e){ 739 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 740 } 741 } 742 743 public void test47_returnNestedEJBMetaData() { 744 try{ 745 Object obj = initialContext.lookup("client/tests/stateful/EncBean"); 746 EncStatefulHome home = (EncStatefulHome)javax.rmi.PortableRemoteObject.narrow( obj, EncStatefulHome.class); 747 assertNotNull("The EJBHome returned from JNDI is null", home); 748 749 EJBMetaData expected = home.getEJBMetaData(); 750 assertNotNull("The EJBMetaData returned is null", expected); 751 752 ObjectGraph graph = ejbObject.returnObjectGraph(new ObjectGraph(expected)); 753 assertNotNull("The ObjectGraph is null", graph); 754 755 EJBMetaData actual = (EJBMetaData )graph.getObject(); 756 assertNotNull("The EJBMetaData returned is null", actual); 757 assertEquals(expected.getHomeInterfaceClass(), actual.getHomeInterfaceClass()); 758 assertEquals(expected.getRemoteInterfaceClass(), actual.getRemoteInterfaceClass()); 759 } catch (Exception e){ 760 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 761 } 762 } 763 764 public void test48_returnNestedEJBMetaData2() { 765 try{ 766 ObjectGraph graph = ejbObject.returnNestedEJBMetaData(); 767 assertNotNull("The ObjectGraph is null", graph); 768 769 EJBMetaData actual = (EJBMetaData )graph.getObject(); 770 assertNotNull("The EJBMetaData returned is null", actual); 771 assertNotNull("The home interface class of the EJBMetaData is null", actual.getHomeInterfaceClass()); 772 assertNotNull("The remote interface class of the EJBMetaData is null", actual.getRemoteInterfaceClass()); 773 } catch (Exception e){ 774 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 775 } 776 } 777 778 public void test49_returnEJBMetaDataArray() { 779 try{ 780 781 Object obj = initialContext.lookup("client/tests/stateful/EncBean"); 782 EncStatefulHome home = (EncStatefulHome)javax.rmi.PortableRemoteObject.narrow( obj, EncStatefulHome.class); 783 assertNotNull("The EJBHome returned from JNDI is null", home); 784 785 EJBMetaData expected[] = new EJBMetaData [3]; 786 for (int i=0; i < expected.length; i++){ 787 expected[i] = home.getEJBMetaData(); 788 assertNotNull("The EJBMetaData returned is null", expected[i]); 789 } 790 791 EJBMetaData [] actual = (EJBMetaData [])ejbObject.returnEJBMetaDataArray(expected); 792 assertNotNull("The EJBMetaData array returned is null", actual); 793 assertEquals(expected.length, actual.length); 794 795 for (int i=0; i < actual.length; i++){ 796 assertNotNull("The EJBMetaData returned is null", actual[i]); 797 assertEquals(expected[i].getHomeInterfaceClass(), actual[i].getHomeInterfaceClass()); 798 assertEquals(expected[i].getRemoteInterfaceClass(), actual[i].getRemoteInterfaceClass()); 799 } 800 } catch (Exception e){ 801 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 802 } 803 } 804 805 806 807 808 809 810 public void test50_returnHandle() { 811 try{ 812 Object obj = initialContext.lookup("client/tests/stateful/EncBean"); 813 EncStatefulHome home = (EncStatefulHome)javax.rmi.PortableRemoteObject.narrow( obj, EncStatefulHome.class); 814 assertNotNull("The EJBHome returned from JNDI is null", home); 815 816 EncStatefulObject object = home.create("test_50 StatefulBean"); 817 assertNotNull("The EJBObject created is null", object); 818 819 Handle expected = object.getHandle(); 820 assertNotNull("The EJBObject Handle returned is null", expected); 821 assertNotNull("The EJBObject in the Handle is null", expected.getEJBObject()); 822 823 Handle actual = ejbObject.returnHandle(expected); 824 assertNotNull("The EJBObject Handle returned is null", actual); 825 assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject()); 826 827 EJBObject exp = expected.getEJBObject(); 828 EJBObject act = actual.getEJBObject(); 829 830 assertTrue("The EJBObjects in the Handles are not identical", exp.isIdentical(act)); 831 } catch (Exception e){ 832 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 833 } 834 } 835 836 public void test51_returnHandle() { 837 try{ 838 Handle actual = ejbObject.returnHandle(); 839 assertNotNull("The EJBObject Handle returned is null", actual); 840 assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject()); 841 842 } catch (Exception e){ 843 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 844 } 845 } 846 847 public void test52_returnNestedHandle() { 848 try{ 849 Object obj = initialContext.lookup("client/tests/stateful/EncBean"); 850 EncStatefulHome home = (EncStatefulHome)javax.rmi.PortableRemoteObject.narrow( obj, EncStatefulHome.class); 851 assertNotNull("The EJBHome returned from JNDI is null", home); 852 853 EncStatefulObject object = home.create("test_52 StatefulBean"); 854 assertNotNull("The EJBObject created is null", object); 855 856 Handle expected = object.getHandle(); 857 assertNotNull("The EJBObject Handle returned is null", expected); 858 assertNotNull("The EJBObject in the Handle is null", expected.getEJBObject()); 859 860 ObjectGraph graph = ejbObject.returnObjectGraph(new ObjectGraph(expected)); 861 assertNotNull("The ObjectGraph is null", graph); 862 863 Handle actual = (Handle )graph.getObject(); 864 assertNotNull("The EJBObject Handle returned is null", actual); 865 assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject()); 866 867 EJBObject exp = expected.getEJBObject(); 868 EJBObject act = actual.getEJBObject(); 869 870 assertTrue("The EJBObjects in the Handles are not identical", exp.isIdentical(act)); 871 872 } catch (Exception e){ 873 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 874 } 875 } 876 877 public void test53_returnNestedHandle2() { 878 try{ 879 ObjectGraph graph = ejbObject.returnNestedHandle(); 880 assertNotNull("The ObjectGraph is null", graph); 881 882 Handle actual = (Handle )graph.getObject(); 883 assertNotNull("The EJBObject Handle returned is null", actual); 884 assertNotNull("The EJBObject in the Handle is null", actual.getEJBObject()); 885 } catch (Exception e){ 886 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 887 } 888 } 889 890 public void test54_returnHandleArray() { 891 try{ 892 Object obj = initialContext.lookup("client/tests/stateful/EncBean"); 893 EncStatefulHome home = (EncStatefulHome)javax.rmi.PortableRemoteObject.narrow( obj, EncStatefulHome.class); 894 assertNotNull("The EJBHome returned from JNDI is null", home); 895 896 EncStatefulObject object = home.create("test_54 StatefulBean"); 897 assertNotNull("The EJBObject created is null", object); 898 899 Handle expected[] = new Handle [3]; 900 for (int i=0; i < expected.length; i++){ 901 expected[i] = object.getHandle(); 902 assertNotNull("The EJBObject Handle returned is null", expected[i]); 903 } 904 905 Handle [] actual = (Handle [])ejbObject.returnHandleArray(expected); 906 assertNotNull("The Handle array returned is null", actual); 907 assertEquals(expected.length, actual.length); 908 909 for (int i=0; i < expected.length; i++){ 910 assertNotNull("The EJBObject Handle returned is null", actual[i]); 911 assertNotNull("The EJBObject in the Handle is null", actual[i].getEJBObject()); 912 assertTrue("The EJBObjects in the Handles are not equal", expected[i].getEJBObject().isIdentical(actual[i].getEJBObject())); 913 } 914 915 } catch (Exception e){ 916 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 917 } 918 } 919 920 921 922 923 924 925 public void test55_returnObjectGraph() { 926 } 927 public void test56_returnObjectGraphArray() { 928 } 929 } 930 931 | Popular Tags |