use of org.apache.openejb.assembler.classic.EnterpriseBeanInfo in project tomee by apache.
the class BusinessInterfacesTest method testYellow.
public void testYellow() throws Exception {
// Results should be the same with strict on or off
for (final boolean strict : Arrays.asList(false, true)) {
setUp();
strict(strict);
final Map<String, EnterpriseBeanInfo> beans = deploy(YellowOneBean.class, YellowTwoBean.class, YellowThreeBean.class, YellowFourBean.class, YellowFiveBean.class, YellowSixBean.class);
EnterpriseBeanInfo beanInfo;
beanInfo = beans.get("YellowOneBean");
assertEquals(list(YellowOneLocal.class), sort(beanInfo.businessLocal));
assertEquals(list(), sort(beanInfo.businessRemote));
assertFalse(beanInfo.localbean);
beanInfo = beans.get("YellowTwoBean");
assertEquals(list(), sort(beanInfo.businessLocal));
assertEquals(list(YellowTwoRemote.class), sort(beanInfo.businessRemote));
assertFalse(beanInfo.localbean);
beanInfo = beans.get("YellowThreeBean");
assertEquals(list(YellowThreeUnspecified.class), sort(beanInfo.businessLocal));
assertEquals(list(), sort(beanInfo.businessRemote));
assertFalse(beanInfo.localbean);
beanInfo = beans.get("YellowFourBean");
assertEquals(list(YellowFourLocal.class), sort(beanInfo.businessLocal));
assertEquals(list(), sort(beanInfo.businessRemote));
assertFalse(beanInfo.localbean);
beanInfo = beans.get("YellowFiveBean");
assertEquals(list(), sort(beanInfo.businessLocal));
assertEquals(list(YellowFiveRemote.class), sort(beanInfo.businessRemote));
assertFalse(beanInfo.localbean);
beanInfo = beans.get("YellowSixBean");
assertEquals(list(), sort(beanInfo.businessLocal));
assertEquals(list(), sort(beanInfo.businessRemote));
assertTrue(beanInfo.localbean);
}
}
use of org.apache.openejb.assembler.classic.EnterpriseBeanInfo in project tomee by apache.
the class BusinessInterfacesTest method testCrimsonStrict.
/**
* Test results should NOT be the same as above. Super class should not be consulted
*
* @throws Exception
*/
public void testCrimsonStrict() throws Exception {
strict(true);
final Map<String, EnterpriseBeanInfo> beans = deploy(CrimsonOneBean.class, CrimsonTwoBean.class);
EnterpriseBeanInfo beanInfo = beans.get("CrimsonOneBean");
assertEquals(list(), sort(beanInfo.businessLocal));
assertEquals(list(), sort(beanInfo.businessRemote));
assertTrue(beanInfo.localbean);
beanInfo = beans.get("CrimsonTwoBean");
assertEquals(list(), sort(beanInfo.businessLocal));
assertEquals(list(), sort(beanInfo.businessRemote));
assertTrue(beanInfo.localbean);
}
use of org.apache.openejb.assembler.classic.EnterpriseBeanInfo in project tomee by apache.
the class BusinessInterfacesTest method testRedStrict.
/**
* Test results should be the same as above.
*
* @throws Exception
*/
public void testRedStrict() throws Exception {
strict(true);
final Map<String, EnterpriseBeanInfo> beans = deploy(RedOneBean.class, RedTwoBean.class);
EnterpriseBeanInfo beanInfo = beans.get("RedOneBean");
assertEquals(list(RedOneLocal.class), sort(beanInfo.businessLocal));
assertEquals(list(RedOneRemote.class, RedOneOverridden.class), sort(beanInfo.businessRemote));
beanInfo = beans.get("RedTwoBean");
assertEquals(list(RedTwoLocal.class, RedTwoOverridden.class), sort(beanInfo.businessLocal));
assertEquals(list(RedTwoRemote.class), sort(beanInfo.businessRemote));
}
use of org.apache.openejb.assembler.classic.EnterpriseBeanInfo in project tomee by apache.
the class UberInterfaceTest method test.
public void test() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
final EjbJar ejbJar = new EjbJar();
final StatelessBean bean = ejbJar.addEnterpriseBean(new StatelessBean(SuperBean.class));
final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
final EnterpriseBeanInfo beanInfo = ejbJarInfo.enterpriseBeans.get(0);
assertEquals(asList(Everything.class.getName()), beanInfo.businessLocal);
assertEquals(asList(Everything.class.getName()), beanInfo.businessRemote);
assertEquals(Everything.class.getName(), beanInfo.serviceEndpoint);
assembler.createApplication(ejbJarInfo);
final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
final BeanContext deployment = containerSystem.getBeanContext(beanInfo.ejbDeploymentId);
assertEquals(asList(Everything.class), deployment.getBusinessLocalInterfaces());
assertEquals(asList(Everything.class), deployment.getBusinessRemoteInterfaces());
assertEquals(Everything.class, deployment.getServiceEndpointInterface());
final InitialContext context = new InitialContext();
final Everything local = (Everything) context.lookup("SuperBeanLocal");
final Everything remote = (Everything) context.lookup("SuperBeanRemote");
final Reference reference = new Reference("test");
assertEquals(reference, local.echo(reference));
// pass by reference
assertSame(reference, local.echo(reference));
assertEquals(reference, remote.echo(reference));
// pass by value
assertNotSame(reference, remote.echo(reference));
}
use of org.apache.openejb.assembler.classic.EnterpriseBeanInfo in project tomee by apache.
the class XmlOverridesTest method test.
public void test() throws Exception {
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
final EjbJar ejbJar = new EjbJar();
final StatefulBean bean = ejbJar.addEnterpriseBean(new StatefulBean(AnnotatedBean.class));
bean.getEjbLocalRef().add(new EjbLocalRef(name("annotatedLocal"), "BarBean"));
bean.getEnvEntry().add(new EnvEntry(name("striing"), "java.lang.Integer", "2"));
bean.getEnvEntry().add(new EnvEntry(name("doouble"), "java.lang.String", "two"));
bean.getEnvEntry().add(new EnvEntry(name("loong"), "java.lang.String", "three"));
bean.getEnvEntry().add(new EnvEntry(name("flooat"), "java.lang.String", "four"));
bean.getEnvEntry().add(new EnvEntry(name("inteeger"), "java.lang.String", "five"));
bean.getEnvEntry().add(new EnvEntry(name("shoort"), "java.lang.String", "six"));
bean.getEnvEntry().add(new EnvEntry(name("booolean"), "java.lang.String", "seven"));
bean.getEnvEntry().add(new EnvEntry(name("byyte"), "java.lang.String", "eight"));
bean.getEnvEntry().add(new EnvEntry(name("chaaracter"), "java.lang.String", "nine"));
final EnvEntry lookupEntry = new EnvEntry(name("lookup"), "java.lang.String", null);
lookupEntry.setLookupName("java:app/AppName");
bean.getEnvEntry().add(lookupEntry);
bean.getResourceRef().add(new ResourceRef(name("daataSource"), DataSource.class.getName(), ResAuth.CONTAINER, ResSharingScope.SHAREABLE));
bean.getPersistenceUnitRef().add(new PersistenceUnitRef(name("emf"), "yellow"));
bean.getPersistenceContextRef().add(new PersistenceContextRef(name("em"), "yellow", PersistenceContextType.TRANSACTION, new ArrayList(Arrays.asList(new Property("zzzz", "AAAA")))));
final org.apache.openejb.jee.jpa.unit.PersistenceUnit persistenceUnit = new org.apache.openejb.jee.jpa.unit.PersistenceUnit("yellow");
final AppModule app = new AppModule(this.getClass().getClassLoader(), "app");
app.getEjbModules().add(new EjbModule(ejbJar));
app.addPersistenceModule(new PersistenceModule("root", new Persistence(persistenceUnit)));
final AppInfo appInfo = config.configureApplication(app);
final EjbJarInfo ejbJarInfo = appInfo.ejbJars.get(0);
final EnterpriseBeanInfo beanInfo = ejbJarInfo.enterpriseBeans.get(0);
final JndiEncInfo enc = beanInfo.jndiEnc;
assertEquals("Enc.ejbLocalReferences.size()", 1, enc.ejbLocalReferences.size());
assertEquals("Enc.ejbLocalReferences.get(0).link", "BarBean", enc.ejbLocalReferences.get(0).link);
assertEquals("Enc.ejbReferences.size()", 0, enc.ejbReferences.size());
// 10 + ComponentName
assertEquals("Enc.envEntries.size()", 11, enc.envEntries.size());
final Map<String, EnvEntryInfo> entries = map(enc.envEntries);
assertEnvEntry(entries, name("striing"), "java.lang.Integer", "2");
assertEnvEntry(entries, name("doouble"), "java.lang.String", "two");
assertEnvEntry(entries, name("loong"), "java.lang.String", "three");
assertEnvEntry(entries, name("flooat"), "java.lang.String", "four");
assertEnvEntry(entries, name("inteeger"), "java.lang.String", "five");
assertEnvEntry(entries, name("shoort"), "java.lang.String", "six");
assertEnvEntry(entries, name("booolean"), "java.lang.String", "seven");
assertEnvEntry(entries, name("byyte"), "java.lang.String", "eight");
assertEnvEntry(entries, name("chaaracter"), "java.lang.String", "nine");
assertEnvEntryLookup(entries, name("lookup"), "java.lang.String", "java:app/AppName");
assertEquals("Enc.persistenceContextRefs.size()", 1, enc.persistenceContextRefs.size());
final PersistenceContextReferenceInfo context = enc.persistenceContextRefs.get(0);
assertEquals("Context.extended", false, context.extended);
assertEquals("Context.persistenceUnitName", "yellow", context.persistenceUnitName);
assertEquals("Context.properties.size()", 1, context.properties.size());
assertEquals("Context.properties.getProperty(\"zzzz\")", "AAAA", context.properties.getProperty("zzzz"));
assertEquals("Enc.persistenceUnitRefs.size()", 1, enc.persistenceUnitRefs.size());
final PersistenceUnitReferenceInfo unit = enc.persistenceUnitRefs.get(0);
assertEquals("Unit.persistenceUnitName", "yellow", unit.persistenceUnitName);
assertEquals("Enc.resourceRefs.size()", 1, enc.resourceRefs.size());
final ResourceReferenceInfo resource = enc.resourceRefs.get(0);
assertEquals("Resource.referenceAuth", "CONTAINER", resource.referenceAuth);
}
Aggregations