/**
* @version $Rev: 610927 $ $Date: 2008-01-10 14:48:37 -0600 (Thu, 10 Jan 2008) $
*/
public class MdbConfigTest extends TestCase {
public void test() throws Exception {
ConfigurationFactory config = new ConfigurationFactory();
Assembler assembler = new Assembler();
// System services
assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
// JMS persistence datasource
ResourceInfo dataSourceInfo = config.configureService("Default Unmanaged JDBC Database", ResourceInfo.class);
dataSourceInfo.properties.setProperty("JdbcUrl", "jdbc:hsqldb:mem:MdbConfigTest");
assembler.createResource(dataSourceInfo);
// JMS
assembler.createResource(config.configureService("Default JMS Resource Adapter", ResourceInfo.class));
// JMS Container
MdbContainerInfo mdbContainerInfo = config.configureService(MdbContainerInfo.class);
assembler.createContainer(mdbContainerInfo);
// FakeRA
ResourceInfo resourceInfo = new ResourceInfo();
resourceInfo.service = "Resource";
resourceInfo.className = FakeRA.class.getName();
resourceInfo.id = "FakeRA";
resourceInfo.properties = new Properties();
assembler.createResource(resourceInfo);
// FakeRA container
ContainerInfo containerInfo = config.configureService(MdbContainerInfo.class);
containerInfo.id = "FakeContainer";
containerInfo.displayName = "Fake Container";
containerInfo.properties.setProperty("ResourceAdapter", "FakeRA");
containerInfo.properties.setProperty("MessageListenerInterface", FakeMessageListener.class.getName());
containerInfo.properties.setProperty("ActivationSpecClass", FakeActivationSpec.class.getName());
assembler.createContainer(containerInfo);
// generate ejb jar application
EjbJar ejbJar = new EjbJar();
ejbJar.addEnterpriseBean(createJaxbMdb("JmsMdb", BasicMdbBean.class.getName(), MessageListener.class.getName()));
ejbJar.addEnterpriseBean(createJaxbMdb("FakeMdb", FakeMdb.class.getName(), FakeMessageListener.class.getName()));
EjbModule ejbModule = new EjbModule(getClass().getClassLoader(), "FakeEjbJar", "fake.jar", ejbJar, null);
// configure and deploy it
EjbJarInfo info = config.configureApplication(ejbModule);
assembler.createEjbJar(info);
}