Search in sources :

Example 6 with Openejb

use of org.apache.openejb.config.sys.Openejb in project tomee by apache.

the class JSonConfigTest method simpleRead.

@Test
public void simpleRead() throws IOException, OpenEJBException {
    final Openejb openejb = JSonConfigReader.read(Openejb.class, Thread.currentThread().getContextClassLoader().getResource(config()).openStream());
    assertEquals(1, openejb.getResource().size());
    final Resource resource = openejb.getResource().iterator().next();
    assertEquals("json-datasource", resource.getId());
    assertTrue("123".equals(resource.getProperties().getProperty("MaxTotal")));
    assertTrue("jdbc:hsqldb:mem:json".equals(resource.getProperties().getProperty("JdbcUrl")));
    assertEquals(1, openejb.getDeployments().size());
    assertEquals("apps", openejb.getDeployments().iterator().next().getDir());
    assertEquals(1, openejb.getContainer().size());
    final Container container = openejb.getContainer().iterator().next();
    assertEquals("STATELESS", container.getType());
    assertEquals("10 seconds", container.getProperties().getProperty("AccessTimeout"));
}
Also used : Container(org.apache.openejb.config.sys.Container) Resource(org.apache.openejb.config.sys.Resource) AppResource(org.apache.openejb.testing.AppResource) Openejb(org.apache.openejb.config.sys.Openejb) Test(org.junit.Test)

Example 7 with Openejb

use of org.apache.openejb.config.sys.Openejb in project tomee by apache.

the class AliasesFromXmlTest method ensureAliasesAreParsed.

@Test
public void ensureAliasesAreParsed() throws IOException, SAXException, ParserConfigurationException {
    final String xml = "<?xml version=\"1.0\"?>" + "<openejb>" + "   <Resource id=\"foo\" aliases=\"bar\" type=\"DataSource\" />" + "</openejb>";
    final Openejb openejb = JaxbOpenejb.readConfig(new InputSource(new ByteArrayInputStream(xml.getBytes())));
    assertEquals(1, openejb.getResource().size());
    final Resource resource = openejb.getResource().iterator().next();
    assertEquals(1, resource.getAliases().size());
    assertEquals("foo", resource.getId());
    assertEquals("bar", resource.getAliases().iterator().next());
}
Also used : InputSource(org.xml.sax.InputSource) ByteArrayInputStream(java.io.ByteArrayInputStream) Resource(org.apache.openejb.config.sys.Resource) Openejb(org.apache.openejb.config.sys.Openejb) JaxbOpenejb(org.apache.openejb.config.sys.JaxbOpenejb) Test(org.junit.Test)

Aggregations

Openejb (org.apache.openejb.config.sys.Openejb)7 JaxbOpenejb (org.apache.openejb.config.sys.JaxbOpenejb)4 Resource (org.apache.openejb.config.sys.Resource)4 Test (org.junit.Test)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 OpenEJBException (org.apache.openejb.OpenEJBException)2 OpenEJBRuntimeException (org.apache.openejb.OpenEJBRuntimeException)2 Assembler (org.apache.openejb.assembler.classic.Assembler)2 ResourceInfo (org.apache.openejb.assembler.classic.ResourceInfo)2 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)2 InputSource (org.xml.sax.InputSource)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileWriter (java.io.FileWriter)1 InputStream (java.io.InputStream)1 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 URL (java.net.URL)1 Arrays.asList (java.util.Arrays.asList)1 HashMap (java.util.HashMap)1