public class EventWaitingLatch extends Object
This is useful when assertions need to be made on the output of a long running process on the server that clearly indicates its completion using an event.
Usage:
EventWaitingLatch latch = new EventWaitingLatch(MyEvent.class, 60000, rpc); try { latch.registerListener(); ... insert code that invokes long running process on server side ... latch.await(); ... insert test assertions ... } finally { latch.clearListener(); }
It is important that the latch is instantiated before the start of the long running process. If constructed after, there is a small chance that the event being listened for is fired before latch is ready to receive it.
Constructor and Description |
---|
EventWaitingLatch(String eventClassName,
TimePeriod timeout,
ConfluenceRpc rpc) |
Modifier and Type | Method and Description |
---|---|
static void |
clearAllLatches(ConfluenceRpc rpc)
It's advisable to clear all latches in a tearDown if multiple latches will be active concurrently.
|
void |
registerListener() |
void |
unregisterListener() |
boolean |
waitForEvent()
Blocks until event is received.
|
public EventWaitingLatch(String eventClassName, TimePeriod timeout, ConfluenceRpc rpc)
public boolean waitForEvent()
public static void clearAllLatches(ConfluenceRpc rpc)
public void registerListener()
public void unregisterListener()
Copyright © 2003–2020 Atlassian. All rights reserved.