Class ExecutingResponseCreator
java.lang.Object
org.springframework.test.web.client.response.ExecutingResponseCreator
- All Implemented Interfaces:
ResponseCreator
ResponseCreator
that obtains the response by executing the request
through a ClientHttpRequestFactory
. This is useful in scenarios with
multiple remote services where some need to be called rather than mocked.
The ClientHttpRequestFactory
is typically obtained from the
RestTemplate
before it is passed to MockRestServiceServer
,
in effect using the original factory rather than the test factory:
ResponseCreator withActualResponse = new ExecutingResponseCreator(restTemplate);
MockRestServiceServer server = MockRestServiceServer.bindTo(restTemplate).build();
//...
server.expect(requestTo("/foo")).andRespond(withSuccess());
server.expect(requestTo("/bar")).andRespond(withActualResponse);
- Since:
- 6.0.4
- Author:
- Simon Baslé
-
Constructor Summary
ConstructorDescriptionExecutingResponseCreator
(ClientHttpRequestFactory requestFactory) Create an instance with the givenClientHttpRequestFactory
. -
Method Summary
Modifier and TypeMethodDescriptioncreateResponse
(ClientHttpRequest request) Create a response for the given request.
-
Constructor Details
-
ExecutingResponseCreator
Create an instance with the givenClientHttpRequestFactory
.- Parameters:
requestFactory
- the request factory to delegate to
-
-
Method Details
-
createResponse
Description copied from interface:ResponseCreator
Create a response for the given request.- Specified by:
createResponse
in interfaceResponseCreator
- Parameters:
request
- the request- Throws:
IOException
-