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.stateful;
17:
18: import java.rmi.NoSuchObjectException;
19:
20: import javax.ejb.EJBObject;
21:
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: * @author <a href="mailto:manu.t.george@gmail.com">Manu George</a>
26: */
27: public class StatefulPojoHandleTests extends BasicStatefulTestClient {
28:
29: public StatefulPojoHandleTests() {
30: super ("PojoHandle.");
31: }
32:
33: protected void setUp() throws Exception {
34: super .setUp();
35: Object obj = initialContext
36: .lookup("client/tests/stateful/BasicStatefulPojoHome");
37: ejbHome = (BasicStatefulHome) javax.rmi.PortableRemoteObject
38: .narrow(obj, BasicStatefulHome.class);
39: ejbObject = ejbHome
40: .createObject("StatefulPojoHandleTests Bean");
41: ejbHandle = ejbObject.getHandle();
42: }
43:
44: //=================================
45: // Test handle methods
46: //
47: public void test01_getEJBObject() {
48:
49: try {
50: EJBObject object = ejbHandle.getEJBObject();
51: assertNotNull("The EJBObject is null", object);
52: assertTrue("EJBObjects are not identical", object
53: .isIdentical(ejbObject));
54: } catch (Exception e) {
55: fail("Received Exception " + e.getClass() + " : "
56: + e.getMessage());
57: }
58: }
59:
60: /**
61: * This remove method of the EJBHome is placed here as it
62: * is more a test on the handle then on the remove method
63: * itself.
64: */
65: public void test02_EJBHome_remove() {
66: try {
67: ejbHome.remove(ejbHandle);
68: try {
69: ejbObject.businessMethod("Should throw an exception");
70: assertTrue(
71: "Calling business method after removing the EJBObject does not throw an exception",
72: false);
73: } catch (NoSuchObjectException e) {
74: assertTrue(true);
75: return;
76: }
77: } catch (Exception e) {
78: fail("Received Exception " + e.getClass() + " : "
79: + e.getMessage());
80: }
81: }
82: //
83: // Test handle methods
84: //=================================
85:
86: }
|