use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class FlowableCacheTest method valuesAndThenError.
@Test
public void valuesAndThenError() {
Flowable<Integer> source = Flowable.range(1, 10).concatWith(Flowable.<Integer>error(new TestException())).cache();
TestSubscriber<Integer> ts = new TestSubscriber<>();
source.subscribe(ts);
ts.assertValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
ts.assertNotComplete();
ts.assertError(TestException.class);
TestSubscriber<Integer> ts2 = new TestSubscriber<>();
source.subscribe(ts2);
ts2.assertValues(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
ts2.assertNotComplete();
ts2.assertError(TestException.class);
}
use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class FlowableBufferTest method timedSizeBufferAlreadyCleared.
@Test
public void timedSizeBufferAlreadyCleared() {
TestScheduler sch = new TestScheduler();
TestSubscriber<List<Integer>> ts = new TestSubscriber<>();
BufferExactBoundedSubscriber<Integer, List<Integer>> sub = new BufferExactBoundedSubscriber<>(ts, Functions.justSupplier((List<Integer>) new ArrayList<Integer>()), 1, TimeUnit.SECONDS, 1, false, sch.createWorker());
BooleanSubscription bs = new BooleanSubscription();
sub.onSubscribe(bs);
sub.producerIndex++;
sub.run();
assertFalse(sub.isDisposed());
sub.enter();
sub.onComplete();
assertTrue(sub.isDisposed());
sub.run();
}
use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class FlowableBufferTest method timedSkipCancelWhenSecondBuffer.
@Test
public void timedSkipCancelWhenSecondBuffer() {
TestScheduler sch = new TestScheduler();
final TestSubscriber<List<Integer>> ts = new TestSubscriber<>();
BufferSkipBoundedSubscriber<Integer, List<Integer>> sub = new BufferSkipBoundedSubscriber<>(ts, new Supplier<List<Integer>>() {
int calls;
@Override
public List<Integer> get() throws Exception {
if (++calls == 2) {
ts.cancel();
}
return new ArrayList<>();
}
}, 1, 1, TimeUnit.SECONDS, sch.createWorker());
sub.onSubscribe(new BooleanSubscription());
sub.run();
assertTrue(ts.isCancelled());
}
use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class FlowableBufferTest method bufferExactBoundaryBadSource.
@Test
public void bufferExactBoundaryBadSource() {
Flowable<Integer> pp = new Flowable<Integer>() {
@Override
protected void subscribeActual(Subscriber<? super Integer> subscriber) {
subscriber.onSubscribe(new BooleanSubscription());
subscriber.onComplete();
subscriber.onNext(1);
subscriber.onComplete();
}
};
final AtomicReference<Subscriber<? super Integer>> ref = new AtomicReference<>();
Flowable<Integer> b = new Flowable<Integer>() {
@Override
protected void subscribeActual(Subscriber<? super Integer> subscriber) {
subscriber.onSubscribe(new BooleanSubscription());
ref.set(subscriber);
}
};
TestSubscriber<List<Integer>> ts = pp.buffer(b).test();
ref.get().onNext(1);
ts.assertResult(Collections.<Integer>emptyList());
}
use of io.reactivex.rxjava3.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class FlowableConcatWithMaybeTest method otherError.
@Test
public void otherError() {
final TestSubscriber<Integer> ts = new TestSubscriber<>();
Flowable.range(1, 5).concatWith(Maybe.<Integer>error(new TestException())).subscribe(ts);
ts.assertFailure(TestException.class, 1, 2, 3, 4, 5);
}
Aggregations