use of org.apache.openejb.jee.EjbJar in project tomee by apache.
the class ApplicationWideTest method testShouldCreateAResourceAndNotRemoveOnUndeploy.
public void testShouldCreateAResourceAndNotRemoveOnUndeploy() throws Exception {
final EjbModule ejbModule = new EjbModule(new EjbJar(), new OpenejbJar());
final EjbJar ejbJar = ejbModule.getEjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(EchoBean.class));
final AppModule appModule = new AppModule(ejbModule);
final Container container = new Container();
container.setId("My Container");
container.setCtype("STATELESS");
container.getProperties().setProperty("ApplicationWide", "true");
appModule.getContainers().add(container);
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
{
// setup the system
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
}
final AppInfo appInfo = config.configureApplication(appModule);
assembler.createApplication(appInfo);
{
final ContainerSystem containerSystem = assembler.getContainerSystem();
final org.apache.openejb.Container appContainer = containerSystem.getContainer(ejbModule.getModuleId() + "/My Container");
assertNotNull(appContainer);
}
assembler.destroyApplication(appInfo);
{
final ContainerSystem containerSystem = assembler.getContainerSystem();
final org.apache.openejb.Container appContainer = containerSystem.getContainer(ejbModule.getModuleId() + "/My Container");
assertNotNull(appContainer);
}
}
use of org.apache.openejb.jee.EjbJar in project tomee by apache.
the class AutoConfigTest method testFirstMatching.
@Test
public void testFirstMatching() throws Exception {
final ConfigurationFactory cf = new ConfigurationFactory();
final AutoConfig ac = new AutoConfig(cf);
final AppModule appModule = new AppModule(new EjbModule(new EjbJar()));
for (final String s : list) {
appModule.getResources().add(new Resource(s, "DataSource"));
}
final AutoConfig.AppResources resources = new AutoConfig.AppResources(appModule, Collections.<ContainerInfo>emptyList());
final Method m = ac.getClass().getDeclaredMethod("firstMatching", String.class, String.class, Properties.class, AutoConfig.AppResources.class);
m.setAccessible(true);
for (final String s : list) {
final String prefix = s.substring(0, s.indexOf('/'));
final String result = (String) m.invoke(ac, prefix, "DataSource", new Properties(), resources);
Assert.assertTrue(result.startsWith(prefix));
}
String result = (String) m.invoke(ac, "abc-jkl-uvw-jkl-web", "DataSource", new Properties(), resources);
Assert.assertEquals("abc-jkl-uvw-jkl-web/jdbc/appmgr-jta", result);
result = (String) m.invoke(ac, "jdbc", "DataSource", new Properties(), resources);
Assert.assertEquals("jdbc/appmgr-jta", result);
}
use of org.apache.openejb.jee.EjbJar in project tomee by apache.
the class CdiDecoratorMultipleDelegateCallsTest method classes.
@Module
@Classes({ ServiceImpl.class })
public EjbModule classes() {
final Beans beans = new Beans();
beans.addDecorator(ServiceDecorator.class);
final EjbModule jar = new EjbModule(new EjbJar());
jar.setBeans(beans);
return jar;
}
use of org.apache.openejb.jee.EjbJar in project tomee by apache.
the class CdiDecoratorTest method setUp.
@Before
public void setUp() throws Exception {
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.createContainer(config.configureService(StatelessSessionContainerInfo.class));
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean("HelloOne", RedBean.class));
ejbJar.addEnterpriseBean(new StatelessBean("HelloTwo", RedBean.class));
ejbJar.addEnterpriseBean(new StatelessBean(OrangeBean.class));
final Beans beans = new Beans();
beans.addInterceptor(OrangeCdiInterceptor.class);
beans.addDecorator(OrangeOneDecorator.class);
beans.addDecorator(OrangeTwoDecorator.class);
beans.addManagedClass(YellowBean.class);
final EjbModule module = new EjbModule(ejbJar);
module.setBeans(beans);
assembler.createApplication(config.configureApplication(module));
final Properties properties = new Properties(System.getProperties());
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
ctx = new InitialContext(properties);
}
use of org.apache.openejb.jee.EjbJar in project tomee by apache.
the class ResourceAdapterControlTest method app.
@Module
@Classes(value = Mdb.class)
public EjbModule app() {
return new EjbModule(new EjbJar("test") {
{
addEnterpriseBean(new MessageDrivenBean("ejb/Mdb", Mdb.class) {
{
setActivationConfig(new ActivationConfig());
getActivationConfig().addProperty("MdbActiveOnStartup", "false");
getActivationConfig().addProperty("MdbJMXControl", "default:type=test");
}
});
}
});
}
Aggregations