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