use of org.apache.openejb.assembler.classic.OpenEjbConfiguration in project tomee by apache.
the class AutoDeployerTest method test.
@Test
public void test() 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("openejb.deployment.unpack.location", "false");
properties.setProperty("openejb.home", tmpdir.getAbsolutePath());
properties.setProperty("openejb.base", tmpdir.getAbsolutePath());
properties.setProperty("openejb.autodeploy.interval", "2 seconds");
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");
// Hot deploy the EAR
final File ear = createEar(tmpdir, Orange.class, State.class);
IO.copy(ear, deployed);
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 AutoDeployerTest method testSpaces.
@Test
public void testSpaces() throws Exception {
final File tmpdir = new File(Files.tmpdir(), "with spaces");
final File apps = Files.mkdir(tmpdir, "my apps");
final File conf = Files.mkdir(tmpdir, "conf");
files.add(apps);
final Properties properties = new Properties();
properties.setProperty("openejb.deployments.classpath", "false");
properties.setProperty("openejb.deployment.unpack.location", "false");
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=\"my apps\"/> </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("my apps", 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");
// Hot deploy the EAR
final File ear = createEar(tmpdir, Orange.class, State.class);
IO.copy(ear, deployed);
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 AutoDeployerTest method testOriginalAppScanning.
@Test
public void testOriginalAppScanning() 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("openejb.deployment.unpack.location", "false");
properties.setProperty("openejb.home", tmpdir.getAbsolutePath());
properties.setProperty("openejb.base", tmpdir.getAbsolutePath());
properties.setProperty("openejb.autodeploy.interval", "2 seconds");
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 File deployed = Files.path(apps, "colors.ear");
final File ear = createEar(tmpdir, Orange.class, State.class);
IO.copy(ear, deployed);
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);
assertTrue(Orange.deployed);
final long start = Orange.start;
assertFalse(Yellow.deployed);
assertTrue(Orange.deployed);
// wait another to ensure it doesnt redeploy again
Thread.sleep(4000);
assertEquals(start, Orange.start);
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 testConfigurationFactoryBooleanOpenEjbConfiguration.
@Test
public void testConfigurationFactoryBooleanOpenEjbConfiguration() throws OpenEJBException {
final boolean offline = false;
final OpenEjbConfiguration openEjbConfiguration = new OpenEjbConfiguration();
final ConfigurationFactory factory = new ConfigurationFactory(offline, openEjbConfiguration);
assertEquals(openEjbConfiguration, factory.getOpenEjbConfiguration());
}
use of org.apache.openejb.assembler.classic.OpenEjbConfiguration in project tomee by apache.
the class ConfigurationFactoryTest method testGetOpenEJBConfigurationInitedAndNewResource.
@Test
public void testGetOpenEJBConfigurationInitedAndNewResource() throws Exception {
SystemInstance.get().setProperty(ConfigurationFactory.VALIDATION_SKIP_PROPERTY, "true");
SystemInstance.get().setProperty(DeploymentsResolver.SEARCH_CLASSPATH_FOR_DEPLOYMENTS_PROPERTY, "false");
SystemInstance.get().setProperty("newDeployment", "new://Deployments?dir=irrelevant");
final ConfigurationFactory factory = new ConfigurationFactory();
final Properties props = new Properties();
final URL configUrl = this.getClass().getClassLoader().getResource("org/apache/openejb/config/configurationfactory-openejb.xml");
props.setProperty(ConfigurationFactory.CONF_FILE_PROPERTY, configUrl.toExternalForm());
factory.init(props);
final OpenEjbConfiguration openEjbConfig = factory.getOpenEjbConfiguration();
assertEquals(0, openEjbConfig.containerSystem.applications.size());
}
Aggregations