use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class ParallelMergeSequentialTest method scanInnerSubscriber.
@Test
public void scanInnerSubscriber() {
CoreSubscriber<Integer> mainActual = new LambdaSubscriber<>(null, e -> {
}, null, null);
MergeSequentialMain<Integer> main = new MergeSequentialMain<>(mainActual, 2, 123, Queues.small());
MergeSequentialInner<Integer> test = new MergeSequentialInner<>(main, 456);
Subscription subscription = Operators.emptySubscription();
test.onSubscribe(subscription);
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class ParallelSourceTest method scanMainSubscriber.
@Test
public void scanMainSubscriber() {
@SuppressWarnings("unchecked") CoreSubscriber<String>[] subs = new CoreSubscriber[1];
subs[0] = new LambdaSubscriber<>(null, e -> {
}, null, null);
ParallelSource.ParallelSourceMain<String> test = new ParallelSource.ParallelSourceMain<>(subs, 123, Queues.one());
Subscription parent = Operators.emptySubscription();
test.onSubscribe(parent);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(parent);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(123);
assertThat(test.scan(Scannable.Attr.BUFFERED)).isZero();
test.queue.offer("foo");
assertThat(test.scan(Scannable.Attr.BUFFERED)).isEqualTo(1);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
assertThat(test.scan(Scannable.Attr.ERROR)).isNull();
test.onError(new IllegalStateException("boom"));
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
assertThat(test.scan(Scannable.Attr.ERROR)).hasMessage("boom");
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class ParallelCollectTest method scanSubscriber.
@Test
public void scanSubscriber() {
CoreSubscriber<List<Integer>> subscriber = new LambdaSubscriber<>(null, e -> {
}, null, null);
ParallelCollectSubscriber<Integer, List<Integer>> test = new ParallelCollectSubscriber<>(subscriber, new ArrayList<>(), List::add);
Subscription s = Operators.emptySubscription();
test.onSubscribe(s);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(subscriber);
assertThat(test.scan(Scannable.Attr.PREFETCH)).isEqualTo(Integer.MAX_VALUE);
assertThat(test.scan(Scannable.Attr.TERMINATED)).isFalse();
test.complete(Collections.emptyList());
assertThat(test.scan(Scannable.Attr.TERMINATED)).isTrue();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class ParallelGroupTest method scanInnerGroup.
@Test
public void scanInnerGroup() {
ParallelInnerGroup<Integer> test = new ParallelInnerGroup<>(1023);
CoreSubscriber<Integer> subscriber = new LambdaSubscriber<>(null, e -> {
}, null, sub -> sub.request(3));
Subscription s = Operators.emptySubscription();
test.onSubscribe(s);
test.subscribe(subscriber);
assertThat(test.scan(Scannable.Attr.PARENT)).isSameAs(s);
assertThat(test.scan(Scannable.Attr.ACTUAL)).isSameAs(subscriber);
// see other test for request
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isZero();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isFalse();
test.cancel();
assertThat(test.scan(Scannable.Attr.CANCELLED)).isTrue();
}
use of org.reactivestreams.Subscription in project reactor-core by reactor.
the class ParallelGroupTest method scanInnerGroupRequestNotTrackedWhenParent.
@Test
public void scanInnerGroupRequestNotTrackedWhenParent() {
ParallelInnerGroup<Integer> test = new ParallelInnerGroup<>(1023);
CoreSubscriber<Integer> subscriber = new LambdaSubscriber<>(null, e -> {
}, null, sub -> sub.request(3));
Subscription s = Operators.emptySubscription();
test.onSubscribe(s);
test.subscribe(subscriber);
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isZero();
test.request(2);
assertThat(test.scan(Scannable.Attr.REQUESTED_FROM_DOWNSTREAM)).isZero();
}
Aggregations