@Override public Flowable<Object> apply(Flowable<Object> f) throws Exception { return f.onBackpressureBuffer(8, Functions.EMPTY_ACTION, BackpressureOverflowStrategy.ERROR); } });
@Override public Object apply(Flowable<Object> f) throws Exception { return f.onBackpressureBuffer(8, Functions.EMPTY_ACTION, BackpressureOverflowStrategy.ERROR); } }, false, 1, 1, 1);
@Override public Publisher<Long> createPublisher(long elements) { return Flowable.intervalRange(0, elements, 0, 1, TimeUnit.MILLISECONDS) .onBackpressureBuffer() ; } }
@Override public Publisher<Integer> createPublisher(long elements) { return Flowable.range(0, (int)elements).onBackpressureBuffer() ; } }
@Override public Publisher<Long> createPublisher(long elements) { return Flowable.interval(0, 1, TimeUnit.MILLISECONDS).take(elements) .onBackpressureBuffer() ; } }
@Test public void badRequest() { TestHelper.assertBadRequestReported(Flowable.just(1) .onBackpressureBuffer(16, Functions.EMPTY_ACTION, BackpressureOverflowStrategy.ERROR)); }
@Test public void dispose() { TestHelper.checkDisposed(Flowable.just(1) .onBackpressureBuffer(16, Functions.EMPTY_ACTION, BackpressureOverflowStrategy.ERROR)); }
@Test public void empty() { Flowable.empty() .onBackpressureBuffer(16, Functions.EMPTY_ACTION, BackpressureOverflowStrategy.ERROR) .test(0L) .assertResult(); }
@Test public void overflowError() { Flowable.range(1, 20) .onBackpressureBuffer(8, Functions.EMPTY_ACTION, BackpressureOverflowStrategy.ERROR) .test(0L) .assertFailure(MissingBackpressureException.class); }
@Test public void emptyDelayError() { Flowable.empty() .onBackpressureBuffer(true) .test() .assertResult(); }
@Test public void overflowCrashes() { Flowable.range(1, 20) .onBackpressureBuffer(8, new Action() { @Override public void run() throws Exception { throw new TestException(); } }, BackpressureOverflowStrategy.DROP_OLDEST) .test(0L) .assertFailure(TestException.class); }
@Test public void justTake() { Flowable.just(1) .onBackpressureBuffer(16, Functions.EMPTY_ACTION, BackpressureOverflowStrategy.ERROR) .take(1) .test() .assertResult(1); } }
@Test public void error() { Flowable .error(new TestException()) .onBackpressureBuffer(16, Functions.EMPTY_ACTION, BackpressureOverflowStrategy.ERROR) .test() .assertFailure(TestException.class); }
@Test public void fusionRejected() { TestSubscriber<Integer> ts = SubscriberFusion.newTest(QueueFuseable.SYNC); Flowable.<Integer>never().onBackpressureBuffer().subscribe(ts); SubscriberFusion.assertFusion(ts, QueueFuseable.NONE) .assertEmpty(); } }
@Test public void maxSize() { TestSubscriber<Integer> ts = TestSubscriber.create(0); Flowable.range(1, 10).onBackpressureBuffer(1).subscribe(ts); ts.assertNoValues(); ts.assertError(MissingBackpressureException.class); ts.assertNotComplete(); }
@Test public void noDelayError() { Flowable.just(1).concatWith(Flowable.<Integer>error(new TestException())) .onBackpressureBuffer(false) .test(0L) .assertFailure(TestException.class); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public Publisher<List<Long>> createPublisher(long elements) { return Flowable.fromIterable(iterate(elements)) .window(Flowable.just(1).concatWith(Flowable.<Integer>never())) .onBackpressureBuffer() .flatMap((Function)Functions.identity()) ; } }
@Test public void delayError() { TestSubscriber<Integer> ts = Flowable.just(1).concatWith(Flowable.<Integer>error(new TestException())) .onBackpressureBuffer(true) .test(0L) .assertEmpty(); ts.request(1); ts.assertFailure(TestException.class, 1); }
@Test public void fusedNormal() { TestSubscriber<Integer> ts = SubscriberFusion.newTest(QueueFuseable.ANY); Flowable.range(1, 10).onBackpressureBuffer().subscribe(ts); ts.assertOf(SubscriberFusion.<Integer>assertFuseable()) .assertOf(SubscriberFusion.<Integer>assertFusionMode(QueueFuseable.ASYNC)) .assertResult(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); }
@Test public void delayErrorBuffer() { TestSubscriber<Integer> ts = Flowable.just(1).concatWith(Flowable.<Integer>error(new TestException())) .onBackpressureBuffer(16, true) .test(0L) .assertEmpty(); ts.request(1); ts.assertFailure(TestException.class, 1); }