From d93c79316d96da75059477248e285bcb098d0077 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 9 Jul 2019 12:13:23 +0100 Subject: [PATCH] Align with body method changes in RequestBodySpec Closes gh-17460 --- .../AbstractWebEndpointIntegrationTests.java | 4 ++-- ...trollerEndpointHandlerMappingIntegrationTests.java | 2 +- ...trollerEndpointHandlerMappingIntegrationTests.java | 2 +- .../logging/LoggersEndpointWebIntegrationTests.java | 11 +++++------ .../error/AbstractErrorWebExceptionHandler.java | 2 +- ...faultErrorWebExceptionHandlerIntegrationTests.java | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java index fe22a6ea2a..5f2f305a4f 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java @@ -163,7 +163,7 @@ public abstract class AbstractWebEndpointIntegrationTests body = new HashMap<>(); body.put("foo", "one"); body.put("bar", "two"); - client.post().uri("/test").syncBody(body).exchange().expectStatus().isNoContent().expectBody().isEmpty(); + client.post().uri("/test").body(body).exchange().expectStatus().isNoContent().expectBody().isEmpty(); }); } @@ -194,7 +194,7 @@ public abstract class AbstractWebEndpointIntegrationTests { Map body = new HashMap<>(); body.put("foo", "one"); - client.post().uri("/test").syncBody(body).exchange().expectStatus().isNoContent().expectBody().isEmpty(); + client.post().uri("/test").body(body).exchange().expectStatus().isNoContent().expectBody().isEmpty(); verify(context.getBean(EndpointDelegate.class)).write("one", null); }); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/ControllerEndpointHandlerMappingIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/ControllerEndpointHandlerMappingIntegrationTests.java index d074d8797d..fe54be2d34 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/ControllerEndpointHandlerMappingIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/reactive/ControllerEndpointHandlerMappingIntegrationTests.java @@ -80,7 +80,7 @@ class ControllerEndpointHandlerMappingIntegrationTests { @Test void post() { this.contextRunner.run(withWebTestClient((webTestClient) -> webTestClient.post().uri("/actuator/example/two") - .syncBody(Collections.singletonMap("id", "test")).exchange().expectStatus().isCreated().expectHeader() + .body(Collections.singletonMap("id", "test")).exchange().expectStatus().isCreated().expectHeader() .valueEquals(HttpHeaders.LOCATION, "/example/test"))); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/ControllerEndpointHandlerMappingIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/ControllerEndpointHandlerMappingIntegrationTests.java index 5f9d03922c..eb365525ad 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/ControllerEndpointHandlerMappingIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/servlet/ControllerEndpointHandlerMappingIntegrationTests.java @@ -79,7 +79,7 @@ class ControllerEndpointHandlerMappingIntegrationTests { @Test void post() { this.contextRunner.run(withWebTestClient((webTestClient) -> webTestClient.post().uri("/actuator/example/two") - .syncBody(Collections.singletonMap("id", "test")).exchange().expectStatus().isCreated().expectHeader() + .body(Collections.singletonMap("id", "test")).exchange().expectStatus().isCreated().expectHeader() .valueEquals(HttpHeaders.LOCATION, "/example/test"))); } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointWebIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointWebIntegrationTests.java index 692fda90cf..97de049835 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointWebIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/logging/LoggersEndpointWebIntegrationTests.java @@ -95,7 +95,7 @@ class LoggersEndpointWebIntegrationTests { @WebEndpointTest void setLoggerUsingApplicationJsonShouldSetLogLevel() { this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.APPLICATION_JSON) - .syncBody(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus().isNoContent(); + .body(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus().isNoContent(); verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG); } @@ -103,15 +103,14 @@ class LoggersEndpointWebIntegrationTests { void setLoggerUsingActuatorV2JsonShouldSetLogLevel() { this.client.post().uri("/actuator/loggers/ROOT") .contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON)) - .syncBody(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus().isNoContent(); + .body(Collections.singletonMap("configuredLevel", "debug")).exchange().expectStatus().isNoContent(); verify(this.loggingSystem).setLogLevel("ROOT", LogLevel.DEBUG); } @WebEndpointTest void setLoggerWithWrongLogLevelResultInBadRequestResponse() { this.client.post().uri("/actuator/loggers/ROOT").contentType(MediaType.APPLICATION_JSON) - .syncBody(Collections.singletonMap("configuredLevel", "other")).exchange().expectStatus() - .isBadRequest(); + .body(Collections.singletonMap("configuredLevel", "other")).exchange().expectStatus().isBadRequest(); verifyZeroInteractions(this.loggingSystem); } @@ -119,14 +118,14 @@ class LoggersEndpointWebIntegrationTests { void setLoggerWithNullLogLevel() { this.client.post().uri("/actuator/loggers/ROOT") .contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON)) - .syncBody(Collections.singletonMap("configuredLevel", null)).exchange().expectStatus().isNoContent(); + .body(Collections.singletonMap("configuredLevel", null)).exchange().expectStatus().isNoContent(); verify(this.loggingSystem).setLogLevel("ROOT", null); } @WebEndpointTest void setLoggerWithNoLogLevel() { this.client.post().uri("/actuator/loggers/ROOT") - .contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON)).syncBody(Collections.emptyMap()) + .contentType(MediaType.parseMediaType(ActuatorMediaType.V2_JSON)).body(Collections.emptyMap()) .exchange().expectStatus().isNoContent(); verify(this.loggingSystem).setLogLevel("ROOT", null); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java index 1777141087..b36b7384f5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java @@ -222,7 +222,7 @@ public abstract class AbstractErrorWebExceptionHandler implements ErrorWebExcept builder.append("
").append(htmlEscape(trace)).append("
"); } builder.append(""); - return responseBody.syncBody(builder.toString()); + return responseBody.body(builder.toString()); } private String htmlEscape(Object input) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java index 81a41b27ac..1fe7dbef98 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java @@ -111,7 +111,7 @@ class DefaultErrorWebExceptionHandlerIntegrationTests { void bindingResultError() { this.contextRunner.run((context) -> { WebTestClient client = getWebClient(context); - client.post().uri("/bind").contentType(MediaType.APPLICATION_JSON).syncBody("{}").exchange().expectStatus() + client.post().uri("/bind").contentType(MediaType.APPLICATION_JSON).body("{}").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()