What is the correct approach to monitor an events inside a testcase?
variant A:
fireEvent(topicX)
assertEvent(topicX, 500, TimeUnit.MILLISECONDS)
fireEvent could then be already happened before assertEvent is ready and the assertion would run into the timeout
variant B:
assertEvent(topicX, 500, TimeUnit.MILLISECONDS)
with this order the testcase would assure that the OSGi EventAdmin is delivering the fireEvent method within the specified timeout of 500 ms.
What would be a meaningful timeout for this variant B?
An other idea:
How about registering an EventListener for the eventAssertion upfront and having a method assertEvent(topic, timeoutPast, timeoutFuture).
This could be the using the registered EventListener to identify if such an event has happened in the timeframe between timeoutPast->now->timeoutFuture ?