use of org.opendaylight.genius.datastoreutils.listeners.DataTreeEventCallbackRegistrar.NextAction in project genius by opendaylight.
the class DataTreeEventCallbackRegistrarTest method testExceptionInCallbackMustBeLogged.
@Test
public void testExceptionInCallbackMustBeLogged() throws TransactionCommitFailedException, InterruptedException {
logCaptureRule.expectLastErrorMessageContains("TestConsumer");
AtomicBoolean added = new AtomicBoolean(false);
DataTreeEventCallbackRegistrar dataTreeEventCallbackRegistrar = new DataTreeEventCallbackRegistrarImpl(db);
dataTreeEventCallbackRegistrar.onAdd(OPERATIONAL, FOO_PATH, new Function<TopLevelList, NextAction>() {
@Override
public NextAction apply(TopLevelList topLevelList) {
added.set(true);
throw new IllegalStateException("TEST");
}
@Override
public String toString() {
return "TestConsumer";
}
});
db1.syncWrite(OPERATIONAL, FOO_PATH, FOO_DATA);
await().untilTrue(added);
// TODO see above we can remove this once we can await DataBroker listeners
// The sleep () is required :( so that the throw new IllegalStateException really leads to an ERROR log,
// because the (easily) await().untilTrue(...) could theoretically complete immediately after added.set(true)
// but before the throw new IllegalStateException("TEST") and LOG. To make this more reliable and without sleep
// would require more work inside DataBroker to be able to await listener event processing.
Thread.sleep(100);
}
Aggregations