Search in sources :

Example 16 with AppModule

use of org.apache.openejb.config.AppModule in project tomee by apache.

the class AsynchInRoleTest method testSessionContext.

@Test
public void testSessionContext() throws Exception {
    // Build the application
    final AppModule app = new AppModule(this.getClass().getClassLoader(), "testcanceltask");
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(TestBeanB.class));
    app.getEjbModules().add(new EjbModule(ejbJar));
    final AppInfo appInfo = config.configureApplication(app);
    assembler.createApplication(appInfo);
    final Properties env = new Properties();
    env.put(javax.naming.Context.SECURITY_PRINCIPAL, "jonathan");
    env.put(javax.naming.Context.SECURITY_CREDENTIALS, "secret");
    final InitialContext context = new InitialContext(env);
    final TestBean test = (TestBean) context.lookup("TestBeanBLocal");
    test.testA(Thread.currentThread().getId());
    Assert.assertEquals("testA was never executed", "testA", test.getLastInvokeMethod());
    final Future<String> future = test.testB(Thread.currentThread().getId());
    Thread.sleep(1000L);
    Assert.assertFalse(future.cancel(true));
    Assert.assertFalse(future.isCancelled());
    Assert.assertFalse(future.isDone());
    Thread.sleep(3000L);
    Assert.assertTrue(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());
    Thread.sleep(3000L);
    Assert.assertEquals("testD was never executed", "testD", test.getLastInvokeMethod());
    context.close();
}
Also used : AppModule(org.apache.openejb.config.AppModule) StatelessBean(org.apache.openejb.jee.StatelessBean) EjbModule(org.apache.openejb.config.EjbModule) Properties(java.util.Properties) InitialContext(javax.naming.InitialContext) EjbJar(org.apache.openejb.jee.EjbJar) AppInfo(org.apache.openejb.assembler.classic.AppInfo) Test(org.junit.Test)

Example 17 with AppModule

use of org.apache.openejb.config.AppModule in project tomee by apache.

the class AsynchTest method testSessionContext.

