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 delete the referenced connection handler.
// This should fail.
try {
deleteConnectionHandler();
Assert.fail("Successfully deleted a referenced component");
} catch (OperationRejectedException e) {
// This is the expected exception - do nothing.
}
} finally {
try {
deleteSubtree(TEST_CHILD_7_DN);
} finally {
try {
deleteConnectionHandler();
} catch (ManagedObjectNotFoundException e) {
// Ignore as it may have been deleted already.
} 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());