use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class DependsOnTest method test.
public void test() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
final Assembler assembler = new Assembler();
final ConfigurationFactory config = new ConfigurationFactory();
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));
final StatelessSessionContainerInfo statelessContainer = config.configureService(StatelessSessionContainerInfo.class);
statelessContainer.properties.setProperty("MinSize", "1");
statelessContainer.properties.setProperty("MaxSize", "1");
assembler.createContainer(statelessContainer);
actualConstruct.clear();
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(Two.class));
ejbJar.addEnterpriseBean(new SingletonBean(One.class));
ejbJar.addEnterpriseBean(new SingletonBean(Four.class));
ejbJar.addEnterpriseBean(new StatelessBean(Three.class));
// startup and trigger @PostConstruct
assembler.createApplication(config.configureApplication(ejbJar));
assertEquals(expected(four, three, two, one), actualConstruct);
actualDestroy.clear();
// startup and trigger @PreDestroy
for (final AppInfo appInfo : assembler.getDeployedApplications()) {
assembler.destroyApplication(appInfo.path);
}
assertEquals(expected(one, two, three, four), actualDestroy);
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class CallbackOverridesTest method setUp.
@Override
protected void setUp() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatefulBean(ChildBean.class));
assembler.createApplication(config.configureApplication(ejbJar));
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class StatefulBeanManagedTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatefulBean(MyBean.class));
assembler.createApplication(config.configureApplication(ejbJar));
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class StatefulConcurrencyTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.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));
final StatefulSessionContainerInfo statefulContainerInfo = config.configureService(StatefulSessionContainerInfo.class);
assembler.createContainer(statefulContainerInfo);
final EjbJar ejbJar = new EjbJar();
final StatefulBean bean1 = new StatefulBean(MyLocalBeanImpl.class);
final Timeout timeout1 = new Timeout();
timeout1.setTimeout(1000);
timeout1.setUnit(TimeUnit.MILLISECONDS);
final ConcurrentMethod method1 = new ConcurrentMethod();
method1.setMethod(new NamedMethod("*"));
method1.setAccessTimeout(timeout1);
bean1.getConcurrentMethod().add(method1);
final StatefulBean bean2 = new StatefulBean("BeanNegative", MyLocalBeanImpl.class);
final Timeout timeout2 = new Timeout();
timeout2.setTimeout(-1);
timeout2.setUnit(TimeUnit.MILLISECONDS);
final ConcurrentMethod method2 = new ConcurrentMethod();
method2.setMethod(new NamedMethod("*"));
method2.setAccessTimeout(timeout2);
bean2.getConcurrentMethod().add(method2);
ejbJar.addEnterpriseBean(bean1);
ejbJar.addEnterpriseBean(bean2);
assembler.createApplication(config.configureApplication(ejbJar));
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class StatefulContainerTest method setUp.
protected void setUp() throws Exception {
super.setUp();
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.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 StatefulSessionContainerInfo statefulContainerInfo = config.configureService(StatefulSessionContainerInfo.class);
statefulContainerInfo.properties.setProperty("PoolSize", "0");
statefulContainerInfo.properties.setProperty("BulkPassivate", "1");
statefulContainerInfo.properties.setProperty("Frequency", "0");
assembler.createContainer(statefulContainerInfo);
// Setup the descriptor information
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatefulBean(WidgetBean.class));
assembler.createApplication(config.configureApplication(ejbJar));
WidgetBean.lifecycle.clear();
expectedLifecycle = Arrays.asList(Lifecycle.values());
inTxExpectedLifecycle = new ArrayList<Lifecycle>();
for (final Lifecycle lifecycle : Lifecycle.values()) {
if (!lifecycle.name().startsWith("PRE_PASSIVATE") && !lifecycle.name().startsWith("POST_ACTIVATE")) {
inTxExpectedLifecycle.add(lifecycle);
}
}
}
Aggregations