use of reactor.test.util.TestLogger in project reactor-core by reactor.
the class FluxFlatMapTest method failDoubleError.
@Test
public void failDoubleError() {
TestLogger testLogger = new TestLogger();
LoggerUtils.enableCaptureWith(testLogger);
try {
StepVerifier.create(Flux.from(s -> {
s.onSubscribe(Operators.emptySubscription());
s.onError(new Exception("test"));
s.onError(new Exception("test2"));
}).flatMap(Flux::just)).verifyErrorMessage("test");
assertThat(testLogger.getErrContent()).contains("Operator called default onErrorDropped").contains("java.lang.Exception: test2");
} finally {
LoggerUtils.disableCapture();
}
}
use of reactor.test.util.TestLogger in project reactor-core by reactor.
the class FluxPeekFuseableTest method afterTerminateCallbackErrorAndErrorCallbackError.
@Test
public void afterTerminateCallbackErrorAndErrorCallbackError() {
TestLogger testLogger = new TestLogger();
LoggerUtils.enableCaptureWith(testLogger);
try {
IllegalStateException error = new IllegalStateException("expected afterTerminate");
IllegalArgumentException error2 = new IllegalArgumentException("error");
FluxPeekFuseable<String> flux = new FluxPeekFuseable<>(Flux.empty(), null, null, e -> {
throw error2;
}, null, () -> {
throw error;
}, null, null);
AssertSubscriber<String> ts = AssertSubscriber.create();
flux.subscribe(ts);
assertThat(testLogger.getErrContent()).contains("Operator called default onErrorDropped").contains(error.getMessage());
assertThat(error2.getSuppressed()).isEmpty();
// error2 is never thrown
ts.assertNoValues();
ts.assertComplete();
} finally {
LoggerUtils.disableCapture();
}
}
use of reactor.test.util.TestLogger in project reactor-core by reactor.
the class FluxPeekFuseableTest method afterTerminateCallbackErrorAndErrorCallbackError2.
@Test
public void afterTerminateCallbackErrorAndErrorCallbackError2() {
TestLogger testLogger = new TestLogger();
LoggerUtils.enableCaptureWith(testLogger);
try {
IllegalStateException afterTerminate = new IllegalStateException("afterTerminate");
IllegalArgumentException error = new IllegalArgumentException("error");
NullPointerException error2 = new NullPointerException();
FluxPeekFuseable<String> flux = new FluxPeekFuseable<>(Flux.error(error2), null, null, e -> {
throw error;
}, null, () -> {
throw afterTerminate;
}, null, null);
AssertSubscriber<String> ts = AssertSubscriber.create();
flux.subscribe(ts);
assertThat(testLogger.getErrContent()).contains("Operator called default onErrorDropped").contains(afterTerminate.getMessage());
// afterTerminate suppressed error which itself suppressed original error2
assertThat(afterTerminate.getSuppressed().length).isEqualTo(1);
assertThat(afterTerminate.getSuppressed()[0]).isEqualTo(error);
assertThat(error.getSuppressed().length).isEqualTo(1);
assertThat(error.getSuppressed()[0]).isEqualTo(error2);
ts.assertNoValues();
// the subscriber still sees the 'error' message since actual.onError is called before the afterTerminate callback
ts.assertErrorMessage("error");
} finally {
LoggerUtils.disableCapture();
}
}
use of reactor.test.util.TestLogger in project reactor-core by reactor.
the class FluxPeekTest method afterTerminateCallbackErrorAndErrorCallbackError2.
@Test
public void afterTerminateCallbackErrorAndErrorCallbackError2() {
TestLogger testLogger = new TestLogger();
LoggerUtils.enableCaptureWith(testLogger);
try {
IllegalStateException afterTerminate = new IllegalStateException("afterTerminate");
IllegalArgumentException error = new IllegalArgumentException("error");
NullPointerException ex = new NullPointerException();
FluxPeek<String> flux = new FluxPeek<>(Flux.error(ex), null, null, e -> {
throw error;
}, null, () -> {
throw afterTerminate;
}, null, null);
AssertSubscriber<String> ts = AssertSubscriber.create();
flux.subscribe(ts);
assertThat(testLogger.getErrContent()).contains("Operator called default onErrorDropped").contains(afterTerminate.getMessage());
// afterTerminate suppressed error which itself suppressed original err
assertThat(afterTerminate.getSuppressed()).hasSize(1);
assertThat(afterTerminate).hasSuppressedException(error);
assertThat(error.getSuppressed()).hasSize(1);
assertThat(error).hasSuppressedException(ex);
ts.assertNoValues();
// the subscriber still sees the 'error' message since actual.onError is called before the afterTerminate callback
ts.assertErrorMessage("error");
} finally {
LoggerUtils.disableCapture();
}
}
Aggregations