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