Class Log4J2Logger
java.lang.Object
com.atlassian.confluence.test.util.AnnotatedMethodTemplate<Log4J2Logger.Record>
com.atlassian.confluence.test.util.Log4J2Logger
- All Implemented Interfaces:
org.junit.rules.TestRule
Record the logging output for a given log4j2 logger.
Usage:
public class MyTest
{
@literal @Rule public Log4JLogger logger = new Log4JLogger(MyTest.class);
@literal @Test
@literal @Log4JLogger.Record(loggerClass = MyUnitUnderTest.class, logLevel = Log4JLogger.LogLevel.DEBUG)
public void myTestMethod() throws Exception
{
// call unit under test
Assert.assertEquals("expected log message", logger.snapshot());
}
}
- Since:
- 7.20
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static @interface
-
Field Summary
Modifier and TypeFieldDescriptionprotected final org.apache.logging.log4j.core.StringLayout
Fields inherited from class com.atlassian.confluence.test.util.AnnotatedMethodTemplate
annotationClass, testClass
-
Constructor Summary
ConstructorDescriptionLog4J2Logger
(Class testClass) Log4J2Logger
(Class testClass, org.apache.logging.log4j.core.StringLayout layout) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.junit.runners.model.Statement
applyForAnnotation
(org.junit.runners.model.Statement statement, org.junit.runner.Description description, Log4J2Logger.Record record) snapshot()
Methods inherited from class com.atlassian.confluence.test.util.AnnotatedMethodTemplate
apply
-
Field Details
-
layout
protected final org.apache.logging.log4j.core.StringLayout layout
-
-
Constructor Details
-
Log4J2Logger
-
Log4J2Logger
-
-
Method Details
-
applyForAnnotation
protected org.junit.runners.model.Statement applyForAnnotation(org.junit.runners.model.Statement statement, org.junit.runner.Description description, Log4J2Logger.Record record) - Specified by:
applyForAnnotation
in classAnnotatedMethodTemplate<Log4J2Logger.Record>
-
snapshot
-