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.cmp;
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 CmpRmiIiopTests extends CmpTestClient {
0031:
0032: protected RmiIiopCmpHome ejbHome;
0033: protected RmiIiopCmpObject ejbObject;
0034:
0035: public CmpRmiIiopTests() {
0036: super ("RMI_IIOP.");
0037: }
0038:
0039: protected void setUp() throws Exception {
0040: super .setUp();
0041: Object obj = initialContext
0042: .lookup("client/tests/entity/cmp/RMI-over-IIOP/EJBHome");
0043: ejbHome = (RmiIiopCmpHome) javax.rmi.PortableRemoteObject
0044: .narrow(obj, RmiIiopCmpHome.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/entity/cmp/EncBean");
0607: EncCmpHome expected = (EncCmpHome) javax.rmi.PortableRemoteObject
0608: .narrow(obj, EncCmpHome.class);
0609: assertNotNull("The EJBHome returned from JNDI is null",
0610: expected);
0611:
0612: EncCmpHome actual = (EncCmpHome) javax.rmi.PortableRemoteObject
0613: .narrow(ejbObject.returnEJBHome(expected),
0614: EncCmpHome.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: EncCmpHome actual = (EncCmpHome) javax.rmi.PortableRemoteObject
0626: .narrow(ejbObject.returnEJBHome(), EncCmpHome.class);
0627: assertNotNull("The EJBHome returned is null", actual);
0628:
0629: } catch (Exception e) {
0630: fail("Received Exception " + e.getClass() + " : "
0631: + e.getMessage());
0632: }
0633: }
0634:
0635: public void test37_returnNestedEJBHome() {
0636: try {
0637: Object obj = initialContext
0638: .lookup("client/tests/entity/cmp/EncBean");
0639: EncCmpHome expected = (EncCmpHome) javax.rmi.PortableRemoteObject
0640: .narrow(obj, EncCmpHome.class);
0641: assertNotNull("The EJBHome returned from JNDI is null",
0642: expected);
0643:
0644: ObjectGraph graph = ejbObject
0645: .returnObjectGraph(new ObjectGraph(expected));
0646: assertNotNull("The ObjectGraph is null", graph);
0647:
0648: EncCmpHome actual = (EncCmpHome) javax.rmi.PortableRemoteObject
0649: .narrow(graph.getObject(), EncCmpHome.class);
0650: assertNotNull("The EJBHome returned is null", actual);
0651: } catch (Exception e) {
0652: fail("Received Exception " + e.getClass() + " : "
0653: + e.getMessage());
0654: }
0655: }
0656:
0657: public void test38_returnNestedEJBHome2() {
0658: try {
0659: ObjectGraph graph = ejbObject.returnNestedEJBHome();
0660: assertNotNull("The ObjectGraph is null", graph);
0661:
0662: EncCmpHome actual = (EncCmpHome) javax.rmi.PortableRemoteObject
0663: .narrow(graph.getObject(), EncCmpHome.class);
0664: assertNotNull("The EJBHome returned is null", actual);
0665: } catch (Exception e) {
0666: fail("Received Exception " + e.getClass() + " : "
0667: + e.getMessage());
0668: }
0669: }
0670:
0671: public void test39_returnEJBHomeArray() {
0672: try {
0673:
0674: EncCmpHome expected[] = new EncCmpHome[3];
0675: for (int i = 0; i < expected.length; i++) {
0676: Object obj = initialContext
0677: .lookup("client/tests/entity/cmp/EncBean");
0678: expected[i] = (EncCmpHome) javax.rmi.PortableRemoteObject
0679: .narrow(obj, EncCmpHome.class);
0680: assertNotNull("The EJBHome returned from JNDI is null",
0681: expected[i]);
0682: }
0683:
0684: EJBHome[] actual = ejbObject.returnEJBHomeArray(expected);
0685: assertNotNull("The EJBHome array returned is null", actual);
0686: assertEquals(expected.length, actual.length);
0687:
0688: } catch (Exception e) {
0689: fail("Received Exception " + e.getClass() + " : "
0690: + e.getMessage());
0691: }
0692: }
0693:
0694: /*-------------------------------------------------*/
0695: /* EJBObject */
0696: /*-------------------------------------------------*/
0697:
0698: public void test40_returnEJBObject() {
0699: try {
0700: Object obj = initialContext
0701: .lookup("client/tests/entity/cmp/EncBean");
0702: EncCmpHome home = (EncCmpHome) javax.rmi.PortableRemoteObject
0703: .narrow(obj, EncCmpHome.class);
0704: assertNotNull("The EJBHome returned from JNDI is null",
0705: home);
0706:
0707: EncCmpObject expected = home.create("test_40 CmpBean");
0708: assertNotNull("The EJBObject created is null", expected);
0709:
0710: EncCmpObject actual = (EncCmpObject) javax.rmi.PortableRemoteObject
0711: .narrow(ejbObject.returnEJBObject(expected),
0712: EncCmpObject.class);
0713: assertNotNull("The EJBObject returned is null", actual);
0714:
0715: assertTrue("The EJBObejcts are not identical", expected
0716: .isIdentical(actual));
0717: } catch (Exception e) {
0718: fail("Received Exception " + e.getClass() + " : "
0719: + e.getMessage());
0720: }
0721: }
0722:
0723: public void test41_returnEJBObject2() {
0724: try {
0725: EncCmpObject actual = (EncCmpObject) javax.rmi.PortableRemoteObject
0726: .narrow(ejbObject.returnEJBObject(),
0727: EncCmpObject.class);
0728: assertNotNull("The EJBObject returned is null", actual);
0729:
0730: } catch (Exception e) {
0731: fail("Received Exception " + e.getClass() + " : "
0732: + e.getMessage());
0733: }
0734: }
0735:
0736: public void test42_returnNestedEJBObject() {
0737: try {
0738: Object obj = initialContext
0739: .lookup("client/tests/entity/cmp/EncBean");
0740: EncCmpHome home = (EncCmpHome) javax.rmi.PortableRemoteObject
0741: .narrow(obj, EncCmpHome.class);
0742: assertNotNull("The EJBHome returned from JNDI is null",
0743: home);
0744:
0745: EncCmpObject expected = home.create("test_42 CmpBean");
0746: assertNotNull("The EJBObject created is null", expected);
0747:
0748: ObjectGraph graph = ejbObject
0749: .returnObjectGraph(new ObjectGraph(expected));
0750: assertNotNull("The ObjectGraph is null", graph);
0751:
0752: EncCmpObject actual = (EncCmpObject) javax.rmi.PortableRemoteObject
0753: .narrow(graph.getObject(), EncCmpObject.class);
0754: assertNotNull("The EJBObject returned is null", actual);
0755:
0756: assertTrue("The EJBObejcts are not identical", expected
0757: .isIdentical(actual));
0758: } catch (Exception e) {
0759: fail("Received Exception " + e.getClass() + " : "
0760: + e.getMessage());
0761: }
0762: }
0763:
0764: public void test43_returnNestedEJBObject2() {
0765: try {
0766: ObjectGraph graph = ejbObject.returnNestedEJBObject();
0767: assertNotNull("The ObjectGraph is null", graph);
0768:
0769: EncCmpObject actual = (EncCmpObject) javax.rmi.PortableRemoteObject
0770: .narrow(graph.getObject(), EncCmpObject.class);
0771: assertNotNull("The EJBHome returned is null", actual);
0772: } catch (Exception e) {
0773: fail("Received Exception " + e.getClass() + " : "
0774: + e.getMessage());
0775: }
0776: }
0777:
0778: public void test44_returnEJBObjectArray() {
0779: try {
0780: Object obj = initialContext
0781: .lookup("client/tests/entity/cmp/EncBean");
0782: EncCmpHome home = (EncCmpHome) javax.rmi.PortableRemoteObject
0783: .narrow(obj, EncCmpHome.class);
0784: assertNotNull("The EJBHome returned from JNDI is null",
0785: home);
0786:
0787: EncCmpObject expected[] = new EncCmpObject[3];
0788: for (int i = 0; i < expected.length; i++) {
0789: expected[i] = home.create("test_44 CmpBean");
0790: assertNotNull("The EJBObject created is null",
0791: expected[i]);
0792: }
0793:
0794: EJBObject[] actual = ejbObject
0795: .returnEJBObjectArray(expected);
0796: assertNotNull("The EJBObject array returned is null",
0797: actual);
0798: assertEquals(expected.length, actual.length);
0799:
0800: for (int i = 0; i < actual.length; i++) {
0801: assertTrue("The EJBObejcts are not identical",
0802: expected[i].isIdentical(actual[i]));
0803: }
0804:
0805: } catch (Exception e) {
0806: fail("Received Exception " + e.getClass() + " : "
0807: + e.getMessage());
0808: }
0809: }
0810:
0811: /*-------------------------------------------------*/
0812: /* EJBMetaData */
0813: /*-------------------------------------------------*/
0814:
0815: public void test45_returnEJBMetaData() {
0816: try {
0817: Object obj = initialContext
0818: .lookup("client/tests/entity/cmp/EncBean");
0819: EncCmpHome home = (EncCmpHome) javax.rmi.PortableRemoteObject
0820: .narrow(obj, EncCmpHome.class);
0821: assertNotNull("The EJBHome returned from JNDI is null",
0822: home);
0823:
0824: EJBMetaData expected = home.getEJBMetaData();
0825: assertNotNull("The EJBMetaData returned is null", expected);
0826:
0827: EJBMetaData actual = ejbObject.returnEJBMetaData(expected);
0828: assertNotNull("The EJBMetaData returned is null", actual);
0829: assertEquals(expected.getHomeInterfaceClass(), actual
0830: .getHomeInterfaceClass());
0831: assertEquals(expected.getRemoteInterfaceClass(), actual
0832: .getRemoteInterfaceClass());
0833: } catch (Exception e) {
0834: fail("Received Exception " + e.getClass() + " : "
0835: + e.getMessage());
0836: }
0837: }
0838:
0839: public void test46_returnEJBMetaData() {
0840: try {
0841: EJBMetaData actual = ejbObject.returnEJBMetaData();
0842: assertNotNull("The EJBMetaData returned is null", actual);
0843: assertEquals(actual.getHomeInterfaceClass(), actual
0844: .getHomeInterfaceClass());
0845: assertEquals(actual.getRemoteInterfaceClass(), actual
0846: .getRemoteInterfaceClass());
0847: } catch (Exception e) {
0848: fail("Received Exception " + e.getClass() + " : "
0849: + e.getMessage());
0850: }
0851: }
0852:
0853: public void test47_returnNestedEJBMetaData() {
0854: try {
0855: Object obj = initialContext
0856: .lookup("client/tests/entity/cmp/EncBean");
0857: EncCmpHome home = (EncCmpHome) javax.rmi.PortableRemoteObject
0858: .narrow(obj, EncCmpHome.class);
0859: assertNotNull("The EJBHome returned from JNDI is null",
0860: home);
0861:
0862: EJBMetaData expected = home.getEJBMetaData();
0863: assertNotNull("The EJBMetaData returned is null", expected);
0864:
0865: ObjectGraph graph = ejbObject
0866: .returnObjectGraph(new ObjectGraph(expected));
0867: assertNotNull("The ObjectGraph is null", graph);
0868:
0869: EJBMetaData actual = (EJBMetaData) graph.getObject();
0870: assertNotNull("The EJBMetaData returned is null", actual);
0871: assertEquals(expected.getHomeInterfaceClass(), actual
0872: .getHomeInterfaceClass());
0873: assertEquals(expected.getRemoteInterfaceClass(), actual
0874: .getRemoteInterfaceClass());
0875: } catch (Exception e) {
0876: fail("Received Exception " + e.getClass() + " : "
0877: + e.getMessage());
0878: }
0879: }
0880:
0881: public void test48_returnNestedEJBMetaData2() {
0882: try {
0883: ObjectGraph graph = ejbObject.returnNestedEJBMetaData();
0884: assertNotNull("The ObjectGraph is null", graph);
0885:
0886: EJBMetaData actual = (EJBMetaData) graph.getObject();
0887: assertNotNull("The EJBMetaData returned is null", actual);
0888: assertNotNull(
0889: "The home interface class of the EJBMetaData is null",
0890: actual.getHomeInterfaceClass());
0891: assertNotNull(
0892: "The remote interface class of the EJBMetaData is null",
0893: actual.getRemoteInterfaceClass());
0894: } catch (Exception e) {
0895: fail("Received Exception " + e.getClass() + " : "
0896: + e.getMessage());
0897: }
0898: }
0899:
0900: public void test49_returnEJBMetaDataArray() {
0901: try {
0902:
0903: Object obj = initialContext
0904: .lookup("client/tests/entity/cmp/EncBean");
0905: EncCmpHome home = (EncCmpHome) javax.rmi.PortableRemoteObject
0906: .narrow(obj, EncCmpHome.class);
0907: assertNotNull("The EJBHome returned from JNDI is null",
0908: home);
0909:
0910: EJBMetaData expected[] = new EJBMetaData[3];
0911: for (int i = 0; i < expected.length; i++) {
0912: expected[i] = home.getEJBMetaData();
0913: assertNotNull("The EJBMetaData returned is null",
0914: expected[i]);
0915: }
0916:
0917: EJBMetaData[] actual = (EJBMetaData[]) ejbObject
0918: .returnEJBMetaDataArray(expected);
0919: assertNotNull("The EJBMetaData array returned is null",
0920: actual);
0921: assertEquals(expected.length, actual.length);
0922:
0923: for (int i = 0; i < actual.length; i++) {
0924: assertNotNull("The EJBMetaData returned is null",
0925: actual[i]);
0926: assertEquals(expected[i].getHomeInterfaceClass(),
0927: actual[i].getHomeInterfaceClass());
0928: assertEquals(expected[i].getRemoteInterfaceClass(),
0929: actual[i].getRemoteInterfaceClass());
0930: }
0931: } catch (Exception e) {
0932: fail("Received Exception " + e.getClass() + " : "
0933: + e.getMessage());
0934: }
0935: }
0936:
0937: /*-------------------------------------------------*/
0938: /* Handle */
0939: /*-------------------------------------------------*/
0940:
0941: public void test50_returnHandle() {
0942: try {
0943: Object obj = initialContext
0944: .lookup("client/tests/entity/cmp/EncBean");
0945: EncCmpHome home = (EncCmpHome) javax.rmi.PortableRemoteObject
0946: .narrow(obj, EncCmpHome.class);
0947: assertNotNull("The EJBHome returned from JNDI is null",
0948: home);
0949:
0950: EncCmpObject object = home.create("test_50 CmpBean");
0951: assertNotNull("The EJBObject created is null", object);
0952:
0953: Handle expected = object.getHandle();
0954: assertNotNull("The EJBObject Handle returned is null",
0955: expected);
0956: assertNotNull("The EJBObject in the Handle is null",
0957: expected.getEJBObject());
0958:
0959: Handle actual = ejbObject.returnHandle(expected);
0960: assertNotNull("The EJBObject Handle returned is null",
0961: actual);
0962: assertNotNull("The EJBObject in the Handle is null", actual
0963: .getEJBObject());
0964:
0965: EJBObject exp = expected.getEJBObject();
0966: EJBObject act = actual.getEJBObject();
0967:
0968: assertTrue(
0969: "The EJBObjects in the Handles are not identical",
0970: exp.isIdentical(act));
0971: } catch (Exception e) {
0972: fail("Received Exception " + e.getClass() + " : "
0973: + e.getMessage());
0974: }
0975: }
0976:
0977: public void test51_returnHandle() {
0978: try {
0979: Handle actual = ejbObject.returnHandle();
0980: assertNotNull("The EJBObject Handle returned is null",
0981: actual);
0982: assertNotNull("The EJBObject in the Handle is null", actual
0983: .getEJBObject());
0984:
0985: } catch (Exception e) {
0986: fail("Received Exception " + e.getClass() + " : "
0987: + e.getMessage());
0988: }
0989: }
0990:
0991: public void test52_returnNestedHandle() {
0992: try {
0993: Object obj = initialContext
0994: .lookup("client/tests/entity/cmp/EncBean");
0995: EncCmpHome home = (EncCmpHome) javax.rmi.PortableRemoteObject
0996: .narrow(obj, EncCmpHome.class);
0997: assertNotNull("The EJBHome returned from JNDI is null",
0998: home);
0999:
1000: EncCmpObject object = home.create("test_52 CmpBean");
1001: assertNotNull("The EJBObject created is null", object);
1002:
1003: Handle expected = object.getHandle();
1004: assertNotNull("The EJBObject Handle returned is null",
1005: expected);
1006: assertNotNull("The EJBObject in the Handle is null",
1007: expected.getEJBObject());
1008:
1009: ObjectGraph graph = ejbObject
1010: .returnObjectGraph(new ObjectGraph(expected));
1011: assertNotNull("The ObjectGraph is null", graph);
1012:
1013: Handle actual = (Handle) graph.getObject();
1014: assertNotNull("The EJBObject Handle returned is null",
1015: actual);
1016: assertNotNull("The EJBObject in the Handle is null", actual
1017: .getEJBObject());
1018:
1019: EJBObject exp = expected.getEJBObject();
1020: EJBObject act = actual.getEJBObject();
1021:
1022: assertTrue(
1023: "The EJBObjects in the Handles are not identical",
1024: exp.isIdentical(act));
1025:
1026: } catch (Exception e) {
1027: fail("Received Exception " + e.getClass() + " : "
1028: + e.getMessage());
1029: }
1030: }
1031:
1032: public void test53_returnNestedHandle2() {
1033: try {
1034: ObjectGraph graph = ejbObject.returnNestedHandle();
1035: assertNotNull("The ObjectGraph is null", graph);
1036:
1037: Handle actual = (Handle) graph.getObject();
1038: assertNotNull("The EJBObject Handle returned is null",
1039: actual);
1040: assertNotNull("The EJBObject in the Handle is null", actual
1041: .getEJBObject());
1042: } catch (Exception e) {
1043: fail("Received Exception " + e.getClass() + " : "
1044: + e.getMessage());
1045: }
1046: }
1047:
1048: public void test54_returnHandleArray() {
1049: try {
1050: Object obj = initialContext
1051: .lookup("client/tests/entity/cmp/EncBean");
1052: EncCmpHome home = (EncCmpHome) javax.rmi.PortableRemoteObject
1053: .narrow(obj, EncCmpHome.class);
1054: assertNotNull("The EJBHome returned from JNDI is null",
1055: home);
1056:
1057: EncCmpObject object = home.create("test_54 CmpBean");
1058: assertNotNull("The EJBObject created is null", object);
1059:
1060: Handle expected[] = new Handle[3];
1061: for (int i = 0; i < expected.length; i++) {
1062: expected[i] = object.getHandle();
1063: assertNotNull("The EJBObject Handle returned is null",
1064: expected[i]);
1065: }
1066:
1067: Handle[] actual = (Handle[]) ejbObject
1068: .returnHandleArray(expected);
1069: assertNotNull("The Handle array returned is null", actual);
1070: assertEquals(expected.length, actual.length);
1071:
1072: for (int i = 0; i < expected.length; i++) {
1073: assertNotNull("The EJBObject Handle returned is null",
1074: actual[i]);
1075: assertNotNull("The EJBObject in the Handle is null",
1076: actual[i].getEJBObject());
1077: assertTrue(
1078: "The EJBObjects in the Handles are not equal",
1079: expected[i].getEJBObject().isIdentical(
1080: actual[i].getEJBObject()));
1081: }
1082:
1083: } catch (Exception e) {
1084: fail("Received Exception " + e.getClass() + " : "
1085: + e.getMessage());
1086: }
1087: }
1088:
1089: /*-------------------------------------------------*/
1090: /* Foo */
1091: /*-------------------------------------------------*/
1092:
1093: public void test55_returnObjectGraph() {
1094: }
1095:
1096: public void test56_returnObjectGraphArray() {
1097: }
1098: }
|