ManagedProperty connectionProperties = mo.getProperty("connection-properties");
MetaType cpType = connectionProperties.getMetaType();
assertTrue("connection-properties.type="+cpType, cpType instanceof CompositeMetaType);
Object cpValue = connectionProperties.getValue();
assertTrue("connection-properties.value="+cpValue, cpValue instanceof CompositeValue);
CompositeValue cvalue = (CompositeValue) cpValue;
// Now update the values
MapCompositeValueSupport map = (MapCompositeValueSupport) cvalue;
map.put("key1", SimpleValueSupport.wrap("value1"));
map.put("key2", SimpleValueSupport.wrap("value2"));
connectionProperties.setValue(map);
// Check the underlying values
List<DataSourceConnectionPropertyMetaData> ldsProps = lds.getDataSourceConnectionProperties();
assertEquals(2, ldsProps.size());
DataSourceConnectionPropertyMetaData key1 = null;
DataSourceConnectionPropertyMetaData key2 = null;
for(DataSourceConnectionPropertyMetaData dspmd : ldsProps)
{
if(dspmd.getName().equals("key1"))
key1 = dspmd;
else if(dspmd.getName().equals("key2"))
key2 = dspmd;
}
assertNotNull(key1);
assertEquals("value1", key1.getValue());
assertNotNull(key2);
assertEquals("value2", key2.getValue());
// Test a simple property
ManagedProperty driverClass = mo.getProperty("driver-class");
driverClass.setValue(SimpleValueSupport.wrap("org.jboss.jdbc.ClusteredDriver"));
String driverClassName = lds.getDriverClass();
assertEquals("org.jboss.jdbc.ClusteredDriver", driverClassName);
// Validate the security-domain
ManagedProperty secDomain = mo.getProperty("security-domain");
assertNotNull("security-domain", secDomain);
CompositeMetaType compType = (CompositeMetaType) secDomain.getMetaType();
assertNotNull(compType);
CompositeValue sdCV = (CompositeValue) secDomain.getValue();
assertNotNull("security-domain.CV", sdCV);
SimpleValue domainName = (SimpleValue) sdCV.get("domain");
assertNotNull("security-domain.domain", domainName);
assertEquals(SimpleValueSupport.wrap("java:/jaas/SomeDomain"), domainName);
assertNotNull("security-domain.deploymentType", sdCV.get("securityDeploymentType"));
assertEquals("APPLICATION", ((EnumValue) sdCV.get("securityDeploymentType")).getValue());
assertFalse(lds.getSecurityMetaData() instanceof SecurityDomainApplicationManagedMetaData);
// Set a new security domain and check if the metaType changed
CompositeValueSupport newSecDomain = new CompositeValueSupport(compType);
newSecDomain.set("domain", SimpleValueSupport.wrap("test"));