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 javax.ejb.RemoveException;
19:
20: /**
21: * [3] Should be run as the third test suite of the BasicStatefulTestClients
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 StatefulPojoEjbLocalHomeTests extends
27: BasicStatefulLocalTestClient {
28:
29: public StatefulPojoEjbLocalHomeTests() {
30: super ("EJBLocalHome.");
31: }
32:
33: protected void setUp() throws Exception {
34: super .setUp();
35: ejbLocalHome = (BasicStatefulLocalHome) initialContext
36: .lookup("client/tests/stateful/BasicStatefulPojoHomeLocal");
37: }
38:
39: //===============================
40: // Test ejb home methods
41: //
42: /**
43: * ------------------------------------
44: * 5.3.2 Removing a session object
45: * A client may remove a session object using the remove() method on the javax.ejb.EJBObject
46: * interface, or the remove(Handle handle) method of the javax.ejb.EJBHome interface.
47: *
48: * Because session objects do not have primary keys that are accessible to clients, invoking the
49: * javax.ejb.EJBHome.remove(Object primaryKey) method on a session results in the
50: * javax.ejb.RemoveException.
51: *
52: * ------------------------------------
53: * 5.5 Session object identity
54: *
55: * Session objects are intended to be private resources used only by the
56: * client that created them. For this reason, session objects, from the
57: * client's perspective, appear anonymous. In contrast to entity objects,
58: * which expose their identity as a primary key, session objects hide their
59: * identity. As a result, the EJBObject.getPrimaryKey() and
60: * EJBHome.remove(Object primaryKey) methods result in a java.rmi.RemoteException
61: * if called on a session bean. If the EJBMetaData.getPrimaryKeyClass()
62: * method is invoked on a EJBMetaData object for a Session bean, the method throws
63: * the java.lang.RuntimeException.
64: * ------------------------------------
65: *
66: * Sections 5.3.2 and 5.5 conflict. 5.3.2 says to throw javax.ejb.RemoveException, 5.5 says to
67: * throw java.rmi.RemoteException.
68: *
69: * For now, we are going with java.rmi.RemoteException.
70: * =====================================================================================================
71: * TODO - MNour: Please add related sections from EJB3.0 Core contracts and requirements specification
72: * (Sections: 3.6.2.2, 3.6.3.2 and 3.6.5)
73: */
74: public void test03_removeByPrimaryKey() {
75: try {
76: ejbLocalHome.remove("primaryKey");
77: } catch (RemoveException e) {
78: assertTrue(true);
79: return;
80: } catch (Exception e) {
81: fail("Received Exception " + e.getClass()
82: + " instead of javax.ejb.RemoveException : "
83: + e.getMessage());
84: }
85: assertTrue("javax.ejb.RemoveException should have been thrown",
86: false);
87: }
88: //
89: // Test ejb home methods
90: //===============================
91: }
|