use of org.apache.openejb.assembler.classic.OpenEjbConfiguration 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.OpenEjbConfiguration in project tomee by apache.
the class AutoDeployerTest method testAltUnpackDir.
@Test
public void testAltUnpackDir() throws Exception {
final File tmpdir = Files.tmpdir();
final File apps = Files.mkdir(tmpdir, "myapps");
final File conf = Files.mkdir(tmpdir, "conf");
files.add(apps);
final Properties properties = new Properties();
properties.setProperty("openejb.deployments.classpath", "false");
properties.setProperty("tomee.unpack.dir", "work");
properties.setProperty("openejb.home", tmpdir.getAbsolutePath());
properties.setProperty("openejb.base", tmpdir.getAbsolutePath());
SystemInstance.init(properties);
{
// Setup the configuration location
final File config = new File(conf, "openejb.xml");
IO.writeString(config, "<openejb><Deployments autoDeploy=\"true\" dir=\"myapps\"/> </openejb>");
SystemInstance.get().setProperty("openejb.configuration", config.getAbsolutePath());
}
final ConfigurationFactory configurationFactory = new ConfigurationFactory();
configurationFactory.init(properties);
final OpenEjbConfiguration configuration = configurationFactory.getOpenEjbConfiguration();
{
// Check the ContainerSystemInfo
final List<String> autoDeploy = configuration.containerSystem.autoDeploy;
assertEquals(1, autoDeploy.size());
assertEquals("myapps", autoDeploy.get(0));
}
final Assembler assembler = new Assembler();
assembler.buildContainerSystem(configuration);
/// start with the testing...
assertFalse(Yellow.deployed);
assertFalse(Orange.deployed);
final File deployed = Files.path(apps, "colors.ear");
deployed.deleteOnExit();
// Hot deploy the EAR
final File ear = createEar(tmpdir, Orange.class, State.class);
ear.deleteOnExit();
IO.copy(ear, deployed);
assertTrue(deployed.exists());
Orange.state.waitForChange(1, TimeUnit.MINUTES);
assertFalse(Yellow.deployed);
assertTrue(Orange.deployed);
Files.delete(deployed);
Orange.state.waitForChange(1, TimeUnit.MINUTES);
assertFalse(Yellow.deployed);
assertFalse(Orange.deployed);
}
use of org.apache.openejb.assembler.classic.OpenEjbConfiguration in project tomee by apache.
the class ConfigurationFactoryTest method testGetOpenEjbConfiguration.
@Test
public void testGetOpenEjbConfiguration() throws OpenEJBException {
SystemInstance.get().setProperty(ConfigurationFactory.VALIDATION_SKIP_PROPERTY, "false");
SystemInstance.get().setProperty(DeploymentsResolver.SEARCH_CLASSPATH_FOR_DEPLOYMENTS_PROPERTY, "false");
final boolean offline = false;
final ConfigurationFactory factory = new ConfigurationFactory(offline);
final OpenEjbConfiguration openEjbConfig = factory.getOpenEjbConfiguration();
// again, not much to assert
assertEquals(0, openEjbConfig.containerSystem.applications.size());
}
use of org.apache.openejb.assembler.classic.OpenEjbConfiguration in project tomee by apache.
the class AutoConfigPersistenceUnitsTest method setUp.
protected void setUp() throws Exception {
System.setProperty(LocalMBeanServer.OPENEJB_JMX_ACTIVE, "false");
System.setProperty("openejb.environment.default", "false");
config = new ConfigurationFactory();
assembler = new Assembler();
assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
final OpenEjbConfiguration configuration = SystemInstance.get().getComponent(OpenEjbConfiguration.class);
resources = configuration.facilities.resources;
}
use of org.apache.openejb.assembler.classic.OpenEjbConfiguration in project tomee by apache.
the class WebServiceInjectionConfigurator method createServiceInfos.
private List<ServiceInfo> createServiceInfos(final Properties properties) {
final OpenEjbConfiguration config = SystemInstance.get().getComponent(OpenEjbConfiguration.class);
final List<ServiceInfo> services = new ArrayList<>(config.facilities != null && config.facilities.services != null ? config.facilities.services : Collections.<ServiceInfo>emptyList());
services.addAll(getServices(properties));
return services;
}
Aggregations