01: /**
02: *
03: * Licensed to the Apache Software Foundation (ASF) under one or more
04: * contributor license agreements. See the NOTICE file distributed with
05: * this work for additional information regarding copyright ownership.
06: * The ASF licenses this file to You under the Apache License, Version 2.0
07: * (the "License"); you may not use this file except in compliance with
08: * the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */package org.apache.openejb.test.entity.cmp2;
18:
19: import org.apache.openejb.test.entity.cmp.UnknownCmpHome;
20:
21: import javax.ejb.EJBHome;
22: import javax.ejb.HomeHandle;
23: import java.rmi.MarshalledObject;
24: import java.io.ByteArrayOutputStream;
25: import java.io.ObjectOutputStream;
26: import java.io.ByteArrayInputStream;
27: import java.io.ObjectInputStream;
28:
29: /**
30: * [6] Should be run as the sixth test suite of the BasicCmpTestClients
31: */
32: public class Unknown2HomeHandleTests extends UnknownCmp2TestClient {
33:
34: public Unknown2HomeHandleTests() {
35: super ("HomeHandle.");
36: }
37:
38: protected void setUp() throws Exception {
39: super .setUp();
40: Object obj = initialContext
41: .lookup("client/tests/entity/cmp2/UnknownCmpHome");
42: ejbHome = (UnknownCmpHome) javax.rmi.PortableRemoteObject
43: .narrow(obj, UnknownCmpHome.class);
44: ejbHomeHandle = ejbHome.getHomeHandle();
45: }
46:
47: //=================================
48: // Test home handle methods
49: //
50: public void test01_getEJBHome() {
51: try {
52: EJBHome home = ejbHomeHandle.getEJBHome();
53: assertNotNull("The EJBHome is null", home);
54: } catch (Exception e) {
55: fail("Received Exception " + e.getClass() + " : "
56: + e.getMessage());
57: }
58: }
59:
60: public void Xtest02_copyHandleByMarshalledObject() {
61: try {
62: MarshalledObject obj = new MarshalledObject(ejbHomeHandle);
63: HomeHandle copy = (HomeHandle) obj.get();
64:
65: assertNotNull("The HomeHandle copy is null", copy);
66: EJBHome home = copy.getEJBHome();
67: assertNotNull("The EJBHome is null", home);
68: } catch (Exception e) {
69: fail("Received Exception " + e.getClass() + " : "
70: + e.getMessage());
71: }
72: }
73:
74: public void Xtest03_copyHandleBySerialize() {
75: try {
76: ByteArrayOutputStream baos = new ByteArrayOutputStream();
77: ObjectOutputStream oos = new ObjectOutputStream(baos);
78: oos.writeObject(ejbHomeHandle);
79: oos.flush();
80: oos.close();
81: ByteArrayInputStream bais = new ByteArrayInputStream(baos
82: .toByteArray());
83: ObjectInputStream ois = new ObjectInputStream(bais);
84: HomeHandle copy = (HomeHandle) ois.readObject();
85:
86: assertNotNull("The HomeHandle copy is null", copy);
87: EJBHome home = copy.getEJBHome();
88: assertNotNull("The EJBHome is null", home);
89: } catch (Exception e) {
90: fail("Received Exception " + e.getClass() + " : "
91: + e.getMessage());
92: }
93: }
94: //
95: // Test home handle methods
96: //=================================
97:
98: }
|