/** * Delay the emission of the terminal events of this Nono * by the given time amount. * @param delay the delay amount * @param unit the time unit * @return the new Nono instance */ @SchedulerSupport(SchedulerSupport.COMPUTATION) public final Nono delay(long delay, TimeUnit unit) { return delay(delay, unit, Schedulers.computation()); }
@Override public Nono apply(Integer v) throws Exception { if (v == 2) { return ioError; } return Nono.complete().delay(50, TimeUnit.MILLISECONDS); } }), 1)
@Override public Nono apply(Integer v) throws Exception { return Nono.complete().delay(50, TimeUnit.MILLISECONDS); } }), 1)
@Override public Nono apply(Integer v) throws Exception { if (v == 2) { return ioError; } return Nono.complete().delay(50, TimeUnit.MILLISECONDS); } }))
@Override public Nono apply(Integer v) throws Exception { return Nono.complete().delay(50, TimeUnit.MILLISECONDS); } }))
@Override public Nono apply(Integer v) throws Exception { return Nono.complete().delay(50, TimeUnit.MILLISECONDS); } }))
@Test public void mergeIterableMaxConcurrentDelayErrorError() { Nono.mergeDelayError(Arrays.asList( Nono.complete().delay(50, TimeUnit.MILLISECONDS), ioError.delay(50, TimeUnit.MILLISECONDS), Nono.complete().delay(100, TimeUnit.MILLISECONDS) ), 1) .test() .awaitDone(5, TimeUnit.SECONDS) .assertFailure(IOException.class); }
@Test public void mergeArrayMaxConcurrentDelayErrorError() { Nono.mergeArrayDelayError(1, Nono.complete().delay(50, TimeUnit.MILLISECONDS), ioError.delay(50, TimeUnit.MILLISECONDS), Nono.complete().delay(100, TimeUnit.MILLISECONDS) ) .test() .awaitDone(5, TimeUnit.SECONDS) .assertFailure(IOException.class); }
@Test public void mergeIterableMaxConcurrentDelayError() { Nono.mergeDelayError(Arrays.asList( Nono.complete().delay(50, TimeUnit.MILLISECONDS), Nono.complete().delay(50, TimeUnit.MILLISECONDS), Nono.complete().delay(100, TimeUnit.MILLISECONDS) ), 1) .test() .awaitDone(5, TimeUnit.SECONDS) .assertResult(); }
@Test public void blockingSubscribeError() { List<Throwable> errors = TestHelper.trackPluginErrors(); try { ioError .delay(100, TimeUnit.MILLISECONDS) .blockingSubscribe(); TestHelper.assertUndeliverable(errors, 0, IOException.class); } finally { RxJavaPlugins.reset(); } }
@Test public void timeout5() { Nono.fromAction(this) .delay(10, TimeUnit.MILLISECONDS) .timeout(1, TimeUnit.SECONDS) .test() .awaitDone(5, TimeUnit.SECONDS) .assertResult(); Assert.assertEquals(1, count); }
@Test public void timeout6() { Nono.fromAction(this) .delay(1, TimeUnit.SECONDS) .timeout(10, TimeUnit.MILLISECONDS) .test() .awaitDone(5, TimeUnit.SECONDS) .assertFailure(TimeoutException.class); Assert.assertEquals(1, count); }
@Test public void timeout9() { Nono.fromAction(this) .delay(10, TimeUnit.MILLISECONDS) .timeout(1, TimeUnit.SECONDS, Schedulers.single()) .test() .awaitDone(5, TimeUnit.SECONDS) .assertResult(); Assert.assertEquals(1, count); }
@Test public void timeout7() { Nono.fromAction(this) .delay(1, TimeUnit.SECONDS) .timeout(10, TimeUnit.MILLISECONDS, Nono.fromAction(this)) .test() .awaitDone(5, TimeUnit.SECONDS) .assertResult(); Assert.assertEquals(2, count); }
@Test public void timeout8() { Nono.fromAction(this) .delay(1, TimeUnit.SECONDS) .timeout(10, TimeUnit.MILLISECONDS, Schedulers.single(), Nono.fromAction(this)) .test() .awaitDone(5, TimeUnit.SECONDS) .assertResult(); Assert.assertEquals(2, count); }