Search in sources :

Example 41 with EjbJarInfo

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

the class AppInfoBuilderTest method testShouldAddSecurityDetailsToPortInfo.

public void testShouldAddSecurityDetailsToPortInfo() throws Exception {
    final EjbJar ejbJar = new EjbJar();
    final SessionBean sessionBean = new SessionBean();
    sessionBean.setEjbName("MySessionBean");
    sessionBean.setEjbClass("org.superbiz.MySessionBean");
    sessionBean.setRemote("org.superbiz.MySession");
    ejbJar.addEnterpriseBean(sessionBean);
    final OpenejbJar openejbJar = new OpenejbJar();
    final EjbDeployment ejbDeployment = new EjbDeployment();
    openejbJar.addEjbDeployment(ejbDeployment);
    ejbDeployment.setEjbName("MySessionBean");
    ejbDeployment.addProperty("webservice.security.realm", "MyRealm");
    ejbDeployment.addProperty("webservice.security.securityRealm", "MySecurityRealm");
    ejbDeployment.addProperty("webservice.security.transportGarantee", TransportGuaranteeType.NONE.value());
    ejbDeployment.addProperty("webservice.security.authMethod", AuthMethodType.BASIC.value());
    ejbDeployment.addProperty("wss4j.in.action", "Timestamp");
    ejbDeployment.addProperty("wss4j.out.action", "Timestamp");
    final EjbModule ejbModule = new EjbModule(ejbJar, openejbJar);
    final EjbJarInfo ejbJarInfo = new EjbJarInfo();
    final PortInfo portInfo = new PortInfo();
    portInfo.serviceLink = "MySessionBean";
    ejbJarInfo.portInfos.add(portInfo);
    new AppInfoBuilder(null).configureWebserviceSecurity(ejbJarInfo, ejbModule);
    final List<PortInfo> portInfoList = ejbJarInfo.portInfos;
    assertEquals(1, portInfoList.size());
    final PortInfo info = portInfoList.get(0);
    assertEquals("MyRealm", info.realmName);
    assertEquals("MySecurityRealm", info.securityRealmName);
    assertEquals("BASIC", info.authMethod);
    assertEquals("NONE", info.transportGuarantee);
    assertEquals("Timestamp", portInfo.properties.getProperty("wss4j.in.action"));
    assertEquals("Timestamp", portInfo.properties.getProperty("wss4j.out.action"));
}
Also used : PortInfo(org.apache.openejb.assembler.classic.PortInfo) OpenejbJar(org.apache.openejb.jee.oejb3.OpenejbJar) EjbDeployment(org.apache.openejb.jee.oejb3.EjbDeployment) SessionBean(org.apache.openejb.jee.SessionBean) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 42 with EjbJarInfo

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

the class AppPathsTest method _testMixedCaseMetaInf.

/**
 * Seems like this may not be a feature that can be supported on
 * all platforms.  Seems to work on the mac VM, but not the linux vm.
 *
 * @throws Exception
 */
public void _testMixedCaseMetaInf() throws Exception {
    final Assembler assmbler = new Assembler();
    final ConfigurationFactory factory = new ConfigurationFactory();
    final URL resource = AppPathsTest.class.getClassLoader().getResource("mixedcase");
    final File file = URLs.toFile(resource);
    final AppInfo appInfo = factory.configureApplication(file);
    assertNotNull(appInfo);
    assertEquals(1, appInfo.ejbJars.size());
    final EjbJarInfo ejbJar = appInfo.ejbJars.get(0);
    // was the footest.ejb-jar.xml picked up
    assertEquals("EjbJar.enterpriseBeans", 1, ejbJar.enterpriseBeans.size());
}
Also used : Assembler(org.apache.openejb.assembler.classic.Assembler) File(java.io.File) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) URL(java.net.URL) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 43 with EjbJarInfo

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

the class AutoConfigMdbContainerTest method _testJmsMdbNoContainerConfigured.

public void _testJmsMdbNoContainerConfigured() throws Exception {
    final EjbJar ejbJar = new EjbJar();
    ejbJar.addEnterpriseBean(new MessageDrivenBean(JmsBean.class));
    final EjbJarInfo info = config.configureApplication(ejbJar);
// assembler.createApplication(info);
}
Also used : MessageDrivenBean(org.apache.openejb.jee.MessageDrivenBean) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) EjbJar(org.apache.openejb.jee.EjbJar)

Example 44 with EjbJarInfo

use of org.apache.openejb.assembler.classic.EjbJarInfo 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)

Example 45 with EjbJarInfo

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

the class EjbModuleIdTest method testDefault.

@Test
public void testDefault() throws Exception {
    final Map<String, String> map = new HashMap<String, String>();
    map.put("META-INF/ejb-jar.xml", "<ejb-jar/>");
    final File file = Archives.jarArchive(map, "test", OrangeBean.class);
    final Assembler assembler = new Assembler();
    final ConfigurationFactory factory = new ConfigurationFactory();
    final AppInfo appInfo = factory.configureApplication(file);
    final EjbJarInfo ejbJarInfo = appInfo.ejbJars.get(0);
    assertEquals(file.getName().substring(0, file.getName().length() - 4), ejbJarInfo.moduleName);
}
Also used : HashMap(java.util.HashMap) Assembler(org.apache.openejb.assembler.classic.Assembler) File(java.io.File) EjbJarInfo(org.apache.openejb.assembler.classic.EjbJarInfo) AppInfo(org.apache.openejb.assembler.classic.AppInfo) Test(org.junit.Test)

Aggregations

EjbJarInfo (org.apache.openejb.assembler.classic.EjbJarInfo)47 Assembler (org.apache.openejb.assembler.classic.Assembler)29 EjbJar (org.apache.openejb.jee.EjbJar)21 EnterpriseBeanInfo (org.apache.openejb.assembler.classic.EnterpriseBeanInfo)17 AppInfo (org.apache.openejb.assembler.classic.AppInfo)16 SecurityServiceInfo (org.apache.openejb.assembler.classic.SecurityServiceInfo)16 TransactionServiceInfo (org.apache.openejb.assembler.classic.TransactionServiceInfo)16 HashMap (java.util.HashMap)14 ConfigurationFactory (org.apache.openejb.config.ConfigurationFactory)14 ProxyFactoryInfo (org.apache.openejb.assembler.classic.ProxyFactoryInfo)13 BeanContext (org.apache.openejb.BeanContext)11 File (java.io.File)10 InitialContext (javax.naming.InitialContext)10 StatelessBean (org.apache.openejb.jee.StatelessBean)10 LocalInitialContextFactory (org.apache.openejb.core.LocalInitialContextFactory)9 ArrayList (java.util.ArrayList)8 WebAppInfo (org.apache.openejb.assembler.classic.WebAppInfo)8 Test (org.junit.Test)8 EjbDeployment (org.apache.openejb.jee.oejb3.EjbDeployment)7 Properties (java.util.Properties)6