Search in sources :

Example 21 with AppInfo

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

the class EjbModuleIdTest method testModuleName.

@Test
public void testModuleName() throws Exception {
    final Map<String, String> map = new HashMap<String, String>();
    map.put("META-INF/ejb-jar.xml", "<ejb-jar><module-name>orange</module-name></ejb-jar>");
    final File file = Archives.jarArchive(map, "test", OrangeBean.class);
    final Assembler assembler = new Assembler();
    final ConfigurationFactory factory = new ConfigurationFactory();
    final AppInfo appInfo = factory.configureApplication(file);
    final EjbJarInfo ejbJarInfo = appInfo.ejbJars.get(0);
    assertEquals("orange", ejbJarInfo.moduleName);
}
Also used : HashMap(java.util.HashMap) Assembler(org.apache.openejb.assembler.classic.Assembler) File(java.io.File) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) AppInfo(org.apache.openejb.assembler.classic.AppInfo) Test(org.junit.Test)

Example 22 with AppInfo

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

the class EjbModuleIdTest method testId.

@Test
public void testId() throws Exception {
    final Map<String, String> map = new HashMap<String, String>();
    map.put("META-INF/ejb-jar.xml", "<ejb-jar id=\"orange\"/>");
    final File file = Archives.jarArchive(map, "test", OrangeBean.class);
    final Assembler assembler = new Assembler();
    final ConfigurationFactory factory = new ConfigurationFactory();
    final AppInfo appInfo = factory.configureApplication(file);
    final EjbJarInfo ejbJarInfo = appInfo.ejbJars.get(0);
    assertEquals("orange", ejbJarInfo.moduleName);
}
Also used : HashMap(java.util.HashMap) Assembler(org.apache.openejb.assembler.classic.Assembler) File(java.io.File) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) AppInfo(org.apache.openejb.assembler.classic.AppInfo) Test(org.junit.Test)

Example 23 with AppInfo

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

the class EjbModuleIdTest method testInvalidNames.

/**
     * OPENEJB-1366
     *
     * @throws Exception
     */
@Test
public void testInvalidNames() throws Exception {
    final Map<String, String> map = new HashMap<String, String>();
    map.put("META-INF/ejb-jar.xml", "<ejb-jar/>");
    final List<String> dirs = new ArrayList<String>();
    dirs.add("orangeDir");
    // invalid
    dirs.add("classes");
    // invalid
    dirs.add("test-classes");
    // invalid
    dirs.add("target");
    // invalid
    dirs.add("build");
    // invalid
    dirs.add("dist");
    // invalid
    dirs.add("bin");
    final File file = Archives.fileArchive(map, dirs, OrangeBean.class);
    final Assembler assembler = new Assembler();
    final ConfigurationFactory factory = new ConfigurationFactory();
    final AppInfo appInfo = factory.configureApplication(file);
    final EjbJarInfo ejbJarInfo = appInfo.ejbJars.get(0);
    assertEquals("orangeDir", ejbJarInfo.moduleName);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Assembler(org.apache.openejb.assembler.classic.Assembler) File(java.io.File) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) AppInfo(org.apache.openejb.assembler.classic.AppInfo) Test(org.junit.Test)

Example 24 with AppInfo

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

the class EarModuleNamesTest method testModuleNameEjbJar.

@Test
public void testModuleNameEjbJar() throws Exception {
    final File appsDir = Files.tmpdir();
    final Assembler assembler = new Assembler();
    final ConfigurationFactory factory = new ConfigurationFactory();
    final File ear = new File(appsDir, "testModuleNameEjbJar.ear");
    final Map<String, Object> contents = new HashMap<String, Object>();
    final Map<String, Object> metaInf = new HashMap<String, Object>();
    metaInf.put("META-INF/ejb-jar.xml", "<ejb-jar><module-name>orange</module-name></ejb-jar>");
    final File ejbJar = Archives.jarArchive(metaInf, "orange", Orange.class);
    contents.put("green.jar", ejbJar);
    Archives.jarArchive(ear, contents);
    final AppInfo appInfo = factory.configureApplication(ear);
    assertEquals(appInfo.ejbJars.size(), 1);
    assertEquals("orange", 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)

Example 25 with AppInfo

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

AppInfo (org.apache.openejb.assembler.classic.AppInfo)106 File (java.io.File)50 Assembler (org.apache.openejb.assembler.classic.Assembler)46 Test (org.junit.Test)31 HashMap (java.util.HashMap)29 WebAppInfo (org.apache.openejb.assembler.classic.WebAppInfo)25 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)16 OpenEJBException (org.apache.openejb.OpenEJBException)15 AppModule (org.apache.openejb.config.AppModule)14 Map (java.util.Map)13 EjbJar (org.apache.openejb.jee.EjbJar)13 ContainerSystem (org.apache.openejb.spi.ContainerSystem)13 Properties (java.util.Properties)10 EjbModule (org.apache.openejb.config.EjbModule)10 Persistence (org.apache.openejb.jee.jpa.unit.Persistence)10 ArrayList (java.util.ArrayList)9 PersistenceUnit (org.apache.openejb.jee.jpa.unit.PersistenceUnit)9 IOException (java.io.IOException)8 URL (java.net.URL)8 InitialContext (javax.naming.InitialContext)8