com.atlassian.confluence.it.rpc
Class EventWaitingLatch

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

public class EventWaitingLatch
extends java.lang.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);

 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 Summary
EventWaitingLatch(java.lang.Class eventClass, TimePeriod timeout, ConfluenceRpc rpc)
          Deprecated. since 5.2 use EventWaitingLatch(String, TimePeriod, ConfluenceRpc) instead, since acceptance test code should not have a compile-time depency
EventWaitingLatch(java.lang.String eventClassName, TimePeriod timeout, ConfluenceRpc rpc)
           
 
Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventWaitingLatch

public EventWaitingLatch(java.lang.String eventClassName,
                         TimePeriod timeout,
                         ConfluenceRpc rpc)

EventWaitingLatch

@Deprecated
public EventWaitingLatch(java.lang.Class eventClass,
                                    TimePeriod timeout,
                                    ConfluenceRpc rpc)
Deprecated. since 5.2 use EventWaitingLatch(String, TimePeriod, ConfluenceRpc) instead, since acceptance test code should not have a compile-time depency

Method Detail

waitForEvent

public boolean waitForEvent()
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.


registerListener

public void registerListener()

unregisterListener

public void unregisterListener()


Copyright © 2003-2014 Atlassian. All Rights Reserved.