Package org.elasticsearch.test
Class MockLog
java.lang.Object
org.elasticsearch.test.MockLog
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.elasticsearch.core.Releasable
Test appender that can be used to verify that certain events were logged correctly
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
static class
static interface
Keeps track of whether theLogEvent
instances it receives match the expected content.static class
static class
static class
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addExpectation
(MockLog.LoggingExpectation expectation) void
static void
assertThatLogger
(Runnable action, Class<?> loggerOwner, MockLog.LoggingExpectation... expectations) Executes an action and verifies expectations against the provided loggervoid
static void
awaitLogger
(Runnable action, Class<?> loggerOwner, MockLog.LoggingExpectation... expectations) Executes an action and waits until the given logging expectations are satisfied.static MockLog
Adds the list of class loggers to thisMockLog
.static MockLog
Same as above except takes string class names of each logger.void
close()
static void
init()
Initialize the mock log appender with the log4j system.
-
Method Details
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceorg.elasticsearch.core.Releasable
-
init
public static void init()Initialize the mock log appender with the log4j system. -
addExpectation
-
assertAllExpectationsMatched
public void assertAllExpectationsMatched() -
awaitAllExpectationsMatched
public void awaitAllExpectationsMatched() -
capture
-
capture
Same as above except takes string class names of each logger. -
assertThatLogger
public static void assertThatLogger(Runnable action, Class<?> loggerOwner, MockLog.LoggingExpectation... expectations) Executes an action and verifies expectations against the provided logger -
awaitLogger
public static void awaitLogger(Runnable action, Class<?> loggerOwner, MockLog.LoggingExpectation... expectations) Executes an action and waits until the given logging expectations are satisfied.
-