use of org.apache.openejb.jee.SingletonBean in project tomee by apache.
the class AsynchTest method testMethodScopeAsynch.
@SuppressWarnings("UseOfSystemOutOrSystemErr")
@Test
public void testMethodScopeAsynch() throws Exception {
System.out.println(long.class.getName());
System.out.println(String[].class.getCanonicalName());
//Build the application
final AppModule app = new AppModule(this.getClass().getClassLoader(), "testasynch");
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new StatelessBean(TestBeanC.class));
ejbJar.addEnterpriseBean(new SingletonBean(TestBeanD.class));
app.getEjbModules().add(new EjbModule(ejbJar));
final AppInfo appInfo = config.configureApplication(app);
assembler.createApplication(appInfo);
final InitialContext context = new InitialContext();
final String[] beans = new String[] { "TestBeanCLocal", "TestBeanDLocal" };
for (final String beanName : beans) {
final TestBean testBean = (TestBean) context.lookup(beanName);
testBean.testA(Thread.currentThread().getId());
Thread.sleep(1000L);
Assert.assertEquals("testA was never executed", "testA", testBean.getLastInvokeMethod());
final Future<String> future = testBean.testB(Thread.currentThread().getId());
Thread.sleep(1000L);
Assert.assertTrue("The task should be done", future.isDone());
Assert.assertEquals("testB was never executed", "testB", testBean.getLastInvokeMethod());
testBean.testC(Thread.currentThread().getId());
Assert.assertEquals("testC was never executed", "testC", testBean.getLastInvokeMethod());
testBean.testD(Thread.currentThread().getId());
Assert.assertEquals("testD was never executed", "testD", testBean.getLastInvokeMethod());
}
}
use of org.apache.openejb.jee.SingletonBean in project tomee by apache.
the class AsynchTest method testClassScopeAsynch.
@Test
public void testClassScopeAsynch() throws Exception {
//Build the application
final AppModule app = new AppModule(this.getClass().getClassLoader(), "testclassasynch");
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new SingletonBean(TestBeanA.class));
app.getEjbModules().add(new EjbModule(ejbJar));
final AppInfo appInfo = config.configureApplication(app);
assembler.createApplication(appInfo);
final InitialContext context = new InitialContext();
final TestBean test = (TestBean) context.lookup("TestBeanALocal");
test.testA(Thread.currentThread().getId());
Thread.sleep(1000L);
Assert.assertEquals("testA was never executed", "testA", test.getLastInvokeMethod());
final Future<String> future = test.testB(Thread.currentThread().getId());
Thread.sleep(1000L);
Assert.assertTrue("The task should be done", future.isDone());
Assert.assertEquals("testB was never executed", "testB", test.getLastInvokeMethod());
test.testC(Thread.currentThread().getId());
Assert.assertEquals("testC was never executed", "testC", test.getLastInvokeMethod());
test.testD(Thread.currentThread().getId());
Assert.assertEquals("testD was never executed", "testD", test.getLastInvokeMethod());
}
use of org.apache.openejb.jee.SingletonBean in project tomee by apache.
the class CustomEndpointConfiguratorTest method module.
@Module
public EjbModule module() {
final EjbModule module = new EjbModule(new EjbJar());
module.setOpenejbJar(new OpenejbJar());
final SingletonBean bean = new SingletonBean(MyWebservice.class);
bean.setLocalBean(new Empty());
final EjbDeployment deployment = new EjbDeployment(bean);
deployment.getProperties().setProperty("openejb.endpoint.configurator", CustomConfigurator.class.getName());
module.getOpenejbJar().addEjbDeployment(deployment);
module.getEjbJar().addEnterpriseBean(bean);
return module;
}
use of org.apache.openejb.jee.SingletonBean in project tomee by apache.
the class FeatureTest method app.
@Module
public EjbModule app() {
final EjbJar jar = new EjbJar();
jar.addEnterpriseBean(new SingletonBean(AuthenticatorServiceBean.class).localBean());
final OpenejbJar openejbJar = new OpenejbJar();
openejbJar.addEjbDeployment(new EjbDeployment(jar.getEnterpriseBeans()[0]));
final Properties properties = openejbJar.getEjbDeployment().iterator().next().getProperties();
properties.setProperty(CxfService.OPENEJB_JAXWS_CXF_FEATURES, MyFeature.class.getName());
properties.setProperty("cxf.jaxws.features", "my-feature");
properties.setProperty("cxf.jaxws.properties", "my-props");
final EjbModule module = new EjbModule(jar);
module.setOpenejbJar(openejbJar);
final Resources resources = new Resources();
final Service service = new Service("my-feature", null, null, null);
service.setClassName(MyFeature.class.getName());
resources.add(service);
final Service myProps = new Service("my-props", null, null, null);
myProps.setClassName(Properties.class.getName());
myProps.getProperties().setProperty("faultStackTraceEnabled", "true");
resources.add(myProps);
module.initResources(resources);
return module;
}
Aggregations