use of reactor.core.publisher.Operators.DeferredSubscription in project reactor-core by reactor.
the class OperatorsTest method onNextErrorModeLocalStrategy.
@Test
public void onNextErrorModeLocalStrategy() {
List<Object> nextDropped = new ArrayList<>();
List<Object> errorDropped = new ArrayList<>();
Hooks.onNextDropped(nextDropped::add);
Hooks.onErrorDropped(errorDropped::add);
Hooks.onNextError(OnNextFailureStrategy.STOP);
Context c = Context.of(OnNextFailureStrategy.KEY_ON_NEXT_ERROR_STRATEGY, OnNextFailureStrategy.RESUME_DROP);
Exception error = new IllegalStateException("boom");
DeferredSubscription s = new Operators.DeferredSubscription();
try {
assertThat(s.isCancelled()).as("s initially cancelled").isFalse();
Throwable e = Operators.onNextError("foo", error, c, s);
assertThat(e).isNull();
assertThat(nextDropped).containsExactly("foo");
assertThat(errorDropped).containsExactly(error);
assertThat(s.isCancelled()).as("s cancelled").isFalse();
} finally {
Hooks.resetOnNextDropped();
Hooks.resetOnErrorDropped();
Hooks.resetOnNextError();
}
}
use of reactor.core.publisher.Operators.DeferredSubscription in project reactor-core by reactor.
the class OperatorsTest method scanDeferredSubscription.
@Test
public void scanDeferredSubscription() {
DeferredSubscription test = new DeferredSubscription();
test.s = Operators.emptySubscription();
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(test.s);
test.requested = 123;
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(123);
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
Aggregations