{
String deploymentName = "profileservice-datasource.ear";
try
{
deployPackage(deploymentName);
ManagementView mgtView = getManagementView();
ManagedDeployment deployment = mgtView.getDeployment(deploymentName);
assertNotNull("Null managed deployment", deployment);
assertNotNull(deployment.getChildren());
assertFalse(deployment.getChildren().isEmpty());
// Update first DataSource
// get test-ds.xml child
ManagedDeployment md = null;
for(ManagedDeployment d : deployment.getChildren())
{
if(d.getName().endsWith("test-ds.xml"))
{
md = d;
break;
}
}
assertNotNull(md);
ManagedComponent mc = md.getComponent("ProfileServiceNestedTestDS");
assertNotNull("Null managed component", mc);
// This should work too
ManagedComponent comp = getManagedComponent(mgtView, "ProfileServiceNestedTestDS");
assertNotNull(comp);
ManagedProperty p = mc.getProperty("jndi-name");
p.setValue(SimpleValueSupport.wrap("ChangedNestedDsJNDIName"));
// Update prepared-statement-cache-size
ManagedProperty property = mc.getProperty("prepared-statement-cache-size");
// assert
assertEquals("prepared-statement-cache-size: "+ property.getValue(), SimpleValueSupport.wrap(32), property.getValue());
// change value
property.setValue(SimpleValueSupport.wrap(34));
// updateComponent and process()
mgtView.updateComponent(mc);
//
// Update 2nd DataSource
md = null;
for(ManagedDeployment d : deployment.getChildren())
{
if(d.getName().endsWith("test-second-ds.xml"))
{
md = d;
break;
}
}
assertNotNull(md);
mc = md.getComponent("OtherNestedTestDS");
// prepared-statement-cache-size
property = mc.getProperty("prepared-statement-cache-size");
// assert
assertEquals(property.getValue(), SimpleValueSupport.wrap(12));
// change
property.setValue(SimpleValueSupport.wrap(33));
// max-pool-size
property = mc.getProperty("max-pool-size");
// assert
assertEquals(property.getValue(), SimpleValueSupport.wrap(22));
// change
property.setValue(SimpleValueSupport.wrap(19));
// updateComponent and process()
mgtView.updateComponent(mc);
// See if the changes are reflected in the managedView after a reload
mgtView = getManagementView();
ManagedComponent comp2 = getManagedComponent(mgtView, "ChangedNestedDsJNDIName");