use of org.apache.openejb.assembler.classic.Assembler in project tomee by apache.
the class ModulePropertiesTest method testOverrideReplace.
public void testOverrideReplace() throws Exception {
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));
}
{
SystemInstance.get().getProperties().put("fooModule.color", "orange");
final Map<String, String> map = new HashMap<String, String>();
map.put("META-INF/ejb-jar.xml", "<ejb-jar id=\"fooModule\"/>");
map.put("META-INF/module.properties", "color=white");
final File module = Archives.fileArchive(map, WidgetBean.class);
final AppModule appModule = config.loadApplication(this.getClass().getClassLoader(), "fooApp", Arrays.asList(module));
final AppInfo appInfo = config.configureApplication(appModule);
assembler.createApplication(appInfo);
}
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
assertContexts(containerSystem);
}
use of org.apache.openejb.assembler.classic.Assembler in project tomee by apache.
the class ModulePropertiesTest method testOverrideFromApplicationProperties.
public void testOverrideFromApplicationProperties() throws Exception {
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 Map<String, String> map = new HashMap<String, String>();
map.put("META-INF/ejb-jar.xml", "<ejb-jar id=\"fooModule\"/>");
map.put("META-INF/module.properties", "color=white");
final File module = Archives.fileArchive(map, WidgetBean.class);
final AppModule appModule = config.loadApplication(this.getClass().getClassLoader(), "fooApp", Arrays.asList(module));
appModule.getProperties().put("fooModule.color", "orange");
final AppInfo appInfo = config.configureApplication(appModule);
assembler.createApplication(appInfo);
}
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
assertContexts(containerSystem);
}
use of org.apache.openejb.assembler.classic.Assembler in project tomee by apache.
the class ServiceClasspathTest method testJson.
@Test
public void testJson() throws Exception {
final String className = "org.superbiz.foo.Orange";
final File jar = subclass(Color.class, className);
final File json = File.createTempFile("config-", ".json");
json.deleteOnExit();
final PrintStream out = new PrintStream(IO.write(json));
out.println("{\n" + " \"resources\":{\n" + " \"Orange\":{\n" + " \"type\":\"org.superbiz.foo.Orange\",\n" + " \"class-name\":\"org.superbiz.foo.Orange\",\n" + " \"classpath\":\"" + jar.getAbsolutePath() + "\",\n" + " \"properties\":{\n" + " \"red\":\"FF\",\n" + " \"green\":\"99\",\n" + " \"blue\":\"00\"\n" + " }\n" + " }\n" + " }\n" + "}\n");
out.close();
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
createEnvrt();
assembler.buildContainerSystem(config.getOpenEjbConfiguration(json));
final InitialContext initialContext = new InitialContext();
final Color color = (Color) initialContext.lookup("openejb:Resource/Orange");
assertNotNull(color);
assertEquals("Orange.FF", color.getRed());
assertEquals("Orange.99", color.getGreen());
assertEquals("Orange.00", color.getBlue());
}
use of org.apache.openejb.assembler.classic.Assembler 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.assembler.classic.Assembler in project tomee by apache.
the class AltDDPrefixTest method testMultitplePrefixes.
public void testMultitplePrefixes() throws Exception {
System.out.println("*** testMultitplePrefixes ***");
final Assembler assmbler = new Assembler();
SystemInstance.get().setProperty("openejb.altdd.prefix", "footest, test");
DeploymentLoader.reloadAltDD();
final ConfigurationFactory factory = new ConfigurationFactory();
final URL resource = AltDDPrefixTest.class.getClassLoader().getResource("altddapp2");
final File file = URLs.toFile(resource);
final AppInfo appInfo = factory.configureApplication(file);
assertNotNull(appInfo);
assertEquals(1, appInfo.ejbJars.size());
final EjbJarInfo ejbJar = appInfo.ejbJars.get(0);
// was the footest.ejb-jar.xml picked up
assertEquals("EjbJar.enterpriseBeans", 1, ejbJar.enterpriseBeans.size());
assertEquals("EjbJar.interceptors.size()", 1, ejbJar.interceptors.size());
// was the test.env-entries.properties picked up
// 4 + ComponentName
assertEquals("EjbJar.enterpriseBeans.get(0).jndiEnc.envEntries.size()", 5, ejbJar.enterpriseBeans.get(0).jndiEnc.envEntries.size());
}
Aggregations