public class TestLoggerAssert extends org.assertj.core.api.AbstractAssert<C,TestLogger>
TestLogger
.
Should be thread safe, as this uses testLogger.getLoggingEvents()
by default. The
assertion mode can be switched to use testLogger.getAllLoggingEvents()
by calling
anyThread()
.
Modifier and Type | Class and Description |
---|---|
static class |
TestLoggerAssert.MdcComparator |
static class |
TestLoggerAssert.PredicateBuilder |
Modifier and Type | Field and Description |
---|---|
protected Supplier<List<LoggingEvent>> |
loggingEventsSupplier |
Modifier | Constructor and Description |
---|---|
protected |
TestLoggerAssert(TestLogger testLogger) |
Modifier and Type | Method and Description |
---|---|
TestLoggerAssert |
anyThread()
Changes the assertion mode to verify that log messages have been logged regardless of which
thread actually logged the message.
|
protected static LoggingEvent |
event(org.slf4j.event.Level level,
String message,
Object... arguments) |
protected static LoggingEvent |
event(Throwable throwable,
org.slf4j.event.Level level,
String message,
Object... arguments) |
protected long |
getLogCount(org.slf4j.event.Level level,
Predicate<LoggingEvent> predicate) |
LevelAssert |
hasLevel(org.slf4j.event.Level level)
Convenience method for a
LevelAssert from a provided test logger. |
TestLoggerAssert |
hasLogged(org.slf4j.event.Level level,
String message,
Object... arguments)
Verify that a log message, at a specific level, has been logged by the test logger.
|
TestLoggerAssert |
hasLogged(LoggingEvent event)
Verify that a
LoggingEvent has been logged by the test logger. |
TestLoggerAssert |
hasLogged(Predicate<LoggingEvent> predicate)
Verify that a
LoggingEvent satisfying the provided predicate has been logged by the
test logger. |
TestLoggerAssert |
hasLogged(TestLoggerAssert.PredicateBuilder predicate)
Uses the supplied
TestLoggerAssert.PredicateBuilder to construct the predicate with which to Verify that
a matching LoggingEvent has been logged by the test logger. |
TestLoggerAssert |
hasLogged(Throwable throwable,
org.slf4j.event.Level level,
String message,
Object... arguments)
Verify that a log message, at a specific level, has been logged by the test logger in the
presence of a
Throwable . |
TestLoggerAssert |
hasNotLogged(org.slf4j.event.Level level,
String message,
Object... arguments)
Verify that a log message, at a specific level, has not been logged by the test logger.
|
TestLoggerAssert |
hasNotLogged(LoggingEvent event)
Verify that a
LoggingEvent has not been logged by the test logger. |
TestLoggerAssert |
hasNotLogged(Predicate<LoggingEvent> predicate)
Verify that a
LoggingEvent satisfying the provided predicate has _not_ been logged by
the test logger. |
TestLoggerAssert |
hasNotLogged(TestLoggerAssert.PredicateBuilder predicate)
Uses the supplied
TestLoggerAssert.PredicateBuilder to construct the predicate with which to Verify that
a matching LoggingEvent has _not_ been logged by the test logger. |
TestLoggerAssert |
hasNotLogged(Throwable throwable,
org.slf4j.event.Level level,
String message,
Object... arguments)
Verify that a log message, at a specific level, has not been logged by the test logger in the
presence of a
Throwable . |
protected static Predicate<LoggingEvent> |
logWithMessage(String message,
Object... arguments) |
protected static Predicate<LoggingEvent> |
logWithMessage(String message,
Optional<Throwable> maybeThrowable,
Object... arguments) |
TestLoggerAssert |
usingMdcComparator(TestLoggerAssert.MdcComparator mdcComparator)
Allows the comparison strategy for verifying the MDC contents to be configured.
|
areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError
protected Supplier<List<LoggingEvent>> loggingEventsSupplier
protected TestLoggerAssert(TestLogger testLogger)
public TestLoggerAssert anyThread()
TestLoggerAssert
for chainingpublic TestLoggerAssert usingMdcComparator(TestLoggerAssert.MdcComparator mdcComparator)
The default behaviour is to verify the contents of the MDC are exactly equal to those on the logging event.
mdcComparator
- the comparator to use when verifying the contents of the MDC captured by
the logging eventTestLoggerAssert
for chainingTestLoggerAssert.MdcComparator
public TestLoggerAssert hasLogged(org.slf4j.event.Level level, String message, Object... arguments)
level
- the level of the log message to look formessage
- the expected messagearguments
- any optional arguments that may be provided to the log messageTestLoggerAssert
for chainingpublic TestLoggerAssert hasLogged(Throwable throwable, org.slf4j.event.Level level, String message, Object... arguments)
Throwable
.throwable
- the throwable that is attached to the log messagelevel
- the level of the log message to look formessage
- the expected messagearguments
- any optional arguments that may be provided to the log messageTestLoggerAssert
for chainingpublic TestLoggerAssert hasLogged(LoggingEvent event)
LoggingEvent
has been logged by the test logger.event
- the event to verify presence ofTestLoggerAssert
for chainingpublic TestLoggerAssert hasLogged(Predicate<LoggingEvent> predicate)
LoggingEvent
satisfying the provided predicate has been logged by the
test logger.predicate
- the predicate to test againstTestLoggerAssert
for chainingpublic TestLoggerAssert hasLogged(TestLoggerAssert.PredicateBuilder predicate)
TestLoggerAssert.PredicateBuilder
to construct the predicate with which to Verify that
a matching LoggingEvent
has been logged by the test logger.predicate
- the TestLoggerAssert.PredicateBuilder
to use to construct the test predicateTestLoggerAssert
for chainingpublic TestLoggerAssert hasNotLogged(org.slf4j.event.Level level, String message, Object... arguments)
level
- the level of the log message to look formessage
- the expected messagearguments
- any optional arguments that may be provided to the log messageTestLoggerAssert
for chainingpublic TestLoggerAssert hasNotLogged(Throwable throwable, org.slf4j.event.Level level, String message, Object... arguments)
Throwable
.throwable
- the throwable that is attached to the log messagelevel
- the level of the log message to look formessage
- the expected messagearguments
- any optional arguments that may be provided to the log messageTestLoggerAssert
for chainingpublic TestLoggerAssert hasNotLogged(LoggingEvent event)
LoggingEvent
has not been logged by the test logger.event
- the event to verify absence ofTestLoggerAssert
for chainingpublic TestLoggerAssert hasNotLogged(Predicate<LoggingEvent> predicate)
LoggingEvent
satisfying the provided predicate has _not_ been logged by
the test logger.predicate
- the predicate to test againstTestLoggerAssert
for chainingpublic TestLoggerAssert hasNotLogged(TestLoggerAssert.PredicateBuilder predicate)
TestLoggerAssert.PredicateBuilder
to construct the predicate with which to Verify that
a matching LoggingEvent
has _not_ been logged by the test logger.predicate
- the TestLoggerAssert.PredicateBuilder
to use to construct the test predicateTestLoggerAssert
for chainingpublic LevelAssert hasLevel(org.slf4j.event.Level level)
LevelAssert
from a provided test logger.level
- the Level
to assert againstLevelAssert
bound to the given Level
protected long getLogCount(org.slf4j.event.Level level, Predicate<LoggingEvent> predicate)
protected static Predicate<LoggingEvent> logWithMessage(String message, Object... arguments)
protected static Predicate<LoggingEvent> logWithMessage(String message, Optional<Throwable> maybeThrowable, Object... arguments)
protected static LoggingEvent event(org.slf4j.event.Level level, String message, Object... arguments)
protected static LoggingEvent event(Throwable throwable, org.slf4j.event.Level level, String message, Object... arguments)
Copyright © 2023. All rights reserved.