}
}
private void verifyDeployment(ConfigurationData configurationData, File unpackedDir, ClassLoader cl, J2eeContext j2eeContext, String resourceAdapterName, boolean is15) throws Exception {
DataSource ds = null;
Kernel kernel = null;
try {
GBeanData config = ExecutableConfigurationUtil.getConfigurationGBeanData(configurationData);
ObjectName objectName = ObjectName.getInstance("test:configuration=test-ejb-jar");
config.setName(objectName);
kernel = KernelFactory.newInstance().createKernel("bar");
kernel.boot();
GBeanData store = new GBeanData(JMXUtil.getObjectName("foo:j2eeType=ConfigurationStore,name=mock"), MockConfigStore.GBEAN_INFO);
kernel.loadGBean(store, this.getClass().getClassLoader());
kernel.startGBean(store.getName());
GBeanData configurationManagerData = new GBeanData(configurationManagerName, ConfigurationManagerImpl.GBEAN_INFO);
configurationManagerData.setReferencePatterns("Stores", Collections.singleton(store.getName()));
kernel.loadGBean(configurationManagerData, getClass().getClassLoader());
kernel.startGBean(configurationManagerName);
ConfigurationManager configurationManager = (ConfigurationManager) kernel.getProxyManager().createProxy(configurationManagerName, ConfigurationManager.class);
ObjectName baseConfigName = configurationManager.load(defaultParentId[0]);
kernel.startGBean(baseConfigName);
ObjectName serverInfoObjectName = ObjectName.getInstance(j2eeContext.getJ2eeDomainName() + ":name=ServerInfo");
GBeanData serverInfoGBean = new GBeanData(serverInfoObjectName, BasicServerInfo.GBEAN_INFO);
serverInfoGBean.setAttribute("baseDirectory", ".");
kernel.loadGBean(serverInfoGBean, cl);
kernel.startGBean(serverInfoObjectName);
assertRunning(kernel, serverInfoObjectName);
ObjectName j2eeServerObjectName = NameFactory.getServerName(null, null, j2eeContext);
GBeanData j2eeServerGBean = new GBeanData(j2eeServerObjectName, J2EEServerImpl.GBEAN_INFO);
j2eeServerGBean.setReferencePatterns("ServerInfo", Collections.singleton(serverInfoObjectName));
kernel.loadGBean(j2eeServerGBean, cl);
kernel.startGBean(j2eeServerObjectName);
assertRunning(kernel, j2eeServerObjectName);
// load the configuration
config.setAttribute("baseURL", unpackedDir.toURL());
kernel.loadGBean(config, cl);
// start the configuration
kernel.startRecursiveGBean(objectName);
Set gb = kernel.listGBeans(JMXUtil.getObjectName("test:*"));
for (Iterator iterator = gb.iterator(); iterator.hasNext();) {
ObjectName name = (ObjectName) iterator.next();
if (State.RUNNING_INDEX != kernel.getGBeanState(name)) {
System.out.println("Not running: " + name);
}
}
assertRunning(kernel, objectName);
ObjectName applicationObjectName = NameFactory.getApplicationName(null, null, null, j2eeContext);
if (!j2eeContext.getJ2eeApplicationName().equals("null")) {
assertRunning(kernel, applicationObjectName);
} else {
Set applications = kernel.listGBeans(applicationObjectName);
assertTrue("No application object should be registered for a standalone module", applications.isEmpty());
}
ObjectName moduleName = NameFactory.getModuleName(null, null, null, NameFactory.RESOURCE_ADAPTER_MODULE, null, j2eeContext);
assertRunning(kernel, moduleName);
//1.5 only
if (is15) {
Map activationSpecInfoMap = (Map) kernel.getAttribute(moduleName, "activationSpecInfoMap");
assertEquals(1, activationSpecInfoMap.size());
GBeanData activationSpecInfo = (GBeanData) activationSpecInfoMap.get("javax.jms.MessageListener");
assertNotNull(activationSpecInfo);
GBeanInfo activationSpecGBeanInfo = activationSpecInfo.getGBeanInfo();
List attributes1 = activationSpecGBeanInfo.getPersistentAttributes();
assertEquals(2, attributes1.size());
Map adminObjectInfoMap = (Map) kernel.getAttribute(moduleName, "adminObjectInfoMap");
assertEquals(1, adminObjectInfoMap.size());
GBeanData adminObjectInfo = (GBeanData) adminObjectInfoMap.get("org.apache.geronimo.connector.mock.MockAdminObject");
assertNotNull(adminObjectInfo);
GBeanInfo adminObjectGBeanInfo = adminObjectInfo.getGBeanInfo();
List attributes2 = adminObjectGBeanInfo.getPersistentAttributes();
assertEquals(3, attributes2.size());
// ResourceAdapter
ObjectName resourceAdapterObjectName = NameFactory.getComponentName(null, null, null, null, null, resourceAdapterName, NameFactory.JCA_RESOURCE_ADAPTER, j2eeContext);
assertRunning(kernel, resourceAdapterObjectName);
assertAttributeValue(kernel, resourceAdapterObjectName, "RAStringProperty", "NewStringValue");
//both, except 1.0 has only one mcf type
Map managedConnectionFactoryInfoMap = (Map) kernel.getAttribute(moduleName, "managedConnectionFactoryInfoMap");
assertEquals(2, managedConnectionFactoryInfoMap.size());
GBeanData managedConnectionFactoryInfo = (GBeanData) managedConnectionFactoryInfoMap.get("javax.resource.cci.ConnectionFactory");
assertNotNull(managedConnectionFactoryInfo);
GBeanInfo managedConnectionFactoryGBeanInfo = managedConnectionFactoryInfo.getGBeanInfo();
List attributes3 = managedConnectionFactoryGBeanInfo.getPersistentAttributes();
assertEquals(10, attributes3.size());
}
// FirstTestOutboundConnectionFactory
ObjectName firstConnectionManagerFactory = NameFactory.getComponentName(null, null, null, null, null, "FirstTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_MANAGER, j2eeContext);
assertRunning(kernel, firstConnectionManagerFactory);
ObjectName firstOutCF = NameFactory.getComponentName(null, null, null, null, null, "FirstTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_FACTORY, j2eeContext);
assertRunning(kernel, firstOutCF);
// ObjectName firstOutSecurity = new ObjectName("geronimo.security:service=Realm,type=PasswordCredential,name=FirstTestOutboundConnectionFactory");
// assertRunning(kernel, firstOutSecurity);
ObjectName firstOutMCF = NameFactory.getComponentName(null, null, null, null, null, "FirstTestOutboundConnectionFactory", NameFactory.JCA_MANAGED_CONNECTION_FACTORY, j2eeContext);
assertRunning(kernel, firstOutMCF);
assertAttributeValue(kernel, firstOutMCF, "OutboundStringProperty1", "newvalue1");
assertAttributeValue(kernel, firstOutMCF, "OutboundStringProperty2", "originalvalue2");
assertAttributeValue(kernel, firstOutMCF, "OutboundStringProperty3", "newvalue2");
// SecondTestOutboundConnectionFactory
ObjectName secondConnectionManagerFactory = NameFactory.getComponentName(null, null, null, null, null, "SecondTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_MANAGER, j2eeContext);
assertRunning(kernel, secondConnectionManagerFactory);
ObjectName secondOutCF = NameFactory.getComponentName(null, null, null, null, null, "SecondTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_FACTORY, j2eeContext);
assertRunning(kernel, secondOutCF);
ObjectName secondOutMCF = NameFactory.getComponentName(null, null, null, null, null, "SecondTestOutboundConnectionFactory", NameFactory.JCA_MANAGED_CONNECTION_FACTORY, j2eeContext);
assertRunning(kernel, secondOutMCF);
// ThirdTestOutboundConnectionFactory
ObjectName thirdConnectionManagerFactory = NameFactory.getComponentName(null, null, null, null, null, "ThirdTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_MANAGER, j2eeContext);
assertRunning(kernel, thirdConnectionManagerFactory);
ObjectName thirdOutCF = NameFactory.getComponentName(null, null, null, null, null, "ThirdTestOutboundConnectionFactory", NameFactory.JCA_CONNECTION_FACTORY, j2eeContext);
assertRunning(kernel, thirdOutCF);
ObjectName thirdOutMCF = NameFactory.getComponentName(null, null, null, null, null, "ThirdTestOutboundConnectionFactory", NameFactory.JCA_MANAGED_CONNECTION_FACTORY, j2eeContext);
assertRunning(kernel, thirdOutMCF);
// 1.5 only
// Admin objects
//
if (is15) {
ObjectName tweedledeeAdminObject = NameFactory.getComponentName(null, null, null, null, null, "tweedledee", NameFactory.JCA_ADMIN_OBJECT, j2eeContext);
assertRunning(kernel, tweedledeeAdminObject);
ObjectName tweedledumAdminObject = NameFactory.getComponentName(null, null, null, null, null, "tweedledum", NameFactory.JCA_ADMIN_OBJECT, j2eeContext);
assertRunning(kernel, tweedledumAdminObject);
}
kernel.stopGBean(objectName);
} finally {
if (ds != null) {
Connection connection = null;
Statement statement = null;
try {
connection = ds.getConnection();
statement = connection.createStatement();
statement.execute("SHUTDOWN");
} finally {
JDBCUtil.close(statement);
JDBCUtil.close(connection);
}
}
if (kernel != null) {
kernel.shutdown();
}
Thread.currentThread().setContextClassLoader(cl);
}
}