001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.openejb.test.stateless;
017:
018: import org.apache.openejb.test.entity.bmp.EncBmpHome;
019: import org.apache.openejb.test.entity.bmp.EncBmpObject;
020: import org.apache.openejb.test.entity.cmp.EncCmpHome;
021: import org.apache.openejb.test.entity.cmp.EncCmpObject;
022: import org.apache.openejb.test.stateful.EncStatefulHome;
023: import org.apache.openejb.test.stateful.EncStatefulObject;
024:
025: /**
026: *
027: * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
028: */
029: public class MiscEjbTests extends BasicStatelessTestClient {
030:
031: public MiscEjbTests() {
032: super ("EJBObject.");
033: }
034:
035: protected void setUp() throws Exception {
036: super .setUp();
037: Object obj = initialContext
038: .lookup("client/tests/stateless/BasicStatelessHome");
039: ejbHome = (BasicStatelessHome) javax.rmi.PortableRemoteObject
040: .narrow(obj, BasicStatelessHome.class);
041: ejbObject = ejbHome.createObject();
042: }
043:
044: protected void tearDown() throws Exception {
045: try {
046: //ejbObject.remove();
047: } catch (Exception e) {
048: throw e;
049: } finally {
050: super .tearDown();
051: }
052: }
053:
054: //===============================
055: // Test ejb object methods
056: //
057: public void test01_isIdentical_stateless() {
058: try {
059: String jndiName = "client/tests/stateless/EncBean";
060: EncStatelessHome ejbHome2 = null;
061: EncStatelessObject ejbObject2 = null;
062:
063: Object obj = initialContext.lookup(jndiName);
064: ejbHome2 = (EncStatelessHome) javax.rmi.PortableRemoteObject
065: .narrow(obj, EncStatelessHome.class);
066: ejbObject2 = ejbHome2.create();
067:
068: //System.out.println("_______________________________________________________");
069: //System.out.println(" ejb1 "+ejbObject);
070: //System.out.println(" ejb2 "+ejbObject2);
071: assertTrue("The EJBObjects should not be identical",
072: !ejbObject.isIdentical(ejbObject2));
073: //System.out.println("-------------------------------------------------------");
074: } catch (Exception e) {
075: //System.out.println("-------------------------------------------------------");
076: fail("Received Exception " + e.getClass() + " : "
077: + e.getMessage());
078: }
079: }
080:
081: public void test02_isIdentical_stateful() {
082: try {
083: String jndiName = "client/tests/stateful/EncBean";
084: EncStatefulHome ejbHome2 = null;
085: EncStatefulObject ejbObject2 = null;
086:
087: Object obj = initialContext.lookup(jndiName);
088: ejbHome2 = (EncStatefulHome) javax.rmi.PortableRemoteObject
089: .narrow(obj, EncStatefulHome.class);
090: ejbObject2 = ejbHome2.create("isIdentical test");
091:
092: //System.out.println("_______________________________________________________");
093: //System.out.println(" ejb1 "+ejbObject);
094: //System.out.println(" ejb2 "+ejbObject2);
095: assertTrue("The EJBObjects should not be identical",
096: !ejbObject.isIdentical(ejbObject2));
097: //System.out.println("-------------------------------------------------------");
098: } catch (Exception e) {
099: //System.out.println("-------------------------------------------------------");
100: fail("Received Exception " + e.getClass() + " : "
101: + e.getMessage());
102: }
103: }
104:
105: public void test03_isIdentical_bmp() {
106: try {
107: String jndiName = "client/tests/entity/bmp/EncBean";
108: EncBmpHome ejbHome2 = null;
109: EncBmpObject ejbObject2 = null;
110:
111: Object obj = initialContext.lookup(jndiName);
112: ejbHome2 = (EncBmpHome) javax.rmi.PortableRemoteObject
113: .narrow(obj, EncBmpHome.class);
114: ejbObject2 = ejbHome2.create("isIdentical test");
115:
116: //System.out.println("_______________________________________________________");
117: assertTrue("The EJBObjects should not be identical",
118: !ejbObject.isIdentical(ejbObject2));
119: //System.out.println(" ejb1 "+ejbObject);
120: //System.out.println(" ejb2 "+ejbObject2);
121: //System.out.println("-------------------------------------------------------");
122: } catch (Exception e) {
123: fail("Received Exception " + e.getClass() + " : "
124: + e.getMessage());
125: }
126: }
127:
128: /**
129: * DMB: Calling this now causes an error as the "entity" table doesn't exist yet
130: */
131: public void _test04_isIdentical_cmp() {
132: try {
133: String jndiName = "client/tests/entity/cmp/EncBean";
134: EncCmpHome ejbHome2 = null;
135: EncCmpObject ejbObject2 = null;
136:
137: Object obj = initialContext.lookup(jndiName);
138: ejbHome2 = (EncCmpHome) javax.rmi.PortableRemoteObject
139: .narrow(obj, EncCmpHome.class);
140: ejbObject2 = ejbHome2.create("isIdentical test");
141:
142: //System.out.println("_______________________________________________________");
143: //System.out.println(" ejb1 "+ejbObject);
144: //System.out.println(" ejb2 "+ejbObject2);
145: assertTrue("The EJBObjects should not be identical",
146: !ejbObject.isIdentical(ejbObject2));
147: //System.out.println("-------------------------------------------------------");
148: } catch (Exception e) {
149: fail("Received Exception " + e.getClass() + " : "
150: + e.getMessage());
151: }
152: }
153:
154: //
155: // Test ejb object methods
156: //===============================
157: }
|