use of reactor.test.util.TestLogger in project reactor-core by reactor.
the class OperatorsTest method onDiscardCallbackErrorsLog.
@Test
public void onDiscardCallbackErrorsLog() {
Context context = Operators.enableOnDiscard(Context.empty(), t -> {
throw new RuntimeException("Boom");
});
TestLogger testLogger = new TestLogger();
LoggerUtils.enableCaptureWith(testLogger);
try {
Operators.onDiscard("Foo", context);
assertThat(testLogger.getErrContent()).contains("Error in discard hook - java.lang.RuntimeException: Boom");
} finally {
LoggerUtils.disableCapture();
}
}
use of reactor.test.util.TestLogger in project reactor-core by reactor.
the class NextProcessorTest method doubleError.
@Test
void doubleError() {
TestLogger testLogger = new TestLogger();
LoggerUtils.enableCaptureWith(testLogger);
try {
NextProcessor<String> mp = new NextProcessor<>(null);
mp.onError(new Exception("test"));
mp.onError(new Exception("test2"));
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 FluxUsingWhenTest method cancelDefaultHandlerFailure.
@ParameterizedTestWithName
@MethodSource("sources01")
@Deprecated
public void cancelDefaultHandlerFailure(Flux<String> source) {
TestResource testResource = new TestResource();
final TestLogger tl = new TestLogger();
Loggers.useCustomLoggers(name -> tl);
try {
Function<TestResource, Publisher<?>> completeOrCancel = r -> {
return r.commit().concatWith(Mono.error(new IllegalStateException("commit error")));
};
Flux<String> test = Flux.usingWhen(Mono.just(testResource), tr -> source, completeOrCancel, (r, e) -> r.rollback(new RuntimeException("placeholder ignored rollback exception")), completeOrCancel).take(2);
StepVerifier.create(test).expectNext("0", "1").verifyComplete();
testResource.commitProbe.assertWasSubscribed();
testResource.cancelProbe.assertWasNotSubscribed();
testResource.rollbackProbe.assertWasNotSubscribed();
} finally {
Loggers.resetLoggerFactory();
}
assertThat(tl.getErrContent()).contains("Async resource cleanup failed after cancel").contains("java.lang.IllegalStateException: commit error");
}
use of reactor.test.util.TestLogger in project reactor-core by reactor.
the class FluxUsingWhenTest method cancelWithHandlerGenerationFailureLogs.
@ParameterizedTestWithName
@MethodSource("sources01")
public void cancelWithHandlerGenerationFailureLogs(Flux<String> source) throws InterruptedException {
TestLogger tl = new TestLogger();
Loggers.useCustomLoggers(name -> tl);
TestResource testResource = new TestResource();
try {
Flux<String> test = Flux.usingWhen(Mono.just(testResource), tr -> source, TestResource::commit, TestResource::rollback, r -> null).take(2);
StepVerifier.create(test).expectNext("0", "1").verifyComplete();
testResource.commitProbe.assertWasNotSubscribed();
testResource.cancelProbe.assertWasNotSubscribed();
testResource.rollbackProbe.assertWasNotSubscribed();
} finally {
Loggers.resetLoggerFactory();
}
assertThat(tl.getErrContent()).contains("Error generating async resource cleanup during onCancel").contains("java.lang.NullPointerException");
}
use of reactor.test.util.TestLogger in project reactor-core by reactor.
the class FluxZipTest method failDoubleError3.
// FIXME use Violation.NO_CLEANUP_ON_TERMINATE
@Test
public void failDoubleError3() {
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();
}
}
Aggregations