use of reactor.core.Exceptions in project reactor-core by reactor.
the class MonoDoOnEachTest method consumerBubbleError.
@Test
public void consumerBubbleError() {
LongAdder state = new LongAdder();
Throwable err = new Exception("test");
assertThatThrownBy(() -> StepVerifier.create(Mono.just(1).doOnEach(s -> {
if (s.isOnNext()) {
state.increment();
throw Exceptions.bubble(err);
}
})).expectErrorMessage("test").verify()).isInstanceOf(RuntimeException.class).matches(Exceptions::isBubbling, "bubbling").hasCause(// equivalent to unwrap for this case
err);
assertThat(state.intValue()).isEqualTo(1);
}
use of reactor.core.Exceptions in project reactor-core by reactor.
the class FluxOnBackpressureBufferTest method onBackpressureBufferMaxCallbackOverflow.
@Test
public void onBackpressureBufferMaxCallbackOverflow() {
AtomicInteger last = new AtomicInteger();
StepVerifier.create(Flux.range(1, 100).hide().onBackpressureBuffer(8, last::set, BufferOverflowStrategy.ERROR), 0).thenRequest(7).expectNext(1, 2, 3, 4, 5, 6, 7).then(() -> assertThat(last.get()).isEqualTo(16)).thenRequest(9).expectNextCount(8).verifyErrorMatches(Exceptions::isOverflow);
}
use of reactor.core.Exceptions in project reactor-core by reactor.
the class FluxOnBackpressureBufferTest method onBackpressureBufferMaxCallback.
@Test
public void onBackpressureBufferMaxCallback() {
AtomicInteger last = new AtomicInteger();
StepVerifier.create(Flux.range(1, 100).hide().onBackpressureBuffer(8, last::set), 0).thenRequest(7).expectNext(1, 2, 3, 4, 5, 6, 7).then(() -> assertThat(last.get()).isEqualTo(16)).thenRequest(9).expectNextCount(8).verifyErrorMatches(Exceptions::isOverflow);
}
Aggregations