@ -117,21 +117,21 @@ logic but without running a server. The following example shows how to do so:
@@ -117,21 +117,21 @@ logic but without running a server. The following example shows how to do so:
// Test code that uses the above RestTemplate ...
----
In the more specific cases where total isolation isn't desired and some integration testing
of one or more calls is needed, a specific `ResponseCreator` can be set up in advance and
used to perform actual requests and assert the response.
The following example shows how to set up and use the `ExecutingResponseCreator` to do so:
In some cases it may be necessary to perform an actual call to a remote service instead
of mocking the response. The following example shows how to do that through
@ -142,7 +142,7 @@ The following example shows how to set up and use the `ExecutingResponseCreator`
@@ -142,7 +142,7 @@ The following example shows how to set up and use the `ExecutingResponseCreator`
----
val restTemplate = RestTemplate()
// Make sure to capture the request factory of the RestTemplate before binding
// Create ExecutingResponseCreator with the original request factory
val withActualResponse = new ExecutingResponseCreator(restTemplate.getRequestFactory())
val mockServer = MockRestServiceServer.bindTo(restTemplate).build()
@ -156,16 +156,15 @@ The following example shows how to set up and use the `ExecutingResponseCreator`
@@ -156,16 +156,15 @@ The following example shows how to set up and use the `ExecutingResponseCreator`
In the preceding example, we create the `ExecutingResponseCreator` using the
`ClientHttpRequestFactory` from the `RestTemplate` _before_ `MockRestServiceServer` replaces
it with the custom one.
Then we define expectations with two kinds of response:
it with a different one that mocks responses.
Then we define expectations with two kinds of responses:
* a stub `200` response for the `/profile` endpoint (no actual request will be executed)
* an "executing response"for the `/quoteOfTheDay` endpoint
* a response obtained through a call to the `/quoteOfTheDay` endpoint
In the second case, the request is executed by the `ClientHttpRequestFactory` that was
In the second case, the request is executed through the `ClientHttpRequestFactory` that was
captured earlier. This generates a response that could e.g. come from an actual remote server,
depending on how the `RestTemplate` was originally configured, and MockMVC can be further
used to assert the content of the response.
depending on how the `RestTemplate` was originally configured.
@ -53,7 +50,7 @@ public class ExecutingResponseCreator implements ResponseCreator {
@@ -53,7 +50,7 @@ public class ExecutingResponseCreator implements ResponseCreator {
@ -63,7 +60,7 @@ public class ExecutingResponseCreator implements ResponseCreator {
@@ -63,7 +60,7 @@ public class ExecutingResponseCreator implements ResponseCreator {