use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class ActivationConfigPropertyOverrideTest method testEjbNameOverrideOpenejbJar.
@Test
public void testEjbNameOverrideOpenejbJar() 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.EjbJar$JAXB in project tomee by apache.
the class ActivationConfigPropertyOverrideTest method testEjbNameOverrideSystem.
@Test
public void testEjbNameOverrideSystem() throws Exception {
SystemInstance.reset();
final Properties properties = SystemInstance.get().getProperties();
properties.setProperty("Orange.activation.maxSessions", "20");
properties.setProperty("Orange.activation.maxMessagesPerSessions", "100");
properties.setProperty("Orange.activation.destinationType", "javax.jms.Queue");
properties.setProperty("Orange.activation.destination", "OVERRIDDEN.QUEUE");
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();
// just to make sure class name is not used
ejbJar.addEnterpriseBean(new MessageDrivenBean("Yellow", Orange.class));
// just to make sure class name is not used
ejbJar.addEnterpriseBean(new MessageDrivenBean("Orange", 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("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"));
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class AnnotationDeployerTest method testLocalBean.
/**
* For https://issues.apache.org/jira/browse/OPENEJB-1188
*
* @throws Exception
*/
@Test
public void testLocalBean() throws Exception {
final EjbModule ejbModule = testModule();
final EjbJar ejbJar = ejbModule.getEjbJar();
AppModule appModule = new AppModule(Thread.currentThread().getContextClassLoader(), "myapp");
appModule.getEjbModules().add(ejbModule);
final AnnotationDeployer annotationDeployer = new AnnotationDeployer();
appModule = annotationDeployer.deploy(appModule);
EnterpriseBean bean = ejbJar.getEnterpriseBean("TestLocalBean");
assert bean != null;
assert (((SessionBean) bean).getLocalBean() != null);
bean = ejbJar.getEnterpriseBean("InterceptedSLSBean");
assert bean != null;
assert (((SessionBean) bean).getLocalBean() == null);
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class AnnotationDeployerTest method interceptingGenericBusinessMethodCalls.
/**
* For https://issues.apache.org/jira/browse/OPENEJB-1128
*/
@Test
public void interceptingGenericBusinessMethodCalls() throws Exception {
EjbModule ejbModule = testModule();
final EjbJar ejbJar = ejbModule.getEjbJar();
final AnnotationDeployer.DiscoverAnnotatedBeans discvrAnnBeans = new AnnotationDeployer.DiscoverAnnotatedBeans();
ejbModule = discvrAnnBeans.deploy(ejbModule);
final EnterpriseBean bean = ejbJar.getEnterpriseBean("InterceptedSLSBean");
assert bean != null;
}
use of org.apache.openejb.jee.EjbJar$JAXB in project tomee by apache.
the class AppInfoBuilderTest method testShouldCreateContainer.
public void testShouldCreateContainer() throws Exception {
final EjbJar ejbJar = new EjbJar();
final OpenejbJar openejbJar = new OpenejbJar();
final EjbModule ejbModule = new EjbModule(ejbJar, openejbJar);
final AppModule appModule = new AppModule(ejbModule);
appModule.getContainers().add(new Container("my-container", "MESSAGE", null));
final AppInfo appInfo = new AppInfoBuilder(new ConfigurationFactory()).build(appModule);
assertEquals(1, appInfo.containers.size());
final ContainerInfo containerInfo = appInfo.containers.get(0);
assertEquals(appInfo.appId + "/my-container", containerInfo.id);
assertEquals(1, containerInfo.types.size());
assertEquals("MESSAGE", containerInfo.types.get(0));
assertEquals(MdbContainerFactory.class.getName(), containerInfo.className);
assertEquals("Default JMS Resource Adapter", containerInfo.properties.get("ResourceAdapter"));
assertEquals(MessageListener.class.getName(), containerInfo.properties.get("MessageListenerInterface"));
assertEquals(TomEEMessageActivationSpec.class.getName(), containerInfo.properties.get("ActivationSpecClass"));
assertEquals("10", containerInfo.properties.get("InstanceLimit"));
assertEquals("true", containerInfo.properties.get("FailOnUnknownActivationSpec"));
}
Aggregations