Search in sources :

Example 6 with EnvEntryInfo

use of org.apache.openejb.assembler.classic.EnvEntryInfo in project tomee by apache.

the class CleanEnvEntriesTest method test.

@Test
public void test() throws Exception {
    final Assembler assembler = new Assembler();
    final ConfigurationFactory factory = new ConfigurationFactory();
    final SingletonBean singletonBean = new SingletonBean(Blue.class);
    // keep
    singletonBean.getEnvEntry().add(new EnvEntry().name("message").type(String.class).value("hello").injectionTarget(Blue.class, "message"));
    // remove
    singletonBean.getEnvEntry().add(new EnvEntry().name("novalue1").type(String.class));
    singletonBean.getEnvEntry().add(new EnvEntry().name("novalue2"));
    // fill in type
    singletonBean.getEnvEntry().add(new EnvEntry().name("value-but-no-type1").value("10").injectionTarget(Blue.class, "number").injectionTarget(Orange.class, // attempt to confuse the type
    "number"));
    singletonBean.getEnvEntry().add(new EnvEntry().name("value-but-no-type2").value("D").injectionTarget(Blue.class, "letter"));
    singletonBean.getEnvEntry().add(new EnvEntry().name("value-but-no-type3").value("2").injectionTarget(Blue.class, // short
    "vague").injectionTarget(Orange.class, // character
    "vague"));
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(singletonBean);
    final EjbJarInfo ejbJarInfo = factory.configureApplication(ejbJar);
    final Map<String, EnvEntryInfo> entries = map(ejbJarInfo.enterpriseBeans.get(0).jndiEnc.envEntries);
    assertNotNull(entries.get("comp/env/message"));
    assertNotNull(entries.get("comp/env/value-but-no-type1"));
    assertNotNull(entries.get("comp/env/value-but-no-type2"));
    assertNull(entries.get("comp/env/novalue1"));
    assertNull(entries.get("comp/env/novalue2"));
    assertEquals(Integer.class.getName(), entries.get("comp/env/value-but-no-type1").type);
    assertEquals(Character.class.getName(), entries.get("comp/env/value-but-no-type2").type);
    assertEquals(String.class.getName(), entries.get("comp/env/value-but-no-type3").type);
}
Also used : EnvEntryInfo(org.apache.openejb.assembler.classic.EnvEntryInfo) SingletonBean(org.apache.openejb.jee.SingletonBean) Assembler(org.apache.openejb.assembler.classic.Assembler) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EnvEntry(org.apache.openejb.jee.EnvEntry) EjbJar(org.apache.openejb.jee.EjbJar) Test(org.junit.Test)

Aggregations

EnvEntryInfo (org.apache.openejb.assembler.classic.EnvEntryInfo)6 EnvEntry (org.apache.openejb.jee.EnvEntry)3 Assembler (org.apache.openejb.assembler.classic.Assembler)2 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)2 PersistenceContextReferenceInfo (org.apache.openejb.assembler.classic.PersistenceContextReferenceInfo)2 PersistenceUnitReferenceInfo (org.apache.openejb.assembler.classic.PersistenceUnitReferenceInfo)2 ResourceReferenceInfo (org.apache.openejb.assembler.classic.ResourceReferenceInfo)2 EjbJar (org.apache.openejb.jee.EjbJar)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 PersistenceUnit (javax.persistence.PersistenceUnit)1 NamingResourcesImpl (org.apache.catalina.deploy.NamingResourcesImpl)1 AppInfo (org.apache.openejb.assembler.classic.AppInfo)1 EjbLocalReferenceInfo (org.apache.openejb.assembler.classic.EjbLocalReferenceInfo)1 EjbReferenceInfo (org.apache.openejb.assembler.classic.EjbReferenceInfo)1 EnterpriseBeanInfo (org.apache.openejb.assembler.classic.EnterpriseBeanInfo)1 JndiEncInfo (org.apache.openejb.assembler.classic.JndiEncInfo)1 ResourceEnvReferenceInfo (org.apache.openejb.assembler.classic.ResourceEnvReferenceInfo)1 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)1 ServiceReferenceInfo (org.apache.openejb.assembler.classic.ServiceReferenceInfo)1