public abstract class LoggingTest
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
LoggingTest(java.lang.Class<?> loggingClass,
java.util.logging.Level level)
Creates a new test suite.
|
Modifier and Type | Method and Description |
---|---|
protected LoggingAssertions |
assertLog()
Obtains the instance of
AssertingHandler of this test. |
protected void |
interceptLogging()
Redirects logging to a custom handler which would accumulate the log output.
|
protected java.util.logging.Level |
level()
Obtains the level of logging assigned for the tests.
|
protected java.lang.Class<?> |
loggingClass()
Obtains the class which logging operations are tested.
|
protected java.util.logging.Level |
previousLevel()
Obtains the level of the logging set for the logging class before the tests.
|
protected void |
restoreLogging()
Removes the handler assigned in
interceptLogging() and restores the value
of the flag for using parent handlers. |
protected LoggingTest(java.lang.Class<?> loggingClass, java.util.logging.Level level)
loggingClass
- the class which performs the logging operationslevel
- the level of logging in which we are interested in the testsprotected final LoggingAssertions assertLog()
AssertingHandler
of this test.java.lang.NullPointerException
- if the handler was not initialized or already removedinterceptLogging()
,
restoreLogging()
protected final java.lang.Class<?> loggingClass()
protected final java.util.logging.Level level()
protected final java.util.logging.Level previousLevel()
protected final void interceptLogging()
The output can be later asserted.
The logging will have the level assigned for the test. The method also turns off parent handlers.
restoreLogging()
@BeforeEach
to allow derived test
suites hook up the logging where appropriate to the test suite. In some cases
the logger should be tuned after some of the operations performed in
a test setup.protected final void restoreLogging()
interceptLogging()
and restores the value
of the flag for using parent handlers.
The handler is not available after this method is called until
it is created and added back by interceptLogging()
.