ConfigurationChangeListener<TestChildCfg> cl = new DummyChangeListener();
try {
// Retrieve the parent and child managed objects and register
// delete and change listeners respectively in order to trigger
// the constraint call-backs.
TestParentCfg parent = getParent("test parent 1");
parent.addTestChildDeleteListener(dl);
TestChildCfg child = parent.getTestChild("test child 7");
child.addChangeListener(cl);
// Now attempt to disable the referenced connection handler.
// This should fail.
try {
RootCfgClient root = TestCaseUtils.getRootConfiguration();
ConnectionHandlerCfgClient client = root
.getConnectionHandler(TEST_CONNECTION_HANDLER_NAME);
client.setEnabled(false);
client.commit();
Assert.fail("Successfully disabled a referenced component");
} catch (OperationRejectedException e) {
// This is the expected exception - do nothing.
}
} finally {
try {
deleteSubtree(TEST_CHILD_7_DN);
} finally {
try {
deleteConnectionHandler();
} finally {
// Remove the temporary delete listener.
TestParentCfg parent = getParent("test parent 1");
parent.removeTestChildDeleteListener(dl);
// Put back the default aggregation definition.
TestCfg
.removeConstraint(aggregationPropertyDefinitionTargetMustBeEnabled
.getSourceConstraint());