LocalDataSourceDeploymentMetaData lds = new LocalDataSourceDeploymentMetaData();
// Set a SecurityMetaData to validate its MO
SecurityMetaData smd = new ApplicationManagedSecurityMetaData();
smd.setDomain("java:/jaas/SomeDomain");
lds.setSecurityMetaData(smd);
ManagedObject mo = mof.initManagedObject(lds, "LocalDataSourceDeploymentMetaData", null);
// Validate the expected property names
Set<String> expectedPropertyNames = new TreeSet<String>();
expectedPropertyNames.addAll(Arrays.asList(ManagedConnectionFactoryDeploymentMetaData_NAMES));
expectedPropertyNames.addAll(Arrays.asList(DataSourceDeploymentMetaData_NAMES));
expectedPropertyNames.addAll(Arrays.asList(NonXADataSourceDeploymentMetaData_NAMES));
Set<String> propertyNames = mo.getPropertyNames();
TreeSet<String> sortedPropertyNames = new TreeSet<String>(propertyNames);
if(expectedPropertyNames.equals(sortedPropertyNames) == false)
{
Set<String> missingNames = new TreeSet<String>();
Set<String> extraNames = new TreeSet<String>();
analyzeDiffs(expectedPropertyNames, sortedPropertyNames,
missingNames, extraNames);
fail("Extra properties: "+extraNames+", missing properties: "+missingNames);
}
// Validate the connection-properties type
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);