2
2
= RestTestClient
3
3
4
4
`RestTestClient` is an HTTP client designed for testing server applications. It wraps
5
- Spring's xref:integration/rest-clients.adoc#rest-restclient[`RestClient`] and uses it to perform requests
5
+ Spring's xref:integration/rest-clients.adoc#rest-restclient[`RestClient`] and uses it to perform requests,
6
6
but exposes a testing facade for verifying responses. `RestTestClient` can be used to
7
7
perform end-to-end HTTP tests. It can also be used to test Spring MVC
8
- applications without a running server via mock server request and response objects .
8
+ applications without a running server via MockMvc .
9
9
10
10
11
11
@@ -14,7 +14,7 @@ applications without a running server via mock server request and response objec
14
14
== Setup
15
15
16
16
To set up a `RestTestClient` you need to choose a server setup to bind to. This can be one
17
- of several mock server setup choices or a connection to a live server.
17
+ of several MockMvc setup choices, or a connection to a live server.
18
18
19
19
20
20
@@ -144,9 +144,7 @@ Kotlin::
144
144
145
145
In addition to the server setup options described earlier, you can also configure client
146
146
options, including base URL, default headers, client filters, and others. These options
147
- are readily available following `bindToServer()`. For all other configuration options,
148
- you need to use `configureClient()` to transition from server to client configuration, as
149
- follows:
147
+ are readily available following the initial `bindTo` call, as follows:
150
148
151
149
[tabs]
152
150
======
@@ -155,7 +153,6 @@ Java::
155
153
[source,java,indent=0,subs="verbatim,quotes"]
156
154
----
157
155
client = RestTestClient.bindToController(new TestController())
158
- .configureClient()
159
156
.baseUrl("/test")
160
157
.build();
161
158
----
@@ -165,7 +162,6 @@ Kotlin::
165
162
[source,kotlin,indent=0,subs="verbatim,quotes"]
166
163
----
167
164
client = RestTestClient.bindToController(TestController())
168
- .configureClient()
169
165
.baseUrl("/test")
170
166
.build()
171
167
----
@@ -180,7 +176,7 @@ Kotlin::
180
176
`RestTestClient` provides an API identical to xref:integration/rest-clients.adoc#rest-restclient[`RestClient`]
181
177
up to the point of performing a request by using `exchange()`.
182
178
183
- After the call to `exchange()`, `RestTestClient` diverges from the `RestClient` and
179
+ After the call to `exchange()`, `RestTestClient` diverges from `RestClient`, and
184
180
instead continues with a workflow to verify responses.
185
181
186
182
To assert the response status and headers, use the following:
@@ -310,8 +306,7 @@ Kotlin::
310
306
======
311
307
312
308
TIP: When you need to decode to a target type with generics, look for the overloaded methods
313
- that accept
314
- {spring-framework-api}/core/ParameterizedTypeReference.html[`ParameterizedTypeReference`]
309
+ that accept{spring-framework-api}/core/ParameterizedTypeReference.html[`ParameterizedTypeReference`]
315
310
instead of `Class<T>`.
316
311
317
312
@@ -346,8 +341,7 @@ Kotlin::
346
341
----
347
342
======
348
343
349
- If you want to ignore the response content, the following releases the content without
350
- any assertions:
344
+ If you want to ignore the response content, the following releases the content without any assertions:
351
345
352
346
[tabs]
353
347
======
0 commit comments