boolean isFound = false;
for (ConfigAddListener l : configEntry.getAddListeners()) {
if (l instanceof DelayedConfigAddListener) {
DelayedConfigAddListener dl = (DelayedConfigAddListener) l;
ConfigDeleteListener tmp = dl.getDelayedDeleteListener();
if (tmp instanceof ConfigDeleteListenerAdaptor) {
ConfigDeleteListenerAdaptor<?> al = (ConfigDeleteListenerAdaptor<?>) tmp;
if (extractListener(al) == listener) {
isFound = true;
}
}
}
}
if (!isFound) {
fail("Unable to locate delayed listener in entry " + parentDN);
}
// Now make sure that the delayed listener is removed from the
// parent and the add listener register against the relation entry
// when it is created.
String[] entry = new String[] {
"dn: cn=test parents,cn=config",
"objectclass: top",
"objectclass: ds-cfg-branch",
"cn: test-parents"
};
TestCaseUtils.addEntry(entry);
// Check the delayed listener is removed.
for (ConfigAddListener l : configEntry.getAddListeners()) {
if (l instanceof DelayedConfigAddListener) {
DelayedConfigAddListener dl = (DelayedConfigAddListener) l;
ConfigDeleteListener tmp = dl.getDelayedDeleteListener();
if (tmp instanceof ConfigDeleteListenerAdaptor) {
ConfigDeleteListenerAdaptor<?> al = (ConfigDeleteListenerAdaptor<?>) tmp;
if (extractListener(al) == listener) {
fail("Delayed listener still exists in entry " + parentDN
+ " when it should have been removed");