Package com.adobe.cq.testing.polling
Class EventPoller
java.lang.Object
org.apache.sling.testing.clients.util.poller.Polling
com.adobe.cq.testing.polling.EventPoller
public class EventPoller
extends org.apache.sling.testing.clients.util.poller.Polling
A poller that checks the occurrence of a given OSGi event.
Can either be used via the checkEventOccurrence() class method or by
instantiating an eventPoller and calling the callUntilCondition() method.
-
Field Summary
Fields inherited from class org.apache.sling.testing.clients.util.poller.Polling
c, exceptions, lastException, waited
-
Constructor Summary
ConstructorDescriptionEventPoller
(org.apache.sling.testing.clients.SlingClient client, String topic, String path, long since) Instantiate a new EventPoller -
Method Summary
Modifier and TypeMethodDescriptioncall()
static boolean
checkEventOccurrence
(org.apache.sling.testing.clients.SlingClient client, String topic, String path, long since) Asynchronously checks for the occurrence of a given event in the OSGi event log.static boolean
containsEvent
(com.fasterxml.jackson.databind.JsonNode events, String topic, String path) Checks if a given array of events contains an event with a given topic at a given pathstatic com.fasterxml.jackson.databind.JsonNode
getEventsSince
(org.apache.sling.testing.clients.SlingClient client, long timestamp) Returns all OSGi event since a given time.static long
getLatestEventTimestamp
(org.apache.sling.testing.clients.SlingClient client) Returns a timestamp of the latest recorded OSGi event.Methods inherited from class org.apache.sling.testing.clients.util.poller.Polling
getExceptions, getLastException, getWaited, message, poll
-
Constructor Details
-
EventPoller
public EventPoller(org.apache.sling.testing.clients.SlingClient client, String topic, String path, long since) Instantiate a new EventPoller- Parameters:
client
- required to read from the event logtopic
- the topic that should be looked forpath
- the path the event should occursince
- the time from which on events are considered
-
-
Method Details
-
call
-
getLatestEventTimestamp
public static long getLatestEventTimestamp(org.apache.sling.testing.clients.SlingClient client) throws org.apache.sling.testing.clients.ClientException Returns a timestamp of the latest recorded OSGi event.- Parameters:
client
- required to read from the event log- Returns:
- a timestamp of the latest event
- Throws:
org.apache.sling.testing.clients.ClientException
- if request to OSGi event log could not be made
-
getEventsSince
public static com.fasterxml.jackson.databind.JsonNode getEventsSince(org.apache.sling.testing.clients.SlingClient client, long timestamp) throws org.apache.sling.testing.clients.ClientException Returns all OSGi event since a given time.- Parameters:
client
- required to read from the event logtimestamp
- the time from which on events are considered- Returns:
- an array of events as JSONArray
- Throws:
org.apache.sling.testing.clients.ClientException
- if request to OSGi event log could not be made
-
containsEvent
public static boolean containsEvent(com.fasterxml.jackson.databind.JsonNode events, String topic, String path) Checks if a given array of events contains an event with a given topic at a given path- Parameters:
events
- array of events that should be searchedtopic
- the topic that should be looked forpath
- the path the event should occur- Returns:
- true if the event was found in the given array
-
checkEventOccurrence
public static boolean checkEventOccurrence(org.apache.sling.testing.clients.SlingClient client, String topic, String path, long since) throws InterruptedException Asynchronously checks for the occurrence of a given event in the OSGi event log.- Parameters:
client
- required to read from the event logtopic
- the topic that should be looked forpath
- the path the event should occursince
- the time from which on events are considered- Returns:
- true if the event occurred.
- Throws:
InterruptedException
- to mark this method as waiting
-