return createTimeout(maxAge, Schedulers.parallel());
@Test public void timedOnSubscribeAndState(){ testReplayProcessorState(ReplayProcessor.createTimeout(Duration.ofSeconds(1))); }
@Test public void timedError() throws Exception { VirtualTimeScheduler.getOrSet(); ReplayProcessor<Integer> rp = ReplayProcessor.createTimeout(Duration.ofSeconds(1)); for (int i = 0; i < 5; i++) { rp.onNext(i); } VirtualTimeScheduler.get().advanceTimeBy(Duration.ofSeconds(2)); for (int i = 5; i < 10; i++) { rp.onNext(i); } rp.onError(new Exception("test")); StepVerifier.create(rp.hide()) .expectNext(5,6,7,8,9) .verifyErrorMessage("test"); }
@Test public void timedFusedError() throws Exception { VirtualTimeScheduler.getOrSet(); ReplayProcessor<Integer> rp = ReplayProcessor.createTimeout(Duration.ofSeconds(1)); for (int i = 0; i < 5; i++) { rp.onNext(i); } VirtualTimeScheduler.get().advanceTimeBy(Duration.ofSeconds(2)); for (int i = 5; i < 10; i++) { rp.onNext(i); } rp.onError(new Exception("test")); StepVerifier.create(rp) .expectFusion(Fuseable.NONE) .expectNext(5,6,7,8,9) .verifyErrorMessage("test"); }
@Test public void timedFusedAfter() throws Exception { ReplayProcessor<Integer> rp = ReplayProcessor.createTimeout(Duration.ofSeconds(1)); StepVerifier.create(rp) .expectFusion(Fuseable.NONE) .then(() -> { for (int i = 0; i < 5; i++) { rp.onNext(i); } VirtualTimeScheduler.get().advanceTimeBy(Duration.ofSeconds(2)); for (int i = 5; i < 10; i++) { rp.onNext(i); } rp.onComplete(); }) .expectNext(0,1,2,3,4,5,6,7,8,9) .verifyComplete(); }
@Test public void timedFused() throws Exception { VirtualTimeScheduler.getOrSet(); ReplayProcessor<Integer> rp = ReplayProcessor.createTimeout(Duration.ofSeconds(1)); for (int i = 0; i < 5; i++) { rp.onNext(i); } VirtualTimeScheduler.get().advanceTimeBy(Duration.ofSeconds(2)); for (int i = 5; i < 10; i++) { rp.onNext(i); } rp.onComplete(); StepVerifier.create(rp) .expectFusion(Fuseable.NONE) .expectNext(5,6,7,8,9) .verifyComplete(); }
@Test public void timedAfter() throws Exception { ReplayProcessor<Integer> rp = ReplayProcessor.createTimeout(Duration.ofSeconds(1)); StepVerifier.create(rp.hide()) .expectFusion(Fuseable.NONE) .then(() -> { for (int i = 0; i < 5; i++) { rp.onNext(i); } VirtualTimeScheduler.get().advanceTimeBy(Duration.ofSeconds(2)); for (int i = 5; i < 10; i++) { rp.onNext(i); } rp.onComplete(); }) .expectNext(0,1,2,3,4,5,6,7,8,9) .verifyComplete(); }
@Test public void timed() throws Exception { VirtualTimeScheduler.getOrSet(); ReplayProcessor<Integer> rp = ReplayProcessor.createTimeout(Duration.ofSeconds(1)); for (int i = 0; i < 5; i++) { rp.onNext(i); } VirtualTimeScheduler.get().advanceTimeBy(Duration.ofSeconds(2)); for (int i = 5; i < 10; i++) { rp.onNext(i); } rp.onComplete(); StepVerifier.create(rp.hide()) .expectFusion(Fuseable.NONE) .expectNext(5,6,7,8,9) .verifyComplete(); }
return createTimeout(maxAge, Schedulers.parallel());