use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class QueueDrainSubscriberTest method unorderedSlowPath.
@Test
public void unorderedSlowPath() {
TestSubscriber<Integer> ts = new TestSubscriber<>(1);
Disposable d = Disposable.empty();
QueueDrainSubscriber<Integer, Integer, Integer> qd = createUnordered(ts, d);
ts.onSubscribe(new BooleanSubscription());
qd.enter();
qd.onNext(1);
ts.assertEmpty();
}
use of io.reactivex.rxjava3.subscribers.TestSubscriber 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.subscribers.TestSubscriber 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.subscribers.TestSubscriber 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.subscribers.TestSubscriber 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);
}
}
Aggregations