0001: /**
0002: * Licensed to the Apache Software Foundation (ASF) under one or more
0003: * contributor license agreements. See the NOTICE file distributed with
0004: * this work for additional information regarding copyright ownership.
0005: * The ASF licenses this file to You under the Apache License, Version 2.0
0006: * (the "License"); you may not use this file except in compliance with
0007: * the License. You may obtain a copy of the License at
0008: *
0009: * http://www.apache.org/licenses/LICENSE-2.0
0010: *
0011: * Unless required by applicable law or agreed to in writing, software
0012: * distributed under the License is distributed on an "AS IS" BASIS,
0013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014: * See the License for the specific language governing permissions and
0015: * limitations under the License.
0016: */package org.apache.openejb.test.stateless;
0017:
0018: import javax.ejb.EJBHome;
0019: import javax.ejb.EJBMetaData;
0020: import javax.ejb.EJBObject;
0021: import javax.ejb.Handle;
0022: import javax.rmi.PortableRemoteObject;
0023:
0024: import org.apache.openejb.test.object.ObjectGraph;
0025:
0026: /**
0027: *
0028: * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
0029: * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
0030: */
0031: public class StatelessRmiIiopTests extends StatelessTestClient {
0032:
0033: protected RmiIiopStatelessHome ejbHome;
0034: protected RmiIiopStatelessObject ejbObject;
0035:
0036: public StatelessRmiIiopTests() {
0037: super ("RMI_IIOP.");
0038: }
0039:
0040: protected void setUp() throws Exception {
0041: super .setUp();
0042: Object obj = initialContext
0043: .lookup("client/tests/stateless/RMI-over-IIOP/EJBHome");
0044: ejbHome = (RmiIiopStatelessHome) javax.rmi.PortableRemoteObject
0045: .narrow(obj, RmiIiopStatelessHome.class);
0046: ejbObject = ejbHome.create();
0047: }
0048:
0049: /*-------------------------------------------------*/
0050: /* String */
0051: /*-------------------------------------------------*/
0052:
0053: public void test01_returnStringObject() {
0054: try {
0055: String expected = new String("1");
0056: String actual = ejbObject.returnStringObject(expected);
0057: assertEquals(expected, actual);
0058: } catch (Exception e) {
0059: fail("Received Exception " + e.getClass() + " : "
0060: + e.getMessage());
0061: }
0062: }
0063:
0064: public void test02_returnStringObjectArray() {
0065: try {
0066: String[] expected = { "1", "2", "3" };
0067: String[] actual = ejbObject
0068: .returnStringObjectArray(expected);
0069:
0070: assertNotNull("The array returned is null", actual);
0071: assertEquals(expected.length, actual.length);
0072: for (int i = 0; i < actual.length; i++) {
0073: assertEquals(
0074: "Array values are not equal at index " + i,
0075: expected[i], actual[i]);
0076: }
0077: } catch (Exception e) {
0078: fail("Received Exception " + e.getClass() + " : "
0079: + e.getMessage());
0080: }
0081: }
0082:
0083: /*-------------------------------------------------*/
0084: /* Character */
0085: /*-------------------------------------------------*/
0086: public void test03_returnCharacterObject() {
0087: try {
0088: Character expected = new Character('1');
0089: Character actual = ejbObject
0090: .returnCharacterObject(expected);
0091: assertEquals(expected, actual);
0092: } catch (Exception e) {
0093: fail("Received Exception " + e.getClass() + " : "
0094: + e.getMessage());
0095: }
0096: }
0097:
0098: public void test04_returnCharacterPrimitive() {
0099: try {
0100: char expected = '1';
0101: char actual = ejbObject.returnCharacterPrimitive(expected);
0102: assertEquals(expected, actual);
0103: } catch (Exception e) {
0104: fail("Received Exception " + e.getClass() + " : "
0105: + e.getMessage());
0106: }
0107: }
0108:
0109: public void test05_returnCharacterObjectArray() {
0110: try {
0111: Character[] expected = { new Character('1'),
0112: new Character('2'), new Character('3') };
0113: Character[] actual = ejbObject
0114: .returnCharacterObjectArray(expected);
0115:
0116: assertNotNull("The array returned is null", actual);
0117: assertEquals(expected.length, actual.length);
0118: for (int i = 0; i < actual.length; i++) {
0119: assertEquals(
0120: "Array values are not equal at index " + i,
0121: expected[i], actual[i]);
0122: }
0123: } catch (Exception e) {
0124: fail("Received Exception " + e.getClass() + " : "
0125: + e.getMessage());
0126: }
0127: }
0128:
0129: public void test06_returnCharacterPrimitiveArray() {
0130: try {
0131: char[] expected = { '1', '2', '3' };
0132: char[] actual = ejbObject
0133: .returnCharacterPrimitiveArray(expected);
0134:
0135: assertNotNull("The array returned is null", actual);
0136: assertEquals(expected.length, actual.length);
0137: for (int i = 0; i < actual.length; i++) {
0138: assertEquals(
0139: "Array values are not equal at index " + i,
0140: expected[i], actual[i]);
0141: }
0142: } catch (Exception e) {
0143: fail("Received Exception " + e.getClass() + " : "
0144: + e.getMessage());
0145: }
0146: }
0147:
0148: /*-------------------------------------------------*/
0149: /* Boolean */
0150: /*-------------------------------------------------*/
0151:
0152: public void test07_returnBooleanObject() {
0153: try {
0154: Boolean expected = new Boolean(true);
0155: Boolean actual = ejbObject.returnBooleanObject(expected);
0156: assertEquals(expected, actual);
0157: } catch (Exception e) {
0158: fail("Received Exception " + e.getClass() + " : "
0159: + e.getMessage());
0160: }
0161: }
0162:
0163: public void test08_returnBooleanPrimitive() {
0164: try {
0165: boolean expected = true;
0166: boolean actual = ejbObject.returnBooleanPrimitive(expected);
0167: assertEquals("" + expected, "" + actual);
0168: } catch (Exception e) {
0169: fail("Received Exception " + e.getClass() + " : "
0170: + e.getMessage());
0171: }
0172: }
0173:
0174: public void test09_returnBooleanObjectArray() {
0175: try {
0176: Boolean[] expected = { new Boolean(true),
0177: new Boolean(false), new Boolean(true) };
0178: Boolean[] actual = ejbObject
0179: .returnBooleanObjectArray(expected);
0180:
0181: assertNotNull("The array returned is null", actual);
0182: assertEquals(expected.length, actual.length);
0183: for (int i = 0; i < actual.length; i++) {
0184: assertEquals(
0185: "Array values are not equal at index " + i,
0186: expected[i], actual[i]);
0187: }
0188: } catch (Exception e) {
0189: fail("Received Exception " + e.getClass() + " : "
0190: + e.getMessage());
0191: }
0192: }
0193:
0194: public void test10_returnBooleanPrimitiveArray() {
0195: try {
0196: boolean[] expected = { false, true, true };
0197: boolean[] actual = ejbObject
0198: .returnBooleanPrimitiveArray(expected);
0199:
0200: assertNotNull("The array returned is null", actual);
0201: assertEquals(expected.length, actual.length);
0202: for (int i = 0; i < actual.length; i++) {
0203: assertEquals(
0204: "Array values are not equal at index " + i,
0205: expected[i], actual[i]);
0206: }
0207: } catch (Exception e) {
0208: fail("Received Exception " + e.getClass() + " : "
0209: + e.getMessage());
0210: }
0211: }
0212:
0213: /*-------------------------------------------------*/
0214: /* Byte */
0215: /*-------------------------------------------------*/
0216:
0217: public void test11_returnByteObject() {
0218: try {
0219: Byte expected = new Byte("1");
0220: Byte actual = ejbObject.returnByteObject(expected);
0221: assertEquals(expected, actual);
0222: } catch (Exception e) {
0223: fail("Received Exception " + e.getClass() + " : "
0224: + e.getMessage());
0225: }
0226: }
0227:
0228: public void test12_returnBytePrimitive() {
0229: try {
0230: byte expected = (byte) 1;
0231: byte actual = ejbObject.returnBytePrimitive(expected);
0232: assertEquals(expected, actual);
0233: } catch (Exception e) {
0234: fail("Received Exception " + e.getClass() + " : "
0235: + e.getMessage());
0236: }
0237: }
0238:
0239: public void test13_returnByteObjectArray() {
0240: try {
0241: Byte[] expected = { new Byte("1"), new Byte("2"),
0242: new Byte("3") };
0243: Byte[] actual = ejbObject.returnByteObjectArray(expected);
0244:
0245: assertNotNull("The array returned is null", actual);
0246: assertEquals(expected.length, actual.length);
0247: for (int i = 0; i < actual.length; i++) {
0248: assertEquals(
0249: "Array values are not equal at index " + i,
0250: expected[i], actual[i]);
0251: }
0252: } catch (Exception e) {
0253: fail("Received Exception " + e.getClass() + " : "
0254: + e.getMessage());
0255: }
0256: }
0257:
0258: public void test14_returnBytePrimitiveArray() {
0259: try {
0260: byte[] expected = { (byte) 1, (byte) 2, (byte) 3 };
0261: byte[] actual = ejbObject
0262: .returnBytePrimitiveArray(expected);
0263:
0264: assertNotNull("The array returned is null", actual);
0265: assertEquals(expected.length, actual.length);
0266: for (int i = 0; i < actual.length; i++) {
0267: assertEquals(
0268: "Array values are not equal at index " + i,
0269: expected[i], actual[i]);
0270: }
0271: } catch (Exception e) {
0272: fail("Received Exception " + e.getClass() + " : "
0273: + e.getMessage());
0274: }
0275: }
0276:
0277: /*-------------------------------------------------*/
0278: /* Short */
0279: /*-------------------------------------------------*/
0280:
0281: public void test15_returnShortObject() {
0282: try {
0283: Short expected = new Short("1");
0284: Short actual = ejbObject.returnShortObject(expected);
0285: assertEquals(expected, actual);
0286: } catch (Exception e) {
0287: fail("Received Exception " + e.getClass() + " : "
0288: + e.getMessage());
0289: }
0290: }
0291:
0292: public void test16_returnShortPrimitive() {
0293: try {
0294: short expected = (short) 1;
0295: short actual = ejbObject.returnShortPrimitive(expected);
0296: assertEquals(expected, actual);
0297: } catch (Exception e) {
0298: fail("Received Exception " + e.getClass() + " : "
0299: + e.getMessage());
0300: }
0301: }
0302:
0303: public void test17_returnShortObjectArray() {
0304: try {
0305: Short[] expected = { new Short("1"), new Short("2"),
0306: new Short("3") };
0307: Short[] actual = ejbObject.returnShortObjectArray(expected);
0308:
0309: assertNotNull("The array returned is null", actual);
0310: assertEquals(expected.length, actual.length);
0311: for (int i = 0; i < actual.length; i++) {
0312: assertEquals(
0313: "Array values are not equal at index " + i,
0314: expected[i], actual[i]);
0315: }
0316: } catch (Exception e) {
0317: fail("Received Exception " + e.getClass() + " : "
0318: + e.getMessage());
0319: }
0320: }
0321:
0322: public void test18_returnShortPrimitiveArray() {
0323: try {
0324: short[] expected = { (short) 1, (short) 2, (short) 3 };
0325: short[] actual = ejbObject
0326: .returnShortPrimitiveArray(expected);
0327:
0328: assertNotNull("The array returned is null", actual);
0329: assertEquals(expected.length, actual.length);
0330: for (int i = 0; i < actual.length; i++) {
0331: assertEquals(
0332: "Array values are not equal at index " + i,
0333: expected[i], actual[i]);
0334: }
0335: } catch (Exception e) {
0336: fail("Received Exception " + e.getClass() + " : "
0337: + e.getMessage());
0338: }
0339: }
0340:
0341: /*-------------------------------------------------*/
0342: /* Integer */
0343: /*-------------------------------------------------*/
0344:
0345: public void test19_returnIntegerObject() {
0346: try {
0347: Integer expected = new Integer(1);
0348: Integer actual = ejbObject.returnIntegerObject(expected);
0349: assertEquals(expected, actual);
0350: } catch (Exception e) {
0351: fail("Received Exception " + e.getClass() + " : "
0352: + e.getMessage());
0353: }
0354: }
0355:
0356: public void test20_returnIntegerPrimitive() {
0357: try {
0358: int expected = 1;
0359: int actual = ejbObject.returnIntegerPrimitive(expected);
0360: assertEquals(expected, actual);
0361: } catch (Exception e) {
0362: fail("Received Exception " + e.getClass() + " : "
0363: + e.getMessage());
0364: }
0365: }
0366:
0367: public void test21_returnIntegerObjectArray() {
0368: try {
0369: Integer[] expected = { new Integer(1), new Integer(2),
0370: new Integer(3) };
0371: Integer[] actual = ejbObject
0372: .returnIntegerObjectArray(expected);
0373:
0374: assertNotNull("The array returned is null", actual);
0375: assertEquals(expected.length, actual.length);
0376: for (int i = 0; i < actual.length; i++) {
0377: assertEquals(
0378: "Array values are not equal at index " + i,
0379: expected[i], actual[i]);
0380: }
0381: } catch (Exception e) {
0382: fail("Received Exception " + e.getClass() + " : "
0383: + e.getMessage());
0384: }
0385: }
0386:
0387: public void test22_returnIntegerPrimitiveArray() {
0388: try {
0389: int[] expected = { 1, 2, 3 };
0390: int[] actual = ejbObject
0391: .returnIntegerPrimitiveArray(expected);
0392:
0393: assertNotNull("The array returned is null", actual);
0394: assertEquals(expected.length, actual.length);
0395: for (int i = 0; i < actual.length; i++) {
0396: assertEquals(
0397: "Array values are not equal at index " + i,
0398: expected[i], actual[i]);
0399: }
0400: } catch (Exception e) {
0401: fail("Received Exception " + e.getClass() + " : "
0402: + e.getMessage());
0403: }
0404: }
0405:
0406: /*-------------------------------------------------*/
0407: /* Long */
0408: /*-------------------------------------------------*/
0409:
0410: public void test23_returnLongObject() {
0411: try {
0412: Long expected = new Long("1");
0413: Long actual = ejbObject.returnLongObject(expected);
0414: assertEquals(expected, actual);
0415: } catch (Exception e) {
0416: fail("Received Exception " + e.getClass() + " : "
0417: + e.getMessage());
0418: }
0419: }
0420:
0421: public void test24_returnLongPrimitive() {
0422: try {
0423: long expected = 1;
0424: long actual = ejbObject.returnLongPrimitive(expected);
0425: assertEquals(expected, actual);
0426: } catch (Exception e) {
0427: fail("Received Exception " + e.getClass() + " : "
0428: + e.getMessage());
0429: }
0430: }
0431:
0432: public void test25_returnLongObjectArray() {
0433: try {
0434: Long[] expected = { new Long("1"), new Long("2"),
0435: new Long("3") };
0436: Long[] actual = ejbObject.returnLongObjectArray(expected);
0437:
0438: assertNotNull("The array returned is null", actual);
0439: assertEquals(expected.length, actual.length);
0440: for (int i = 0; i < actual.length; i++) {
0441: assertEquals(
0442: "Array values are not equal at index " + i,
0443: expected[i], actual[i]);
0444: }
0445: } catch (Exception e) {
0446: fail("Received Exception " + e.getClass() + " : "
0447: + e.getMessage());
0448: }
0449: }
0450:
0451: public void test26_returnLongPrimitiveArray() {
0452: try {
0453: long[] expected = { 1, 2, 3 };
0454: long[] actual = ejbObject
0455: .returnLongPrimitiveArray(expected);
0456:
0457: assertNotNull("The array returned is null", actual);
0458: assertEquals(expected.length, actual.length);
0459: for (int i = 0; i < actual.length; i++) {
0460: assertEquals(
0461: "Array values are not equal at index " + i,
0462: expected[i], actual[i]);
0463: }
0464: } catch (Exception e) {
0465: fail("Received Exception " + e.getClass() + " : "
0466: + e.getMessage());
0467: }
0468: }
0469:
0470: /*-------------------------------------------------*/
0471: /* Float */
0472: /*-------------------------------------------------*/
0473:
0474: public void test27_returnFloatObject() {
0475: try {
0476: Float expected = new Float("1.3");
0477: Float actual = ejbObject.returnFloatObject(expected);
0478: assertEquals(expected, actual);
0479: } catch (Exception e) {
0480: fail("Received Exception " + e.getClass() + " : "
0481: + e.getMessage());
0482: }
0483: }
0484:
0485: public void test28_returnFloatPrimitive() {
0486: try {
0487: float expected = 1.2F;
0488: float actual = ejbObject.returnFloatPrimitive(expected);
0489: assertEquals(expected, actual, 0.00D);
0490: } catch (Exception e) {
0491: fail("Received Exception " + e.getClass() + " : "
0492: + e.getMessage());
0493: }
0494: }
0495:
0496: public void test29_returnFloatObjectArray() {
0497: try {
0498: Float[] expected = { new Float("1.1"), new Float("2.2"),
0499: new Float("3.3") };
0500: Float[] actual = ejbObject.returnFloatObjectArray(expected);
0501:
0502: assertNotNull("The array returned is null", actual);
0503: assertEquals(expected.length, actual.length);
0504: for (int i = 0; i < actual.length; i++) {
0505: assertEquals(
0506: "Array values are not equal at index " + i,
0507: expected[i], actual[i]);
0508: }
0509: } catch (Exception e) {
0510: fail("Received Exception " + e.getClass() + " : "
0511: + e.getMessage());
0512: }
0513: }
0514:
0515: public void test30_returnFloatPrimitiveArray() {
0516: try {
0517: float[] expected = { 1.2F, 2.3F, 3.4F };
0518: float[] actual = ejbObject
0519: .returnFloatPrimitiveArray(expected);
0520:
0521: assertNotNull("The array returned is null", actual);
0522: assertEquals(expected.length, actual.length);
0523: for (int i = 0; i < actual.length; i++) {
0524: assertEquals(
0525: "Array values are not equal at index " + i,
0526: expected[i], actual[i], 0.0D);
0527: }
0528: } catch (Exception e) {
0529: fail("Received Exception " + e.getClass() + " : "
0530: + e.getMessage());
0531: }
0532: }
0533:
0534: /*-------------------------------------------------*/
0535: /* Double */
0536: /*-------------------------------------------------*/
0537:
0538: public void test31_returnDoubleObject() {
0539: try {
0540: Double expected = new Double("1.1");
0541: Double actual = ejbObject.returnDoubleObject(expected);
0542: assertEquals(expected, actual);
0543: } catch (Exception e) {
0544: fail("Received Exception " + e.getClass() + " : "
0545: + e.getMessage());
0546: }
0547: }
0548:
0549: public void test32_returnDoublePrimitive() {
0550: try {
0551: double expected = 1.2;
0552: double actual = ejbObject.returnDoublePrimitive(expected);
0553: assertEquals(expected, actual, 0.0D);
0554: } catch (Exception e) {
0555: fail("Received Exception " + e.getClass() + " : "
0556: + e.getMessage());
0557: }
0558: }
0559:
0560: public void test33_returnDoubleObjectArray() {
0561: try {
0562: Double[] expected = { new Double("1.3"), new Double("2.4"),
0563: new Double("3.5") };
0564: Double[] actual = ejbObject
0565: .returnDoubleObjectArray(expected);
0566:
0567: assertNotNull("The array returned is null", actual);
0568: assertEquals(expected.length, actual.length);
0569: for (int i = 0; i < actual.length; i++) {
0570: assertEquals(
0571: "Array values are not equal at index " + i,
0572: expected[i], actual[i]);
0573: }
0574: } catch (Exception e) {
0575: fail("Received Exception " + e.getClass() + " : "
0576: + e.getMessage());
0577: }
0578: }
0579:
0580: public void test34_returnDoublePrimitiveArray() {
0581: try {
0582: double[] expected = { 1.4, 2.5, 3.6 };
0583: double[] actual = ejbObject
0584: .returnDoublePrimitiveArray(expected);
0585:
0586: assertNotNull("The array returned is null", actual);
0587: assertEquals(expected.length, actual.length);
0588: for (int i = 0; i < actual.length; i++) {
0589: assertEquals(
0590: "Array values are not equal at index " + i,
0591: expected[i], actual[i], 0.0D);
0592: }
0593: } catch (Exception e) {
0594: fail("Received Exception " + e.getClass() + " : "
0595: + e.getMessage());
0596: }
0597: }
0598:
0599: /*-------------------------------------------------*/
0600: /* EJBHome */
0601: /*-------------------------------------------------*/
0602:
0603: public void test35_returnEJBHome() {
0604: try {
0605: Object obj = initialContext
0606: .lookup("client/tests/stateless/EncBean");
0607: EncStatelessHome expected = (EncStatelessHome) javax.rmi.PortableRemoteObject
0608: .narrow(obj, EncStatelessHome.class);
0609: assertNotNull("The EJBHome returned from JNDI is null",
0610: expected);
0611:
0612: EncStatelessHome actual = (EncStatelessHome) PortableRemoteObject
0613: .narrow(ejbObject.returnEJBHome(expected),
0614: EncStatelessHome.class);
0615: assertNotNull("The EJBHome returned is null", actual);
0616:
0617: } catch (Exception e) {
0618: fail("Received Exception " + e.getClass() + " : "
0619: + e.getMessage());
0620: }
0621: }
0622:
0623: public void test36_returnEJBHome2() {
0624: try {
0625: EncStatelessHome actual = (EncStatelessHome) PortableRemoteObject
0626: .narrow(ejbObject.returnEJBHome(),
0627: EncStatelessHome.class);
0628: assertNotNull("The EJBHome returned is null", actual);
0629:
0630: } catch (Exception e) {
0631: fail("Received Exception " + e.getClass() + " : "
0632: + e.getMessage());
0633: }
0634: }
0635:
0636: public void test37_returnNestedEJBHome() {
0637: try {
0638: Object obj = initialContext
0639: .lookup("client/tests/stateless/EncBean");
0640: EncStatelessHome expected = (EncStatelessHome) javax.rmi.PortableRemoteObject
0641: .narrow(obj, EncStatelessHome.class);
0642: assertNotNull("The EJBHome returned from JNDI is null",
0643: expected);
0644:
0645: ObjectGraph graph = ejbObject
0646: .returnObjectGraph(new ObjectGraph(expected));
0647: assertNotNull("The ObjectGraph is null", graph);
0648:
0649: EncStatelessHome actual = (EncStatelessHome) PortableRemoteObject
0650: .narrow(graph.getObject(), EncStatelessHome.class);
0651: assertNotNull("The EJBHome returned is null", actual);
0652: } catch (Exception e) {
0653: fail("Received Exception " + e.getClass() + " : "
0654: + e.getMessage());
0655: }
0656: }
0657:
0658: public void test38_returnNestedEJBHome2() {
0659: try {
0660: ObjectGraph graph = ejbObject.returnNestedEJBHome();
0661: assertNotNull("The ObjectGraph is null", graph);
0662:
0663: EncStatelessHome actual = (EncStatelessHome) PortableRemoteObject
0664: .narrow(graph.getObject(), EncStatelessHome.class);
0665: assertNotNull("The EJBHome returned is null", actual);
0666: } catch (Exception e) {
0667: fail("Received Exception " + e.getClass() + " : "
0668: + e.getMessage());
0669: }
0670: }
0671:
0672: public void test39_returnEJBHomeArray() {
0673: try {
0674:
0675: EncStatelessHome expected[] = new EncStatelessHome[3];
0676: for (int i = 0; i < expected.length; i++) {
0677: Object obj = initialContext
0678: .lookup("client/tests/stateless/EncBean");
0679: expected[i] = (EncStatelessHome) javax.rmi.PortableRemoteObject
0680: .narrow(obj, EncStatelessHome.class);
0681: assertNotNull("The EJBHome returned from JNDI is null",
0682: expected[i]);
0683: }
0684:
0685: EJBHome[] actual = ejbObject.returnEJBHomeArray(expected);
0686: assertNotNull("The EJBHome array returned is null", actual);
0687: assertEquals(expected.length, actual.length);
0688:
0689: } catch (Exception e) {
0690: fail("Received Exception " + e.getClass() + " : "
0691: + e.getMessage());
0692: }
0693: }
0694:
0695: /*-------------------------------------------------*/
0696: /* EJBObject */
0697: /*-------------------------------------------------*/
0698:
0699: public void test40_returnEJBObject() {
0700: try {
0701: Object obj = initialContext
0702: .lookup("client/tests/stateless/EncBean");
0703: EncStatelessHome home = (EncStatelessHome) javax.rmi.PortableRemoteObject
0704: .narrow(obj, EncStatelessHome.class);
0705: assertNotNull("The EJBHome returned from JNDI is null",
0706: home);
0707:
0708: EncStatelessObject expected = home.create();
0709: assertNotNull("The EJBObject created is null", expected);
0710:
0711: EncStatelessObject actual = (EncStatelessObject) PortableRemoteObject
0712: .narrow(ejbObject.returnEJBObject(expected),
0713: EncStatelessObject.class);
0714: assertNotNull("The EJBObject returned is null", actual);
0715:
0716: assertTrue("The EJBObejcts are not identical", expected
0717: .isIdentical(actual));
0718: } catch (Exception e) {
0719: fail("Received Exception " + e.getClass() + " : "
0720: + e.getMessage());
0721: }
0722: }
0723:
0724: public void test41_returnEJBObject2() {
0725: try {
0726: EncStatelessObject actual = (EncStatelessObject) PortableRemoteObject
0727: .narrow(ejbObject.returnEJBObject(),
0728: EncStatelessObject.class);
0729: assertNotNull("The EJBObject returned is null", actual);
0730:
0731: } catch (Exception e) {
0732: fail("Received Exception " + e.getClass() + " : "
0733: + e.getMessage());
0734: }
0735: }
0736:
0737: public void test42_returnNestedEJBObject() {
0738: try {
0739: Object obj = initialContext
0740: .lookup("client/tests/stateless/EncBean");
0741: EncStatelessHome home = (EncStatelessHome) javax.rmi.PortableRemoteObject
0742: .narrow(obj, EncStatelessHome.class);
0743: assertNotNull("The EJBHome returned from JNDI is null",
0744: home);
0745:
0746: EncStatelessObject expected = home.create();
0747: assertNotNull("The EJBObject created is null", expected);
0748:
0749: ObjectGraph graph = ejbObject
0750: .returnObjectGraph(new ObjectGraph(expected));
0751: assertNotNull("The ObjectGraph is null", graph);
0752:
0753: EncStatelessObject actual = (EncStatelessObject) PortableRemoteObject
0754: .narrow(graph.getObject(), EncStatelessObject.class);
0755: assertNotNull("The EJBObject returned is null", actual);
0756:
0757: assertTrue("The EJBObejcts are not identical", expected
0758: .isIdentical(actual));
0759: } catch (Exception e) {
0760: fail("Received Exception " + e.getClass() + " : "
0761: + e.getMessage());
0762: }
0763: }
0764:
0765: public void test43_returnNestedEJBObject2() {
0766: try {
0767: ObjectGraph graph = ejbObject.returnNestedEJBObject();
0768: assertNotNull("The ObjectGraph is null", graph);
0769:
0770: EncStatelessObject actual = (EncStatelessObject) PortableRemoteObject
0771: .narrow(graph.getObject(), EncStatelessObject.class);
0772: assertNotNull("The EJBHome returned is null", actual);
0773: } catch (Exception e) {
0774: fail("Received Exception " + e.getClass() + " : "
0775: + e.getMessage());
0776: }
0777: }
0778:
0779: public void test44_returnEJBObjectArray() {
0780: try {
0781: Object obj = initialContext
0782: .lookup("client/tests/stateless/EncBean");
0783: EncStatelessHome home = (EncStatelessHome) javax.rmi.PortableRemoteObject
0784: .narrow(obj, EncStatelessHome.class);
0785: assertNotNull("The EJBHome returned from JNDI is null",
0786: home);
0787:
0788: EncStatelessObject expected[] = new EncStatelessObject[3];
0789: for (int i = 0; i < expected.length; i++) {
0790: expected[i] = home.create();
0791: assertNotNull("The EJBObject created is null",
0792: expected[i]);
0793: }
0794:
0795: EJBObject[] actual = ejbObject
0796: .returnEJBObjectArray(expected);
0797: assertNotNull("The EJBObject array returned is null",
0798: actual);
0799: assertEquals(expected.length, actual.length);
0800:
0801: for (int i = 0; i < actual.length; i++) {
0802: assertTrue("The EJBObejcts are not identical",
0803: expected[i].isIdentical(actual[i]));
0804: }
0805:
0806: } catch (Exception e) {
0807: fail("Received Exception " + e.getClass() + " : "
0808: + e.getMessage());
0809: }
0810: }
0811:
0812: /*-------------------------------------------------*/
0813: /* EJBMetaData */
0814: /*-------------------------------------------------*/
0815:
0816: public void test45_returnEJBMetaData() {
0817: try {
0818: Object obj = initialContext
0819: .lookup("client/tests/stateless/EncBean");
0820: EncStatelessHome home = (EncStatelessHome) javax.rmi.PortableRemoteObject
0821: .narrow(obj, EncStatelessHome.class);
0822: assertNotNull("The EJBHome returned from JNDI is null",
0823: home);
0824:
0825: EJBMetaData expected = home.getEJBMetaData();
0826: assertNotNull("The EJBMetaData returned is null", expected);
0827:
0828: EJBMetaData actual = ejbObject.returnEJBMetaData(expected);
0829: assertNotNull("The EJBMetaData returned is null", actual);
0830: assertEquals(expected.getHomeInterfaceClass(), actual
0831: .getHomeInterfaceClass());
0832: assertEquals(expected.getRemoteInterfaceClass(), actual
0833: .getRemoteInterfaceClass());
0834: } catch (Exception e) {
0835: fail("Received Exception " + e.getClass() + " : "
0836: + e.getMessage());
0837: }
0838: }
0839:
0840: public void test46_returnEJBMetaData() {
0841: try {
0842: EJBMetaData actual = ejbObject.returnEJBMetaData();
0843: assertNotNull("The EJBMetaData returned is null", actual);
0844: assertEquals(actual.getHomeInterfaceClass(), actual
0845: .getHomeInterfaceClass());
0846: assertEquals(actual.getRemoteInterfaceClass(), actual
0847: .getRemoteInterfaceClass());
0848: } catch (Exception e) {
0849: fail("Received Exception " + e.getClass() + " : "
0850: + e.getMessage());
0851: }
0852: }
0853:
0854: public void test47_returnNestedEJBMetaData() {
0855: try {
0856: Object obj = initialContext
0857: .lookup("client/tests/stateless/EncBean");
0858: EncStatelessHome home = (EncStatelessHome) javax.rmi.PortableRemoteObject
0859: .narrow(obj, EncStatelessHome.class);
0860: assertNotNull("The EJBHome returned from JNDI is null",
0861: home);
0862:
0863: EJBMetaData expected = home.getEJBMetaData();
0864: assertNotNull("The EJBMetaData returned is null", expected);
0865:
0866: ObjectGraph graph = ejbObject
0867: .returnObjectGraph(new ObjectGraph(expected));
0868: assertNotNull("The ObjectGraph is null", graph);
0869:
0870: EJBMetaData actual = (EJBMetaData) graph.getObject();
0871: assertNotNull("The EJBMetaData returned is null", actual);
0872: assertEquals(expected.getHomeInterfaceClass(), actual
0873: .getHomeInterfaceClass());
0874: assertEquals(expected.getRemoteInterfaceClass(), actual
0875: .getRemoteInterfaceClass());
0876: } catch (Exception e) {
0877: fail("Received Exception " + e.getClass() + " : "
0878: + e.getMessage());
0879: }
0880: }
0881:
0882: public void test48_returnNestedEJBMetaData2() {
0883: try {
0884: ObjectGraph graph = ejbObject.returnNestedEJBMetaData();
0885: assertNotNull("The ObjectGraph is null", graph);
0886:
0887: EJBMetaData actual = (EJBMetaData) graph.getObject();
0888: assertNotNull("The EJBMetaData returned is null", actual);
0889: assertNotNull(
0890: "The home interface class of the EJBMetaData is null",
0891: actual.getHomeInterfaceClass());
0892: assertNotNull(
0893: "The remote interface class of the EJBMetaData is null",
0894: actual.getRemoteInterfaceClass());
0895: } catch (Exception e) {
0896: fail("Received Exception " + e.getClass() + " : "
0897: + e.getMessage());
0898: }
0899: }
0900:
0901: public void test49_returnEJBMetaDataArray() {
0902: try {
0903:
0904: Object obj = initialContext
0905: .lookup("client/tests/stateless/EncBean");
0906: EncStatelessHome home = (EncStatelessHome) javax.rmi.PortableRemoteObject
0907: .narrow(obj, EncStatelessHome.class);
0908: assertNotNull("The EJBHome returned from JNDI is null",
0909: home);
0910:
0911: EJBMetaData expected[] = new EJBMetaData[3];
0912: for (int i = 0; i < expected.length; i++) {
0913: expected[i] = home.getEJBMetaData();
0914: assertNotNull("The EJBMetaData returned is null",
0915: expected[i]);
0916: }
0917:
0918: EJBMetaData[] actual = (EJBMetaData[]) ejbObject
0919: .returnEJBMetaDataArray(expected);
0920: assertNotNull("The EJBMetaData array returned is null",
0921: actual);
0922: assertEquals(expected.length, actual.length);
0923:
0924: for (int i = 0; i < actual.length; i++) {
0925: assertNotNull("The EJBMetaData returned is null",
0926: actual[i]);
0927: assertEquals(expected[i].getHomeInterfaceClass(),
0928: actual[i].getHomeInterfaceClass());
0929: assertEquals(expected[i].getRemoteInterfaceClass(),
0930: actual[i].getRemoteInterfaceClass());
0931: }
0932: } catch (Exception e) {
0933: fail("Received Exception " + e.getClass() + " : "
0934: + e.getMessage());
0935: }
0936: }
0937:
0938: /*-------------------------------------------------*/
0939: /* Handle */
0940: /*-------------------------------------------------*/
0941:
0942: public void test50_returnHandle() {
0943: try {
0944: Object obj = initialContext
0945: .lookup("client/tests/stateless/EncBean");
0946: EncStatelessHome home = (EncStatelessHome) javax.rmi.PortableRemoteObject
0947: .narrow(obj, EncStatelessHome.class);
0948: assertNotNull("The EJBHome returned from JNDI is null",
0949: home);
0950:
0951: EncStatelessObject object = home.create();
0952: assertNotNull("The EJBObject created is null", object);
0953:
0954: Handle expected = object.getHandle();
0955: assertNotNull("The EJBObject Handle returned is null",
0956: expected);
0957: assertNotNull("The EJBObject in the Handle is null",
0958: expected.getEJBObject());
0959:
0960: Handle actual = ejbObject.returnHandle(expected);
0961: assertNotNull("The EJBObject Handle returned is null",
0962: actual);
0963: assertNotNull("The EJBObject in the Handle is null", actual
0964: .getEJBObject());
0965:
0966: EJBObject exp = expected.getEJBObject();
0967: EJBObject act = actual.getEJBObject();
0968:
0969: assertTrue(
0970: "The EJBObjects in the Handles are not identical",
0971: exp.isIdentical(act));
0972: } catch (Exception e) {
0973: fail("Received Exception " + e.getClass() + " : "
0974: + e.getMessage());
0975: }
0976: }
0977:
0978: public void test51_returnHandle() {
0979: try {
0980: Handle actual = ejbObject.returnHandle();
0981: assertNotNull("The EJBObject Handle returned is null",
0982: actual);
0983: assertNotNull("The EJBObject in the Handle is null", actual
0984: .getEJBObject());
0985:
0986: } catch (Exception e) {
0987: fail("Received Exception " + e.getClass() + " : "
0988: + e.getMessage());
0989: }
0990: }
0991:
0992: public void test52_returnNestedHandle() {
0993: try {
0994: Object obj = initialContext
0995: .lookup("client/tests/stateless/EncBean");
0996: EncStatelessHome home = (EncStatelessHome) javax.rmi.PortableRemoteObject
0997: .narrow(obj, EncStatelessHome.class);
0998: assertNotNull("The EJBHome returned from JNDI is null",
0999: home);
1000:
1001: EncStatelessObject object = home.create();
1002: assertNotNull("The EJBObject created is null", object);
1003:
1004: Handle expected = object.getHandle();
1005: assertNotNull("The EJBObject Handle returned is null",
1006: expected);
1007: assertNotNull("The EJBObject in the Handle is null",
1008: expected.getEJBObject());
1009:
1010: ObjectGraph graph = ejbObject
1011: .returnObjectGraph(new ObjectGraph(expected));
1012: assertNotNull("The ObjectGraph is null", graph);
1013:
1014: Handle actual = (Handle) graph.getObject();
1015: assertNotNull("The EJBObject Handle returned is null",
1016: actual);
1017: assertNotNull("The EJBObject in the Handle is null", actual
1018: .getEJBObject());
1019:
1020: EJBObject exp = expected.getEJBObject();
1021: EJBObject act = actual.getEJBObject();
1022:
1023: assertTrue(
1024: "The EJBObjects in the Handles are not identical",
1025: exp.isIdentical(act));
1026:
1027: } catch (Exception e) {
1028: fail("Received Exception " + e.getClass() + " : "
1029: + e.getMessage());
1030: }
1031: }
1032:
1033: public void test53_returnNestedHandle2() {
1034: try {
1035: ObjectGraph graph = ejbObject.returnNestedHandle();
1036: assertNotNull("The ObjectGraph is null", graph);
1037:
1038: Handle actual = (Handle) graph.getObject();
1039: assertNotNull("The EJBObject Handle returned is null",
1040: actual);
1041: assertNotNull("The EJBObject in the Handle is null", actual
1042: .getEJBObject());
1043: } catch (Exception e) {
1044: fail("Received Exception " + e.getClass() + " : "
1045: + e.getMessage());
1046: }
1047: }
1048:
1049: public void test54_returnHandleArray() {
1050: try {
1051: Object obj = initialContext
1052: .lookup("client/tests/stateless/EncBean");
1053: EncStatelessHome home = (EncStatelessHome) javax.rmi.PortableRemoteObject
1054: .narrow(obj, EncStatelessHome.class);
1055: assertNotNull("The EJBHome returned from JNDI is null",
1056: home);
1057:
1058: EncStatelessObject object = home.create();
1059: assertNotNull("The EJBObject created is null", object);
1060:
1061: Handle expected[] = new Handle[3];
1062: for (int i = 0; i < expected.length; i++) {
1063: expected[i] = object.getHandle();
1064: assertNotNull("The EJBObject Handle returned is null",
1065: expected[i]);
1066: }
1067:
1068: Handle[] actual = (Handle[]) ejbObject
1069: .returnHandleArray(expected);
1070: assertNotNull("The Handle array returned is null", actual);
1071: assertEquals(expected.length, actual.length);
1072:
1073: for (int i = 0; i < expected.length; i++) {
1074: assertNotNull("The EJBObject Handle returned is null",
1075: actual[i]);
1076: assertNotNull("The EJBObject in the Handle is null",
1077: actual[i].getEJBObject());
1078: assertTrue(
1079: "The EJBObjects in the Handles are not equal",
1080: expected[i].getEJBObject().isIdentical(
1081: actual[i].getEJBObject()));
1082: }
1083:
1084: } catch (Exception e) {
1085: fail("Received Exception " + e.getClass() + " : "
1086: + e.getMessage());
1087: }
1088: }
1089:
1090: /*-------------------------------------------------*/
1091: /* Foo */
1092: /*-------------------------------------------------*/
1093:
1094: public void test55_returnObjectGraph() {
1095: }
1096:
1097: public void test56_returnObjectGraphArray() {
1098: }
1099: }
|