Search in sources :

Example 1 with LongConsumer

use of io.reactivex.functions.LongConsumer in project RxJava by ReactiveX.

the class FlowableSkipTest method testBackpressureMultipleSmallAsyncRequests.

@Test
public void testBackpressureMultipleSmallAsyncRequests() throws InterruptedException {
    final AtomicLong requests = new AtomicLong(0);
    TestSubscriber<Long> ts = new TestSubscriber<Long>(0L);
    Flowable.interval(100, TimeUnit.MILLISECONDS).doOnRequest(new LongConsumer() {

        @Override
        public void accept(long n) {
            requests.addAndGet(n);
        }
    }).skip(4).subscribe(ts);
    Thread.sleep(100);
    ts.request(1);
    ts.request(1);
    Thread.sleep(100);
    ts.dispose();
    // FIXME not assertable anymore
    //        ts.assertUnsubscribed();
    ts.assertNoErrors();
    assertEquals(6, requests.get());
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) LongConsumer(io.reactivex.functions.LongConsumer) AtomicLong(java.util.concurrent.atomic.AtomicLong) TestSubscriber(io.reactivex.subscribers.TestSubscriber) Test(org.junit.Test)

Aggregations

LongConsumer (io.reactivex.functions.LongConsumer)1 TestSubscriber (io.reactivex.subscribers.TestSubscriber)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Test (org.junit.Test)1