use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class DeploymentContextPropertiesTest method testModuleContextProperties.
public void testModuleContextProperties() throws Exception {
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
final EjbModule ejbModule = new EjbModule(new EjbJar(), new OpenejbJar());
final EjbJar ejbJar = ejbModule.getEjbJar();
final OpenejbJar openejbJar = ejbModule.getOpenejbJar();
openejbJar.getProperties().setProperty("color", "orange");
ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
final EjbJarInfo moduleInfo = config.configureApplication(ejbModule);
assertProperty(moduleInfo.properties, "color", "orange");
assembler.createApplication(moduleInfo);
}
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
final BeanContext beanContext = containerSystem.getBeanContext("WidgetBean");
final Properties properties = beanContext.getModuleContext().getProperties();
assertProperty(properties, "color", "orange");
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class OpenEjbContainerNoRestartTest method normalRestart.
@Test
public void normalRestart() throws Exception {
final EJBContainer container1 = EJBContainer.createEJBContainer(new Properties() {
{
put(EJBContainer.MODULES, new EjbJar());
}
});
container1.close();
final EJBContainer container2 = EJBContainer.createEJBContainer(new Properties() {
{
put(EJBContainer.MODULES, new EjbJar());
}
});
container2.close();
assertNotSame(container1, container2);
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class OpenEjbContainerNoRestartTest method noRestart.
@Test
public void noRestart() throws Exception {
final EJBContainer container1 = EJBContainer.createEJBContainer(new Properties() {
{
put(EJBContainer.MODULES, new EjbJar());
put(OpenEjbContainer.OPENEJB_EJBCONTAINER_CLOSE, OpenEjbContainer.OPENEJB_EJBCONTAINER_CLOSE_SINGLE);
}
});
container1.close();
final EJBContainer container2 = EJBContainer.createEJBContainer(new Properties() {
{
put(EJBContainer.MODULES, new EjbJar());
}
});
container2.close();
assertTrue(SystemInstance.isInitialized());
assertSame(container1, container2);
Reflections.invokeByReflection(container2, "doClose", new Class<?>[0], null);
assertFalse(SystemInstance.isInitialized());
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class AutoConfigResourceRefsTest 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.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
assembler.createResource(config.configureService(new org.apache.openejb.config.sys.Resource("defaultDataSource", "DataSource", null), ResourceInfo.class));
assembler.createResource(config.configureService(new org.apache.openejb.config.sys.Resource("yellowDataSource", "DataSource", null), ResourceInfo.class));
assembler.createResource(config.configureService(new org.apache.openejb.config.sys.Resource("PurpleDataSource", "DataSource", null), ResourceInfo.class));
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
final EnterpriseBeanInfo beanInfo = ejbJarInfo.enterpriseBeans.get(0);
final Map<String, ResourceReferenceInfo> refs = new HashMap<String, ResourceReferenceInfo>();
for (final ResourceReferenceInfo ref : beanInfo.jndiEnc.resourceRefs) {
refs.put(ref.referenceName.replaceAll(".*/", ""), ref);
}
ResourceReferenceInfo info;
info = refs.get("yellowDataSource");
assertNotNull(info);
assertEquals("yellowDataSource", info.resourceID);
info = refs.get("orangeDataSource");
assertNotNull(info);
assertEquals("defaultDataSource", info.resourceID);
info = refs.get("purpleDataSource");
assertNotNull(info);
assertEquals("PurpleDataSource", info.resourceID);
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class AutoConfigResourceRefsTest method testCaseInsensitive.
public void testCaseInsensitive() throws Exception {
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));
assembler.createResource(config.configureService(new org.apache.openejb.config.sys.Resource("DeFAultDataSource", "DataSource", null), ResourceInfo.class));
assembler.createResource(config.configureService(new org.apache.openejb.config.sys.Resource("YeLLowDataSource", "DataSource", null), ResourceInfo.class));
assembler.createResource(config.configureService(new org.apache.openejb.config.sys.Resource("PurpLEDataSource", "DataSource", null), ResourceInfo.class));
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(WidgetBean.class));
final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
final EnterpriseBeanInfo beanInfo = ejbJarInfo.enterpriseBeans.get(0);
final Map<String, ResourceReferenceInfo> refs = new HashMap<String, ResourceReferenceInfo>();
for (final ResourceReferenceInfo ref : beanInfo.jndiEnc.resourceRefs) {
refs.put(ref.referenceName.replaceAll(".*/", ""), ref);
}
ResourceReferenceInfo info;
info = refs.get("yellowDataSource");
assertNotNull(info);
assertEquals("YeLLowDataSource", info.resourceID);
info = refs.get("orangeDataSource");
assertNotNull(info);
assertEquals("DeFAultDataSource", info.resourceID);
info = refs.get("purpleDataSource");
assertNotNull(info);
assertEquals("PurpLEDataSource", info.resourceID);
}
Aggregations