use of org.apache.openejb.jee.MessageDrivenBean in project tomee by apache.
the class ActivationConfigPropertyOverrideTest method testNotOverridden.
public void testNotOverridden() 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 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 in project tomee by apache.
the class ActivationConfigPropertyOverrideTest method testMdbOverrideOpenejbJar.
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.MessageDrivenBean 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);
}
use of org.apache.openejb.jee.MessageDrivenBean in project tomee by apache.
the class CustomMdbContainerTest method test.
public void test() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
// Setup the descriptor information
EmailBean.lifecycle.clear();
final AppModule app = new AppModule(this.getClass().getClassLoader(), "testapp");
final Connector connector = new Connector("email-ra");
final ResourceAdapter adapter = new ResourceAdapter(EmailResourceAdapter.class);
connector.setResourceAdapter(adapter);
final InboundResourceadapter inbound = adapter.setInboundResourceAdapter(new InboundResourceadapter());
final MessageAdapter messageAdapter = inbound.setMessageAdapter(new MessageAdapter());
final MessageListener listener = messageAdapter.addMessageListener(new MessageListener(EmailConsumer.class, EmailAccountInfo.class));
listener.getActivationSpec().addRequiredConfigProperty("address");
app.getConnectorModules().add(new ConnectorModule(connector));
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new MessageDrivenBean(EmailBean.class));
app.getEjbModules().add(new EjbModule(ejbJar));
final AppInfo appInfo = config.configureApplication(app);
assembler.createApplication(appInfo);
final InitialContext initialContext = new InitialContext();
final EmailResourceAdapter ra = (EmailResourceAdapter) initialContext.lookup("java:openejb/Resource/email-raRA");
final Properties headers = new Properties();
headers.put("To", "dblevins@apache.org");
headers.put("From", "dblevins@visi.com");
headers.put("Subject", "Hello");
ra.deliverEmail(headers, "How's it going?");
final Stack<Lifecycle> lifecycle = EmailBean.lifecycle;
final List expected = Arrays.asList(Lifecycle.values());
Assert.assertEquals(Join.join("\n", expected), Join.join("\n", lifecycle));
}
use of org.apache.openejb.jee.MessageDrivenBean in project tomee by apache.
the class JmsMdbContainerTest method test.
public void test() throws Exception {
System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
final ConfigurationFactory config = new ConfigurationFactory();
final Assembler assembler = new Assembler();
// define props for RA in order to change the default activeMQ port
final Properties props = new Properties();
final String brokerAddress = NetworkUtil.getLocalAddress("tcp://", "");
final String brokerXmlConfig = "broker:(" + brokerAddress + ")?useJmx=false";
props.put("BrokerXmlConfig", brokerXmlConfig);
props.put("StartupTimeout", 10000);
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
assembler.createResource(config.configureService(ResourceInfo.class, "Default Unmanaged JDBC Database", new Properties(), "Default Unmanaged JDBC Database", "DataSource"));
assembler.createResource(config.configureService(ResourceInfo.class, "Default JMS Resource Adapter", props, "Default JMS Resource Adapter", "ActiveMQResourceAdapter"));
// Setup the descriptor information
WidgetBean.lifecycle.clear();
final EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(new MessageDrivenBean(WidgetBean.class));
assembler.createApplication(config.configureApplication(ejbJar));
final InitialContext initialContext = new InitialContext();
final ConnectionFactory connectionFactory = (ConnectionFactory) initialContext.lookup("java:openejb/Resource/Default JMS Connection Factory");
sendMessage(connectionFactory, "WidgetBean", "test");
final Stack<Lifecycle> lifecycle = WidgetBean.lifecycle;
final List expected = Arrays.asList(Lifecycle.values());
assertEquals(join("\n", expected), join("\n", lifecycle));
}
Aggregations