use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class ParallelJoinTest method overflowSlowpathDelayError.
@Test
public void overflowSlowpathDelayError() {
@SuppressWarnings("unchecked") final Subscriber<? super Integer>[] subs = new Subscriber[1];
TestSubscriber<Integer> ts = new TestSubscriber<Integer>(1) {
@Override
public void onNext(Integer t) {
super.onNext(t);
if (t == 1) {
subs[0].onNext(2);
subs[0].onNext(3);
}
}
};
new ParallelFlowable<Integer>() {
@Override
public void subscribe(Subscriber<? super Integer>[] subscribers) {
subs[0] = subscribers[0];
subscribers[0].onSubscribe(new BooleanSubscription());
subscribers[0].onNext(1);
}
@Override
public int parallelism() {
return 1;
}
}.sequentialDelayError(1).subscribe(ts);
ts.request(1);
ts.assertFailure(MissingBackpressureException.class, 1, 2);
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class ParallelJoinTest method overflowSlowpath.
@Test
public void overflowSlowpath() {
@SuppressWarnings("unchecked") final Subscriber<? super Integer>[] subs = new Subscriber[1];
TestSubscriber<Integer> ts = new TestSubscriber<Integer>(1) {
@Override
public void onNext(Integer t) {
super.onNext(t);
subs[0].onNext(2);
subs[0].onNext(3);
}
};
new ParallelFlowable<Integer>() {
@Override
public void subscribe(Subscriber<? super Integer>[] subscribers) {
subs[0] = subscribers[0];
subscribers[0].onSubscribe(new BooleanSubscription());
subscribers[0].onNext(1);
}
@Override
public int parallelism() {
return 1;
}
}.sequential(1).subscribe(ts);
ts.assertFailure(MissingBackpressureException.class, 1);
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class ParallelJoinTest method onNextMissingBackpressureDelayErrorRace.
@Test
public void onNextMissingBackpressureDelayErrorRace() throws Throwable {
TestHelper.withErrorTracking(errors -> {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
AtomicReference<Subscriber<? super Integer>> ref1 = new AtomicReference<>();
AtomicReference<Subscriber<? super Integer>> ref2 = new AtomicReference<>();
Flowable<Integer> f1 = new Flowable<Integer>() {
@Override
public void subscribeActual(Subscriber<? super Integer> s) {
s.onSubscribe(new BooleanSubscription());
ref1.set(s);
}
};
Flowable<Integer> f2 = new Flowable<Integer>() {
@Override
public void subscribeActual(Subscriber<? super Integer> s) {
s.onSubscribe(new BooleanSubscription());
ref2.set(s);
}
};
ParallelFlowable.fromArray(f1, f2).sequentialDelayError(1).test(0);
TestHelper.race(() -> {
ref1.get().onNext(1);
ref1.get().onNext(2);
}, () -> {
ref2.get().onNext(3);
ref2.get().onNext(4);
});
errors.clear();
}
});
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class ParallelJoinTest method overflowFastpathDelayError.
@Test
public void overflowFastpathDelayError() {
new ParallelFlowable<Integer>() {
@Override
public void subscribe(Subscriber<? super Integer>[] subscribers) {
subscribers[0].onSubscribe(new BooleanSubscription());
subscribers[0].onNext(1);
subscribers[0].onNext(2);
}
@Override
public int parallelism() {
return 1;
}
}.sequentialDelayError(1).test(0).requestMore(1).assertFailure(MissingBackpressureException.class, 1);
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class SerializedProcessorTest method normal.
@Test
public void normal() {
FlowableProcessor<Integer> s = PublishProcessor.<Integer>create().toSerialized();
TestSubscriber<Integer> ts = s.test();
Flowable.range(1, 10).subscribe(s);
ts.assertResult(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
assertFalse(s.hasSubscribers());
s.onNext(11);
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
s.onError(new TestException());
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
s.onComplete();
BooleanSubscription bs = new BooleanSubscription();
s.onSubscribe(bs);
assertTrue(bs.isCancelled());
}
Aggregations