use of reactor.test.util.TestLogger in project reactor-core by reactor.
the class FluxTests method unimplementedErrorCallback.
@Test
public void unimplementedErrorCallback() {
TestLogger testLogger = new TestLogger();
LoggerUtils.enableCaptureWith(testLogger);
try {
Flux.error(new Exception("forced1")).log("error").subscribe();
Flux.error(new Exception("forced2")).subscribe();
assertThat(testLogger.getErrContent()).contains("Operator called default onErrorDropped").contains("reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.Exception: forced2");
} finally {
LoggerUtils.disableCapture();
}
}
use of reactor.test.util.TestLogger in project reactor-core by reactor.
the class SinkOneMulticastTest method doubleSignal.
@Test
void doubleSignal() {
TestLogger testLogger = new TestLogger();
LoggerUtils.enableCaptureWith(testLogger);
try {
SinkOneMulticast<String> sink = new SinkOneMulticast<>();
sink.emitValue("test", Sinks.EmitFailureHandler.FAIL_FAST);
sink.emitError(new Exception("test2"), Sinks.EmitFailureHandler.FAIL_FAST);
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 ReplayProcessorTest method testReplayProcessorState.
@SuppressWarnings("unchecked")
void testReplayProcessorState(ReplayProcessor<String> rp) {
TestLogger testLogger = new TestLogger();
LoggerUtils.enableCaptureWith(testLogger);
try {
Disposable d1 = rp.subscribe();
rp.subscribe();
ReplayProcessor.ReplayInner<String> s = ((ReplayProcessor.ReplayInner<String>) rp.inners().findFirst().get());
assertThat(d1).isEqualTo(s.actual());
assertThat(s.isEmpty()).isTrue();
assertThat(s.isCancelled()).isFalse();
assertThat(s.isCancelled()).isFalse();
assertThat(rp.getPrefetch()).isEqualTo(Integer.MAX_VALUE);
if (rp.getBufferSize() != Integer.MAX_VALUE) {
assertThat(rp.getBufferSize()).isEqualTo(1);
}
FluxSink<String> sink = rp.sink();
sink.next("test");
rp.onComplete();
rp.onComplete();
Exception e = new RuntimeException("test");
rp.onError(e);
Assertions.assertThat(testLogger.getErrContent()).contains("Operator called default onErrorDropped").contains(e.getMessage());
} finally {
LoggerUtils.disableCapture();
}
}
use of reactor.test.util.TestLogger in project reactor-core by reactor.
the class FluxDoFinallyTest method gh951_withoutDoOnError.
@Test
public // see https://github.com/reactor/reactor-core/issues/951
void gh951_withoutDoOnError() {
TestLogger testLogger = new TestLogger();
LoggerUtils.enableCaptureWith(testLogger);
try {
List<String> events = new ArrayList<>();
Mono.just(true).map(this::throwError).doFinally(any -> events.add("doFinally " + any.toString())).subscribe();
Assertions.assertThat(events).as("withoutDoOnError").containsExactly("doFinally onError");
Assertions.assertThat(testLogger.getErrContent()).contains("Operator called default onErrorDropped").contains("reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalStateException: boom");
} finally {
LoggerUtils.disableCapture();
}
}
use of reactor.test.util.TestLogger in project reactor-core by reactor.
the class FluxFlatMapTest method failDoubleErrorTerminatedInner.
// FIXME use Violation.NO_CLEANUP_ON_TERMINATE
@Test
public void failDoubleErrorTerminatedInner() {
TestLogger testLogger = new TestLogger();
LoggerUtils.enableCaptureWith(testLogger);
try {
StepVerifier.create(Flux.just(1).hide().flatMap(f -> Flux.from(s -> {
s.onSubscribe(Operators.emptySubscription());
Exceptions.terminate(FluxFlatMap.FlatMapMain.ERROR, ((FluxFlatMap.FlatMapInner) s).parent);
s.onError(new Exception("test"));
}))).verifyComplete();
assertThat(testLogger.getErrContent()).contains("Operator called default onErrorDropped").contains("java.lang.Exception: test");
} finally {
LoggerUtils.disableCapture();
}
}
Aggregations