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);
}
Aggregations