com.atlassian.confluence.it.rpc
Class EventWaitingLatch

java.lang.Object
  extended by com.atlassian.confluence.it.rpc.EventWaitingLatch

public class EventWaitingLatch
extends Object

Latch that allows acceptance testing code to wait for a specific Confluence event to be published on the server side before proceeding with assertions.

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);

 ... insert code that invokes long running process on server side ...

 latch.await();

 ... insert test assertions ...
 
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 Summary
EventWaitingLatch(Class eventClass, int timeout, ConfluenceRpc rpc)
           
EventWaitingLatch(String eventClassName, int timeout, ConfluenceRpc rpc)
           
 
Method Summary
 boolean await()
          Blocks until event is received.
static void clearAllLatches(ConfluenceRpc rpc)
          It's advisable to clear all latches in a tearDown if multiple latches will be active concurrently.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventWaitingLatch

public EventWaitingLatch(String eventClassName,
                         int timeout,
                         ConfluenceRpc rpc)

EventWaitingLatch

public EventWaitingLatch(Class eventClass,
                         int timeout,
                         ConfluenceRpc rpc)
Method Detail

await

public boolean await()
Blocks until event is received. Returns true if this happens within the timeout, false otherwise.

Returns:
true if the event is received within the timeout, false otherwise.

clearAllLatches

public static void clearAllLatches(ConfluenceRpc rpc)
It's advisable to clear all latches in a tearDown if multiple latches will be active concurrently.



Copyright © 2003-2011 Atlassian. All Rights Reserved.