use of org.apache.openejb.assembler.classic.Assembler in project tomee by apache.
the class ServiceClasspathTest method testRelativePath.
@Test
public void testRelativePath() throws Exception {
final String className = "org.superbiz.foo.Orange";
final File jar = subclass(Color.class, className);
final File xml = File.createTempFile("config-", ".xml");
xml.deleteOnExit();
final PrintStream out = new PrintStream(IO.write(xml));
out.println("<openejb>\n" + " <Resource id=\"Orange\" type=\"org.superbiz.foo.Orange\"" + " class-name=\"org.superbiz.foo.Orange\"" + " classpath=\"${openejb.home}/" + jar.getName() + "\">\n" + " red = FF\n" + " green = 99\n" + " blue = 00\n" + " </Resource>\n" + "</openejb>");
out.close();
new File(jar.getParentFile(), "temp").mkdirs();
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
final Properties properties = new Properties();
properties.setProperty("openejb.home", jar.getParentFile().getAbsolutePath());
SystemInstance.init(properties);
PropertyPlaceHolderHelper.reset();
createEnvrt();
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.buildContainerSystem(config.getOpenEjbConfiguration(xml));
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 ModulePropertiesTest method testOverrideAdd.
public void testOverrideAdd() 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\"/>");
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 StatefulTimeoutTest 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);
statefulContainerInfo.properties.setProperty("BulkPassivate", "1");
// clear cache every 3 seconds
statefulContainerInfo.properties.setProperty("Frequency", "3");
assembler.createContainer(statefulContainerInfo);
final EjbJar ejbJar = new EjbJar();
Timeout timeout;
final StatefulBean bean1 = new StatefulBean("BeanNegative", MyLocalBeanImpl.class);
timeout = new Timeout();
timeout.setTimeout(-1);
timeout.setUnit(TimeUnit.SECONDS);
bean1.setStatefulTimeout(timeout);
final StatefulBean bean0 = new StatefulBean("BeanZero", MyLocalBeanImpl.class);
timeout = new Timeout();
timeout.setTimeout(0);
timeout.setUnit(TimeUnit.SECONDS);
bean0.setStatefulTimeout(timeout);
final StatefulBean bean5 = new StatefulBean("Bean", MyLocalBeanImpl.class);
timeout = new Timeout();
timeout.setTimeout(5);
timeout.setUnit(TimeUnit.SECONDS);
bean5.setStatefulTimeout(timeout);
ejbJar.addEnterpriseBean(bean1);
ejbJar.addEnterpriseBean(bean0);
ejbJar.addEnterpriseBean(bean5);
assembler.createApplication(config.configureApplication(ejbJar));
}
use of org.apache.openejb.assembler.classic.Assembler in project tomee by apache.
the class StatelessInstanceManagerPoolingTest 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 StatelessSessionContainerInfo statelessContainerInfo = config.configureService(StatelessSessionContainerInfo.class);
statelessContainerInfo.properties.setProperty("TimeOut", "100");
statelessContainerInfo.properties.setProperty("MaxSize", "10");
statelessContainerInfo.properties.setProperty("MinSize", "2");
statelessContainerInfo.properties.setProperty("StrictPooling", "true");
assembler.createContainer(statelessContainerInfo);
// Setup the descriptor information
final StatelessBean bean = new StatelessBean(CounterBean.class);
bean.addBusinessLocal(Counter.class.getName());
bean.addBusinessRemote(RemoteCounter.class.getName());
bean.addPostConstruct("init");
bean.addPreDestroy("destroy");
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(bean);
instances.set(0);
assembler.createApplication(config.configureApplication(ejbJar));
}
use of org.apache.openejb.assembler.classic.Assembler in project tomee by apache.
the class StatelessInterceptorTest method setUp.
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 EjbJarInfo ejbJar = config.configureApplication(buildTestApp());
assertNotNull(ejbJar);
assembler.createApplication(ejbJar);
final Properties properties = new Properties(System.getProperties());
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
ctx = new InitialContext(properties);
}
Aggregations