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.stateful;
0017:
0018: import javax.ejb.EJBHome;
0019: import javax.ejb.EJBMetaData;
0020: import javax.ejb.EJBObject;
0021: import javax.ejb.Handle;
0022:
0023: import org.apache.openejb.test.object.ObjectGraph;
0024:
0025: /**
0026: *
0027: * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
0028: * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
0029: */
0030: public class StatefulRmiIiopTests extends StatefulTestClient {
0031:
0032: protected RmiIiopStatefulHome ejbHome;
0033: protected RmiIiopStatefulObject ejbObject;
0034:
0035: public StatefulRmiIiopTests() {
0036: super ("RMI_IIOP.");
0037: }
0038:
0039: protected void setUp() throws Exception {
0040: super .setUp();
0041: Object obj = initialContext
0042: .lookup("client/tests/stateful/RMI-over-IIOP/EJBHome");
0043: ejbHome = (RmiIiopStatefulHome) javax.rmi.PortableRemoteObject
0044: .narrow(obj, RmiIiopStatefulHome.class);
0045: ejbObject = ejbHome.create("RMI-IIOP TestBean");
0046: }
0047:
0048: /*-------------------------------------------------*/
0049: /* String */
0050: /*-------------------------------------------------*/
0051:
0052: public void test01_returnStringObject() {
0053: try {
0054: String expected = new String("1");
0055: String actual = ejbObject.returnStringObject(expected);
0056: assertEquals(expected, actual);
0057: } catch (Exception e) {
0058: fail("Received Exception " + e.getClass() + " : "
0059: + e.getMessage());
0060: }
0061: }
0062:
0063: public void test02_returnStringObjectArray() {
0064: try {
0065: String[] expected = { "1", "2", "3" };
0066: String[] actual = ejbObject
0067: .returnStringObjectArray(expected);
0068:
0069: assertNotNull("The array returned is null", actual);
0070: assertEquals(expected.length, actual.length);
0071: for (int i = 0; i < actual.length; i++) {
0072: assertEquals(
0073: "Array values are not equal at index " + i,
0074: expected[i], actual[i]);
0075: }
0076: } catch (Exception e) {
0077: fail("Received Exception " + e.getClass() + " : "
0078: + e.getMessage());
0079: }
0080: }
0081:
0082: /*-------------------------------------------------*/
0083: /* Character */
0084: /*-------------------------------------------------*/
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/stateful/EncBean");
0607: EncStatefulHome expected = (EncStatefulHome) javax.rmi.PortableRemoteObject
0608: .narrow(obj, EncStatefulHome.class);
0609: assertNotNull("The EJBHome returned from JNDI is null",
0610: expected);
0611:
0612: EncStatefulHome actual = (EncStatefulHome) javax.rmi.PortableRemoteObject
0613: .narrow(ejbObject.returnEJBHome(expected),
0614: EncStatefulHome.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: EncStatefulHome actual = (EncStatefulHome) javax.rmi.PortableRemoteObject
0626: .narrow(ejbObject.returnEJBHome(),
0627: EncStatefulHome.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/stateful/EncBean");
0640: EncStatefulHome expected = (EncStatefulHome) javax.rmi.PortableRemoteObject
0641: .narrow(obj, EncStatefulHome.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: EncStatefulHome actual = (EncStatefulHome) javax.rmi.PortableRemoteObject
0650: .narrow(graph.getObject(), EncStatefulHome.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: EncStatefulHome actual = (EncStatefulHome) javax.rmi.PortableRemoteObject
0664: .narrow(graph.getObject(), EncStatefulHome.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: EncStatefulHome expected[] = new EncStatefulHome[3];
0676: for (int i = 0; i < expected.length; i++) {
0677: Object obj = initialContext
0678: .lookup("client/tests/stateful/EncBean");
0679: expected[i] = (EncStatefulHome) javax.rmi.PortableRemoteObject
0680: .narrow(obj, EncStatefulHome.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/stateful/EncBean");
0703: EncStatefulHome home = (EncStatefulHome) javax.rmi.PortableRemoteObject
0704: .narrow(obj, EncStatefulHome.class);
0705: assertNotNull("The EJBHome returned from JNDI is null",
0706: home);
0707:
0708: EncStatefulObject expected = home
0709: .create("test_40 StatefulBean");
0710: assertNotNull("The EJBObject created is null", expected);
0711:
0712: EncStatefulObject actual = (EncStatefulObject) javax.rmi.PortableRemoteObject
0713: .narrow(ejbObject.returnEJBObject(expected),
0714: EncStatefulObject.class);
0715: assertNotNull("The EJBObject returned is null", actual);
0716:
0717: assertTrue("The EJBObejcts are not identical", expected
0718: .isIdentical(actual));
0719: } catch (Exception e) {
0720: fail("Received Exception " + e.getClass() + " : "
0721: + e.getMessage());
0722: }
0723: }
0724:
0725: public void test41_returnEJBObject2() {
0726: try {
0727: EncStatefulObject actual = (EncStatefulObject) javax.rmi.PortableRemoteObject
0728: .narrow(ejbObject.returnEJBObject(),
0729: EncStatefulObject.class);
0730: assertNotNull("The EJBObject returned is null", actual);
0731:
0732: } catch (Exception e) {
0733: fail("Received Exception " + e.getClass() + " : "
0734: + e.getMessage());
0735: }
0736: }
0737:
0738: public void test42_returnNestedEJBObject() {
0739: try {
0740: Object obj = initialContext
0741: .lookup("client/tests/stateful/EncBean");
0742: EncStatefulHome home = (EncStatefulHome) javax.rmi.PortableRemoteObject
0743: .narrow(obj, EncStatefulHome.class);
0744: assertNotNull("The EJBHome returned from JNDI is null",
0745: home);
0746:
0747: EncStatefulObject expected = home
0748: .create("test_42 StatefulBean");
0749: assertNotNull("The EJBObject created is null", expected);
0750:
0751: ObjectGraph graph = ejbObject
0752: .returnObjectGraph(new ObjectGraph(expected));
0753: assertNotNull("The ObjectGraph is null", graph);
0754:
0755: EncStatefulObject actual = (EncStatefulObject) javax.rmi.PortableRemoteObject
0756: .narrow(graph.getObject(), EncStatefulObject.class);
0757: assertNotNull("The EJBObject returned is null", actual);
0758:
0759: assertTrue("The EJBObejcts are not identical", expected
0760: .isIdentical(actual));
0761: } catch (Exception e) {
0762: fail("Received Exception " + e.getClass() + " : "
0763: + e.getMessage());
0764: }
0765: }
0766:
0767: public void test43_returnNestedEJBObject2() {
0768: try {
0769: ObjectGraph graph = ejbObject.returnNestedEJBObject();
0770: assertNotNull("The ObjectGraph is null", graph);
0771:
0772: EncStatefulObject actual = (EncStatefulObject) javax.rmi.PortableRemoteObject
0773: .narrow(graph.getObject(), EncStatefulObject.class);
0774: assertNotNull("The EJBHome returned is null", actual);
0775: } catch (Exception e) {
0776: fail("Received Exception " + e.getClass() + " : "
0777: + e.getMessage());
0778: }
0779: }
0780:
0781: public void test44_returnEJBObjectArray() {
0782: try {
0783: Object obj = initialContext
0784: .lookup("client/tests/stateful/EncBean");
0785: EncStatefulHome home = (EncStatefulHome) javax.rmi.PortableRemoteObject
0786: .narrow(obj, EncStatefulHome.class);
0787: assertNotNull("The EJBHome returned from JNDI is null",
0788: home);
0789:
0790: EncStatefulObject expected[] = new EncStatefulObject[3];
0791: for (int i = 0; i < expected.length; i++) {
0792: expected[i] = home.create("test_44 StatefulBean");
0793: assertNotNull("The EJBObject created is null",
0794: expected[i]);
0795: }
0796:
0797: EJBObject[] actual = ejbObject
0798: .returnEJBObjectArray(expected);
0799: assertNotNull("The EJBObject array returned is null",
0800: actual);
0801: assertEquals(expected.length, actual.length);
0802:
0803: for (int i = 0; i < actual.length; i++) {
0804: assertTrue("The EJBObejcts are not identical",
0805: expected[i].isIdentical(actual[i]));
0806: }
0807:
0808: } catch (Exception e) {
0809: fail("Received Exception " + e.getClass() + " : "
0810: + e.getMessage());
0811: }
0812: }
0813:
0814: /*-------------------------------------------------*/
0815: /* EJBMetaData */
0816: /*-------------------------------------------------*/
0817:
0818: public void test45_returnEJBMetaData() {
0819: try {
0820: Object obj = initialContext
0821: .lookup("client/tests/stateful/EncBean");
0822: EncStatefulHome home = (EncStatefulHome) javax.rmi.PortableRemoteObject
0823: .narrow(obj, EncStatefulHome.class);
0824: assertNotNull("The EJBHome returned from JNDI is null",
0825: home);
0826:
0827: EJBMetaData expected = home.getEJBMetaData();
0828: assertNotNull("The EJBMetaData returned is null", expected);
0829:
0830: EJBMetaData actual = ejbObject.returnEJBMetaData(expected);
0831: assertNotNull("The EJBMetaData returned is null", actual);
0832: assertEquals(expected.getHomeInterfaceClass(), actual
0833: .getHomeInterfaceClass());
0834: assertEquals(expected.getRemoteInterfaceClass(), actual
0835: .getRemoteInterfaceClass());
0836: } catch (Exception e) {
0837: fail("Received Exception " + e.getClass() + " : "
0838: + e.getMessage());
0839: }
0840: }
0841:
0842: public void test46_returnEJBMetaData() {
0843: try {
0844: EJBMetaData actual = ejbObject.returnEJBMetaData();
0845: assertNotNull("The EJBMetaData returned is null", actual);
0846: assertEquals(actual.getHomeInterfaceClass(), actual
0847: .getHomeInterfaceClass());
0848: assertEquals(actual.getRemoteInterfaceClass(), actual
0849: .getRemoteInterfaceClass());
0850: } catch (Exception e) {
0851: fail("Received Exception " + e.getClass() + " : "
0852: + e.getMessage());
0853: }
0854: }
0855:
0856: public void test47_returnNestedEJBMetaData() {
0857: try {
0858: Object obj = initialContext
0859: .lookup("client/tests/stateful/EncBean");
0860: EncStatefulHome home = (EncStatefulHome) javax.rmi.PortableRemoteObject
0861: .narrow(obj, EncStatefulHome.class);
0862: assertNotNull("The EJBHome returned from JNDI is null",
0863: home);
0864:
0865: EJBMetaData expected = home.getEJBMetaData();
0866: assertNotNull("The EJBMetaData returned is null", expected);
0867:
0868: ObjectGraph graph = ejbObject
0869: .returnObjectGraph(new ObjectGraph(expected));
0870: assertNotNull("The ObjectGraph is null", graph);
0871:
0872: EJBMetaData actual = (EJBMetaData) graph.getObject();
0873: assertNotNull("The EJBMetaData returned is null", actual);
0874: assertEquals(expected.getHomeInterfaceClass(), actual
0875: .getHomeInterfaceClass());
0876: assertEquals(expected.getRemoteInterfaceClass(), actual
0877: .getRemoteInterfaceClass());
0878: } catch (Exception e) {
0879: fail("Received Exception " + e.getClass() + " : "
0880: + e.getMessage());
0881: }
0882: }
0883:
0884: public void test48_returnNestedEJBMetaData2() {
0885: try {
0886: ObjectGraph graph = ejbObject.returnNestedEJBMetaData();
0887: assertNotNull("The ObjectGraph is null", graph);
0888:
0889: EJBMetaData actual = (EJBMetaData) graph.getObject();
0890: assertNotNull("The EJBMetaData returned is null", actual);
0891: assertNotNull(
0892: "The home interface class of the EJBMetaData is null",
0893: actual.getHomeInterfaceClass());
0894: assertNotNull(
0895: "The remote interface class of the EJBMetaData is null",
0896: actual.getRemoteInterfaceClass());
0897: } catch (Exception e) {
0898: fail("Received Exception " + e.getClass() + " : "
0899: + e.getMessage());
0900: }
0901: }
0902:
0903: public void test49_returnEJBMetaDataArray() {
0904: try {
0905:
0906: Object obj = initialContext
0907: .lookup("client/tests/stateful/EncBean");
0908: EncStatefulHome home = (EncStatefulHome) javax.rmi.PortableRemoteObject
0909: .narrow(obj, EncStatefulHome.class);
0910: assertNotNull("The EJBHome returned from JNDI is null",
0911: home);
0912:
0913: EJBMetaData expected[] = new EJBMetaData[3];
0914: for (int i = 0; i < expected.length; i++) {
0915: expected[i] = home.getEJBMetaData();
0916: assertNotNull("The EJBMetaData returned is null",
0917: expected[i]);
0918: }
0919:
0920: EJBMetaData[] actual = (EJBMetaData[]) ejbObject
0921: .returnEJBMetaDataArray(expected);
0922: assertNotNull("The EJBMetaData array returned is null",
0923: actual);
0924: assertEquals(expected.length, actual.length);
0925:
0926: for (int i = 0; i < actual.length; i++) {
0927: assertNotNull("The EJBMetaData returned is null",
0928: actual[i]);
0929: assertEquals(expected[i].getHomeInterfaceClass(),
0930: actual[i].getHomeInterfaceClass());
0931: assertEquals(expected[i].getRemoteInterfaceClass(),
0932: actual[i].getRemoteInterfaceClass());
0933: }
0934: } catch (Exception e) {
0935: fail("Received Exception " + e.getClass() + " : "
0936: + e.getMessage());
0937: }
0938: }
0939:
0940: /*-------------------------------------------------*/
0941: /* Handle */
0942: /*-------------------------------------------------*/
0943:
0944: public void test50_returnHandle() {
0945: try {
0946: Object obj = initialContext
0947: .lookup("client/tests/stateful/EncBean");
0948: EncStatefulHome home = (EncStatefulHome) javax.rmi.PortableRemoteObject
0949: .narrow(obj, EncStatefulHome.class);
0950: assertNotNull("The EJBHome returned from JNDI is null",
0951: home);
0952:
0953: EncStatefulObject object = home
0954: .create("test_50 StatefulBean");
0955: assertNotNull("The EJBObject created is null", object);
0956:
0957: Handle expected = object.getHandle();
0958: assertNotNull("The EJBObject Handle returned is null",
0959: expected);
0960: assertNotNull("The EJBObject in the Handle is null",
0961: expected.getEJBObject());
0962:
0963: Handle actual = ejbObject.returnHandle(expected);
0964: assertNotNull("The EJBObject Handle returned is null",
0965: actual);
0966: assertNotNull("The EJBObject in the Handle is null", actual
0967: .getEJBObject());
0968:
0969: EJBObject exp = expected.getEJBObject();
0970: EJBObject act = actual.getEJBObject();
0971:
0972: assertTrue(
0973: "The EJBObjects in the Handles are not identical",
0974: exp.isIdentical(act));
0975: } catch (Exception e) {
0976: fail("Received Exception " + e.getClass() + " : "
0977: + e.getMessage());
0978: }
0979: }
0980:
0981: public void test51_returnHandle() {
0982: try {
0983: Handle actual = ejbObject.returnHandle();
0984: assertNotNull("The EJBObject Handle returned is null",
0985: actual);
0986: assertNotNull("The EJBObject in the Handle is null", actual
0987: .getEJBObject());
0988:
0989: } catch (Exception e) {
0990: fail("Received Exception " + e.getClass() + " : "
0991: + e.getMessage());
0992: }
0993: }
0994:
0995: public void test52_returnNestedHandle() {
0996: try {
0997: Object obj = initialContext
0998: .lookup("client/tests/stateful/EncBean");
0999: EncStatefulHome home = (EncStatefulHome) javax.rmi.PortableRemoteObject
1000: .narrow(obj, EncStatefulHome.class);
1001: assertNotNull("The EJBHome returned from JNDI is null",
1002: home);
1003:
1004: EncStatefulObject object = home
1005: .create("test_52 StatefulBean");
1006: assertNotNull("The EJBObject created is null", object);
1007:
1008: Handle expected = object.getHandle();
1009: assertNotNull("The EJBObject Handle returned is null",
1010: expected);
1011: assertNotNull("The EJBObject in the Handle is null",
1012: expected.getEJBObject());
1013:
1014: ObjectGraph graph = ejbObject
1015: .returnObjectGraph(new ObjectGraph(expected));
1016: assertNotNull("The ObjectGraph is null", graph);
1017:
1018: Handle actual = (Handle) graph.getObject();
1019: assertNotNull("The EJBObject Handle returned is null",
1020: actual);
1021: assertNotNull("The EJBObject in the Handle is null", actual
1022: .getEJBObject());
1023:
1024: EJBObject exp = expected.getEJBObject();
1025: EJBObject act = actual.getEJBObject();
1026:
1027: assertTrue(
1028: "The EJBObjects in the Handles are not identical",
1029: exp.isIdentical(act));
1030:
1031: } catch (Exception e) {
1032: fail("Received Exception " + e.getClass() + " : "
1033: + e.getMessage());
1034: }
1035: }
1036:
1037: public void test53_returnNestedHandle2() {
1038: try {
1039: ObjectGraph graph = ejbObject.returnNestedHandle();
1040: assertNotNull("The ObjectGraph is null", graph);
1041:
1042: Handle actual = (Handle) graph.getObject();
1043: assertNotNull("The EJBObject Handle returned is null",
1044: actual);
1045: assertNotNull("The EJBObject in the Handle is null", actual
1046: .getEJBObject());
1047: } catch (Exception e) {
1048: fail("Received Exception " + e.getClass() + " : "
1049: + e.getMessage());
1050: }
1051: }
1052:
1053: public void test54_returnHandleArray() {
1054: try {
1055: Object obj = initialContext
1056: .lookup("client/tests/stateful/EncBean");
1057: EncStatefulHome home = (EncStatefulHome) javax.rmi.PortableRemoteObject
1058: .narrow(obj, EncStatefulHome.class);
1059: assertNotNull("The EJBHome returned from JNDI is null",
1060: home);
1061:
1062: EncStatefulObject object = home
1063: .create("test_54 StatefulBean");
1064: assertNotNull("The EJBObject created is null", object);
1065:
1066: Handle expected[] = new Handle[3];
1067: for (int i = 0; i < expected.length; i++) {
1068: expected[i] = object.getHandle();
1069: assertNotNull("The EJBObject Handle returned is null",
1070: expected[i]);
1071: }
1072:
1073: Handle[] actual = (Handle[]) ejbObject
1074: .returnHandleArray(expected);
1075: assertNotNull("The Handle array returned is null", actual);
1076: assertEquals(expected.length, actual.length);
1077:
1078: for (int i = 0; i < expected.length; i++) {
1079: assertNotNull("The EJBObject Handle returned is null",
1080: actual[i]);
1081: assertNotNull("The EJBObject in the Handle is null",
1082: actual[i].getEJBObject());
1083: assertTrue(
1084: "The EJBObjects in the Handles are not equal",
1085: expected[i].getEJBObject().isIdentical(
1086: actual[i].getEJBObject()));
1087: }
1088:
1089: } catch (Exception e) {
1090: fail("Received Exception " + e.getClass() + " : "
1091: + e.getMessage());
1092: }
1093: }
1094:
1095: /*-------------------------------------------------*/
1096: /* Foo */
1097: /*-------------------------------------------------*/
1098:
1099: public void test55_returnObjectGraph() {
1100: }
1101:
1102: public void test56_returnObjectGraphArray() {
1103: }
1104: }
|