use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeCreateTest method onErrorThrows.
@Test
public void onErrorThrows() {
Maybe.create(new MaybeOnSubscribe<Object>() {
@Override
public void subscribe(MaybeEmitter<Object> e) throws Exception {
Disposable d = Disposable.empty();
e.setDisposable(d);
try {
e.onError(new IOException());
fail("Should have thrown");
} catch (TestException ex) {
// expected
}
assertTrue(d.isDisposed());
assertTrue(e.isDisposed());
}
}).subscribe(new MaybeObserver<Object>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onSuccess(Object value) {
}
@Override
public void onError(Throwable e) {
throw new TestException();
}
@Override
public void onComplete() {
}
});
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeConcatArrayTest method errorAfterTermination.
@Test
public void errorAfterTermination() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final MaybeObserver<?>[] o = { null };
Maybe.concatArrayDelayError(Maybe.just(1), Maybe.error(new IOException()), new Maybe<Integer>() {
@Override
protected void subscribeActual(MaybeObserver<? super Integer> observer) {
observer.onSubscribe(Disposable.empty());
observer.onSuccess(2);
o[0] = observer;
}
}).test().assertFailure(IOException.class, 1, 2);
o[0].onError(new TestException());
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeDelayTest method delayedErrorOnError.
@Test
public void delayedErrorOnError() {
final TestScheduler scheduler = new TestScheduler();
final TestObserver<?> observer = Maybe.error(new TestException()).delay(5, TimeUnit.SECONDS, scheduler, true).test();
scheduler.advanceTimeTo(2, TimeUnit.SECONDS);
observer.assertNoErrors();
scheduler.advanceTimeTo(5, TimeUnit.SECONDS);
observer.assertError(TestException.class);
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeDoFinallyTest method actionThrowsConditional.
@Test
public void actionThrowsConditional() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
Maybe.just(1).doFinally(new Action() {
@Override
public void run() throws Exception {
throw new TestException();
}
}).filter(Functions.alwaysTrue()).test().assertResult(1).dispose();
TestHelper.assertUndeliverable(errors, 0, TestException.class);
} finally {
RxJavaPlugins.reset();
}
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class MaybeBlockingSubscribeTest method oneArgErrorAsync.
@Test
public void oneArgErrorAsync() throws Throwable {
TestHelper.withErrorTracking(errors -> {
@SuppressWarnings("unchecked") Consumer<Integer> success = mock(Consumer.class);
Maybe.<Integer>error(new TestException()).delay(50, TimeUnit.MILLISECONDS, Schedulers.computation()).blockingSubscribe(success);
TestHelper.assertUndeliverable(errors, 0, TestException.class);
verify(success, never()).accept(any());
});
}
Aggregations