Request body improvements in WebClient, WebTestClient
This commit makes changes to WebClient and WebTestClient in oder to limit setting the body according to HTTP method and also to facilitate providing the request body as Object. Specifically, this commit: - Moves methods that operate on the request body to a RequestBodySpec in both WebClient and WebTestClient, and rename them to `body`. These methods now just *set* the body, without performing an exchange (which now requires an explicit exchange call). - Parameterizes UriSpec in both WebClient and WebTestClient, so that it returns either a RequestHeadersSpec or a RequestBodySpec. Issue: SPR-15394
This commit is contained in:
committed by
Rossen Stoyanchev
parent
cbd98d5247
commit
118f33aeda
@@ -41,7 +41,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.endsWith;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.http.MediaType.TEXT_EVENT_STREAM;
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,8 @@ public class ResponseEntityTests {
|
||||
@Test
|
||||
public void postEntity() throws Exception {
|
||||
this.client.post().uri("/persons")
|
||||
.exchange(Mono.just(new Person("John")), Person.class)
|
||||
.body(Mono.just(new Person("John")), Person.class)
|
||||
.exchange()
|
||||
.expectStatus().isCreated()
|
||||
.expectHeader().valueEquals("location", "/persons/John")
|
||||
.expectBody().isEmpty();
|
||||
|
||||
Reference in New Issue
Block a user