protected void setUp() throws Exception { super.setUp(); System.setProperty( javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName()); final ConfigurationFactory config = new ConfigurationFactory(); final Assembler assembler = new Assembler(); assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class)); assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class)); assembler.createSecurityService(config.configureService(SecurityServiceInfo.class)); // containers final StatelessSessionContainerInfo statelessContainerInfo = config.configureService(StatelessSessionContainerInfo.class); statelessContainerInfo.properties.setProperty("TimeOut", "10"); statelessContainerInfo.properties.setProperty("MaxSize", "0"); statelessContainerInfo.properties.setProperty("StrictPooling", "false"); assembler.createContainer(statelessContainerInfo); // Setup the descriptor information final StatelessBean bean = new StatelessBean(WidgetBean.class); bean.addBusinessLocal(Widget.class.getName()); bean.addBusinessRemote(RemoteWidget.class.getName()); final EjbJar ejbJar = new EjbJar(); ejbJar.addEnterpriseBean(bean); assembler.createApplication(config.configureApplication(ejbJar)); }
protected void setUp() throws Exception { super.setUp(); System.setProperty( javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName()); ConfigurationFactory config = new ConfigurationFactory(); Assembler assembler = new Assembler(); assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class)); assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class)); assembler.createSecurityService(config.configureService(SecurityServiceInfo.class)); // containers assembler.createContainer(config.configureService(SingletonSessionContainerInfo.class)); // Setup the descriptor information SingletonBean bean = new SingletonBean(WidgetBean.class); bean.addBusinessLocal(Widget.class.getName()); bean.addBusinessRemote(RemoteWidget.class.getName()); bean.addPostConstruct("init"); bean.addPreDestroy("destroy"); bean.setLocalBean(new Empty()); EjbJar ejbJar = new EjbJar(); ejbJar.addEnterpriseBean(bean); assembler.createApplication(config.configureApplication(ejbJar)); }
public void test() throws Exception { System.setProperty( javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName()); ConfigurationFactory config = new ConfigurationFactory(); Assembler assembler = new Assembler(); assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class)); assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class)); assembler.createSecurityService(config.configureService(SecurityServiceInfo.class)); // containers StatefulSessionContainerInfo statefulContainerInfo = config.configureService(StatefulSessionContainerInfo.class); statefulContainerInfo.properties.setProperty("PoolSize", "0"); statefulContainerInfo.properties.setProperty("BulkPassivate", "1"); statefulContainerInfo.properties.setProperty("Frequency", "0"); assembler.createContainer(statefulContainerInfo); EjbJar ejbJar = new EjbJar(); StatefulBean bean = ejbJar.addEnterpriseBean(new StatefulBean(TargetBean.class)); bean.setHomeAndRemote(TargetHome.class, Target.class); assembler.createApplication( config.configureApplication( new EjbModule( getClass().getClassLoader(), getClass().getSimpleName(), "test", ejbJar, null))); calls.clear(); InitialContext ctx = new InitialContext(); TargetHome home = (TargetHome) ctx.lookup("TargetBeanRemoteHome"); assertNotNull(home); Target target = home.create("Fuzz"); assertNotNull(target); String name = target.getName(); assertEquals("Fuzz", name); target.remove(); assertCalls(Call.values()); }