use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class ExecutorSchedulerDelayedRunnableTest method delayedRunnableCrash.
@Test(expected = TestException.class)
@SuppressUndeliverable
public void delayedRunnableCrash() {
DelayedRunnable dl = new DelayedRunnable(new Runnable() {
@Override
public void run() {
throw new TestException();
}
});
dl.run();
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class SingleSwitchOnNextTest method delaySwitch.
@Test
public void delaySwitch() {
PublishProcessor<Single<Integer>> pp = PublishProcessor.create();
TestSubscriber<Integer> ts = Single.switchOnNextDelayError(pp).test();
assertTrue(pp.hasSubscribers());
ts.assertEmpty();
SingleSubject<Integer> ss1 = SingleSubject.create();
SingleSubject<Integer> ss2 = SingleSubject.create();
pp.onNext(ss1);
assertTrue(ss1.hasObservers());
pp.onNext(ss2);
assertFalse(ss1.hasObservers());
assertTrue(ss2.hasObservers());
assertTrue(ss2.hasObservers());
ss2.onError(new TestException());
assertTrue(pp.hasSubscribers());
ts.assertEmpty();
pp.onComplete();
ts.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class SingleZipArrayTest method innerErrorRace.
@Test
public void innerErrorRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final PublishProcessor<Integer> pp0 = PublishProcessor.create();
final PublishProcessor<Integer> pp1 = PublishProcessor.create();
final TestObserver<Object> to = Single.zip(pp0.single(0), pp1.single(0), addString).test();
final TestException ex = new TestException();
Runnable r1 = new Runnable() {
@Override
public void run() {
pp0.onError(ex);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
pp1.onError(ex);
}
};
TestHelper.race(r1, r2);
to.assertFailure(TestException.class);
if (!errors.isEmpty()) {
TestHelper.assertUndeliverable(errors, 0, TestException.class);
}
} finally {
RxJavaPlugins.reset();
}
}
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class SingleConcatMapCompletableTest method mapperThrows.
@Test
public void mapperThrows() {
final boolean[] b = { false };
Single.just(1).concatMapCompletable(new Function<Integer, Completable>() {
@Override
public Completable apply(Integer t) throws Exception {
throw new TestException();
}
}).test().assertFailure(TestException.class);
assertFalse(b[0]);
}
use of io.reactivex.rxjava3.exceptions.TestException in project RxJava by ReactiveX.
the class SingleCreateTest method tryOnError.
@Test
public void tryOnError() {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final Boolean[] response = { null };
Single.create(new SingleOnSubscribe<Object>() {
@Override
public void subscribe(SingleEmitter<Object> e) throws Exception {
e.onSuccess(1);
response[0] = e.tryOnError(new TestException());
}
}).test().assertResult(1);
assertFalse(response[0]);
assertTrue(errors.toString(), errors.isEmpty());
} finally {
RxJavaPlugins.reset();
}
}
Aggregations