use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class AutoConfigPersistenceUnitsTest method testFromWebAppIdJta.
/**
* Existing data source "orange-web", jta managed
* <p/>
* Application contains a web module with id "orange-id"
* <p/>
* Persistence xml like so:
* <p/>
* <persistence-unit name="orange-unit" />
* <p/>
* The orange-unit app should automatically use orange-id data source and create a new non-JtaManaged datasource
*
* @throws Exception
*/
public void testFromWebAppIdJta() throws Exception {
final ResourceInfo supplied = addDataSource("orange-id", OrangeDriver.class, "jdbc:orange-web:some:stuff", true);
assertSame(supplied, resources.get(0));
final PersistenceUnit persistenceUnit = new PersistenceUnit("orange-unit");
final ClassLoader cl = this.getClass().getClassLoader();
final AppModule app = new AppModule(cl, "orange-app");
app.addPersistenceModule(new PersistenceModule("root", new Persistence(persistenceUnit)));
final WebApp webApp = new WebApp();
webApp.setMetadataComplete(true);
app.getWebModules().add(new WebModule(webApp, "orange-web", cl, "war", "orange-id"));
// Create app
final AppInfo appInfo = config.configureApplication(app);
assembler.createApplication(appInfo);
// Check results
final ResourceInfo generated = resources.get(1);
assertEquals(supplied.id + "NonJta", generated.id);
assertEquals(supplied.service, generated.service);
assertEquals(supplied.className, generated.className);
assertEquals(supplied.properties.get("JdbcDriver"), generated.properties.get("JdbcDriver"));
assertEquals(supplied.properties.get("JdbcUrl"), generated.properties.get("JdbcUrl"));
assertEquals("false", generated.properties.get("JtaManaged"));
}
use of org.apache.openejb.assembler.classic.AppInfo in project tomee by apache.
the class DeploymentsElementTest method deploymentsFile_and_Dir_Jars_Order.
/**
* <Deployments dir="myapps/2000.jar"/>
* <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 deploymentsFile_and_Dir_Jars_Order() 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");
Archives.jarArchive(jar, null, Yellow.class);
}
{
// Jar two
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);
}
use of org.apache.openejb.assembler.classic.AppInfo 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);
}
use of org.apache.openejb.assembler.classic.AppInfo 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);
}
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);
}
Aggregations