return createSizeAndTimeout(Integer.MAX_VALUE, maxAge, scheduler);
return createSizeAndTimeout(size, maxAge, Schedulers.parallel());
@Test(expected = IllegalArgumentException.class) public void failNegativeBufferBoundedAndTimed() { ReplayProcessor.createSizeAndTimeout(-1, Duration.ofSeconds(1)); }
@Test public void timedAndBoundedOnSubscribeAndState(){ testReplayProcessorState(ReplayProcessor.createSizeAndTimeout(1, Duration.ofSeconds(1))); }
@Test public void timedAndBoundFusedError() throws Exception { ReplayProcessor<Integer> rp = ReplayProcessor.createSizeAndTimeout(5, Duration.ofSeconds(1)); for (int i = 0; i < 10; i++) { rp.onNext(i); } VirtualTimeScheduler.get().advanceTimeBy(Duration.ofSeconds(2)); for (int i = 10; i < 20; i++) { rp.onNext(i); } rp.onError(new Exception("test")); StepVerifier.create(rp) .expectFusion(Fuseable.ASYNC) .expectNext(15,16,17,18,19) .verifyErrorMessage("test"); Assert.assertFalse("Has subscribers?", rp.hasDownstreams()); }
@Test public void timedAndBoundError() throws Exception { ReplayProcessor<Integer> rp = ReplayProcessor.createSizeAndTimeout(5, Duration.ofSeconds(1)); for (int i = 0; i < 10; i++) { rp.onNext(i); } VirtualTimeScheduler.get().advanceTimeBy(Duration.ofSeconds(2)); for (int i = 10; i < 20; i++) { rp.onNext(i); } rp.onError(new Exception("test")); StepVerifier.create(rp.hide()) .expectFusion(Fuseable.NONE) .expectNext(15,16,17,18,19) .verifyErrorMessage("test"); Assert.assertFalse("Has subscribers?", rp.hasDownstreams()); }
@Test public void timedAndBoundFused() throws Exception { ReplayProcessor<Integer> rp = ReplayProcessor.createSizeAndTimeout(5, Duration.ofSeconds(1)); for (int i = 0; i < 10; i++) { rp.onNext(i); } VirtualTimeScheduler.get().advanceTimeBy(Duration.ofSeconds(2)); for (int i = 10; i < 20; i++) { rp.onNext(i); } rp.onComplete(); StepVerifier.create(rp) .expectFusion(Fuseable.ASYNC) .expectNext(15,16,17,18,19) .verifyComplete(); Assert.assertFalse("Has subscribers?", rp.hasDownstreams()); }
@Test public void timedAndBound() throws Exception { ReplayProcessor<Integer> rp = ReplayProcessor.createSizeAndTimeout(5, Duration.ofSeconds(1)); for (int i = 0; i < 10; i++) { rp.onNext(i); } VirtualTimeScheduler.get().advanceTimeBy(Duration.ofSeconds(2)); for (int i = 10; i < 20; i++) { rp.onNext(i); } rp.onComplete(); StepVerifier.create(rp.hide()) .expectFusion(Fuseable.NONE) .expectNext(15,16,17,18,19) .verifyComplete(); Assert.assertFalse("Has subscribers?", rp.hasDownstreams()); }
@Test public void timedAndBoundAfter() throws Exception { ReplayProcessor<Integer> rp = ReplayProcessor.createSizeAndTimeout(5, Duration.ofSeconds(1)); StepVerifier.create(rp.hide()) .expectFusion(Fuseable.NONE) .then(() -> { for (int i = 0; i < 10; i++) { rp.onNext(i); } VirtualTimeScheduler.get().advanceTimeBy(Duration.ofSeconds(2)); for (int i = 10; i < 20; i++) { rp.onNext(i); } rp.onComplete(); }) .expectNextCount(20) .verifyComplete(); Assert.assertFalse("Has subscribers?", rp.hasDownstreams()); }
return createSizeAndTimeout(Integer.MAX_VALUE, maxAge, scheduler);
return createSizeAndTimeout(size, maxAge, Schedulers.parallel());