Search in sources :

Example 66 with Assembler

use of org.apache.openejb.assembler.classic.Assembler in project tomee by apache.

the class BeanPropertiesTest method testOverrideFromModuleProperties.

public void testOverrideFromModuleProperties() 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));
    }
    {
        final Map<String, String> map = new HashMap<String, String>();
        map.put("META-INF/openejb-jar.xml", "<openejb-jar>\n" + "  <ejb-deployment ejb-name=\"WidgetBean\">\n" + "    <properties>\n" + "      color=white\n" + "    </properties>\n" + "  </ejb-deployment>\n" + "</openejb-jar>");
        map.put("META-INF/module.properties", "WidgetBean.color=orange");
        final File app = Archives.fileArchive(map, WidgetBean.class);
        assembler.createApplication(config.configureApplication(app));
    }
    final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
    assertContexts(containerSystem);
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) Assembler(org.apache.openejb.assembler.classic.Assembler) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File)

Example 67 with Assembler

use of org.apache.openejb.assembler.classic.Assembler in project tomee by apache.

the class BeanPropertiesTest 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("WidgetBean.color", "orange");
        final Map<String, String> map = new HashMap<String, String>();
        final File app = Archives.fileArchive(map, WidgetBean.class);
        assembler.createApplication(config.configureApplication(app));
    }
    final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
    assertContexts(containerSystem);
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) Assembler(org.apache.openejb.assembler.classic.Assembler) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File)

Example 68 with Assembler

use of org.apache.openejb.assembler.classic.Assembler 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 69 with Assembler

use of org.apache.openejb.assembler.classic.Assembler 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 70 with Assembler

use of org.apache.openejb.assembler.classic.Assembler in project tomee by apache.

the class EarModuleNamesTest method testIdEjbJar.

@Test
public void testIdEjbJar() throws Exception {
    final File appsDir = Files.tmpdir();
    final Assembler assembler = new Assembler();
    final ConfigurationFactory factory = new ConfigurationFactory();
    final File ear = new File(appsDir, "testIdEjbJar.ear");
    final Map<String, Object> metaInf = new HashMap<String, Object>();
    metaInf.put("META-INF/ejb-jar.xml", "<ejb-jar id=\"testIdEjbJar\" />");
    final File ejbJar = Archives.jarArchive(metaInf, "testIdEjbJar", Orange.class);
    final Map<String, Object> contents = new HashMap<String, Object>();
    contents.put("green.jar", ejbJar);
    Archives.jarArchive(ear, contents);
    final AppInfo appInfo = factory.configureApplication(ear);
    assertEquals(appInfo.ejbJars.size(), 1);
    assertEquals("testIdEjbJar", appInfo.ejbJars.get(0).moduleId);
}
Also used : HashMap(java.util.HashMap) Assembler(org.apache.openejb.assembler.classic.Assembler) File(java.io.File) AppInfo(org.apache.openejb.assembler.classic.AppInfo) Test(org.junit.Test)

Aggregations

Assembler (org.apache.openejb.assembler.classic.Assembler)171 EjbJar (org.apache.openejb.jee.EjbJar)88 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)84 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)76 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)76 StatelessBean (org.apache.openejb.jee.StatelessBean)56 InitialContext (javax.naming.InitialContext)50 File (java.io.File)49 AppInfo (org.apache.openejb.assembler.classic.AppInfo)47 Properties (java.util.Properties)42 HashMap (java.util.HashMap)39 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)39 ContainerSystem (org.apache.openejb.spi.ContainerSystem)35 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)29 LocalInitialContextFactory (org.apache.openejb.core.LocalInitialContextFactory)29 InitContextFactory (org.apache.openejb.core.ivm.naming.InitContextFactory)29 Test (org.junit.Test)29 EjbModule (org.apache.openejb.config.EjbModule)27 StatelessSessionContainerInfo (org.apache.openejb.assembler.classic.StatelessSessionContainerInfo)22 Map (java.util.Map)21