Search in sources :

Example 1 with DisposableCompletableObserver

use of io.reactivex.rxjava3.observers.DisposableCompletableObserver in project RxJava by ReactiveX.

the class FlowableIgnoreElementsTest method doesNotHangAndProcessesAllUsingBackpressure.

@Test
public void doesNotHangAndProcessesAllUsingBackpressure() {
    final AtomicInteger upstreamCount = new AtomicInteger();
    final AtomicInteger count = new AtomicInteger(0);
    int num = 10;
    Flowable.range(1, num).doOnNext(new Consumer<Integer>() {

        @Override
        public void accept(Integer t) {
            upstreamCount.incrementAndGet();
        }
    }).ignoreElements().subscribe(new DisposableCompletableObserver() {

        @Override
        public void onComplete() {
        }

        @Override
        public void onError(Throwable e) {
        }
    });
    assertEquals(num, upstreamCount.get());
    assertEquals(0, count.get());
}
Also used : DisposableCompletableObserver(io.reactivex.rxjava3.observers.DisposableCompletableObserver) Test(org.junit.Test)

Example 2 with DisposableCompletableObserver

use of io.reactivex.rxjava3.observers.DisposableCompletableObserver in project RxJava by ReactiveX.

the class SchedulerWhenTest method onCompleteActionRunCrash.

@Test
public void onCompleteActionRunCrash() {
    final AtomicInteger count = new AtomicInteger();
    OnCompletedAction a = new OnCompletedAction(new Runnable() {

        @Override
        public void run() {
            throw new TestException();
        }
    }, new DisposableCompletableObserver() {

        @Override
        public void onComplete() {
            count.incrementAndGet();
        }

        @Override
        public void onError(Throwable e) {
            count.decrementAndGet();
            e.printStackTrace();
        }
    });
    try {
        a.run();
        fail("Should have thrown");
    } catch (TestException expected) {
    }
    assertEquals(1, count.get());
}
Also used : DisposableCompletableObserver(io.reactivex.rxjava3.observers.DisposableCompletableObserver) TestException(io.reactivex.rxjava3.exceptions.TestException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Test(org.junit.Test)

Aggregations

DisposableCompletableObserver (io.reactivex.rxjava3.observers.DisposableCompletableObserver)2 Test (org.junit.Test)2 TestException (io.reactivex.rxjava3.exceptions.TestException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1