Class AbstractTestableListener
- java.lang.Object
-
- org.opendaylight.genius.datastoreutils.testutils.AbstractTestableListener
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,AsyncEventsWaiter
- Direct Known Subclasses:
TestableDataTreeChangeListener
public abstract class AbstractTestableListener extends java.lang.Object implements AsyncEventsWaiter
Event listener which offer testability in asynchronous usage scenarios.- Author:
- Michael Vorburger.ch
-
-
Constructor Summary
Constructors Constructor Description AbstractTestableListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
awaitEventsConsumption()
Wait by blocking calling thread until pending events have been processed by other threads in the background.protected boolean
awaitEventsConsumption(long timeout, java.util.concurrent.TimeUnit unit)
boolean
awaitEventsConsumption(java.time.Duration timeout)
void
close()
protected void
consumedEvents(int howMany)
Signal that a testable listener has consumed an event.
-
-
-
Method Detail
-
awaitEventsConsumption
public boolean awaitEventsConsumption()
Description copied from interface:AsyncEventsWaiter
Wait by blocking calling thread until pending events have been processed by other threads in the background. Implementations must have some sensible fixed timeout value. This method is normally called from the JUnit Test main thread.- Specified by:
awaitEventsConsumption
in interfaceAsyncEventsWaiter
- Returns:
- true if anything was pending to be processed and has been processed, false if nothing needed to be
-
awaitEventsConsumption
public boolean awaitEventsConsumption(java.time.Duration timeout)
-
awaitEventsConsumption
protected boolean awaitEventsConsumption(long timeout, java.util.concurrent.TimeUnit unit)
-
consumedEvents
protected void consumedEvents(int howMany)
Signal that a testable listener has consumed an event. This is normally called either from the JUnit Test main thread if the event listener is synchronous, or from a background thread if the event listener is asynchronous.- Parameters:
howMany
- number of events consumed; may be negative, to decrement
-
close
public void close() throws java.lang.IllegalStateException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.lang.IllegalStateException
-
-