01: package com.mockrunner.test.ejb;
02:
03: import java.rmi.RemoteException;
04: import java.util.Hashtable;
05:
06: import javax.ejb.CreateException;
07: import javax.ejb.EJBException;
08: import javax.ejb.SessionBean;
09: import javax.ejb.SessionContext;
10: import javax.naming.Context;
11: import javax.naming.InitialContext;
12:
13: import com.mockrunner.ejb.Configuration;
14: import com.mockrunner.ejb.EJBTestCaseAdapter;
15: import com.mockrunner.mock.ejb.EJBMockObjectFactory;
16: import com.mockrunner.test.ejb.TestJNDI.TestContextFactory;
17:
18: public class EJBTestCaseAdapterExternalJNDITest extends
19: EJBTestCaseAdapter {
20: protected void setUp() throws Exception {
21: Hashtable env = new Hashtable();
22: env.put(Context.INITIAL_CONTEXT_FACTORY,
23: TestContextFactory.class.getName());
24: InitialContext context = new InitialContext(env);
25: Configuration configuration = new Configuration();
26: configuration.setContext(context);
27: setEJBMockObjectFactory(new EJBMockObjectFactory(configuration));
28: super .setUp();
29: }
30:
31: public void testLookupAndBindToContext() {
32: assertEquals("TestObject", lookup("testName"));
33: bindToContext("testName", "testValue");
34: assertEquals("TestObject", lookup("testName"));
35: deploySessionBean("testName", TestSessionBean.class);
36: assertEquals("TestObject", lookup("testName"));
37: }
38:
39: public static class TestSessionBean implements SessionBean {
40: public void test() {
41:
42: }
43:
44: public void ejbCreate() throws CreateException {
45:
46: }
47:
48: public void ejbCreate(Integer testInt) throws CreateException {
49:
50: }
51:
52: public void ejbCreate(int testInt, Boolean testBoolean)
53: throws CreateException {
54:
55: }
56:
57: public void ejbCreateWithPostfix(int testInt,
58: Boolean testBoolean) throws CreateException {
59:
60: }
61:
62: public void ejbActivate() throws EJBException, RemoteException {
63:
64: }
65:
66: public void ejbPassivate() throws EJBException, RemoteException {
67:
68: }
69:
70: public void ejbRemove() throws EJBException, RemoteException {
71:
72: }
73:
74: public void setSessionContext(SessionContext context)
75: throws EJBException, RemoteException {
76:
77: }
78: }
79:
80: public static interface TestSession extends javax.ejb.EJBObject {
81: public void test(boolean setRollbackOnly)
82: throws RemoteException;
83: }
84:
85: public static interface TestSessionHome extends javax.ejb.EJBHome {
86: public TestSession create() throws CreateException,
87: RemoteException;
88: }
89: }
|