com.atlassian.plugin.test
Class CapturedLogging
java.lang.Object
org.junit.rules.ExternalResource
com.atlassian.plugin.test.CapturedLogging
- All Implemented Interfaces:
- org.junit.rules.TestRule
public class CapturedLogging
- extends org.junit.rules.ExternalResource
A JUnit Rule for capturing and verifying log messages from a given class.
This implementation is Log4J specific, but the interface is framed in SLF4J terminology. The intent is that if we need to switch
to a different logger we should be able to preserve the interface, since it mirrors the SLF4J interface used by non test code.
The implementation uses a Log4j appender to capture log messages for verification.
- Since:
- 3.2.16
| Methods inherited from class org.junit.rules.ExternalResource |
apply |
CapturedLogging
public CapturedLogging(Class logSource)
getLoggingEvents
public List<org.apache.log4j.spi.LoggingEvent> getLoggingEvents()
before
protected void before()
throws Throwable
- Overrides:
before in class org.junit.rules.ExternalResource
- Throws:
Throwable
after
protected void after()
- Overrides:
after in class org.junit.rules.ExternalResource
didLog
public static org.hamcrest.Matcher<CapturedLogging> didLog(org.hamcrest.Matcher<org.apache.log4j.spi.LoggingEvent> loggingEventMatcher)
didLogWarn
public static org.hamcrest.Matcher<CapturedLogging> didLogWarn(org.hamcrest.Matcher<String> messageMatcher)
didLogWarn
public static org.hamcrest.Matcher<CapturedLogging> didLogWarn(String... substrings)
didLogDebug
public static org.hamcrest.Matcher<CapturedLogging> didLogDebug(org.hamcrest.Matcher<String> messageMatcher)
didLogDebug
public static org.hamcrest.Matcher<CapturedLogging> didLogDebug(String... substrings)
levelIs
public static org.hamcrest.Matcher<org.apache.log4j.spi.LoggingEvent> levelIs(org.apache.log4j.Level level)
messageMatches
public static org.hamcrest.Matcher<org.apache.log4j.spi.LoggingEvent> messageMatches(org.hamcrest.Matcher<String> stringMatcher)
toString
public String toString()
- Overrides:
toString in class Object
levelAndMessageMatch
public static org.hamcrest.Matcher<org.apache.log4j.spi.LoggingEvent> levelAndMessageMatch(org.apache.log4j.Level level,
org.hamcrest.Matcher<String> messageMatcher)
Copyright © 2015 Atlassian. All rights reserved.