01: /**
02: *
03: * Licensed to the Apache Software Foundation (ASF) under one or more
04: * contributor license agreements. See the NOTICE file distributed with
05: * this work for additional information regarding copyright ownership.
06: * The ASF licenses this file to You under the Apache License, Version 2.0
07: * (the "License"); you may not use this file except in compliance with
08: * the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */package org.apache.openejb.test.entity.cmp;
18:
19: import javax.rmi.PortableRemoteObject;
20: import javax.ejb.EJBObject;
21:
22: /**
23: * [7] Should be run as the seventh test suite of the UnknownCmpTestClients
24: *
25: * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
26: * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
27: */
28: public class UnknownHandleTests extends UnknownCmpTestClient {
29:
30: public UnknownHandleTests() {
31: super ("Handle.");
32: }
33:
34: protected void setUp() throws Exception {
35: super .setUp();
36: Object obj = initialContext
37: .lookup("client/tests/entity/cmp/UnknownCmpHome");
38: ejbHome = (UnknownCmpHome) PortableRemoteObject.narrow(obj,
39: UnknownCmpHome.class);
40: ejbObject = ejbHome.createObject("Fifth Bean");
41: ejbHandle = ejbObject.getHandle();
42: }
43:
44: protected void tearDown() throws Exception {
45: if (ejbObject != null)
46: ejbObject.remove();
47: super .tearDown();
48: }
49:
50: //=================================
51: // Test handle methods
52: //
53: public void test01_getEJBObject() {
54:
55: try {
56: EJBObject object = ejbHandle.getEJBObject();
57: assertNotNull("The EJBObject is null", object);
58: // Wait until isIdentical is working.
59: //assertTrue("EJBObjects are not identical", object.isIdentical(ejbObject));
60: } catch (Exception e) {
61: fail("Received Exception " + e.getClass() + " : "
62: + e.getMessage());
63: }
64: }
65:
66: /**
67: * This remove method of the EJBHome is placed hear as it
68: * is more a test on the handle then on the remove method
69: * itself.
70: */
71: public void test02_EJBHome_remove() {
72: try {
73: ejbHome.remove(ejbHandle);
74: try {
75: ejbObject.businessMethod("Should throw an exception");
76: assertTrue(
77: "Calling business method after removing the EJBObject does not throw an exception",
78: false);
79: } catch (Exception e) {
80: assertTrue(true);
81: }
82: } catch (Exception e) {
83: fail("Received Exception " + e.getClass() + " : "
84: + e.getMessage());
85: } finally {
86: ejbObject = null;
87: }
88: }
89: //
90: // Test handle methods
91: //=================================
92:
93: }
|