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);
}
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);
}
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);
}
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());
}
}
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());
}
}
Aggregations