Class LoggingListener
java.lang.Object
org.junit.runner.notification.RunListener
org.elasticsearch.test.junit.listeners.LoggingListener
public class LoggingListener
extends org.junit.runner.notification.RunListener
A
RunListener
that allows changing the log level for a specific test method. When a test method is annotated with the
TestLogging
annotation, the level for the specified loggers will be internally saved before the test method execution and
overridden with the specified ones. At the end of the test method execution the original loggers levels will be restored.
This class is not thread-safe. Given the static nature of the logging API, it assumes that tests are never run concurrently in the same
JVM. For the very same reason no synchronization has been implemented regarding the save/restore process of the original loggers
levels.-
Nested Class Summary
Nested classes/interfaces inherited from class org.junit.runner.notification.RunListener
org.junit.runner.notification.RunListener.ThreadSafe
-
Constructor Summary
Constructors Constructor Description LoggingListener()
-
Method Summary
Modifier and Type Method Description void
testFinished(org.junit.runner.Description description)
void
testRunFinished(org.junit.runner.Result result)
void
testRunStarted(org.junit.runner.Description description)
void
testStarted(org.junit.runner.Description description)
Methods inherited from class org.junit.runner.notification.RunListener
testAssumptionFailure, testFailure, testIgnored
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
LoggingListener
public LoggingListener()
-
-
Method Details
-
testRunStarted
public void testRunStarted(org.junit.runner.Description description) throws java.lang.Exception- Overrides:
testRunStarted
in classorg.junit.runner.notification.RunListener
- Throws:
java.lang.Exception
-
testRunFinished
public void testRunFinished(org.junit.runner.Result result) throws java.lang.Exception- Overrides:
testRunFinished
in classorg.junit.runner.notification.RunListener
- Throws:
java.lang.Exception
-
testStarted
public void testStarted(org.junit.runner.Description description) throws java.lang.Exception- Overrides:
testStarted
in classorg.junit.runner.notification.RunListener
- Throws:
java.lang.Exception
-
testFinished
public void testFinished(org.junit.runner.Description description) throws java.lang.Exception- Overrides:
testFinished
in classorg.junit.runner.notification.RunListener
- Throws:
java.lang.Exception
-