use of io.reactivex.functions.BooleanSupplier in project RxJava by ReactiveX.
the class QueueDrainHelperTest method postCompleteCancelledAfterOne.
@Test
public void postCompleteCancelledAfterOne() {
final TestSubscriber<Integer> ts = new TestSubscriber<Integer>() {
@Override
public void onNext(Integer t) {
super.onNext(t);
cancel();
}
};
ArrayDeque<Integer> queue = new ArrayDeque<Integer>();
AtomicLong state = new AtomicLong();
BooleanSupplier isCancelled = new BooleanSupplier() {
@Override
public boolean getAsBoolean() throws Exception {
return ts.isCancelled();
}
};
ts.onSubscribe(new BooleanSubscription());
queue.offer(1);
state.getAndIncrement();
QueueDrainHelper.postComplete(ts, queue, state, isCancelled);
ts.assertValue(1).assertNoErrors().assertNotComplete();
}
use of io.reactivex.functions.BooleanSupplier in project RxJava by ReactiveX.
the class QueueDrainHelperTest method postCompleteEmpty.
@Test
public void postCompleteEmpty() {
TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
ArrayDeque<Integer> queue = new ArrayDeque<Integer>();
AtomicLong state = new AtomicLong();
BooleanSupplier isCancelled = new BooleanSupplier() {
@Override
public boolean getAsBoolean() throws Exception {
return false;
}
};
ts.onSubscribe(new BooleanSubscription());
QueueDrainHelper.postComplete(ts, queue, state, isCancelled);
ts.assertResult();
}
use of io.reactivex.functions.BooleanSupplier in project RxJava by ReactiveX.
the class QueueDrainHelperTest method postCompleteWithRequest.
@Test
public void postCompleteWithRequest() {
TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
ArrayDeque<Integer> queue = new ArrayDeque<Integer>();
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.functions.BooleanSupplier in project RxJava by ReactiveX.
the class QueueDrainHelperTest method completeRequestRace.
@Test
public void completeRequestRace() {
for (int i = 0; i < 500; i++) {
final TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
final ArrayDeque<Integer> queue = new ArrayDeque<Integer>();
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.functions.BooleanSupplier in project RxJava by ReactiveX.
the class QueueDrainHelperTest method postCompleteCancelled.
@Test
public void postCompleteCancelled() {
final TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
ArrayDeque<Integer> queue = new ArrayDeque<Integer>();
AtomicLong state = new AtomicLong();
BooleanSupplier isCancelled = new BooleanSupplier() {
@Override
public boolean getAsBoolean() throws Exception {
return ts.isCancelled();
}
};
ts.onSubscribe(new BooleanSubscription());
queue.offer(1);
state.getAndIncrement();
ts.cancel();
QueueDrainHelper.postComplete(ts, queue, state, isCancelled);
ts.assertEmpty();
}
Aggregations