From 77eb26c29ac62864a83b3adc0d2a88b871c96443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Basl=C3=A9?= Date: Mon, 7 Jan 2019 11:58:56 +0100 Subject: [PATCH] [test] Use virtual time in flakky sampleTimeout test --- .../core/publisher/FluxSampleTimeoutTest.java | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) 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