KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > itest > client > EjbCommunicationTest


1 /**
2  *
3  * Copyright 2003-2004 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.itest.client;
19
20 import javax.ejb.EJBHome JavaDoc;
21 import javax.ejb.EJBMetaData JavaDoc;
22 import javax.ejb.EJBObject JavaDoc;
23 import javax.ejb.Handle JavaDoc;
24 import javax.naming.InitialContext JavaDoc;
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 JavaDoc initialContext;
38
39
40     protected void setUp() throws Exception JavaDoc {
41         initialContext = new InitialContext JavaDoc();
42         Object JavaDoc obj = initialContext.lookup("java:comp/env/ejb/rmiiiopbean");
43         ejbHome = (RmiIiopStatelessHome) obj;
44         ejbObject = ejbHome.create();
45     }
46
47 /*-------------------------------------------------*/
48 /* String */
49 /*-------------------------------------------------*/
50
51     public void testReturnStringObject() {
52         try {
53             String JavaDoc expected = new String JavaDoc("1");
54             String JavaDoc actual = ejbObject.returnStringObject(expected);
55             assertEquals(expected, actual);
56         } catch (Exception JavaDoc e) {
57             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
58         }
59     }
60
61     public void testReturnStringObjectArray() {
62         try {
63             String JavaDoc[] expected = {"1", "2", "3"};
64             String JavaDoc[] 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 JavaDoc e) {
72             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
73         }
74     }
75
76
77 /*-------------------------------------------------*/
78 /* Character */
79 /*-------------------------------------------------*/
80     public void testReturnCharacterObject() {
81         try {
82             Character JavaDoc expected = new Character JavaDoc('1');
83             Character JavaDoc actual = ejbObject.returnCharacterObject(expected);
84             assertEquals(expected, actual);
85         } catch (Exception JavaDoc 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 JavaDoc e) {
96             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
97         }
98     }
99
100     public void testReturnCharacterObjectArray() {
101         try {
102             Character JavaDoc[] expected = {new Character JavaDoc('1'), new Character JavaDoc('2'), new Character JavaDoc('3')};
103             Character JavaDoc[] 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 JavaDoc 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 JavaDoc e) {
126             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
127         }
128     }
129
130
131 /*-------------------------------------------------*/
132 /* Boolean */
133 /*-------------------------------------------------*/
134
135     public void testReturnBooleanObject() {
136         try {
137             Boolean JavaDoc expected = new Boolean JavaDoc(true);
138             Boolean JavaDoc actual = ejbObject.returnBooleanObject(expected);
139             assertEquals(expected, actual);
140         } catch (Exception JavaDoc 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 JavaDoc e) {
151             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
152         }
153     }
154
155     public void testReturnBooleanObjectArray() {
156         try {
157             Boolean JavaDoc[] expected = {new Boolean JavaDoc(true), new Boolean JavaDoc(false), new Boolean JavaDoc(true)};
158             Boolean JavaDoc[] 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 JavaDoc 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 JavaDoc e) {
181             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
182         }
183     }
184
185
186 /*-------------------------------------------------*/
187 /* Byte */
188 /*-------------------------------------------------*/
189
190     public void testReturnByteObject() {
191         try {
192             Byte JavaDoc expected = new Byte JavaDoc("1");
193             Byte JavaDoc actual = ejbObject.returnByteObject(expected);
194             assertEquals(expected, actual);
195         } catch (Exception JavaDoc 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 JavaDoc e) {
206             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
207         }
208     }
209
210     public void testReturnByteObjectArray() {
211         try {
212             Byte JavaDoc[] expected = {new Byte JavaDoc("1"), new Byte JavaDoc("2"), new Byte JavaDoc("3")};
213             Byte JavaDoc[] 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 JavaDoc 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 JavaDoc e) {
236             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
237         }
238     }
239
240
241 /*-------------------------------------------------*/
242 /* Short */
243 /*-------------------------------------------------*/
244
245     public void testReturnShortObject() {
246         try {
247             Short JavaDoc expected = new Short JavaDoc("1");
248             Short JavaDoc actual = ejbObject.returnShortObject(expected);
249             assertEquals(expected, actual);
250         } catch (Exception JavaDoc 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 JavaDoc e) {
261             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
262         }
263     }
264
265     public void testReturnShortObjectArray() {
266         try {
267             Short JavaDoc[] expected = {new Short JavaDoc("1"), new Short JavaDoc("2"), new Short JavaDoc("3")};
268             Short JavaDoc[] 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 JavaDoc 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 JavaDoc e) {
291             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
292         }
293     }
294
295
296 /*-------------------------------------------------*/
297 /* Integer */
298 /*-------------------------------------------------*/
299
300     public void testReturnIntegerObject() {
301         try {
302             Integer JavaDoc expected = new Integer JavaDoc(1);
303             Integer JavaDoc actual = ejbObject.returnIntegerObject(expected);
304             assertEquals(expected, actual);
305         } catch (Exception JavaDoc 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 JavaDoc e) {
316             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
317         }
318     }
319
320     public void testReturnIntegerObjectArray() {
321         try {
322             Integer JavaDoc[] expected = {new Integer JavaDoc(1), new Integer JavaDoc(2), new Integer JavaDoc(3)};
323             Integer JavaDoc[] 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 JavaDoc 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 JavaDoc e) {
346             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
347         }
348     }
349
350
351 /*-------------------------------------------------*/
352 /* Long */
353 /*-------------------------------------------------*/
354
355     public void testReturnLongObject() {
356         try {
357             Long JavaDoc expected = new Long JavaDoc("1");
358             Long JavaDoc actual = ejbObject.returnLongObject(expected);
359             assertEquals(expected, actual);
360         } catch (Exception JavaDoc 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 JavaDoc e) {
371             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
372         }
373     }
374
375     public void testReturnLongObjectArray() {
376         try {
377             Long JavaDoc[] expected = {new Long JavaDoc("1"), new Long JavaDoc("2"), new Long JavaDoc("3")};
378             Long JavaDoc[] 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 JavaDoc 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 JavaDoc e) {
401             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
402         }
403     }
404
405
406 /*-------------------------------------------------*/
407 /* Float */
408 /*-------------------------------------------------*/
409
410     public void testReturnFloatObject() {
411         try {
412             Float JavaDoc expected = new Float JavaDoc("1.3");
413             Float JavaDoc actual = ejbObject.returnFloatObject(expected);
414             assertEquals(expected, actual);
415         } catch (Exception JavaDoc 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 JavaDoc e) {
426             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
427         }
428     }
429
430     public void testReturnFloatObjectArray() {
431         try {
432             Float JavaDoc[] expected = {new Float JavaDoc("1.1"), new Float JavaDoc("2.2"), new Float JavaDoc("3.3")};
433             Float JavaDoc[] 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 JavaDoc 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 JavaDoc e) {
456             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
457         }
458     }
459
460
461 /*-------------------------------------------------*/
462 /* Double */
463 /*-------------------------------------------------*/
464
465     public void testReturnDoubleObject() {
466         try {
467             Double JavaDoc expected = new Double JavaDoc("1.1");
468             Double JavaDoc actual = ejbObject.returnDoubleObject(expected);
469             assertEquals(expected, actual);
470         } catch (Exception JavaDoc 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 JavaDoc e) {
481             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
482         }
483     }
484
485     public void testReturnDoubleObjectArray() {
486         try {
487             Double JavaDoc[] expected = {new Double JavaDoc("1.3"), new Double JavaDoc("2.4"), new Double JavaDoc("3.5")};
488             Double JavaDoc[] 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 JavaDoc 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 JavaDoc e) {
511             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
512         }
513     }
514
515
516 /*-------------------------------------------------*/
517 /* EJBHome */
518 /*-------------------------------------------------*/
519
520     public void testReturnEJBHome() {
521         try {
522             Object JavaDoc 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 JavaDoc 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 JavaDoc e) {
540             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
541         }
542     }
543
544     public void testReturnNestedEJBHome() {
545         try {
546             Object JavaDoc 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 JavaDoc 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 JavaDoc 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 JavaDoc 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 JavaDoc[] actual = ejbObject.returnEJBHomeArray(expected);
583             assertNotNull("The EJBHome array returned is null", actual);
584             assertEquals(expected.length, actual.length);
585
586         } catch (Exception JavaDoc e) {
587             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
588         }
589     }
590
591
592 /*-------------------------------------------------*/
593 /* EJBObject */
594 /*-------------------------------------------------*/
595
596     public void testReturnEJBObject() {
597         try {
598             Object JavaDoc 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 JavaDoc 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 JavaDoc e) {
620             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
621         }
622     }
623
624     public void testReturnNestedEJBObject() {
625         try {
626             Object JavaDoc 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 JavaDoc 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 JavaDoc e) {
653             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
654         }
655     }
656
657     public void XtestReturnEJBObjectArray() {
658         try {
659             Object JavaDoc 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 JavaDoc[] 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 JavaDoc e) {
678             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
679         }
680     }
681
682 /*-------------------------------------------------*/
683 /* EJBMetaData */
684 /*-------------------------------------------------*/
685
686     public void testReturnEJBMetaData() {
687         try {
688             Object JavaDoc 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 JavaDoc expected = home.getEJBMetaData();
693             assertNotNull("The EJBMetaData returned is null", expected);
694
695             EJBMetaData JavaDoc 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 JavaDoc e) {
700             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
701         }
702     }
703
704     public void testReturnEJBMetaData2() {
705         try {
706             EJBMetaData JavaDoc 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 JavaDoc e) {
711             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
712         }
713     }
714
715     public void testReturnNestedEJBMetaData() {
716         try {
717             Object JavaDoc 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 JavaDoc 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 JavaDoc actual = (EJBMetaData JavaDoc) 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 JavaDoc 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 JavaDoc actual = (EJBMetaData JavaDoc) 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 JavaDoc e) {
746             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
747         }
748     }
749
750     public void testReturnEJBMetaDataArray() {
751         try {
752
753             Object JavaDoc 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 JavaDoc expected[] = new EJBMetaData JavaDoc[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 JavaDoc[] actual = (EJBMetaData JavaDoc[]) 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 JavaDoc e) {
773             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
774         }
775     }
776
777
778 /*-------------------------------------------------*/
779 /* Handle */
780 /*-------------------------------------------------*/
781
782     public void testReturnHandle() {
783         try {
784             Object JavaDoc 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 JavaDoc 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 JavaDoc 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 JavaDoc exp = expected.getEJBObject();
800             EJBObject JavaDoc act = actual.getEJBObject();
801
802             assertTrue("The EJBObjects in the Handles are not identical", exp.isIdentical(act));
803         } catch (Exception JavaDoc e) {
804             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
805         }
806     }
807
808     public void testReturnHandle2() {
809         try {
810             Handle JavaDoc 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 JavaDoc e) {
815             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
816         }
817     }
818
819     public void testReturnNestedHandle() {
820         try {
821             Object JavaDoc 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 JavaDoc 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 JavaDoc actual = (Handle JavaDoc) 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 JavaDoc exp = expected.getEJBObject();
840             EJBObject JavaDoc act = actual.getEJBObject();
841
842             assertTrue("The EJBObjects in the Handles are not identical", exp.isIdentical(act));
843
844         } catch (Exception JavaDoc 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 JavaDoc actual = (Handle JavaDoc) 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 JavaDoc e) {
858             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
859         }
860     }
861
862     public void testReturnHandleArray() {
863         try {
864             Object JavaDoc 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 JavaDoc expected[] = new Handle JavaDoc[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 JavaDoc[] actual = (Handle JavaDoc[]) 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 JavaDoc e) {
888             fail("Received Exception " + e.getClass() + " : " + e.getMessage());
889         }
890     }
891
892 }
893
Popular Tags