Package org.apache.pekko.testkit
Class EventFilter
- java.lang.Object
-
- org.apache.pekko.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
Constructors Constructor Description EventFilter(int occurrences)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
apply(Logging.LogEvent event)
static <A extends java.lang.Throwable>
java.lang.Stringapply$default$1()
static <A extends java.lang.Throwable>
java.lang.Stringapply$default$2()
static <A extends java.lang.Throwable>
java.lang.Stringapply$default$3()
static <A extends java.lang.Throwable>
java.lang.Stringapply$default$4()
static <A extends java.lang.Throwable>
intapply$default$5()
void
assertDone(scala.concurrent.duration.Duration max)
Assert that this filter has matched as often as requested by itsoccurrences
parameter specifies.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 int
custom$default$2()
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.static java.lang.String
debug$default$1()
static java.lang.String
debug$default$2()
static java.lang.String
debug$default$3()
static java.lang.String
debug$default$4()
static int
debug$default$5()
protected boolean
doMatch(java.lang.String src, java.lang.Object msg)
internal implementation helper, no guaranteed APIstatic 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.static java.lang.String
error$default$1()
static java.lang.String
error$default$2()
static java.lang.String
error$default$3()
static java.lang.String
error$default$4()
static int
error$default$5()
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.static java.lang.String
info$default$1()
static java.lang.String
info$default$2()
static java.lang.String
info$default$3()
static java.lang.String
info$default$4()
static int
info$default$5()
<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.static java.lang.String
warning$default$1()
static java.lang.String
warning$default$2()
static java.lang.String
warning$default$3()
static java.lang.String
warning$default$4()
static int
warning$default$5()
-
-
-
Method Detail
-
apply$default$1
public static <A extends java.lang.Throwable> java.lang.String apply$default$1()
-
apply$default$2
public static <A extends java.lang.Throwable> java.lang.String apply$default$2()
-
apply$default$3
public static <A extends java.lang.Throwable> java.lang.String apply$default$3()
-
apply$default$4
public static <A extends java.lang.Throwable> java.lang.String apply$default$4()
-
apply$default$5
public static <A extends java.lang.Throwable> int apply$default$5()
-
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. See apply() for more details.
-
error$default$1
public static java.lang.String error$default$1()
-
error$default$2
public static java.lang.String error$default$2()
-
error$default$3
public static java.lang.String error$default$3()
-
error$default$4
public static java.lang.String error$default$4()
-
error$default$5
public static int error$default$5()
-
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 ofstart
andpattern
:EventFilter.warning() // filter only on warning event 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
beingnull
does NOT work (passingnull
disables the source filter).''
-
warning$default$1
public static java.lang.String warning$default$1()
-
warning$default$2
public static java.lang.String warning$default$2()
-
warning$default$3
public static java.lang.String warning$default$3()
-
warning$default$4
public static java.lang.String warning$default$4()
-
warning$default$5
public static int warning$default$5()
-
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 ofstart
andpattern
:EventFilter.info() // filter only on info event 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
beingnull
does NOT work (passingnull
disables the source filter).''
-
info$default$1
public static java.lang.String info$default$1()
-
info$default$2
public static java.lang.String info$default$2()
-
info$default$3
public static java.lang.String info$default$3()
-
info$default$4
public static java.lang.String info$default$4()
-
info$default$5
public static int info$default$5()
-
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 ofstart
andpattern
:EventFilter.debug() // filter only on debug 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
beingnull
does NOT work (passingnull
disables the source filter).''
-
debug$default$1
public static java.lang.String debug$default$1()
-
debug$default$2
public static java.lang.String debug$default$2()
-
debug$default$3
public static java.lang.String debug$default$3()
-
debug$default$4
public static java.lang.String debug$default$4()
-
debug$default$5
public static int debug$default$5()
-
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 returnstrue
.EventFilter.custom { case Warning(ref, "my warning") if ref == actor || ref == null => true }
-
custom$default$2
public static int custom$default$2()
-
matches
protected abstract boolean matches(Logging.LogEvent event)
This method decides whether to filter the event (true
) or not (false
).
-
apply
public final boolean apply(Logging.LogEvent event)
-
awaitDone
public boolean awaitDone(scala.concurrent.duration.Duration max)
-
assertDone
public void assertDone(scala.concurrent.duration.Duration max)
Assert that this filter has matched as often as requested by itsoccurrences
parameter specifies.
-
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.
-
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
-
-