use of io.reactivex.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class FlowableCacheTest method testValuesAndThenError.
@Test
public void testValuesAndThenError() {
Flowable<Integer> source = Flowable.range(1, 10).concatWith(Flowable.<Integer>error(new TestException())).cache();
TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
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<Integer>();
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.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class FlowableDetachTest method error.
@Test
public void error() {
TestSubscriber<Object> ts = new TestSubscriber<Object>();
Flowable.error(new TestException()).onTerminateDetach().subscribe(ts);
ts.assertNoValues();
ts.assertError(TestException.class);
ts.assertNotComplete();
}
use of io.reactivex.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class FlowablePublishTest method testObserveOn.
@Test
public void testObserveOn() {
ConnectableFlowable<Integer> co = Flowable.range(0, 1000).hide().publish();
Flowable<Integer> obs = co.observeOn(Schedulers.computation());
for (int i = 0; i < 1000; i++) {
for (int j = 1; j < 6; j++) {
List<TestSubscriber<Integer>> tss = new ArrayList<TestSubscriber<Integer>>();
for (int k = 1; k < j; k++) {
TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
tss.add(ts);
obs.subscribe(ts);
}
Disposable s = co.connect();
for (TestSubscriber<Integer> ts : tss) {
ts.awaitDone(5, TimeUnit.SECONDS).assertSubscribed().assertValueCount(1000).assertNoErrors().assertComplete();
}
s.dispose();
}
}
}
use of io.reactivex.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class FlowablePublishTest method asyncFusedObserveOn.
@Test
public void asyncFusedObserveOn() {
ConnectableFlowable<Integer> co = Flowable.range(0, 1000).observeOn(ImmediateThinScheduler.INSTANCE).publish();
for (int i = 0; i < 1000; i++) {
for (int j = 1; j < 6; j++) {
List<TestSubscriber<Integer>> tss = new ArrayList<TestSubscriber<Integer>>();
for (int k = 1; k < j; k++) {
TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
tss.add(ts);
co.subscribe(ts);
}
Disposable s = co.connect();
for (TestSubscriber<Integer> ts : tss) {
ts.awaitDone(5, TimeUnit.SECONDS).assertSubscribed().assertValueCount(1000).assertNoErrors().assertComplete();
}
s.dispose();
}
}
}
use of io.reactivex.subscribers.TestSubscriber in project RxJava by ReactiveX.
the class FlowablePublishTest method syncFusedObserveOn.
@Test
public void syncFusedObserveOn() {
ConnectableFlowable<Integer> co = Flowable.range(0, 1000).publish();
Flowable<Integer> obs = co.observeOn(Schedulers.computation());
for (int i = 0; i < 1000; i++) {
for (int j = 1; j < 6; j++) {
List<TestSubscriber<Integer>> tss = new ArrayList<TestSubscriber<Integer>>();
for (int k = 1; k < j; k++) {
TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
tss.add(ts);
obs.subscribe(ts);
}
Disposable s = co.connect();
for (TestSubscriber<Integer> ts : tss) {
ts.awaitDone(5, TimeUnit.SECONDS).assertSubscribed().assertValueCount(1000).assertNoErrors().assertComplete();
}
s.dispose();
}
}
}
Aggregations