Search in sources :

Example 86 with AppInfo

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

the class AltDDPrefixTest method testPersistenceUnitWithAllDD.

/**
 * OPENEJB-1059: altdd does not work with a persistence.xml when no embedded
 * in EjbModule/Client module.
 *
 * @throws Exception if something wrong happen
 */
public void testPersistenceUnitWithAllDD() throws Exception {
    System.out.println("*** testPersistenceUnitWithAllDD ***");
    final Assembler assmbler = new Assembler();
    // TODO should be better to add a remove property method
    SystemInstance.get().getProperties().remove("openejb.altdd.prefix");
    DeploymentLoader.reloadAltDD();
    final ConfigurationFactory factory = new ConfigurationFactory();
    final URL resource = AltDDPrefixTest.class.getClassLoader().getResource("altddPU1");
    final File file = URLs.toFile(resource);
    final AppInfo appInfo = factory.configureApplication(file);
    assertNotNull(appInfo);
    assertEquals(0, appInfo.ejbJars.size());
    assertEquals(1, appInfo.persistenceUnits.size());
    final PersistenceUnitInfo info = appInfo.persistenceUnits.get(0);
    // a space must be present before hashcode
    assertTrue(info.id.startsWith("unit "));
}
Also used : Assembler(org.apache.openejb.assembler.classic.Assembler) File(java.io.File) PersistenceUnitInfo(org.apache.openejb.assembler.classic.PersistenceUnitInfo) URL(java.net.URL) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 87 with AppInfo

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

the class AppPathsTest method _testMixedCaseMetaInf.

/**
 * Seems like this may not be a feature that can be supported on
 * all platforms.  Seems to work on the mac VM, but not the linux vm.
 *
 * @throws Exception
 */
public void _testMixedCaseMetaInf() throws Exception {
    final Assembler assmbler = new Assembler();
    final ConfigurationFactory factory = new ConfigurationFactory();
    final URL resource = AppPathsTest.class.getClassLoader().getResource("mixedcase");
    final File file = URLs.toFile(resource);
    final AppInfo appInfo = factory.configureApplication(file);
    assertNotNull(appInfo);
    assertEquals(1, appInfo.ejbJars.size());
    final EjbJarInfo ejbJar = appInfo.ejbJars.get(0);
    // was the footest.ejb-jar.xml picked up
    assertEquals("EjbJar.enterpriseBeans", 1, ejbJar.enterpriseBeans.size());
}
Also used : Assembler(org.apache.openejb.assembler.classic.Assembler) File(java.io.File) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) URL(java.net.URL) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 88 with AppInfo

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

the class ApplicationPropertiesTest method testConflictingFiles.

/**
 * A child module META-INF/application.properties sets color to white
 * <p/>
 * In the root ear META-INF/application.properties color is set to orange
 * <p/>
 * The root ear META-INF/application.properties wins
 *
 * @throws Exception
 */
public void testConflictingFiles() 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> moduleFiles = new HashMap<String, String>();
        moduleFiles.put("META-INF/ejb-jar.xml", "<ejb-jar id=\"fooModule\"/>");
        moduleFiles.put("META-INF/application.properties", "color=white");
        final File module = Archives.jarArchive(moduleFiles, "fooModule", WidgetBean.class);
        final Map<String, String> appFiles = new HashMap<String, String>();
        appFiles.put("META-INF/application.xml", "" + "<application id=\"fooApp\">\n" + "  <module>\n" + "    <ejb>" + module.getName() + "</ejb>\n" + "  </module>\n" + "</application>");
        appFiles.put("META-INF/application.properties", "color=orange");
        final File app = Archives.fileArchive(appFiles);
        assertTrue(module.renameTo(new File(app, module.getName())));
        final AppInfo appInfo = config.configureApplication(app);
        assembler.createApplication(appInfo);
    }
    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) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 89 with AppInfo

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

the class ApplicationPropertiesTest method testOverrideReplace.

public void testOverrideReplace() 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("fooApp.color", "orange");
        final Map<String, String> map = new HashMap<String, String>();
        map.put("META-INF/ejb-jar.xml", "<ejb-jar id=\"fooModule\"/>");
        map.put("META-INF/application.properties", "color=white");
        final File module = Archives.fileArchive(map, WidgetBean.class);
        final AppModule appModule = config.loadApplication(this.getClass().getClassLoader(), "fooApp", Arrays.asList(module));
        final AppInfo appInfo = config.configureApplication(appModule);
        assembler.createApplication(appInfo);
    }
    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) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 90 with AppInfo

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

the class ApplicationPropertiesTest method testOverrideUnprefixedVsPrefixedTomEE.

public void testOverrideUnprefixedVsPrefixedTomEE() 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("tomee.fooApp.color", "orange");
        SystemInstance.get().getProperties().put("fooApp.color", "green");
        final Map<String, String> map = new HashMap<String, String>();
        map.put("META-INF/ejb-jar.xml", "<ejb-jar id=\"fooModule\"/>");
        final File module = Archives.fileArchive(map, WidgetBean.class);
        final AppModule appModule = config.loadApplication(this.getClass().getClassLoader(), "fooApp", Arrays.asList(module));
        final AppInfo appInfo = config.configureApplication(appModule);
        assembler.createApplication(appInfo);
    }
    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) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Aggregations

AppInfo (org.apache.openejb.assembler.classic.AppInfo)109 File (java.io.File)49 Assembler (org.apache.openejb.assembler.classic.Assembler)49 Test (org.junit.Test)31 HashMap (java.util.HashMap)29 WebAppInfo (org.apache.openejb.assembler.classic.WebAppInfo)25 EjbJar (org.apache.openejb.jee.EjbJar)17 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)16 ContainerSystem (org.apache.openejb.spi.ContainerSystem)15 OpenEJBException (org.apache.openejb.OpenEJBException)14 AppModule (org.apache.openejb.config.AppModule)14 Map (java.util.Map)12 EjbModule (org.apache.openejb.config.EjbModule)11 Properties (java.util.Properties)10 Persistence (org.apache.openejb.jee.jpa.unit.Persistence)10 ArrayList (java.util.ArrayList)9 InitialContext (javax.naming.InitialContext)9 StatelessBean (org.apache.openejb.jee.StatelessBean)9 PersistenceUnit (org.apache.openejb.jee.jpa.unit.PersistenceUnit)9 IOException (java.io.IOException)8