01: package com.mockrunner.test.ejb;
02:
03: import javax.naming.Context;
04: import javax.naming.InitialContext;
05: import javax.naming.NameNotFoundException;
06:
07: import org.mockejb.jndi.MockContextFactory;
08:
09: import com.mockrunner.ejb.Configuration;
10: import com.mockrunner.ejb.EJBTestCaseAdapter;
11: import com.mockrunner.mock.ejb.EJBMockObjectFactory;
12:
13: public class EJBTestCaseAdapterTest extends EJBTestCaseAdapter {
14: protected void setUp() throws Exception {
15: Configuration configuration = new Configuration();
16: configuration.setBindMockUserTransactionToJNDI(false);
17: setEJBMockObjectFactory(new EJBMockObjectFactory(configuration));
18: super .setUp();
19: }
20:
21: public void testTearDownRevertCalled() throws Exception {
22: assertEquals(MockContextFactory.class.getName(), System
23: .getProperty(Context.INITIAL_CONTEXT_FACTORY));
24: super .tearDown();
25: assertNull(System.getProperty(Context.INITIAL_CONTEXT_FACTORY));
26: }
27:
28: public void testUserTransactionNotBound() throws Exception {
29: InitialContext context = new InitialContext();
30: try {
31: context.lookup("javax.transaction.UserTransaction");
32: fail();
33: } catch (NameNotFoundException exc) {
34: //should throw exception
35: }
36: try {
37: context.lookup("java:comp/UserTransaction");
38: fail();
39: } catch (NameNotFoundException exc) {
40: //should throw exception
41: }
42: }
43: }
|