use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.
the class ObservableWindowWithTimeTest method exactTimeBoundNoInterruptWindowOutputOnError.
@Test
@SuppressUndeliverable
public void exactTimeBoundNoInterruptWindowOutputOnError() throws Exception {
final AtomicBoolean isInterrupted = new AtomicBoolean();
final PublishSubject<Integer> ps = PublishSubject.create();
final CountDownLatch doOnNextDone = new CountDownLatch(1);
final CountDownLatch secondWindowProcessing = new CountDownLatch(1);
ps.window(100, TimeUnit.MILLISECONDS).doOnNext(new Consumer<Observable<Integer>>() {
int count;
@Override
public void accept(Observable<Integer> v) throws Exception {
System.out.println(Thread.currentThread());
if (count++ == 1) {
secondWindowProcessing.countDown();
try {
Thread.sleep(200);
isInterrupted.set(Thread.interrupted());
} catch (InterruptedException ex) {
isInterrupted.set(true);
}
doOnNextDone.countDown();
}
}
}).test();
ps.onNext(1);
assertTrue(secondWindowProcessing.await(5, TimeUnit.SECONDS));
ps.onError(new TestException());
assertTrue(doOnNextDone.await(5, TimeUnit.SECONDS));
assertFalse("The doOnNext got interrupted!", isInterrupted.get());
}
use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.
the class ObservableWindowWithTimeTest method exactOnError.
@Test
@SuppressUndeliverable
public void exactOnError() {
TestScheduler scheduler = new TestScheduler();
PublishSubject<Integer> ps = PublishSubject.create();
TestObserver<Integer> to = ps.window(1, 1, TimeUnit.SECONDS, scheduler).flatMap(Functions.<Observable<Integer>>identity()).test();
ps.onError(new TestException());
to.assertFailure(TestException.class);
}
use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.
the class ObservableWindowWithTimeTest method exactTimeAndSizeBoundNoInterruptWindowOutputOnError.
@Test
@SuppressUndeliverable
public void exactTimeAndSizeBoundNoInterruptWindowOutputOnError() throws Exception {
final AtomicBoolean isInterrupted = new AtomicBoolean();
final PublishSubject<Integer> ps = PublishSubject.create();
final CountDownLatch doOnNextDone = new CountDownLatch(1);
final CountDownLatch secondWindowProcessing = new CountDownLatch(1);
ps.window(100, TimeUnit.MILLISECONDS, 10).doOnNext(new Consumer<Observable<Integer>>() {
int count;
@Override
public void accept(Observable<Integer> v) throws Exception {
System.out.println(Thread.currentThread());
if (count++ == 1) {
secondWindowProcessing.countDown();
try {
Thread.sleep(200);
isInterrupted.set(Thread.interrupted());
} catch (InterruptedException ex) {
isInterrupted.set(true);
}
doOnNextDone.countDown();
}
}
}).test();
ps.onNext(1);
assertTrue(secondWindowProcessing.await(5, TimeUnit.SECONDS));
ps.onError(new TestException());
assertTrue(doOnNextDone.await(5, TimeUnit.SECONDS));
assertFalse("The doOnNext got interrupted!", isInterrupted.get());
}
use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.
the class SerializedSubscriberTest method onErrorQueuedUp.
@Test
@SuppressUndeliverable
public void onErrorQueuedUp() {
AtomicReference<SerializedSubscriber<Integer>> ssRef = new AtomicReference<>();
TestSubscriberEx<Integer> ts = new TestSubscriberEx<Integer>() {
@Override
public void onNext(Integer t) {
super.onNext(t);
ssRef.get().onNext(2);
ssRef.get().onError(new TestException());
}
};
final SerializedSubscriber<Integer> so = new SerializedSubscriber<>(ts, true);
ssRef.set(so);
BooleanSubscription bs = new BooleanSubscription();
so.onSubscribe(bs);
so.onNext(1);
ts.assertFailure(TestException.class, 1, 2);
}
use of io.reactivex.rxjava3.testsupport.SuppressUndeliverable in project RxJava by ReactiveX.
the class CompletableFromSupplierTest method fromActionErrorsDisposed.
@Test
@SuppressUndeliverable
public void fromActionErrorsDisposed() {
final AtomicInteger calls = new AtomicInteger();
Completable.fromSupplier(new Supplier<Object>() {
@Override
public Object get() throws Exception {
calls.incrementAndGet();
throw new TestException();
}
}).test(true).assertEmpty();
assertEquals(1, calls.get());
}
Aggregations