use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.
the class CheckedExceptionMapperTest method module.
@Module
@Classes({ ExampleExceptionMapper.class })
public EjbModule module() {
final SingletonBean bean = new SingletonBean(ExampleRest.class);
bean.setRestService(true);
final EjbJar ejbJar = new EjbJar("beans");
ejbJar.addEnterpriseBean(bean);
final OpenejbJar openejbJar = new OpenejbJar();
openejbJar.addEjbDeployment(new EjbDeployment(bean));
final Properties properties = openejbJar.getEjbDeployment().iterator().next().getProperties();
properties.setProperty("cxf.jaxrs.providers", "org.apache.openejb.server.cxf.rs.CheckedExceptionMapperTest$ExampleExceptionMapper");
final EjbModule module = new EjbModule(ejbJar);
module.setOpenejbJar(openejbJar);
return module;
}
use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.
the class CustomContextTest method service.
@Module
public static EjbModule service() throws Exception {
final EjbModule module = new EjbModule(new EjbJar(), new OpenejbJar());
final SingletonBean bean = new SingletonBean(CustomContextInjectedBean.class);
bean.setLocalBean(new Empty());
module.getEjbJar().addEnterpriseBean(bean);
final PojoDeployment e = new PojoDeployment();
e.setClassName("jaxrs-application");
e.getProperties().setProperty("cxf.jaxrs.providers", CustomProvider.class.getName());
module.getOpenejbJar().getPojoDeployment().add(e);
return module;
}
use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.
the class FeatureTest method app.
@Module
public EjbModule app() {
final StatelessBean bean = (StatelessBean) new StatelessBean(MySecondRestClass.class).localBean();
bean.setRestService(true);
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(bean);
final OpenejbJar openejbJar = new OpenejbJar();
final PojoDeployment e = new PojoDeployment();
openejbJar.getPojoDeployment().add(e);
e.setClassName("jaxrs-application");
final Properties properties = e.getProperties();
properties.setProperty(CxfRsHttpListener.CXF_JAXRS_PREFIX + CxfUtil.FEATURES, "my-feature");
final EjbModule module = new EjbModule(ejbJar);
module.setOpenejbJar(openejbJar);
final Resources resources = new Resources();
final Service feature = new Service("my-feature", null);
feature.setClassName(MyFeature.class.getName());
resources.getService().add(feature);
module.initResources(resources);
return module;
}
use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.
the class ActivationConfigPropertyOverrideTest method testMdbOverrideOpenejbJar.
@Test
public void testMdbOverrideOpenejbJar() throws Exception {
SystemInstance.reset();
final Assembler assembler = new Assembler();
final ConfigurationFactory config = new ConfigurationFactory();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
{
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new MessageDrivenBean(Orange.class));
ejbJar.addEnterpriseBean(new MessageDrivenBean(Yellow.class));
final OpenejbJar openejbJar = new OpenejbJar();
final Properties properties = openejbJar.getProperties();
properties.setProperty("mdb.activation.maxSessions", "20");
properties.setProperty("mdb.activation.maxMessagesPerSessions", "100");
properties.setProperty("mdb.activation.destinationType", "javax.jms.Queue");
properties.setProperty("mdb.activation.destination", "OVERRIDDEN.QUEUE");
final EjbModule ejbModule = new EjbModule(ejbJar, openejbJar);
final EjbJarInfo ejbJarInfo = config.configureApplication(ejbModule);
assertEquals(2, ejbJarInfo.enterpriseBeans.size());
final MessageDrivenBeanInfo orange = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(0);
final MessageDrivenBeanInfo yellow = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(1);
assertEquals("20", orange.activationProperties.get("maxSessions"));
assertEquals("100", orange.activationProperties.get("maxMessagesPerSessions"));
assertEquals("javax.jms.Queue", orange.activationProperties.get("destinationType"));
assertEquals("OVERRIDDEN.QUEUE", orange.activationProperties.get("destination"));
assertEquals("20", yellow.activationProperties.get("maxSessions"));
assertEquals("100", yellow.activationProperties.get("maxMessagesPerSessions"));
assertEquals("javax.jms.Queue", yellow.activationProperties.get("destinationType"));
assertEquals("OVERRIDDEN.QUEUE", yellow.activationProperties.get("destination"));
}
// Verify the openejb-jar level overrides do not affect other apps
{
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new MessageDrivenBean(Orange.class));
ejbJar.addEnterpriseBean(new MessageDrivenBean(Yellow.class));
final EjbJarInfo ejbJarInfo = config.configureApplication(ejbJar);
assertEquals(2, ejbJarInfo.enterpriseBeans.size());
final MessageDrivenBeanInfo orange = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(0);
final MessageDrivenBeanInfo yellow = (MessageDrivenBeanInfo) ejbJarInfo.enterpriseBeans.get(1);
assertEquals("7", orange.activationProperties.get("maxSessions"));
assertEquals("4", orange.activationProperties.get("maxMessagesPerSessions"));
assertEquals("javax.jms.Queue", orange.activationProperties.get("destinationType"));
assertEquals("ORANGE.QUEUE", orange.activationProperties.get("destination"));
assertEquals("5", yellow.activationProperties.get("maxSessions"));
assertEquals("10", yellow.activationProperties.get("maxMessagesPerSessions"));
assertEquals("javax.jms.Topic", yellow.activationProperties.get("destinationType"));
assertEquals("YELLOW.TOPIC", yellow.activationProperties.get("destination"));
}
}
use of org.apache.openejb.jee.oejb3.OpenejbJar in project tomee by apache.
the class AppInfoBuilderTest method testShouldIgnorePortInfoThatDontMatchTheEjb.
public void testShouldIgnorePortInfoThatDontMatchTheEjb() 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");
final EjbModule ejbModule = new EjbModule(ejbJar, openejbJar);
final EjbJarInfo ejbJarInfo = new EjbJarInfo();
final PortInfo portInfo = new PortInfo();
portInfo.authMethod = "DIGEST";
portInfo.realmName = "";
portInfo.securityRealmName = "";
portInfo.transportGuarantee = "CONFIDENTIAL";
portInfo.serviceLink = "DifferentInfo";
final Properties props = new Properties();
props.put("wss4j.in.action", "Timestamp");
props.put("wss4j.out.action", "Timestamp");
portInfo.properties = props;
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("", info.realmName);
assertEquals("", info.securityRealmName);
assertEquals("DIGEST", info.authMethod);
assertEquals("CONFIDENTIAL", info.transportGuarantee);
assertEquals("Timestamp", portInfo.properties.getProperty("wss4j.in.action"));
assertEquals("Timestamp", portInfo.properties.getProperty("wss4j.out.action"));
}
Aggregations