Search in sources :

Example 41 with EjbModule

use of org.apache.openejb.config.EjbModule 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 42 with EjbModule

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

the class AppModuleBuilder method anAppModule.

public AppModuleBuilder anAppModule() {
    ejbModule = new EjbModule(getClass().getClassLoader(), "FakeEjbJar", "fake.jar", ejbJar, null);
    ejbModule.setOpenejbJar(openEJBJar);
    return this;
}
Also used : EjbModule(org.apache.openejb.config.EjbModule)

Example 43 with EjbModule

use of org.apache.openejb.config.EjbModule 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 44 with EjbModule

use of org.apache.openejb.config.EjbModule 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 45 with EjbModule

use of org.apache.openejb.config.EjbModule 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

EjbModule (org.apache.openejb.config.EjbModule)91 EjbJar (org.apache.openejb.jee.EjbJar)81 AppModule (org.apache.openejb.config.AppModule)41 StatelessBean (org.apache.openejb.jee.StatelessBean)37 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)30 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)29 Assembler (org.apache.openejb.assembler.classic.Assembler)27 Properties (java.util.Properties)24 SingletonBean (org.apache.openejb.jee.SingletonBean)21 InitialContext (javax.naming.InitialContext)20 Module (org.apache.openejb.testing.Module)18 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)15 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)13 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)13 Beans (org.apache.openejb.jee.Beans)12 AppInfo (org.apache.openejb.assembler.classic.AppInfo)11 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)10 ContainerSystem (org.apache.openejb.spi.ContainerSystem)10 ArrayList (java.util.ArrayList)9 EnterpriseBean (org.apache.openejb.jee.EnterpriseBean)9