use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class ObservableMergeWithSingleTest method cancelMainOnOtherError.
@Test
public void cancelMainOnOtherError() {
PublishSubject<Integer> ps = PublishSubject.create();
SingleSubject<Integer> ss = SingleSubject.create();
TestObserver<Integer> to = ps.mergeWith(ss).test();
assertTrue(ps.hasObservers());
assertTrue(ss.hasObservers());
ss.onError(new TestException());
to.assertFailure(TestException.class);
assertFalse("main has observers!", ps.hasObservers());
assertFalse("other has observers", ss.hasObservers());
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class ObservableMergeWithSingleTest method onErrorMainOverflow.
@Test
public void onErrorMainOverflow() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final AtomicReference<Observer<?>> observerRef = new AtomicReference<>();
TestObserver<Integer> to = new Observable<Integer>() {
@Override
protected void subscribeActual(Observer<? super Integer> observer) {
observer.onSubscribe(Disposable.empty());
observerRef.set(observer);
}
}.mergeWith(Single.<Integer>error(new IOException())).test();
observerRef.get().onError(new TestException());
to.assertFailure(IOException.class);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class ObservableGroupByTest method newGroupValueSelectorFails.
@Test
public void newGroupValueSelectorFails() {
TestObserver<Object> to1 = new TestObserver<>();
final TestObserver<Object> to2 = new TestObserver<>();
Observable.just(1).groupBy(Functions.<Integer>identity(), new Function<Integer, Object>() {
@Override
public Object apply(Integer v) throws Throwable {
throw new TestException();
}
}).doOnNext(new Consumer<GroupedObservable<Integer, Object>>() {
@Override
public void accept(GroupedObservable<Integer, Object> g) throws Throwable {
g.subscribe(to2);
}
}).subscribe(to1);
to1.assertValueCount(1).assertError(TestException.class).assertNotComplete();
to2.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class ObservablePublishTest method onErrorAvailableUntilReset.
@Test
public void onErrorAvailableUntilReset() {
ConnectableObservable<Integer> co = Observable.just(1).concatWith(Observable.<Integer>error(new TestException())).publish();
TestObserver<Integer> to = co.test();
to.assertEmpty();
co.connect();
to.assertFailure(TestException.class, 1);
co.test().assertFailure(TestException.class);
co.reset();
to = co.test();
to.assertEmpty();
co.connect();
to.assertFailure(TestException.class, 1);
}
use of io.reactivex.rxjava3.observers.TestObserver in project RxJava by ReactiveX.
the class SerializedSubjectTest method onErrorOnErrorRace.
@Test
public void onErrorOnErrorRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
final Subject<Integer> s = PublishSubject.<Integer>create().toSerialized();
TestObserver<Integer> to = s.test();
final TestException ex = new TestException();
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Runnable r1 = new Runnable() {
@Override
public void run() {
s.onError(ex);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
s.onError(ex);
}
};
TestHelper.race(r1, r2);
to.assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
}
Aggregations