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: * @author <a href="mailto:david.blevins@visi.com">David Blevins</a>
22: * @author <a href="mailto:Richard@Monson-Haefel.com">Richard Monson-Haefel</a>
23: * @author <a href="mailto:manu.t.george@gmail.com">Manu George</a>
24: */
25: public class StatelessPojoHandleTests extends BasicStatelessTestClient {
26:
27: public StatelessPojoHandleTests() {
28: super ("PojoHandle.");
29: }
30:
31: protected void setUp() throws Exception {
32: super .setUp();
33: Object obj = initialContext
34: .lookup("client/tests/stateless/BasicStatelessPojoHome");
35: ejbHome = (BasicStatelessHome) javax.rmi.PortableRemoteObject
36: .narrow(obj, BasicStatelessHome.class);
37: ejbObject = ejbHome.createObject();
38: ejbHandle = ejbObject.getHandle();
39: }
40:
41: protected void tearDown() throws Exception {
42: super .tearDown();
43: }
44:
45: //=================================
46: // Test handle methods
47: //
48: public void test01_getEJBObject() {
49:
50: try {
51: EJBObject object = ejbHandle.getEJBObject();
52: assertNotNull("The EJBObject is null", object);
53: assertTrue("EJBObjects are not identical", object
54: .isIdentical(ejbObject));
55: } catch (Exception e) {
56: fail("Received Exception " + e.getClass() + " : "
57: + e.getMessage());
58: }
59: }
60:
61: /**
62: * <B>3.6.6 Client view of session object's life cycle</B>
63: * <p/>
64: * ....It is invalid to reference a session object that does
65: * not exist. Attempted invocations on a session object
66: * that does not exist result in java.rmi.NoSuchObjectException.
67: * </P>
68: * <p/>
69: * <p/>
70: * This remove method of the EJBHome is placed hear as it
71: * is more a test on the handle then on the remove method
72: * itself.
73: * </P>
74: */
75: public void test02_EJBHome_remove() {
76: try {
77: ejbHome.remove(ejbHandle);
78: // you can't really remove a stateless handle
79: ejbObject.businessMethod("Should not throw an exception");
80: } catch (Exception e) {
81: fail("Received Exception " + e.getClass() + " : "
82: + e.getMessage());
83: }
84: }
85: //
86: // Test handle methods
87: //=================================
88:
89: }
|