use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class SingleSafeSubscribeTest method onSubscribeCrash.
@Test
public void onSubscribeCrash() throws Throwable {
TestHelper.withErrorTracking(errors -> {
@SuppressWarnings("unchecked") SingleObserver<Integer> consumer = mock(SingleObserver.class);
doThrow(new TestException()).when(consumer).onSubscribe(any());
Disposable d = Disposable.empty();
new Single<Integer>() {
@Override
protected void subscribeActual(@NonNull SingleObserver<? super Integer> observer) {
observer.onSubscribe(d);
// none of the following should arrive at the consumer
observer.onSuccess(1);
observer.onError(new IOException());
}
}.safeSubscribe(consumer);
InOrder order = inOrder(consumer);
order.verify(consumer).onSubscribe(any(Disposable.class));
order.verifyNoMoreInteractions();
assertTrue(d.isDisposed());
TestHelper.assertUndeliverable(errors, 0, TestException.class);
TestHelper.assertUndeliverable(errors, 1, IOException.class);
});
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class SingleTakeUntilTest method mainErrorSingle.
@Test
public void mainErrorSingle() {
PublishProcessor<Integer> pp = PublishProcessor.create();
PublishProcessor<Integer> source = PublishProcessor.create();
TestObserver<Integer> to = source.single(-99).takeUntil(pp.single(-99)).test();
source.onError(new TestException());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class SingleTakeUntilTest method mainErrorPublisher.
@Test
public void mainErrorPublisher() {
PublishProcessor<Integer> pp = PublishProcessor.create();
PublishProcessor<Integer> source = PublishProcessor.create();
TestObserver<Integer> to = source.single(-99).takeUntil(pp).test();
source.onError(new TestException());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class SingleTakeUntilTest method mainErrorCompletable.
@Test
public void mainErrorCompletable() {
PublishProcessor<Integer> pp = PublishProcessor.create();
PublishProcessor<Integer> source = PublishProcessor.create();
TestObserver<Integer> to = source.single(-99).takeUntil(pp.ignoreElements()).test();
source.onError(new TestException());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class SingleTakeUntilTest method untilSingleMainError.
@Test
public void untilSingleMainError() {
SingleSubject<Integer> main = SingleSubject.create();
SingleSubject<Integer> other = SingleSubject.create();
TestObserver<Integer> to = main.takeUntil(other).test();
assertTrue("Main no observers?", main.hasObservers());
assertTrue("Other no observers?", other.hasObservers());
main.onError(new TestException());
assertFalse("Main has observers?", main.hasObservers());
assertFalse("Other has observers?", other.hasObservers());
to.assertFailure(TestException.class);
}
Aggregations