{
enableTrace("org.jboss.managed.plugins.factory");
ManagedObjectFactory mof = ManagedObjectFactory.getInstance();
XADSInstanceClassFactory icf = new XADSInstanceClassFactory();
mof.setInstanceClassFactory(XADataSourceDeploymentMetaData.class, icf);
XADataSourceDeploymentMetaData xads = new XADataSourceDeploymentMetaData();
ManagedObject mo = mof.initManagedObject(xads, "XADataSourceDeploymentMetaData", 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(XADataSourceDeploymentMetaData_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 xa-datasource-properties type
ManagedProperty connectionProperties = mo.getProperty("xa-datasource-properties");
MetaType cpType = connectionProperties.getMetaType();
assertTrue("xa-datasource-properties.type="+cpType, cpType instanceof CompositeMetaType);
Object cpValue = connectionProperties.getValue();
assertTrue("xa-datasource-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<XAConnectionPropertyMetaData> xaProps = xads.getXADataSourceProperties();
assertEquals(2, xaProps.size());
DataSourceConnectionPropertyMetaData key1 = null;
DataSourceConnectionPropertyMetaData key2 = null;
for(XAConnectionPropertyMetaData dspmd : xaProps)
{
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 jndiName = mo.getProperty("jndi-name");
jndiName.setValue(SimpleValueSupport.wrap("java:ClusteredDS"));
String jndiNameTest = xads.getJndiName();
assertEquals("java:ClusteredDS", jndiNameTest);
}