Rename WebFlux response body methods

This commit adapts to recent changes in Spring Framework.
See spring-projects/spring-framework#23212
This commit is contained in:
Brian Clozel
2019-08-20 13:03:24 +02:00
parent 752bb0f5ab
commit e7c3ab3e27
6 changed files with 21 additions and 16 deletions

View File

@@ -171,7 +171,7 @@ public abstract class AbstractErrorWebExceptionHandler implements ErrorWebExcept
}
Resource resource = resolveResource(viewName);
if (resource != null) {
return responseBody.body(BodyInserters.fromResource(resource));
return responseBody.bodyValue(BodyInserters.fromResource(resource));
}
return Mono.empty();
}
@@ -223,7 +223,7 @@ public abstract class AbstractErrorWebExceptionHandler implements ErrorWebExcept
builder.append("<div style='white-space:pre-wrap;'>").append(htmlEscape(trace)).append("</div>");
}
builder.append("</body></html>");
return responseBody.body(builder.toString());
return responseBody.bodyValue(builder.toString());
}
private String htmlEscape(Object input) {

View File

@@ -111,7 +111,7 @@ class DefaultErrorWebExceptionHandlerIntegrationTests {
void bindingResultError() {
this.contextRunner.run((context) -> {
WebTestClient client = getWebClient(context);
client.post().uri("/bind").contentType(MediaType.APPLICATION_JSON).body("{}").exchange().expectStatus()
client.post().uri("/bind").contentType(MediaType.APPLICATION_JSON).bodyValue("{}").exchange().expectStatus()
.isBadRequest().expectBody().jsonPath("status").isEqualTo("400").jsonPath("error")
.isEqualTo(HttpStatus.BAD_REQUEST.getReasonPhrase()).jsonPath("path").isEqualTo(("/bind"))
.jsonPath("exception").doesNotExist().jsonPath("errors").isArray().jsonPath("message").isNotEmpty()