73
73
* Client for testing web servers that uses {@link WebClient} internally to
74
74
* perform requests while also providing a fluent API to verify responses.
75
75
* This client can connect to any server over HTTP, or to a WebFlux application
76
- * via mock request and response objects .
76
+ * with a mock request and response.
77
77
*
78
78
* <p>Use one of the bindToXxx methods to create an instance. For example:
79
79
* <ul>
89
89
* @author Sam Brannen
90
90
* @author Michał Rowicki
91
91
* @since 5.0
92
- * @see StatusAssertions
93
- * @see HeaderAssertions
94
- * @see JsonPathAssertions
95
92
*/
96
93
public interface WebTestClient {
97
94
@@ -172,12 +169,10 @@ public interface WebTestClient {
172
169
173
170
174
171
/**
175
- * Use this server setup to test one {@code @Controller} at a time.
176
- * This option loads the default configuration of
177
- * {@link org.springframework.web.reactive.config.EnableWebFlux @EnableWebFlux}.
178
- * There are builder methods to customize the Java config. The resulting
179
- * WebFlux application will be tested without an HTTP server using a mock
180
- * request and response.
172
+ * Begin creating a {@link WebTestClient} with a mock server setup that
173
+ * tests one {@code @Controller} at a time with
174
+ * {@link org.springframework.web.reactive.config.EnableWebFlux @EnableWebFlux}
175
+ * equivalent configuration.
181
176
* @param controllers one or more controller instances to test
182
177
* (specified {@code Class} will be turned into instance)
183
178
* @return chained API to customize server and client config; use
@@ -188,10 +183,10 @@ static ControllerSpec bindToController(Object... controllers) {
188
183
}
189
184
190
185
/**
191
- * Use this option to set up a server from a {@link RouterFunction}.
192
- * Internally the provided configuration is passed to
193
- * {@code RouterFunctions#toWebHandler}. The resulting WebFlux application
194
- * will be tested without an HTTP server using a mock request and response .
186
+ * Begin creating a {@link WebTestClient} with a mock server setup that
187
+ * tests one {@code RouterFunction} at a time with
188
+ * {@link org.springframework.web.reactive.config.EnableWebFlux @EnableWebFlux}
189
+ * equivalent configuration .
195
190
* @param routerFunction the RouterFunction to test
196
191
* @return chained API to customize server and client config; use
197
192
* {@link MockServerSpec#configureClient()} to transition to client config
@@ -229,8 +224,7 @@ static MockServerSpec<?> bindToWebHandler(WebHandler webHandler) {
229
224
}
230
225
231
226
/**
232
- * This server setup option allows you to connect to a live server through
233
- * a Reactor Netty client connector.
227
+ * This server setup option allows you to connect to a live server.
234
228
* <p><pre class="code">
235
229
* WebTestClient client = WebTestClient.bindToServer()
236
230
* .baseUrl("http://localhost:8080")
@@ -389,17 +383,12 @@ interface RouterFunctionSpec extends MockServerSpec<RouterFunctionSpec> {
389
383
390
384
391
385
/**
392
- * Steps for customizing the {@link WebClient} used to test with,
393
- * internally delegating to a
394
- * {@link org.springframework.web.reactive.function.client.WebClient.Builder
395
- * WebClient.Builder}.
386
+ * Steps to customize the underlying {@link WebClient} via {@link WebClient.Builder}.
396
387
*/
397
388
interface Builder {
398
389
399
390
/**
400
- * Configure a base URI as described in
401
- * {@link org.springframework.web.reactive.function.client.WebClient#create(String)
402
- * WebClient.create(String)}.
391
+ * Configure a base URI as described in {@link WebClient#create(String)}.
403
392
*/
404
393
Builder baseUrl (String baseUrl );
405
394
@@ -428,7 +417,7 @@ interface Builder {
428
417
Builder defaultHeaders (Consumer <HttpHeaders > headersConsumer );
429
418
430
419
/**
431
- * Add the given header to all requests that haven't added it.
420
+ * Add the given cookie to all requests that haven't already added it.
432
421
* @param cookieName the cookie name
433
422
* @param cookieValues the cookie values
434
423
*/
@@ -718,6 +707,7 @@ interface RequestHeadersSpec<S extends RequestHeadersSpec<S>> {
718
707
* Specification for providing body of a request.
719
708
*/
720
709
interface RequestBodySpec extends RequestHeadersSpec <RequestBodySpec > {
710
+
721
711
/**
722
712
* Set the length of the body in bytes, as specified by the
723
713
* {@code Content-Length} header.
@@ -738,7 +728,7 @@ interface RequestBodySpec extends RequestHeadersSpec<RequestBodySpec> {
738
728
739
729
/**
740
730
* Set the body to the given {@code Object} value. This method invokes the
741
- * {@link org.springframework.web.reactive.function.client. WebClient.RequestBodySpec#bodyValue(Object)
731
+ * {@link WebClient.RequestBodySpec#bodyValue(Object)
742
732
* bodyValue} method on the underlying {@code WebClient}.
743
733
* @param body the value to write to the request body
744
734
* @return spec for further declaration of the request
@@ -773,7 +763,7 @@ <T, S extends Publisher<T>> RequestHeadersSpec<?> body(
773
763
774
764
/**
775
765
* Set the body from the given producer. This method invokes the
776
- * {@link org.springframework.web.reactive.function.client. WebClient.RequestBodySpec#body(Object, Class)
766
+ * {@link WebClient.RequestBodySpec#body(Object, Class)
777
767
* body(Object, Class)} method on the underlying {@code WebClient}.
778
768
* @param producer the producer to write to the request. This must be a
779
769
* {@link Publisher} or another producer adaptable to a
@@ -786,7 +776,7 @@ <T, S extends Publisher<T>> RequestHeadersSpec<?> body(
786
776
787
777
/**
788
778
* Set the body from the given producer. This method invokes the
789
- * {@link org.springframework.web.reactive.function.client. WebClient.RequestBodySpec#body(Object, ParameterizedTypeReference)
779
+ * {@link WebClient.RequestBodySpec#body(Object, ParameterizedTypeReference)
790
780
* body(Object, ParameterizedTypeReference)} method on the underlying {@code WebClient}.
791
781
* @param producer the producer to write to the request. This must be a
792
782
* {@link Publisher} or another producer adaptable to a
@@ -800,7 +790,7 @@ <T, S extends Publisher<T>> RequestHeadersSpec<?> body(
800
790
/**
801
791
* Set the body of the request to the given {@code BodyInserter}.
802
792
* This method invokes the
803
- * {@link org.springframework.web.reactive.function.client. WebClient.RequestBodySpec#body(BodyInserter)
793
+ * {@link WebClient.RequestBodySpec#body(BodyInserter)
804
794
* body(BodyInserter)} method on the underlying {@code WebClient}.
805
795
* @param inserter the body inserter to use
806
796
* @return spec for further declaration of the request
@@ -908,8 +898,8 @@ interface ResponseSpec {
908
898
BodyContentSpec expectBody ();
909
899
910
900
/**
911
- * Exit the chained flow in order to consume the response body
912
- * externally, for example, via {@link reactor.test.StepVerifier}.
901
+ * Exit the chained flow in order to consume the response body externally,
902
+ * for example, via {@link reactor.test.StepVerifier}.
913
903
* <p>Note that when {@code Void.class} is passed in, the response body
914
904
* is consumed and released. If no content is expected, then consider
915
905
* using {@code .expectBody().isEmpty()} instead which asserts that
0 commit comments