@Test
public void testSessionContext() throws Exception {
    // Build the application
    final AppModule app = new AppModule(this.getClass().getClassLoader(), "testcanceltask");
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new StatelessBean(TestBeanB.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("TestBeanBLocal");
    test.testA(Thread.currentThread().getId());
    Assert.assertEquals("testA was never executed", "testA", test.getLastInvokeMethod());
    final Future<String> future = test.testB(Thread.currentThread().getId());
    Thread.sleep(1000L);
    Assert.assertFalse(future.cancel(true));
    Assert.assertFalse(future.isCancelled());
    Assert.assertFalse(future.isDone());
    Thread.sleep(3000L);
    Assert.assertTrue(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());
    Thread.sleep(3000L);
    Assert.assertEquals("testD was never executed", "testD", test.getLastInvokeMethod());
}
Also used : AppModule(org.apache.openejb.config.AppModule) StatelessBean(org.apache.openejb.jee.StatelessBean) EjbModule(org.apache.openejb.config.EjbModule) InitialContext(javax.naming.InitialContext) EjbJar(org.apache.openejb.jee.EjbJar) AppInfo(org.apache.openejb.assembler.classic.AppInfo) Test(org.junit.Test)

Example 18 with AppModule

use of org.apache.openejb.config.AppModule in project tomee by apache.

the class EjbObjectInputStreamTest method testShouldAllowPrimitiveArraysToBeSerialized.

@Test
public void testShouldAllowPrimitiveArraysToBeSerialized() throws Exception {
    final EjbJar ejbJar = new EjbJar();
    final StatelessBean statelessBean = new StatelessBean(TestBean.class);
    ejbJar.addEnterpriseBean(statelessBean);
    final AppModule app = new AppModule(this.getClass().getClassLoader(), "Test");
    final EjbModule ejbModule = new EjbModule(ejbJar);
    ejbModule.setModuleId("EjbModule");
    app.getEjbModules().add(ejbModule);
    assembler.createApplication(config.configureApplication(app));
    final TestRemote testBean = (TestRemote) context.lookup("TestBeanRemote");
    assertEquals('J', testBean.getChar());
    assertEquals("Hello", new String(testBean.getCharArray()));
    assertEquals("test", new String(testBean.getCharArrayArray()[0]));
    assertEquals("run", new String(testBean.getCharArrayArray()[1]));
    assertEquals(1, testBean.getIntArray()[0]);
    assertEquals(2, testBean.getIntArray()[1]);
    assertEquals(true, testBean.getBooleanArray()[0]);
    assertEquals(false, testBean.getBooleanArray()[1]);
    assertEquals(0xD, testBean.getByteArray()[0]);
    assertEquals(0xE, testBean.getByteArray()[1]);
    assertEquals(0xA, testBean.getByteArray()[2]);
    assertEquals(0xD, testBean.getByteArray()[3]);
    assertEquals(0xB, testBean.getByteArray()[4]);
    assertEquals(0xE, testBean.getByteArray()[5]);
    assertEquals(0xE, testBean.getByteArray()[6]);
    assertEquals(0xF, testBean.getByteArray()[7]);
    assertEquals(1, testBean.getShortArray()[0]);
    assertEquals(2, testBean.getShortArray()[1]);
    assertEquals(1.1f, testBean.getFloatArray()[0], 0.001);
    assertEquals(2.2f, testBean.getFloatArray()[1], 0.001);
    assertEquals(5L, testBean.getLongArray()[0]);
    assertEquals(6L, testBean.getLongArray()[1]);
    assertEquals(1.1, testBean.getDoubleArray()[0], 0.001);
    assertEquals(2.2, testBean.getDoubleArray()[1], 0.001);
}
Also used : AppModule(org.apache.openejb.config.AppModule) StatelessBean(org.apache.openejb.jee.StatelessBean) EjbModule(org.apache.openejb.config.EjbModule) EjbJar(org.apache.openejb.jee.EjbJar) Test(org.junit.Test)

Example 19 with AppModule

use of org.apache.openejb.config.AppModule in project tomee by apache.

the class EjbRefTest method ear.

private void ear(final EjbJar... ejbJars) throws OpenEJBException, NamingException, IOException {
    final AppModule app = new AppModule(this.getClass().getClassLoader(), "classpath-" + ejbJars.hashCode());
    for (final EjbJar ejbJar : ejbJars) {
        app.getEjbModules().add(new EjbModule(ejbJar));
    }
    assembler.createApplication(config.configureApplication(app));
}
Also used : AppModule(org.apache.openejb.config.AppModule) EjbModule(org.apache.openejb.config.EjbModule) EjbJar(org.apache.openejb.jee.EjbJar)

Example 20 with AppModule

use of org.apache.openejb.config.AppModule in project tomee by apache.

the class ResourcePropertyLeakTest method application.

@Module
public AppModule application() {
    final EjbModule ejbModule = new EjbModule(new EjbJar());
    final AppModule appModule = new AppModule(Thread.currentThread().getContextClassLoader(), null);
    appModule.getEjbModules().add(ejbModule);
    return appModule;
}
Also used : AppModule(org.apache.openejb.config.AppModule) EjbModule(org.apache.openejb.config.EjbModule) EjbJar(org.apache.openejb.jee.EjbJar) EjbModule(org.apache.openejb.config.EjbModule) AppModule(org.apache.openejb.config.AppModule) Module(org.apache.openejb.testing.Module)

Aggregations

AppModule (org.apache.openejb.config.AppModule)51 EjbModule (org.apache.openejb.config.EjbModule)41 EjbJar (org.apache.openejb.jee.EjbJar)40 StatelessBean (org.apache.openejb.jee.StatelessBean)18 InitialContext (javax.naming.InitialContext)15 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)15 Properties (java.util.Properties)14 AppInfo (org.apache.openejb.assembler.classic.AppInfo)14 Assembler (org.apache.openejb.assembler.classic.Assembler)14 SingletonBean (org.apache.openejb.jee.SingletonBean)11 Test (org.junit.Test)10 WebModule (org.apache.openejb.config.WebModule)9 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)8 File (java.io.File)7 IOException (java.io.IOException)6 List (java.util.List)6 OpenEJBException (org.apache.openejb.OpenEJBException)6 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)6 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)6 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)6