Skip to content

Commit b89a48a

Browse files
committed
Improve FlushingIntegrationTests
1 parent 3c2d186 commit b89a48a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

spring-webflux/src/test/java/org/springframework/web/reactive/FlushingIntegrationTests.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.springframework.http.server.reactive.HttpHandler;
3333
import org.springframework.http.server.reactive.ServerHttpRequest;
3434
import org.springframework.http.server.reactive.ServerHttpResponse;
35-
import org.springframework.web.reactive.function.BodyExtractors;
3635
import org.springframework.web.reactive.function.client.WebClient;
3736

3837
import static org.junit.Assert.assertTrue;
@@ -57,8 +56,8 @@ public void setup() throws Exception {
5756
public void writeAndFlushWith() throws Exception {
5857
Mono<String> result = this.webClient.get()
5958
.uri("/write-and-flush")
60-
.exchange()
61-
.flatMapMany(response -> response.body(BodyExtractors.toFlux(String.class)))
59+
.retrieve()
60+
.bodyToFlux(String.class)
6261
.takeUntil(s -> s.endsWith("data1"))
6362
.reduce((s1, s2) -> s1 + s2);
6463

@@ -72,13 +71,13 @@ public void writeAndFlushWith() throws Exception {
7271
public void writeAndAutoFlushOnComplete() {
7372
Mono<String> result = this.webClient.get()
7473
.uri("/write-and-complete")
75-
.exchange()
76-
.flatMapMany(response -> response.bodyToFlux(String.class))
74+
.retrieve()
75+
.bodyToFlux(String.class)
7776
.reduce((s1, s2) -> s1 + s2);
7877

7978
try {
8079
StepVerifier.create(result)
81-
.consumeNextWith(value -> assertTrue(value.length() == 200000))
80+
.consumeNextWith(value -> assertTrue(value.length() == 20000 * "0123456789".length()))
8281
.expectComplete()
8382
.verify(Duration.ofSeconds(5L));
8483
}
@@ -95,14 +94,15 @@ public void writeAndAutoFlushOnComplete() {
9594

9695
@Test // SPR-14992
9796
public void writeAndAutoFlushBeforeComplete() {
98-
Flux<String> result = this.webClient.get()
97+
Mono<String> result = this.webClient.get()
9998
.uri("/write-and-never-complete")
100-
.exchange()
101-
.flatMapMany(response -> response.bodyToFlux(String.class));
99+
.retrieve()
100+
.bodyToFlux(String.class)
101+
.next();
102102

103103
StepVerifier.create(result)
104104
.expectNextMatches(s -> s.startsWith("0123456789"))
105-
.thenCancel()
105+
.expectComplete()
106106
.verify(Duration.ofSeconds(5L));
107107
}
108108

0 commit comments

Comments
 (0)