Search in sources :

Example 31 with OpenEjbConfiguration

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

the class ConfigurationFactoryTest method testConfigurationFactoryBooleanDynamicDeployerOpenEjbConfiguration.

@Test
public void testConfigurationFactoryBooleanDynamicDeployerOpenEjbConfiguration() throws OpenEJBException {
    final boolean offline = false;
    final DynamicDeployer dynamicDeployer = null;
    final OpenEjbConfiguration openEjbConfiguration = new OpenEjbConfiguration();
    final ConfigurationFactory factory = new ConfigurationFactory(offline, dynamicDeployer, openEjbConfiguration);
    assertEquals(openEjbConfiguration, factory.getOpenEjbConfiguration());
}
Also used : OpenEjbConfiguration(org.apache.openejb.assembler.classic.OpenEjbConfiguration) Test(org.junit.Test)

Example 32 with OpenEjbConfiguration

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

the class DeploymentsElementTest method deploymentsFile_Jars_Order.

/**
 * <Deployments dir="myapps"/>
 * <p/>
 * Two ejb jars
 * <p/>
 * Order should be guaranteed to be the same as
 * they are declared in the openejb.xml
 * <p/>
 * To test, the jars are named intentionally in an order
 * that would naturally sort to be the reverse.
 *
 * @throws Exception
 */
@Test
public void deploymentsFile_Jars_Order() throws Exception {
    final Server server = new Server();
    {
        // Jar one
        final File jar = server.deploymentsFile("2000.jar");
        Archives.jarArchive(jar, null, Yellow.class);
    }
    {
        // Jar two
        final File jar = server.deploymentsFile("1000.jar");
        Archives.jarArchive(jar, null, Orange.class);
    }
    final OpenEjbConfiguration configuration = server.init();
    assertEquals(2, configuration.containerSystem.applications.size());
    assertEquals("2000", configuration.containerSystem.applications.get(0).appId);
    assertEquals("1000", configuration.containerSystem.applications.get(1).appId);
    final AppInfo yellow = configuration.containerSystem.applications.get(0);
    assertEquals(1, yellow.ejbJars.size());
    assertEquals(1, yellow.ejbJars.get(0).enterpriseBeans.size());
    assertEquals("Yellow", yellow.ejbJars.get(0).enterpriseBeans.get(0).ejbName);
    final AppInfo orange = configuration.containerSystem.applications.get(1);
    assertEquals(1, orange.ejbJars.size());
    assertEquals(1, orange.ejbJars.get(0).enterpriseBeans.size());
    assertEquals("Orange", orange.ejbJars.get(0).enterpriseBeans.get(0).ejbName);
}
Also used : File(java.io.File) OpenEjbConfiguration(org.apache.openejb.assembler.classic.OpenEjbConfiguration) AppInfo(org.apache.openejb.assembler.classic.AppInfo) Test(org.junit.Test)

Example 33 with OpenEjbConfiguration

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

the class DeploymentsElementTest method deploymentsDir_Ear_Unpacked_ApplicationXml.

/**
 * <Deployments dir="myapps"/>
 * <p/>
 * EAR file extracted
 * Application.xml
 *
 * @throws Exception
 */
@Test
public void deploymentsDir_Ear_Unpacked_ApplicationXml() throws Exception {
    final Server server = new Server();
    final File apps = server.deploymentsDir("myapps");
    final String appName = "deploymentsDir_Ear_Unpacked_ApplicationXml";
    final File ear = new File(server.getBase(), appName + ".ear");
    {
        final Map<String, Object> contents = new HashMap<String, Object>();
        contents.put("foo.jar", Archives.jarArchive(Orange.class));
        contents.put("META-INF/application.xml", "<application><module><ejb>foo.jar</ejb></module></application>");
        Archives.jarArchive(ear, contents);
    }
    Zips.unzip(ear, Files.mkdir(apps, appName));
    final OpenEjbConfiguration configuration = server.init();
    assertEquals(1, configuration.containerSystem.applications.size());
    assertEquals(1, configuration.containerSystem.applications.get(0).ejbJars.size());
    assertEquals(1, configuration.containerSystem.applications.get(0).ejbJars.get(0).enterpriseBeans.size());
    assertEquals("Orange", configuration.containerSystem.applications.get(0).ejbJars.get(0).enterpriseBeans.get(0).ejbName);
}
Also used : File(java.io.File) HashMap(java.util.HashMap) Map(java.util.Map) OpenEjbConfiguration(org.apache.openejb.assembler.classic.OpenEjbConfiguration) Test(org.junit.Test)

Example 34 with OpenEjbConfiguration

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

the class DeploymentsElementTest method invalidFile_notAFile.

@Test
public void invalidFile_notAFile() throws Exception {
    exceptions.expect(RuntimeException.class);
    exceptions.expectMessage("Deployments file=");
    exceptions.expectMessage("Not a file");
    exceptions.expectMessage("myapp.jar");
    final Server server = new Server();
    final File file = server.deploymentsFile("myapp.jar");
    Files.delete(file);
    Files.mkdir(file);
    final OpenEjbConfiguration configuration = server.init();
    assertEquals(0, configuration.containerSystem.applications.size());
}
Also used : File(java.io.File) OpenEjbConfiguration(org.apache.openejb.assembler.classic.OpenEjbConfiguration) Test(org.junit.Test)

Example 35 with OpenEjbConfiguration

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

the class DeploymentsElementTest method invalidDir_doesNotExist.

/**
 * We do not treat this as a failure case due to backwards compatibility
 *
 * @throws Exception
 */
@Test
public void invalidDir_doesNotExist() throws Exception {
    final Server server = new Server();
    final File dir = server.deploymentsDir("myapps");
    Files.delete(dir);
    final OpenEjbConfiguration configuration = server.init();
    assertEquals(0, configuration.containerSystem.applications.size());
}
Also used : File(java.io.File) OpenEjbConfiguration(org.apache.openejb.assembler.classic.OpenEjbConfiguration) Test(org.junit.Test)

Aggregations

OpenEjbConfiguration (org.apache.openejb.assembler.classic.OpenEjbConfiguration)37 Test (org.junit.Test)24 File (java.io.File)23 Map (java.util.Map)9 Properties (java.util.Properties)9 HashMap (java.util.HashMap)8 ArrayList (java.util.ArrayList)7 Assembler (org.apache.openejb.assembler.classic.Assembler)7 AppInfo (org.apache.openejb.assembler.classic.AppInfo)6 List (java.util.List)5 ResourceInfo (org.apache.openejb.assembler.classic.ResourceInfo)4 BmpEntityContainerInfo (org.apache.openejb.assembler.classic.BmpEntityContainerInfo)3 CmpEntityContainerInfo (org.apache.openejb.assembler.classic.CmpEntityContainerInfo)3 ContainerInfo (org.apache.openejb.assembler.classic.ContainerInfo)3 ManagedContainerInfo (org.apache.openejb.assembler.classic.ManagedContainerInfo)3 MdbContainerInfo (org.apache.openejb.assembler.classic.MdbContainerInfo)3 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)3 ServiceInfo (org.apache.openejb.assembler.classic.ServiceInfo)3 SingletonSessionContainerInfo (org.apache.openejb.assembler.classic.SingletonSessionContainerInfo)3 StatefulSessionContainerInfo (org.apache.openejb.assembler.classic.StatefulSessionContainerInfo)3