* @throws Exception
* If the test unexpectedly fails.
*/
@Test
public void testDeleteConstraintFail() throws Exception {
TestParentCfg parent = getParent("test parent 1");
DeleteListener listener = new DeleteListener();
parent.addTestChildDeleteListener(listener);
MockConstraint constraint = new MockConstraint(true, false);
TestCfg.addConstraint(constraint);
try {
// Add the entry.
TestCaseUtils.addEntry(TEST_CHILD_1);
try {
// Now delete it - this should trigger the constraint.
deleteSubtree(TEST_CHILD_1_DN);
// Should not have succeeded.
Assert.fail("Delete constraint failed to prevent deletion");
} catch (OperationNotSupportedException e) {
// Ignore - this is the expected exception.
}
} finally {
TestCfg.removeConstraint(constraint);
parent.removeTestChildDeleteListener(listener);
try {
// Clean up.
deleteSubtree(TEST_CHILD_1_DN);
} catch (Exception e) {