Class ExecutingResponseCreator

java.lang.Object
org.springframework.test.web.client.response.ExecutingResponseCreator
All Implemented Interfaces:
ResponseCreator

public class ExecutingResponseCreator extends Object implements 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é