Rename body(Object) to bodyValue
The recently added body(Object) variant can be confused easily with body(Publisher, Class) forgetting to provide the element type and only running into the IllegalArgumentException at runtime. See gh-23212
This commit is contained in:
@@ -61,7 +61,7 @@ public class ApplicationContextSpecTests {
|
||||
.GET("/sessionClassName", request ->
|
||||
request.session().flatMap(session -> {
|
||||
String className = session.getClass().getSimpleName();
|
||||
return ServerResponse.ok().body(className);
|
||||
return ServerResponse.ok().bodyValue(className);
|
||||
}))
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ErrorTests {
|
||||
EntityExchangeResult<Void> result = this.client.post()
|
||||
.uri("/post")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.body(new Person("Dan"))
|
||||
.bodyValue(new Person("Dan"))
|
||||
.exchange()
|
||||
.expectStatus().isBadRequest()
|
||||
.expectBody().isEmpty();
|
||||
|
||||
@@ -82,7 +82,7 @@ public class JsonContentTests {
|
||||
public void postJsonContent() {
|
||||
this.client.post().uri("/persons")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.body("{\"name\":\"John\"}")
|
||||
.bodyValue("{\"name\":\"John\"}")
|
||||
.exchange()
|
||||
.expectStatus().isCreated()
|
||||
.expectBody().isEmpty();
|
||||
|
||||
@@ -145,7 +145,7 @@ public class ResponseEntityTests {
|
||||
@Test
|
||||
public void postEntity() {
|
||||
this.client.post()
|
||||
.body(new Person("John"))
|
||||
.bodyValue(new Person("John"))
|
||||
.exchange()
|
||||
.expectStatus().isCreated()
|
||||
.expectHeader().valueEquals("location", "/persons/John")
|
||||
|
||||
@@ -116,7 +116,7 @@ public class XmlContentTests {
|
||||
|
||||
this.client.post().uri("/persons")
|
||||
.contentType(MediaType.APPLICATION_XML)
|
||||
.body(content)
|
||||
.bodyValue(content)
|
||||
.exchange()
|
||||
.expectStatus().isCreated()
|
||||
.expectHeader().valueEquals(HttpHeaders.LOCATION, "/persons/John")
|
||||
|
||||
@@ -45,7 +45,7 @@ public class HttpServerTests {
|
||||
@BeforeEach
|
||||
public void start() throws Exception {
|
||||
HttpHandler httpHandler = RouterFunctions.toHttpHandler(
|
||||
route(GET("/test"), request -> ServerResponse.ok().body("It works!")));
|
||||
route(GET("/test"), request -> ServerResponse.ok().bodyValue("It works!")));
|
||||
|
||||
this.server = new ReactorHttpServer();
|
||||
this.server.setHandler(httpHandler);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class RouterFunctionTests {
|
||||
public void setUp() throws Exception {
|
||||
|
||||
RouterFunction<?> route = route(GET("/test"), request ->
|
||||
ServerResponse.ok().body("It works!"));
|
||||
ServerResponse.ok().bodyValue("It works!"));
|
||||
|
||||
this.testClient = WebTestClient.bindToRouterFunction(route).build();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user