Search in sources :

Example 96 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class AutoConfigTest method testFirstMatching.

@Test
public void testFirstMatching() throws Exception {
    final ConfigurationFactory cf = new ConfigurationFactory();
    final AutoConfig ac = new AutoConfig(cf);
    final AppModule appModule = new AppModule(new EjbModule(new EjbJar()));
    for (final String s : list) {
        appModule.getResources().add(new Resource(s, "DataSource"));
    }
    final AutoConfig.AppResources resources = new AutoConfig.AppResources(appModule, Collections.<ContainerInfo>emptyList());
    final Method m = ac.getClass().getDeclaredMethod("firstMatching", String.class, String.class, Properties.class, AutoConfig.AppResources.class);
    m.setAccessible(true);
    for (final String s : list) {
        final String prefix = s.substring(0, s.indexOf('/'));
        final String result = (String) m.invoke(ac, prefix, "DataSource", new Properties(), resources);
        Assert.assertTrue(result.startsWith(prefix));
    }
    String result = (String) m.invoke(ac, "abc-jkl-uvw-jkl-web", "DataSource", new Properties(), resources);
    Assert.assertEquals("abc-jkl-uvw-jkl-web/jdbc/appmgr-jta", result);
    result = (String) m.invoke(ac, "jdbc", "DataSource", new Properties(), resources);
    Assert.assertEquals("jdbc/appmgr-jta", result);
}
Also used : Resource(org.apache.openejb.config.sys.Resource) Method(java.lang.reflect.Method) Properties(java.util.Properties) EjbJar(org.apache.openejb.jee.EjbJar) Test(org.junit.Test)

Example 97 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class BusinessInterfacesTest method setUp.

@Override
protected void setUp() throws Exception {
    final Assembler assembler = new Assembler();
    config = new ConfigurationFactory();
    ejbModule = new EjbModule(new EjbJar());
    ejbModule.setOpenejbJar(new OpenejbJar());
    ejbJar = ejbModule.getEjbJar();
    strict(false);
}
Also used : OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) Assembler(org.apache.openejb.assembler.classic.Assembler) EjbJar(org.apache.openejb.jee.EjbJar)

Example 98 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class ConfigurationFactoryTest method testConfigureApplicationEjbJar.

@Test
public void testConfigureApplicationEjbJar() throws OpenEJBException {
    // Just to find out whether the validationDisabled message shows up
    SystemInstance.get().setProperty(ConfigurationFactory.VALIDATION_SKIP_PROPERTY, "true");
    final boolean offline = true;
    final ConfigurationFactory factory = new ConfigurationFactory(offline);
    final String id = "testConfigureApplicationEjbJar";
    final EjbJar ejbJar = new EjbJar(id);
    // no real classes engaged so disable metadata (annotation) processing
    ejbJar.setMetadataComplete(true);
    final EjbJarInfo info = factory.configureApplication(ejbJar);
    // not much to assert
    assertEquals(id, info.moduleName);
}
Also used : EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar) Test(org.junit.Test)

Example 99 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class DefaultDataSourceTest method test.

/**
 * Default DataSource should be a JtaManaged DataSource
 *
 * @throws Exception
 */
public void test() throws Exception {
    final ConfigurationFactory config = new ConfigurationFactory();
    final Assembler assembler = new Assembler();
    assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
    assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new SingletonBean(MyBean.class));
    assembler.createApplication(config.configureApplication(new EjbModule(ejbJar)));
    final OpenEjbConfiguration configuration = SystemInstance.get().getComponent(OpenEjbConfiguration.class);
    final ResourceInfo resourceInfo = configuration.facilities.resources.get(0);
    assertEquals("Default JDBC Database", resourceInfo.id);
    assertEquals("true", resourceInfo.properties.getProperty("JtaManaged"));
}
Also used : ResourceInfo(org.apache.openejb.assembler.classic.ResourceInfo) SingletonBean(org.apache.openejb.jee.SingletonBean) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) Assembler(org.apache.openejb.assembler.classic.Assembler) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJar(org.apache.openejb.jee.EjbJar) OpenEjbConfiguration(org.apache.openejb.assembler.classic.OpenEjbConfiguration)

Example 100 with EjbJar$JAXB

use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.

the class CheckNoBusinessMethodTest method noBusinessMethod.

@Keys({ @Key(value = "no.busines.method.case", count = 4), @Key(value = "no.busines.method.args", count = 4), @Key(value = "no.busines.method", count = 4) })
public EjbJar noBusinessMethod() throws OpenEJBException {
    // System.setProperty("openejb.validation.output.level", "VERBOSE");
    final EjbJar ejbJar = new EjbJar();
    final StatelessBean stateLessLocal = new StatelessBean(FooStatelessSession.class);
    stateLessLocal.setLocalHome("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooLocalHome");
    stateLessLocal.setLocal("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooLocal");
    final StatefulBean statefulLocal = new StatefulBean(FooStatefulSession.class);
    statefulLocal.setLocalHome("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooLocalHome");
    statefulLocal.setLocal("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooLocal");
    final StatelessBean stateLessRemote = new StatelessBean(FooRemoteStatelessSession.class);
    stateLessRemote.setHome("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooRemoteHome");
    stateLessRemote.setRemote("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooRemote");
    final StatefulBean statefulRemote = new StatefulBean(FooRemoteStatefulSession.class);
    statefulRemote.setHome("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooRemoteHome");
    statefulRemote.setRemote("org.apache.openejb.config.rules.CheckNoBusinessMethodTest$FooRemote");
    ejbJar.addEnterpriseBean(stateLessLocal);
    ejbJar.addEnterpriseBean(statefulLocal);
    ejbJar.addEnterpriseBean(stateLessRemote);
    ejbJar.addEnterpriseBean(statefulRemote);
    return ejbJar;
}
Also used : StatelessBean(org.apache.openejb.jee.StatelessBean) StatefulBean(org.apache.openejb.jee.StatefulBean) EjbJar(org.apache.openejb.jee.EjbJar)

Aggregations

EjbJar (org.apache.openejb.jee.EjbJar)242 StatelessBean (org.apache.openejb.jee.StatelessBean)117 Assembler (org.apache.openejb.assembler.classic.Assembler)88 EjbModule (org.apache.openejb.config.EjbModule)81 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)76 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)60 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)60 OpenejbJar (org.apache.openejb.jee.oejb3.OpenejbJar)50 Properties (java.util.Properties)49 InitialContext (javax.naming.InitialContext)43 SingletonBean (org.apache.openejb.jee.SingletonBean)42 AppModule (org.apache.openejb.config.AppModule)40 StatefulBean (org.apache.openejb.jee.StatefulBean)33 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)31 Module (org.apache.openejb.testing.Module)30 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)27 Test (org.junit.Test)26 LocalInitialContextFactory (org.apache.openejb.core.LocalInitialContextFactory)25 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)24 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)21