use of org.apache.openejb.jee.MessageDrivenBean$JAXB.readMessageDrivenBean in project tomee by apache.
the class CheckInvalidAsynchronousAnnotationsTest method ejbJarWithMessageDrivenBean.
private static EjbJar ejbJarWithMessageDrivenBean(final Class<?> beanClass) {
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new MessageDrivenBean(beanClass));
return ejbJar;
}
use of org.apache.openejb.jee.MessageDrivenBean$JAXB.readMessageDrivenBean 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.MessageDrivenBean$JAXB.readMessageDrivenBean in project tomee by apache.
the class ActivationConfigPropertyOverrideTest method testNoOverrideSetShouldNotOverride.
@Test
public void testNoOverrideSetShouldNotOverride() throws OpenEJBException {
if (SystemInstance.get().getProperties().containsKey("ENTERPRISEBEAN.mdb.activation.destinationType")) {
SystemInstance.get().getProperties().remove("ENTERPRISEBEAN.mdb.activation.destinationType");
}
System.clearProperty("ENTERPRISEBEAN.mdb.activation.destinationType");
final MessageDrivenBean mdb = new MdbBuilder().anMdb().withActivationProperty("destinationType", "shouldNotBeOverriddenString").build();
final AppModule appModule = new AppModuleBuilder().anAppModule().withAnMdb(mdb).build();
final ActivationConfigPropertyOverride activationPropertyOverride = new ActivationConfigPropertyOverride();
activationPropertyOverride.deploy(appModule);
assertTrue(containsActivationKeyValuePair(mdb, "destinationType", "shouldNotBeOverriddenString"));
}
use of org.apache.openejb.jee.MessageDrivenBean$JAXB.readMessageDrivenBean in project tomee by apache.
the class ActivationConfigPropertyOverrideTest method testAddActivationConfigPropertyIfNotAlreadyPresent.
/**
* If activation property was not present initially, then add the specified
* one.
*
* @throws OpenEJBException
*/
@Test
public void testAddActivationConfigPropertyIfNotAlreadyPresent() throws OpenEJBException {
// set overrides
System.setProperty("ENTERPRISEBEAN.mdb.activation.destinationType", "testString");
// deploy with an mdb that has no "destinationType" activationConfigProp
final MessageDrivenBean mdb = new MdbBuilder().anMdb().build();
final AppModule appModule = new AppModuleBuilder().anAppModule().withAnMdb(mdb).build();
final ActivationConfigPropertyOverride activationPropertyOverride = new ActivationConfigPropertyOverride();
activationPropertyOverride.deploy(appModule);
assertTrue(containsActivationKeyValuePair(mdb, "destinationType", "testString"));
assertTrue(mdb.getActivationConfig().getActivationConfigProperty().size() == 1);
System.clearProperty("ENTERPRISEBEAN.mdb.activation.destinationType");
}
use of org.apache.openejb.jee.MessageDrivenBean$JAXB.readMessageDrivenBean 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"));
}
Aggregations