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