Class TestLoggerResource
- java.lang.Object
-
- org.junit.rules.ExternalResource
-
- org.apache.flink.testutils.logging.TestLoggerResource
-
- All Implemented Interfaces:
org.junit.rules.TestRule
public class TestLoggerResource extends org.junit.rules.ExternalResourceUtility for auditing logged messages.Note: If a parent logger is already defined with a less specific log level, then using the
TestLoggerResourcecan increase the number of log messages received by this logger.Example: You define a logger for org.apache.runtime with log level INFO and then use
TestLoggerResourceto listen on org.apache.runtime.feature with log level DEBUG. In this case, the log output for the parent logger will include DEBUG messages org.apache.runtime.feature.Implementation note: Make sure to not expose log4j dependencies in the interface of this class to ease updates in logging infrastructure.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTestLoggerResource.SingleTestResourceSingleTestResource re-uses the code inTestLoggerResourcefor try-with-resources statement.
-
Constructor Summary
Constructors Constructor Description TestLoggerResource(Class<?> clazz, org.slf4j.event.Level level)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidafter()static TestLoggerResource.SingleTestResourceasSingleTestResource(String loggerName, org.slf4j.event.Level level)Enables the use ofTestLoggerResourcefor try-with-resources statement.protected voidbefore()List<String>getMessages()
-
-
-
Constructor Detail
-
TestLoggerResource
public TestLoggerResource(Class<?> clazz, org.slf4j.event.Level level)
-
-
Method Detail
-
before
protected void before() throws Throwable- Overrides:
beforein classorg.junit.rules.ExternalResource- Throws:
Throwable
-
after
protected void after()
- Overrides:
afterin classorg.junit.rules.ExternalResource
-
asSingleTestResource
public static TestLoggerResource.SingleTestResource asSingleTestResource(String loggerName, org.slf4j.event.Level level) throws Throwable
Enables the use ofTestLoggerResourcefor try-with-resources statement.- Throws:
Throwable
-
-