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.BasicEJBTestCaseAdapter;
10: import com.mockrunner.ejb.Configuration;
11: import com.mockrunner.mock.ejb.EJBMockObjectFactory;
12:
13: public class BasicEJBTestCaseAdapterTest extends
14: BasicEJBTestCaseAdapter {
15: protected void setUp() throws Exception {
16: Configuration configuration = new Configuration();
17: configuration.setBindMockUserTransactionToJNDI(false);
18: setEJBMockObjectFactory(new EJBMockObjectFactory(configuration));
19: super .setUp();
20: }
21:
22: public void testTearDownRevertCalled() throws Exception {
23: assertEquals(MockContextFactory.class.getName(), System
24: .getProperty(Context.INITIAL_CONTEXT_FACTORY));
25: super .tearDown();
26: assertNull(System.getProperty(Context.INITIAL_CONTEXT_FACTORY));
27: }
28:
29: public void testUserTransactionNotBound() throws Exception {
30: InitialContext context = new InitialContext();
31: try {
32: context.lookup("javax.transaction.UserTransaction");
33: fail();
34: } catch (NameNotFoundException exc) {
35: //should throw exception
36: }
37: try {
38: context.lookup("java:comp/UserTransaction");
39: fail();
40: } catch (NameNotFoundException exc) {
41: //should throw exception
42: }
43: }
44: }
|