use of org.apache.openejb.config.ConfigurationFactory in project tomee by apache.
the class OpenejbLookupTest method testPlainInitialContext.
public void testPlainInitialContext() throws Exception {
final Assembler assembler = new Assembler();
final ConfigurationFactory config = new ConfigurationFactory();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(FooBean.class));
assembler.createApplication(config.configureApplication(ejbJar));
final Context context = new InitialContext();
assertOpenejbUrlLookups(context);
}
use of org.apache.openejb.config.ConfigurationFactory in project tomee by apache.
the class QuartzMdbContainerTest method test.
public void test() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
// Setup the descriptor information
CronBean.lifecycle.clear();
final AppModule app = new AppModule(this.getClass().getClassLoader(), "testapp");
final Connector connector = new Connector("email-ra");
final ResourceAdapter adapter = new ResourceAdapter(QuartzResourceAdapter.class);
connector.setResourceAdapter(adapter);
final InboundResourceadapter inbound = adapter.setInboundResourceAdapter(new InboundResourceadapter());
final MessageAdapter messageAdapter = inbound.setMessageAdapter(new MessageAdapter());
final MessageListener listener = messageAdapter.addMessageListener(new MessageListener(Job.class, JobSpec.class));
listener.getActivationSpec().addRequiredConfigProperty("cronExpression");
app.getConnectorModules().add(new ConnectorModule(connector));
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new MessageDrivenBean(CronBean.class));
app.getEjbModules().add(new EjbModule(ejbJar));
final AppInfo appInfo = config.configureApplication(app);
assembler.createApplication(appInfo);
assertTrue(CronBean.latch.await(5, TimeUnit.SECONDS));
final Stack<Lifecycle> lifecycle = CronBean.lifecycle;
final List expected = Arrays.asList(Lifecycle.values());
Assert.assertEquals(expected.get(0), lifecycle.get(0));
Assert.assertEquals(expected.get(1), lifecycle.get(1));
}
use of org.apache.openejb.config.ConfigurationFactory in project tomee by apache.
the class DependsOnTest method testCircuit.
public void testCircuit() 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 EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new SingletonBean(One.class));
ejbJar.addEnterpriseBean(new SingletonBean(Two.class));
ejbJar.addEnterpriseBean(new SingletonBean(Three.class));
ejbJar.addEnterpriseBean(new SingletonBean(Four.class)).setDependsOn("One");
try {
config.configureApplication(ejbJar);
fail("Validation should have found a circular reference");
} catch (final ValidationFailedException e) {
final ValidationFailure[] failures = e.getFailures();
assertEquals(1, failures.length);
assertEquals("dependsOn.circuit", failures[0].getMessageKey());
}
}
use of org.apache.openejb.config.ConfigurationFactory in project tomee by apache.
the class DependsOnTest method testNoStartUp.
public void testNoStartUp() 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));
actualConstruct.clear();
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new SingletonBean(Two.class)).setInitOnStartup(false);
ejbJar.addEnterpriseBean(new SingletonBean(One.class));
ejbJar.addEnterpriseBean(new SingletonBean(Four.class)).setInitOnStartup(false);
ejbJar.addEnterpriseBean(new SingletonBean(Three.class)).setInitOnStartup(false);
// 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.config.ConfigurationFactory 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);
}
Aggregations