Search in sources :

Example 26 with OpenEjbConfiguration

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);
}
Also used : List(java.util.List) Assembler(org.apache.openejb.assembler.classic.Assembler) Properties(java.util.Properties) File(java.io.File) OpenEjbConfiguration(org.apache.openejb.assembler.classic.OpenEjbConfiguration) Test(org.junit.Test)

Example 27 with OpenEjbConfiguration

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);
}
Also used : List(java.util.List) Assembler(org.apache.openejb.assembler.classic.Assembler) Properties(java.util.Properties) File(java.io.File) OpenEjbConfiguration(org.apache.openejb.assembler.classic.OpenEjbConfiguration) Test(org.junit.Test)

Example 28 with OpenEjbConfiguration

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);
}
Also used : List(java.util.List) Assembler(org.apache.openejb.assembler.classic.Assembler) Properties(java.util.Properties) File(java.io.File) OpenEjbConfiguration(org.apache.openejb.assembler.classic.OpenEjbConfiguration) Test(org.junit.Test)

Example 29 with OpenEjbConfiguration

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());
}
Also used : OpenEjbConfiguration(org.apache.openejb.assembler.classic.OpenEjbConfiguration) Test(org.junit.Test)

Example 30 with OpenEjbConfiguration

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());
}
Also used : Properties(java.util.Properties) URL(java.net.URL) OpenEjbConfiguration(org.apache.openejb.assembler.classic.OpenEjbConfiguration) Test(org.junit.Test)

Aggregations

OpenEjbConfiguration (org.apache.openejb.assembler.classic.OpenEjbConfiguration)37 Test (org.junit.Test)24 File (java.io.File)23 Map (java.util.Map)9 Properties (java.util.Properties)9 HashMap (java.util.HashMap)8 ArrayList (java.util.ArrayList)7 Assembler (org.apache.openejb.assembler.classic.Assembler)7 AppInfo (org.apache.openejb.assembler.classic.AppInfo)6 List (java.util.List)5 ResourceInfo (org.apache.openejb.assembler.classic.ResourceInfo)4 BmpEntityContainerInfo (org.apache.openejb.assembler.classic.BmpEntityContainerInfo)3 CmpEntityContainerInfo (org.apache.openejb.assembler.classic.CmpEntityContainerInfo)3 ContainerInfo (org.apache.openejb.assembler.classic.ContainerInfo)3 ManagedContainerInfo (org.apache.openejb.assembler.classic.ManagedContainerInfo)3 MdbContainerInfo (org.apache.openejb.assembler.classic.MdbContainerInfo)3 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)3 ServiceInfo (org.apache.openejb.assembler.classic.ServiceInfo)3 SingletonSessionContainerInfo (org.apache.openejb.assembler.classic.SingletonSessionContainerInfo)3 StatefulSessionContainerInfo (org.apache.openejb.assembler.classic.StatefulSessionContainerInfo)3