Search in sources :

Example 11 with EnterpriseBeanInfo

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

Example 12 with EnterpriseBeanInfo

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

Example 13 with EnterpriseBeanInfo

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

Example 14 with EnterpriseBeanInfo

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));
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) LocalInitialContextFactory(org.apache.openejb.core.LocalInitialContextFactory) InitialContext(javax.naming.InitialContext) EnterpriseBeanInfo(org.apache.openejb.assembler.classic.EnterpriseBeanInfo) BeanContext(org.apache.openejb.BeanContext) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) StatelessBean(org.apache.openejb.jee.StatelessBean) Assembler(org.apache.openejb.assembler.classic.Assembler) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 15 with EnterpriseBeanInfo

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);
}
Also used : PersistenceContextRef(org.apache.openejb.jee.PersistenceContextRef) ArrayList(java.util.ArrayList) PersistenceUnitReferenceInfo(org.apache.openejb.assembler.classic.PersistenceUnitReferenceInfo) EnterpriseBeanInfo(org.apache.openejb.assembler.classic.EnterpriseBeanInfo) ResourceReferenceInfo(org.apache.openejb.assembler.classic.ResourceReferenceInfo) PersistenceUnit(javax.persistence.PersistenceUnit) SecurityServiceInfo(org.apache.openejb.assembler.classic.SecurityServiceInfo) Property(org.apache.openejb.jee.Property) PersistenceUnitRef(org.apache.openejb.jee.PersistenceUnitRef) EjbJar(org.apache.openejb.jee.EjbJar) EnvEntry(org.apache.openejb.jee.EnvEntry) EjbLocalRef(org.apache.openejb.jee.EjbLocalRef) PersistenceContextReferenceInfo(org.apache.openejb.assembler.classic.PersistenceContextReferenceInfo) JndiEncInfo(org.apache.openejb.assembler.classic.JndiEncInfo) StatefulBean(org.apache.openejb.jee.StatefulBean) EnvEntryInfo(org.apache.openejb.assembler.classic.EnvEntryInfo) AppInfo(org.apache.openejb.assembler.classic.AppInfo) Persistence(org.apache.openejb.jee.jpa.unit.Persistence) TransactionServiceInfo(org.apache.openejb.assembler.classic.TransactionServiceInfo) ResourceRef(org.apache.openejb.jee.ResourceRef) Assembler(org.apache.openejb.assembler.classic.Assembler) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo)

Aggregations

EnterpriseBeanInfo (org.apache.openejb.assembler.classic.EnterpriseBeanInfo)31 EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)17 BeanContext (org.apache.openejb.BeanContext)8 HashMap (java.util.HashMap)7 AppInfo (org.apache.openejb.assembler.classic.AppInfo)7 WebAppInfo (org.apache.openejb.assembler.classic.WebAppInfo)7 Assembler (org.apache.openejb.assembler.classic.Assembler)6 EjbJar (org.apache.openejb.jee.EjbJar)6 ArrayList (java.util.ArrayList)5 OpenEJBException (org.apache.openejb.OpenEJBException)5 StatelessBean (org.apache.openejb.jee.StatelessBean)5 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)4 SingletonBeanInfo (org.apache.openejb.assembler.classic.SingletonBeanInfo)4 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)4 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)4 URL (java.net.URL)3 Map (java.util.Map)3 InitialContext (javax.naming.InitialContext)3 StatelessBeanInfo (org.apache.openejb.assembler.classic.StatelessBeanInfo)3 File (java.io.File)2