Package reactor.test.util
Class LoggerUtils
java.lang.Object
reactor.test.util.LoggerUtils
This class eases testing interested in what reactor classes emit using
loggers.- Author:
- Eric Bottard
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidDisable capturing, forgetting about the logger set viaenableCaptureWith(Logger).static voidenableCaptureWith(Logger testLogger) Set the logger used for capturing.static voidenableCaptureWith(Logger testLogger, boolean redirectToOriginal) Set the logger used for capturing, an optionally suppress log messages from original logger.static DisposableSets alogger factorythat will return loggers that not only use the original logging framework used by reactor, but also use the logger set viaenableCaptureWith(Logger), irrespective of its name or how it was obtained.
-
Method Details
-
useCurrentLoggersWithCapture
Sets alogger factorythat will return loggers that not only use the original logging framework used by reactor, but also use the logger set viaenableCaptureWith(Logger), irrespective of its name or how it was obtained. The expectation here is that tests that want to assess that something is logged by reactor will pass aTestLoggerinstance toenableCaptureWith(Logger), trigger the operation under scrutiny, assert the logger contents and reset state by callingdisableCapture().This method should be called very early in the application/tests lifecycle, before reactor classes have created their loggers.
- Returns:
- a disposable that re-installs the original factory when disposed
- Throws:
IllegalStateException
-
enableCaptureWith
Set the logger used for capturing.- Parameters:
testLogger- theLoggerin which to copy logs- Throws:
IllegalStateException- if no capturing factory is installed or a previous logger has been set but not cleared viadisableCapture()
-
enableCaptureWith
Set the logger used for capturing, an optionally suppress log messages from original logger.- Parameters:
testLogger- theTestLoggerin which to copy or redirect logsredirectToOriginal- whether log messages should also go to the original logging infrastructure- Throws:
IllegalStateException- if no capturing factory is installed or a previous logger has been set but not cleared viadisableCapture()
-
disableCapture
public static void disableCapture()Disable capturing, forgetting about the logger set viaenableCaptureWith(Logger).
-