use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class BlockingOptionalMonoSubscriber method dispose.
@Override
public final void dispose() {
cancelled = true;
Subscription s = this.s;
if (s != null) {
this.s = null;
s.cancel();
}
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class BlockingSingleSubscriber method dispose.
@Override
public final void dispose() {
cancelled = true;
Subscription s = this.s;
if (s != null) {
this.s = null;
s.cancel();
}
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class FluxWindowBoundaryTest method scanOtherSubscriber.
@Test
public void scanOtherSubscriber() {
CoreSubscriber<Flux<Integer>> actual = new LambdaSubscriber<>(null, e -> {
}, null, null);
FluxWindowBoundary.WindowBoundaryMain<Integer, Integer> main = new FluxWindowBoundary.WindowBoundaryMain<>(actual, Queues.unbounded(), Queues.<Integer>unbounded().get());
FluxWindowBoundary.WindowBoundaryOther<Integer> test = new FluxWindowBoundary.WindowBoundaryOther<>(main);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
Assertions.assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(main);
test.requested = 35;
Assertions.assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(35);
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class FluxWindowPredicateTest method scanMainSubscriber.
@Test
public void scanMainSubscriber() {
CoreSubscriber<Flux<Integer>> actual = new LambdaSubscriber<>(null, e -> {
}, null, null);
FluxWindowPredicate.WindowPredicateMain<Integer> test = new FluxWindowPredicate.WindowPredicateMain<>(actual, Queues.<Flux<Integer>>unbounded().get(), Queues.unbounded(), 123, i -> true, Mode.WHILE);
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
Assertions.assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
Assertions.assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(123);
test.requested = 35;
Assertions.assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isEqualTo(35);
test.queue.offer(Flux.just(1).groupBy(i -> i).blockFirst());
Assertions.assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
Assertions.assertThat(test.scan(Scannable.Attr.ERROR)).isNull();
test.error = new IllegalStateException("boom");
Assertions.assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom");
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onComplete();
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class FluxWindowTest method scanSkipSubscriber.
@Test
public void scanSkipSubscriber() {
CoreSubscriber<Flux<Integer>> actual = new LambdaSubscriber<>(null, e -> {
}, null, null);
FluxWindow.WindowSkipSubscriber<Integer> test = new FluxWindow.WindowSkipSubscriber<Integer>(actual, 123, 3, Queues.unbounded());
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
Assertions.assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
Assertions.assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(actual);
Assertions.assertThat(test.scan(Scannable.Attr.CAPACITY)).isEqualTo(123);
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.onComplete();
Assertions.assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
Assertions.assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
Aggregations