public class JmsMdbContainerTest extends TestCase {
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");