use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.
the class ObservableCreateTest method basicWithCancellable.
@Test
@SuppressUndeliverable
public void basicWithCancellable() {
final Disposable d1 = Disposable.empty();
final Disposable d2 = Disposable.empty();
Observable.<Integer>create(new ObservableOnSubscribe<Integer>() {
@Override
public void subscribe(ObservableEmitter<Integer> e) throws Exception {
e.setDisposable(d1);
e.setCancellable(new Cancellable() {
@Override
public void cancel() throws Exception {
d2.dispose();
}
});
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(d1.isDisposed());
assertTrue(d2.isDisposed());
}
use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.
the class CachedThreadSchedulerTest method shutdownRejects.
@Test
@SuppressUndeliverable
public void shutdownRejects() {
final int[] calls = { 0 };
Runnable r = new Runnable() {
@Override
public void run() {
calls[0]++;
}
};
IoScheduler s = new IoScheduler();
s.shutdown();
s.shutdown();
s.scheduleDirect(r);
s.scheduleDirect(r, 1, TimeUnit.SECONDS);
s.schedulePeriodicallyDirect(r, 1, 1, TimeUnit.SECONDS);
Worker w = s.createWorker();
w.dispose();
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 AsyncProcessorTest method onErrorCancelRace.
@Test
@SuppressUndeliverable
public void onErrorCancelRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
final AsyncProcessor<Object> p = AsyncProcessor.create();
final TestSubscriberEx<Object> ts1 = p.to(TestHelper.<Object>testConsumer());
Runnable r1 = new Runnable() {
@Override
public void run() {
ts1.cancel();
}
};
final TestException ex = new TestException();
Runnable r2 = new Runnable() {
@Override
public void run() {
p.onError(ex);
}
};
TestHelper.race(r1, r2);
if (ts1.errors().size() != 0) {
ts1.assertFailure(TestException.class);
} else {
ts1.assertEmpty();
}
}
}
use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.
the class AsyncProcessorTest method onErrorCrossCancel.
@Test
@SuppressUndeliverable
public void onErrorCrossCancel() {
AsyncProcessor<Object> p = AsyncProcessor.create();
final TestSubscriber<Object> ts2 = new TestSubscriber<>();
TestSubscriber<Object> ts1 = new TestSubscriber<Object>() {
@Override
public void onError(Throwable t) {
ts2.cancel();
super.onError(t);
}
};
p.subscribe(ts1);
p.subscribe(ts2);
p.onError(new TestException());
ts1.assertFailure(TestException.class);
ts2.assertEmpty();
}
use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.
the class CompletableFromCallableTest method fromActionErrorsDisposed.
@Test
@SuppressUndeliverable
public void fromActionErrorsDisposed() {
final AtomicInteger calls = new AtomicInteger();
Completable.fromCallable(new Callable<Object>() {
@Override
public Object call() throws Exception {
calls.incrementAndGet();
throw new TestException();
}
}).test(true).assertEmpty();
assertEquals(1, calls.get());
}
Aggregations