use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable 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.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.
the class ComputationSchedulerTests method shutdownRejects.
@Test
@SuppressUndeliverable
public void shutdownRejects() {
final int[] calls = { 0 };
Runnable r = new Runnable() {
@Override
public void run() {
calls[0]++;
}
};
Scheduler s = new ComputationScheduler();
s.shutdown();
s.shutdown();
assertEquals(Disposable.disposed(), s.scheduleDirect(r));
assertEquals(Disposable.disposed(), s.scheduleDirect(r, 1, TimeUnit.SECONDS));
assertEquals(Disposable.disposed(), s.schedulePeriodicallyDirect(r, 1, 1, TimeUnit.SECONDS));
Worker w = s.createWorker();
w.dispose();
assertTrue(w.isDisposed());
assertEquals(Disposable.disposed(), w.schedule(r));
assertEquals(Disposable.disposed(), w.schedule(r, 1, TimeUnit.SECONDS));
assertEquals(Disposable.disposed(), w.schedulePeriodically(r, 1, 1, TimeUnit.SECONDS));
assertEquals(0, calls[0]);
}
use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.
the class NewThreadSchedulerTest method npeRegression.
/**
* Regression test to ensure there is no NPE when the worker has been disposed.
* @throws Exception on error
*/
@Test
@SuppressUndeliverable
public void npeRegression() throws Exception {
Scheduler s = getScheduler();
NewThreadWorker w = (NewThreadWorker) s.createWorker();
w.dispose();
// This method used to throw a NPE when the worker has been disposed and the parent is null
w.scheduleActual(new Runnable() {
@Override
public void run() {
}
}, 0, TimeUnit.MILLISECONDS, null);
}
use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.
the class AsyncSubjectTest method onErrorCrossCancel.
@Test
@SuppressUndeliverable
public void onErrorCrossCancel() {
AsyncSubject<Object> p = AsyncSubject.create();
final TestObserver<Object> to2 = new TestObserver<>();
TestObserver<Object> to1 = new TestObserver<Object>() {
@Override
public void onError(Throwable t) {
to2.dispose();
super.onError(t);
}
};
p.subscribe(to1);
p.subscribe(to2);
p.onError(new TestException());
to1.assertFailure(TestException.class);
to2.assertEmpty();
}
use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.
the class ObservableCreateTest method basicSerialized.
@Test
@SuppressUndeliverable
public void basicSerialized() {
final Disposable d = Disposable.empty();
Observable.<Integer>create(new ObservableOnSubscribe<Integer>() {
@Override
public void subscribe(ObservableEmitter<Integer> e) throws Exception {
e = e.serialize();
e.setDisposable(d);
e.onNext(1);
e.onNext(2);
e.onNext(3);
e.onComplete();
e.onError(new TestException());
e.onNext(4);
e.onError(new TestException());
e.onComplete();
}
}).test().assertResult(1, 2, 3);
assertTrue(d.isDisposed());
}
Aggregations