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