akka.testkit
Class EventFilter

java.lang.Object
  extended by akka.testkit.EventFilter
Direct Known Subclasses:
CustomEventFilter, DeadLettersFilter, DebugFilter, ErrorFilter, InfoFilter, WarningFilter

public abstract class EventFilter
extends java.lang.Object

Facilities for selectively filtering out expected events from logging so that you can keep your test run’s console output clean and do not miss real error messages.

See the companion object for convenient factory methods.

If the occurrences is set to Int.MaxValue, no tracking is done.


Constructor Summary
EventFilter(int occurrences)
           
 
Method Summary
 boolean apply(Logging.LogEvent event)
           
 boolean awaitDone(scala.concurrent.duration.Duration max)
           
protected  boolean complete()
           
static EventFilter custom(scala.PartialFunction<Logging.LogEvent,java.lang.Object> test, int occurrences)
          Create a custom event filter.
static EventFilter debug(java.lang.String message, java.lang.String source, java.lang.String start, java.lang.String pattern, int occurrences)
          Create a filter for Debug events.
protected  boolean doMatch(java.lang.String src, java.lang.Object msg)
          internal implementation helper, no guaranteed API
static EventFilter error(java.lang.String message, java.lang.String source, java.lang.String start, java.lang.String pattern, int occurrences)
          Create a filter for Error events which do not have a cause set (i.e.
static EventFilter info(java.lang.String message, java.lang.String source, java.lang.String start, java.lang.String pattern, int occurrences)
          Create a filter for Info events.
<T> T
intercept(scala.Function0<T> code, ActorSystem system)
          Apply this filter while executing the given code block.
protected abstract  boolean matches(Logging.LogEvent event)
          This method decides whether to filter the event (true) or not (false).
protected  scala.util.Either<java.lang.String,scala.util.matching.Regex> message()
           
protected  scala.Option<java.lang.String> source()
           
static EventFilter warning(java.lang.String message, java.lang.String source, java.lang.String start, java.lang.String pattern, int occurrences)
          Create a filter for Warning events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventFilter

public EventFilter(int occurrences)
Method Detail

error

public static EventFilter error(java.lang.String message,
                                java.lang.String source,
                                java.lang.String start,
                                java.lang.String pattern,
                                int occurrences)
Create a filter for Error events which do not have a cause set (i.e. use implicitly supplied Logging.Error.NoCause). See apply() for more details.

Parameters:
message - (undocumented)
source - (undocumented)
start - (undocumented)
pattern - (undocumented)
occurrences - (undocumented)
Returns:
(undocumented)

warning

public static EventFilter warning(java.lang.String message,
                                  java.lang.String source,
                                  java.lang.String start,
                                  java.lang.String pattern,
                                  int occurrences)
Create a filter for Warning events. Give up to one of start and pattern:


 EventFilter.warning()                                         // filter only on exception type
 EventFilter.warning(source = obj)                             // filter on event source
 EventFilter.warning(start = "Expected")                       // filter on start of message
 EventFilter.warning(source = obj, pattern = "weird.*message") // filter on pattern and message
 

''Please note that filtering on the source being null does NOT work (passing null disables the source filter).''

Parameters:
message - (undocumented)
source - (undocumented)
start - (undocumented)
pattern - (undocumented)
occurrences - (undocumented)
Returns:
(undocumented)

info

public static EventFilter info(java.lang.String message,
                               java.lang.String source,
                               java.lang.String start,
                               java.lang.String pattern,
                               int occurrences)
Create a filter for Info events. Give up to one of start and pattern:


 EventFilter.info()                                         // filter only on exception type
 EventFilter.info(source = obj)                             // filter on event source
 EventFilter.info(start = "Expected")                       // filter on start of message
 EventFilter.info(source = obj, pattern = "weird.*message") // filter on pattern and message
 

''Please note that filtering on the source being null does NOT work (passing null disables the source filter).''

Parameters:
message - (undocumented)
source - (undocumented)
start - (undocumented)
pattern - (undocumented)
occurrences - (undocumented)
Returns:
(undocumented)

debug

public static EventFilter debug(java.lang.String message,
                                java.lang.String source,
                                java.lang.String start,
                                java.lang.String pattern,
                                int occurrences)
Create a filter for Debug events. Give up to one of start and pattern:


 EventFilter.debug()                                         // filter only on exception type
 EventFilter.debug(source = obj)                             // filter on event source
 EventFilter.debug(start = "Expected")                       // filter on start of message
 EventFilter.debug(source = obj, pattern = "weird.*message") // filter on pattern and message
 

''Please note that filtering on the source being null does NOT work (passing null disables the source filter).''

Parameters:
message - (undocumented)
source - (undocumented)
start - (undocumented)
pattern - (undocumented)
occurrences - (undocumented)
Returns:
(undocumented)

custom

public static EventFilter custom(scala.PartialFunction<Logging.LogEvent,java.lang.Object> test,
                                 int occurrences)
Create a custom event filter. The filter will affect those events for which the supplied partial function is defined and returns true.


 EventFilter.custom {
   case Warning(ref, "my warning") if ref == actor || ref == null => true
 }
 

Parameters:
test - (undocumented)
occurrences - (undocumented)
Returns:
(undocumented)

matches

protected abstract boolean matches(Logging.LogEvent event)
This method decides whether to filter the event (true) or not (false).

Parameters:
event - (undocumented)
Returns:
(undocumented)

apply

public final boolean apply(Logging.LogEvent event)

awaitDone

public boolean awaitDone(scala.concurrent.duration.Duration max)

intercept

public <T> T intercept(scala.Function0<T> code,
                       ActorSystem system)
Apply this filter while executing the given code block. Care is taken to remove the filter when the block is finished or aborted.

Parameters:
code - (undocumented)
system - (undocumented)
Returns:
(undocumented)

source

protected scala.Option<java.lang.String> source()

message

protected scala.util.Either<java.lang.String,scala.util.matching.Regex> message()

complete

protected boolean complete()

doMatch

protected boolean doMatch(java.lang.String src,
                          java.lang.Object msg)
internal implementation helper, no guaranteed API

Parameters:
src - (undocumented)
msg - (undocumented)
Returns:
(undocumented)