1 7 package jfox.test.ejb3; 8 9 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 27 public class EJB3ContainerTest { 28 static Framework framework; 29 @BeforeClass 30 public static void setUp() throws Exception { 31 framework = new Framework(); 33 Module petstoreModule = framework.loadModule(new File ("MODULES/Petstore")); 34 framework.start(); 35 } 36 37 @AfterClass 38 public static void tearDown() throws Exception { 39 framework.stop(); 40 } 41 42 @Test 43 public void testContainer() throws Exception { 44 EJBContainer container = (EJBContainer)framework.getSystemModule().getComponent("EJB3Container"); 45 } 46 47 @Test 48 public void testEJB() throws Exception { 49 Context ctx = new InitialContext (); 50 AccountBO accountMgr = (AccountBO)ctx.lookup("AccountBOImpl"); 51 System.out.println("!!!!! hashCode: " + accountMgr.hashCode()); 52 System.out.println("!!!!! Account name: " + accountMgr.getAccountName()); 53 } 54 55 @Test 56 public void testHandle() throws Exception { 57 Context ctx = new InitialContext (); 58 AccountBO accountMgr = (AccountBO)ctx.lookup("AccountBOImpl"); 59 Handle handler = ((EJBObject )accountMgr).getHandle(); 60 EJBObject ejbObject = handler.getEJBObject(); 61 System.out.println("!!!!!!" + ((AccountBO)ejbObject).getAccountName()); 62 Assert.assertTrue(ejbObject.isIdentical((EJBObject )accountMgr)); 63 Assert.assertEquals(accountMgr,ejbObject); 64 } 65 66 public static void main(String [] args) { 67 68 } 69 } 70 | Popular Tags |