use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class QueueDrainSubscriberTest method unorderedFastPathReject.
@Test
public void unorderedFastPathReject() {
TestSubscriber<Integer> ts = new TestSubscriber<>(1);
Disposable d = Disposable.empty();
QueueDrainSubscriber<Integer, Integer, Integer> qd = createUnorderedReject(ts, d);
ts.onSubscribe(new BooleanSubscription());
qd.requested(1);
qd.onNext(1);
ts.assertValuesOnly(1);
assertEquals(1, qd.requested());
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class QueueDrainSubscriberTest method orderedOnNextRace.
@Test
public void orderedOnNextRace() {
for (int i = 0; i < TestHelper.RACE_LONG_LOOPS; i++) {
TestSubscriber<Integer> ts = new TestSubscriber<>(1);
Disposable d = Disposable.empty();
final QueueDrainSubscriber<Integer, Integer, Integer> qd = createOrdered(ts, d);
ts.onSubscribe(new BooleanSubscription());
qd.requested(Long.MAX_VALUE);
Runnable r1 = new Runnable() {
@Override
public void run() {
qd.onNext(1);
}
};
TestHelper.race(r1, r1);
ts.assertValuesOnly(1, 1);
}
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class StrictSubscriberTest method cancelAfterOnComplete.
@Test
public void cancelAfterOnComplete() {
final List<Object> list = new ArrayList<>();
Subscriber<Object> sub = new Subscriber<Object>() {
Subscription upstream;
@Override
public void onSubscribe(Subscription s) {
this.upstream = s;
}
@Override
public void onNext(Object t) {
list.add(t);
}
@Override
public void onError(Throwable t) {
upstream.cancel();
list.add(t);
}
@Override
public void onComplete() {
upstream.cancel();
list.add("Done");
}
};
new Flowable<Object>() {
@Override
protected void subscribeActual(Subscriber<? super Object> s) {
BooleanSubscription b = new BooleanSubscription();
s.onSubscribe(b);
s.onComplete();
list.add(b.isCancelled());
}
}.subscribe(sub);
assertEquals(Arrays.<Object>asList("Done", false), list);
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class StrictSubscriberTest method cancelAfterOnError.
@Test
public void cancelAfterOnError() {
final List<Object> list = new ArrayList<>();
Subscriber<Object> sub = new Subscriber<Object>() {
Subscription upstream;
@Override
public void onSubscribe(Subscription s) {
this.upstream = s;
}
@Override
public void onNext(Object t) {
list.add(t);
}
@Override
public void onError(Throwable t) {
upstream.cancel();
list.add(t.getMessage());
}
@Override
public void onComplete() {
upstream.cancel();
list.add("Done");
}
};
new Flowable<Object>() {
@Override
protected void subscribeActual(Subscriber<? super Object> s) {
BooleanSubscription b = new BooleanSubscription();
s.onSubscribe(b);
s.onError(new TestException("Forced failure"));
list.add(b.isCancelled());
}
}.subscribe(sub);
assertEquals(Arrays.<Object>asList("Forced failure", false), list);
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class SubscriberResourceWrapperTest method cancel.
@Test
public void cancel() {
BooleanSubscription bs = new BooleanSubscription();
Disposable d = Disposable.empty();
s.setResource(d);
s.onSubscribe(bs);
assertFalse(d.isDisposed());
assertFalse(s.isDisposed());
ts.cancel();
assertTrue(bs.isCancelled());
assertTrue(d.isDisposed());
assertTrue(s.isDisposed());
}
Aggregations