From b89a48a7039e3fcf39ec2986adb4d96b2ef99e44 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Tue, 21 Nov 2017 22:12:27 -0500 Subject: [PATCH] Improve FlushingIntegrationTests --- .../reactive/FlushingIntegrationTests.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java b/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java index 588f6e2b2a..e85223570d 100644 --- a/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java +++ b/spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java @@ -32,7 +32,6 @@ import org.springframework.http.server.reactive.AbstractHttpHandlerIntegrationTe import org.springframework.http.server.reactive.HttpHandler; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.http.server.reactive.ServerHttpResponse; -import org.springframework.web.reactive.function.BodyExtractors; import org.springframework.web.reactive.function.client.WebClient; import static org.junit.Assert.assertTrue; @@ -57,8 +56,8 @@ public class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTest public void writeAndFlushWith() throws Exception { Mono result = this.webClient.get() .uri("/write-and-flush") - .exchange() - .flatMapMany(response -> response.body(BodyExtractors.toFlux(String.class))) + .retrieve() + .bodyToFlux(String.class) .takeUntil(s -> s.endsWith("data1")) .reduce((s1, s2) -> s1 + s2); @@ -72,13 +71,13 @@ public class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTest public void writeAndAutoFlushOnComplete() { Mono result = this.webClient.get() .uri("/write-and-complete") - .exchange() - .flatMapMany(response -> response.bodyToFlux(String.class)) + .retrieve() + .bodyToFlux(String.class) .reduce((s1, s2) -> s1 + s2); try { StepVerifier.create(result) - .consumeNextWith(value -> assertTrue(value.length() == 200000)) + .consumeNextWith(value -> assertTrue(value.length() == 20000 * "0123456789".length())) .expectComplete() .verify(Duration.ofSeconds(5L)); } @@ -95,14 +94,15 @@ public class FlushingIntegrationTests extends AbstractHttpHandlerIntegrationTest @Test // SPR-14992 public void writeAndAutoFlushBeforeComplete() { - Flux result = this.webClient.get() + Mono result = this.webClient.get() .uri("/write-and-never-complete") - .exchange() - .flatMapMany(response -> response.bodyToFlux(String.class)); + .retrieve() + .bodyToFlux(String.class) + .next(); StepVerifier.create(result) .expectNextMatches(s -> s.startsWith("0123456789")) - .thenCancel() + .expectComplete() .verify(Duration.ofSeconds(5L)); }