01: /*
02: * JFox - The most lightweight Java EE Application Server!
03: * more details please visit http://www.huihoo.org/jfox or http://www.jfox.org.cn.
04: *
05: * JFox is licenced and re-distributable under GNU LGPL.
06: */
07: package jfox.test.ejb3;
08:
09: import java.io.File;
10: import javax.naming.Context;
11: import javax.naming.InitialContext;
12: import javax.ejb.Handle;
13: import javax.ejb.EJBObject;
14:
15: import org.jfox.framework.Framework;
16: import org.jfox.framework.component.Module;
17: import org.jfox.ejb3.EJBContainer;
18: import org.junit.BeforeClass;
19: import org.junit.AfterClass;
20: import org.junit.Test;
21: import org.junit.Assert;
22: import jfox.test.ejbcomponent.bo.AccountBO;
23:
24: /**
25: * @author <a href="mailto:jfox.young@gmail.com">Young Yang</a>
26: */
27: public class EJB3ContainerTest {
28: static Framework framework;
29:
30: @BeforeClass
31: public static void setUp() throws Exception {
32: // PlaceholderUtils.loadGlobalProperty(Constants.GLOBAL_PROPERTIES);
33: framework = new Framework();
34: Module petstoreModule = framework.loadModule(new File(
35: "MODULES/Petstore"));
36: framework.start();
37: }
38:
39: @AfterClass
40: public static void tearDown() throws Exception {
41: framework.stop();
42: }
43:
44: @Test
45: public void testContainer() throws Exception {
46: EJBContainer container = (EJBContainer) framework
47: .getSystemModule().getComponent("EJB3Container");
48: }
49:
50: @Test
51: public void testEJB() throws Exception {
52: Context ctx = new InitialContext();
53: AccountBO accountMgr = (AccountBO) ctx.lookup("AccountBOImpl");
54: System.out.println("!!!!! hashCode: " + accountMgr.hashCode());
55: System.out.println("!!!!! Account name: "
56: + accountMgr.getAccountName());
57: }
58:
59: @Test
60: public void testHandle() throws Exception {
61: Context ctx = new InitialContext();
62: AccountBO accountMgr = (AccountBO) ctx.lookup("AccountBOImpl");
63: Handle handler = ((EJBObject) accountMgr).getHandle();
64: EJBObject ejbObject = handler.getEJBObject();
65: System.out.println("!!!!!!"
66: + ((AccountBO) ejbObject).getAccountName());
67: Assert
68: .assertTrue(ejbObject
69: .isIdentical((EJBObject) accountMgr));
70: Assert.assertEquals(accountMgr, ejbObject);
71: }
72:
73: public static void main(String[] args) {
74:
75: }
76: }
|