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 classstatic classstatic classstatic interfaceKeeps track of whether theLogEventinstances it receives match the expected content.static classstatic classstatic class -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExpectation(MockLog.LoggingExpectation expectation) voidstatic voidassertThatLogger(Runnable action, Class<?> loggerOwner, MockLog.LoggingExpectation... expectations) Executes an action and verifies expectations against the provided loggervoidstatic voidawaitLogger(Runnable action, Class<?> loggerOwner, MockLog.LoggingExpectation... expectations) Executes an action and waits until the given logging expectations are satisfied.static MockLogAdds the list of class loggers to thisMockLog.static MockLogSame as above except takes string class names of each logger.voidclose()static voidinit()Initialize the mock log appender with the log4j system.
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein 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.
-