use of reactor.test.util.TestLogger in project reactor-core by reactor.
the class SignalLoggerTests method currentContextLogWhenTrace.
@Test
public void currentContextLogWhenTrace() {
TestLogger logger = new TestLogger();
SignalLogger<?> signalLogger = new SignalLogger<>(Mono.empty(), null, Level.FINEST, false, name -> logger);
assertThat(logger.getOutContent()).as("before currentContext()").isEmpty();
Context context = Context.of("foo", "bar");
signalLogger.onCurrentContextCall().accept(context);
assertThat(logger.getOutContent()).startsWith("[TRACE] (").endsWith(") currentContext(Context1{foo=bar})\n");
}
use of reactor.test.util.TestLogger in project reactor-core by reactor.
the class SignalLoggerTests method safeLogsWhenLoggerThrows.
@Test
public void safeLogsWhenLoggerThrows() {
TestLogger logger = new TestLogger() {
@Override
public synchronized void info(String format, Object... arguments) {
if (arguments[0] instanceof SignalType && arguments[1] instanceof Integer) {
throw new UnsupportedOperationException("boom on integer");
}
super.info(format, arguments);
}
};
SignalLogger signalLogger = new SignalLogger<>(Flux.empty(), null, Level.INFO, false, it -> logger);
signalLogger.safeLog(SignalType.ON_NEXT, 404);
assertThat(logger.getOutContent()).contains("UnsupportedOperationException has been raised by the logging framework, does your log() placement make sense? " + "eg. 'window(2).log()' instead of 'window(2).flatMap(w -> w.log())' - " + "java.lang.UnsupportedOperationException: boom on integer").contains("onNext(404)");
}
use of reactor.test.util.TestLogger in project reactor-core by reactor.
the class SignalLoggerTests method currentContextLogWhenDebug.
@Test
public void currentContextLogWhenDebug() {
TestLogger logger = new TestLogger();
SignalLogger<?> signalLogger = new SignalLogger<>(Mono.empty(), null, Level.FINE, false, name -> logger);
assertThat(logger.getOutContent()).as("before currentContext()").isEmpty();
Context context = Context.of("foo", "bar");
signalLogger.onCurrentContextCall().accept(context);
assertThat(logger.getOutContent()).startsWith("[DEBUG] (").endsWith(") currentContext(Context1{foo=bar})\n");
}
use of reactor.test.util.TestLogger in project reactor-core by reactor.
the class FluxZipTest method failDoubleError2.
// FIXME use Violation.NO_CLEANUP_ON_TERMINATE
@Test
public void failDoubleError2() {
TestLogger testLogger = new TestLogger();
LoggerUtils.enableCaptureWith(testLogger);
try {
StepVerifier.create(Flux.zip(obj -> 0, Flux.just(1).hide(), Flux.never(), s -> {
s.onSubscribe(Operators.emptySubscription());
s.onError(new Exception("test"));
s.onError(new Exception("test2"));
})).verifyErrorMessage("test");
Assertions.assertThat(testLogger.getErrContent()).contains("Operator called default onErrorDropped").contains("test2");
} finally {
LoggerUtils.disableCapture();
}
}
use of reactor.test.util.TestLogger in project reactor-core by reactor.
the class FluxZipTest method failDoubleError.
// FIXME use Violation.NO_CLEANUP_ON_TERMINATE
@Test
public void failDoubleError() {
TestLogger testLogger = new TestLogger();
LoggerUtils.enableCaptureWith(testLogger);
try {
StepVerifier.create(Flux.zip(obj -> 0, Flux.just(1), Flux.never(), s -> {
s.onSubscribe(Operators.emptySubscription());
s.onError(new Exception("test"));
s.onError(new Exception("test2"));
})).verifyErrorMessage("test");
Assertions.assertThat(testLogger.getErrContent()).contains("Operator called default onErrorDropped").contains("test2");
} finally {
LoggerUtils.disableCapture();
}
}
Aggregations