@Keys({ @Key(value = "no.home.create", count = 4), @Key(value = "unused.ejb.create", count = 2, type = KeyType.WARNING), @Key(value = "unused.ejbPostCreate", type = KeyType.WARNING), @Key("entity.no.ejb.create"), @Key(value = "session.no.ejb.create", count = 2) }) public EjbJar noCreateMethod() throws OpenEJBException { System.setProperty("openejb.validation.output.level", "VERBOSE"); EjbJar ejbJar = new EjbJar(); StatelessBean stateless = new StatelessBean(FooStateless.class); stateless.setHomeAndRemote(FooStatelessHome.class, FooStatelessRemote.class); stateless.setHomeAndLocal(FooStatelessLocalHome.class, FooStatelessLocal.class); ejbJar.addEnterpriseBean(stateless); StatefulBean stateful = new StatefulBean(FooStateful.class); stateful.setHomeAndRemote(FooStatefulHome.class, FooStatefulRemote.class); stateful.setHomeAndLocal(FooStatefulLocalHome.class, FooStatefulLocal.class); ejbJar.addEnterpriseBean(stateful); org.apache.openejb.jee.EntityBean bean = new org.apache.openejb.jee.EntityBean(MyEntity.class, PersistenceType.BEAN); bean.setLocalHome(MyLocalHome.class.getName()); bean.setLocal(MyLocal.class.getName()); ejbJar.addEnterpriseBean(bean); org.apache.openejb.jee.EntityBean bean1 = new org.apache.openejb.jee.EntityBean(YourEntity.class, PersistenceType.BEAN); bean1.setLocalHome(MyLocalHome.class.getName()); bean1.setLocal(MyLocal.class.getName()); ejbJar.addEnterpriseBean(bean1); StatelessBean bar = new StatelessBean(BarStateless.class); bar.setHomeAndRemote(BarStatelessHome.class, BarStatelessRemote.class); ejbJar.addEnterpriseBean(bar); StatefulBean bazStateful = new StatefulBean(BazStateful.class); ejbJar.addEnterpriseBean(bazStateful); return 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()); }