Better "no content" support and polish in WebTestClient

The WebTestClient now takes advantage of the support for decoding
response to Void.class in WebClient so that applications can use
expectBody(Void.class) to the same effect as using
response.bodyToMono(Void.class) as documneted on WebClient#exchange.

The top-level, no-arg returnResult method (added very recently) has been
retracted, since the use of returnResult at that level, i.e. without
consuming the response content, should be used mainly for streaming.
It shouldn't be used for "no content" scenarios.

Documentation and Javadoc have been udpated accordingly.
This commit is contained in:
Rossen Stoyanchev
2017-10-04 14:58:11 -04:00
parent decb6329db
commit d04d4bfb4d
4 changed files with 120 additions and 78 deletions

View File

@@ -39,7 +39,7 @@ public class ErrorTests {
this.client.get().uri("/invalid")
.exchange()
.expectStatus().isNotFound()
.expectBody().isEmpty();
.expectBody(Void.class);
}
@Test
@@ -47,7 +47,7 @@ public class ErrorTests {
this.client.get().uri("/server-error")
.exchange()
.expectStatus().isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR)
.expectBody().isEmpty();
.expectBody(Void.class);
}