use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class SubscriberResourceWrapperTest method error.
@Test
public void error() {
BooleanSubscription bs = new BooleanSubscription();
Disposable d = Disposable.empty();
s.setResource(d);
s.onSubscribe(bs);
s.onError(new TestException());
assertTrue(d.isDisposed());
assertFalse(bs.isCancelled());
ts.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class SubscriberResourceWrapperTest method complete.
@Test
public void complete() {
BooleanSubscription bs = new BooleanSubscription();
Disposable d = Disposable.empty();
s.setResource(d);
s.onSubscribe(bs);
s.onComplete();
assertTrue(d.isDisposed());
assertFalse(bs.isCancelled());
ts.assertResult();
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class QueueDrainHelperTest method postCompleteWithRequest.
@Test
public void postCompleteWithRequest() {
TestSubscriber<Integer> ts = new TestSubscriber<>();
ArrayDeque<Integer> queue = new ArrayDeque<>();
AtomicLong state = new AtomicLong();
BooleanSupplier isCancelled = new BooleanSupplier() {
@Override
public boolean getAsBoolean() throws Exception {
return false;
}
};
ts.onSubscribe(new BooleanSubscription());
queue.offer(1);
state.getAndIncrement();
QueueDrainHelper.postComplete(ts, queue, state, isCancelled);
ts.assertResult(1);
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class QueueDrainHelperTest method completeRequestRace.
@Test
public void completeRequestRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
final TestSubscriber<Integer> ts = new TestSubscriber<>();
final ArrayDeque<Integer> queue = new ArrayDeque<>();
final AtomicLong state = new AtomicLong();
final BooleanSupplier isCancelled = new BooleanSupplier() {
@Override
public boolean getAsBoolean() throws Exception {
return false;
}
};
ts.onSubscribe(new BooleanSubscription());
queue.offer(1);
Runnable r1 = new Runnable() {
@Override
public void run() {
QueueDrainHelper.postCompleteRequest(1, ts, queue, state, isCancelled);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
QueueDrainHelper.postComplete(ts, queue, state, isCancelled);
}
};
TestHelper.race(r1, r2);
ts.assertResult(1);
}
}
use of io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription in project RxJava by ReactiveX.
the class QueueDrainHelperTest method checkTerminatedNonDelayErrorError.
@Test
public void checkTerminatedNonDelayErrorError() {
TestSubscriber<Integer> ts = new TestSubscriber<>();
ts.onSubscribe(new BooleanSubscription());
QueueDrain<Integer, Integer> qd = new QueueDrain<Integer, Integer>() {
@Override
public boolean cancelled() {
return false;
}
@Override
public boolean done() {
return false;
}
@Override
public Throwable error() {
return new TestException();
}
@Override
public boolean enter() {
return true;
}
@Override
public long requested() {
return 0;
}
@Override
public long produced(long n) {
return 0;
}
@Override
public int leave(int m) {
return 0;
}
@Override
public boolean accept(Subscriber<? super Integer> a, Integer v) {
return false;
}
};
SpscArrayQueue<Integer> q = new SpscArrayQueue<>(32);
QueueDrainHelper.checkTerminated(true, false, ts, false, q, qd);
ts.assertFailure(TestException.class);
}
Aggregations