use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class ObservableAnyTest method predicateThrowsSuppressOthers.
@Test
public void predicateThrowsSuppressOthers() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
new Observable<Integer>() {
@Override
protected void subscribeActual(Observer<? super Integer> observer) {
observer.onSubscribe(Disposables.empty());
observer.onNext(1);
observer.onNext(2);
observer.onError(new IOException());
observer.onComplete();
}
}.any(new Predicate<Integer>() {
@Override
public boolean test(Integer v) throws Exception {
throw new TestException();
}
}).toObservable().test().assertFailure(TestException.class);
TestHelper.assertUndeliverable(errors, 0, IOException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class ObservableCreateTest method onCompleteCrash.
@Test
public void onCompleteCrash() {
Observable.create(new ObservableOnSubscribe<Object>() {
@Override
public void subscribe(ObservableEmitter<Object> e) throws Exception {
Disposable d = Disposables.empty();
e.setDisposable(d);
try {
e.onComplete();
fail("Should have thrown");
} catch (TestException ex) {
// expected
}
assertTrue(d.isDisposed());
}
}).subscribe(new Observer<Object>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Object value) {
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
throw new TestException();
}
});
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class ObservableCreateTest method onErrorCrash.
@Test
public void onErrorCrash() {
Observable.create(new ObservableOnSubscribe<Object>() {
@Override
public void subscribe(ObservableEmitter<Object> e) throws Exception {
Disposable d = Disposables.empty();
e.setDisposable(d);
try {
e.onError(new IOException());
fail("Should have thrown");
} catch (TestException ex) {
// expected
}
assertTrue(d.isDisposed());
}
}).subscribe(new Observer<Object>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Object value) {
}
@Override
public void onError(Throwable e) {
throw new TestException();
}
@Override
public void onComplete() {
}
});
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class ObservableDebounceTest method debounceSelectorObservableThrows.
@Test
public void debounceSelectorObservableThrows() {
PublishSubject<Integer> source = PublishSubject.create();
Function<Integer, Observable<Integer>> debounceSel = new Function<Integer, Observable<Integer>>() {
@Override
public Observable<Integer> apply(Integer t1) {
return Observable.error(new TestException());
}
};
Observer<Object> o = TestHelper.mockObserver();
source.debounce(debounceSel).subscribe(o);
source.onNext(1);
verify(o, never()).onNext(any());
verify(o, never()).onComplete();
verify(o).onError(any(TestException.class));
}
use of io.reactivex.exceptions.TestException in project RxJava by ReactiveX.
the class ObservableDefaultIfEmptyTest method testEmptyButClientThrows.
@Test
@Ignore("Subscribers should not throw")
public void testEmptyButClientThrows() {
final Observer<Integer> o = TestHelper.mockObserver();
Observable.<Integer>empty().defaultIfEmpty(1).subscribe(new DefaultObserver<Integer>() {
@Override
public void onNext(Integer t) {
throw new TestException();
}
@Override
public void onError(Throwable e) {
o.onError(e);
}
@Override
public void onComplete() {
o.onComplete();
}
});
verify(o).onError(any(TestException.class));
verify(o, never()).onNext(any(Integer.class));
verify(o, never()).onComplete();
}
Aggregations