Search in sources :

Example 11 with OpenEjbConfiguration

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

the class DeploymentsElementTest method deploymentsDir_Ear_Unpacked_NoApplicationXml.

/**
     * <Deployments dir="myapps"/>
     * <p/>
     * EAR file extracted
     *
     * @throws Exception
     */
@Test
public void deploymentsDir_Ear_Unpacked_NoApplicationXml() throws Exception {
    final Server server = new Server();
    final File apps = server.deploymentsDir("myapps");
    final String appName = "deploymentsDir_Ear_Unpacked_NoApplicationXml";
    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));
        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 12 with OpenEjbConfiguration

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

the class DeploymentsElementTest method deployments_Duplicates.

/**
     * <Deployments dir="myapps/2000.jar"/>
     * <Deployments dir="myapps/2000.jar"/>
     * <Deployments dir="myapps"/>
     * <Deployments dir="myapps"/>
     * <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 deployments_Duplicates() throws Exception {
    final Server server = new Server();
    final File apps = Files.mkdir(server.getBase(), "myapps");
    {
        // Jar one
        final File jar = server.deploymentsFile("myapps/2000.jar");
        server.deploymentsFile("myapps/2000.jar");
        Archives.jarArchive(jar, null, Yellow.class);
    }
    {
        // Jar two
        server.deploymentsDir("myapps");
        server.deploymentsDir("myapps");
        final File jar = Files.path(apps, "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 13 with OpenEjbConfiguration

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

the class DeploymentsElementTest method deploymentsDir_Jars_Packed.

/**
     * <Deployments dir="myapps"/>
     * <p/>
     * Two ejb jars
     *
     * @throws Exception
     */
@Test
public void deploymentsDir_Jars_Packed() throws Exception {
    final Server server = new Server();
    final File apps = server.deploymentsDir("myapps");
    {
        // Jar one
        final File ear = new File(apps, "yellow.jar");
        Archives.jarArchive(ear, null, Yellow.class);
    }
    {
        // Jar two
        final File ear = new File(apps, "orange.jar");
        Archives.jarArchive(ear, null, Orange.class);
    }
    final OpenEjbConfiguration configuration = server.init();
    assertEquals(2, configuration.containerSystem.applications.size());
    final AppInfo yellow = select(configuration.containerSystem.applications, "yellow");
    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 = select(configuration.containerSystem.applications, "orange");
    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 14 with OpenEjbConfiguration

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

the class DeploymentsElementTest method invalidFile_notReadable.

@Test
public void invalidFile_notReadable() throws Exception {
    if (!System.getProperty("os.name", "unknown").toLowerCase().startsWith("win") && !"root".equals(System.getProperty("user.name", "openejb"))) {
        //File.setReadable(false) does nothing on win platforms
        exceptions.expect(RuntimeException.class);
        exceptions.expectMessage("Deployments file=");
        exceptions.expectMessage("Not readable");
        exceptions.expectMessage("myapp.jar");
        final Server server = new Server();
        final File file = server.deploymentsFile("myapp.jar");
        assertTrue(file.createNewFile());
        assertTrue(file.setReadable(false));
        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 15 with OpenEjbConfiguration

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

the class DeploymentsElementTest method invalidDir_notReadable.

@Test
public void invalidDir_notReadable() throws Exception {
    if (!System.getProperty("os.name", "unknown").toLowerCase().startsWith("win") && !"root".equals(System.getProperty("user.name", "openejb"))) {
        //File.setReadable(false) does nothing on win platforms
        exceptions.expect(RuntimeException.class);
        exceptions.expectMessage("Deployments dir=");
        exceptions.expectMessage("Not readable");
        exceptions.expectMessage("myapps");
        final Server server = new Server();
        final File dir = server.deploymentsDir("myapps");
        assertTrue(dir.setReadable(false));
        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