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
@@ -35,8 +35,8 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.codec.Pojo;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.springframework.web.reactive.function.BodyInserters.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* Integration tests using a {@link ExchangeFunction} through {@link WebClient}.
|
||||
@@ -188,7 +188,8 @@ public class WebClientIntegrationTests {
|
||||
.uri("/pojo/capitalize")
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.exchange(fromObject(new Pojo("foofoo", "barbar")))
|
||||
.body(new Pojo("foofoo", "barbar"))
|
||||
.exchange()
|
||||
.then(response -> response.bodyToMono(Pojo.class));
|
||||
|
||||
StepVerifier.create(result)
|
||||
|
||||
Reference in New Issue
Block a user