diff --git a/reactor-core/src/test/java/reactor/core/publisher/FluxSampleTimeoutTest.java b/reactor-core/src/test/java/reactor/core/publisher/FluxSampleTimeoutTest.java index 1a34fa8a07..7c8a0b83da 100644 --- a/reactor-core/src/test/java/reactor/core/publisher/FluxSampleTimeoutTest.java +++ b/reactor-core/src/test/java/reactor/core/publisher/FluxSampleTimeoutTest.java @@ -137,20 +137,17 @@ public void throttlerReturnsNull() { @Test public void sampleIncludesLastItem() { - Flux source = Flux.concat( - Flux.range(1, 5), - Mono.delay(Duration.ofMillis(260)).ignoreElement().map(Long::intValue), - Flux.just(80, 90, 100) - ).hide(); - - Duration duration = StepVerifier.create(source - .sampleTimeout(i -> Mono.delay(Duration.ofMillis(250)))) - .expectNext(5) - .expectNext(100) - .verifyComplete(); - - //sanity check on the sequence duration - assertThat(duration.toMillis()).isLessThan(500); + StepVerifier.withVirtualTime(() -> + Flux.concat( + Flux.range(1, 5), + Mono.delay(Duration.ofMillis(260)).ignoreElement().map(Long::intValue), + Flux.just(80, 90, 100) + ).hide() + .sampleTimeout(i -> Mono.delay(Duration.ofMillis(250)))) + .thenAwait(Duration.ofMillis(500)) + .expectNext(5) + .expectNext(100) + .verifyComplete(); } @Test