public class MockRestServiceServer extends Object
RestTemplate, set up
expectations on request messages, and create response messages.
The typical usage of this class is:
MockRestServiceServer instance by calling createServer(RestTemplate).
expect(RequestMatcher), possibly by using the default
RequestMatcher implementations provided in RequestMatchers (which can be statically imported).
Multiple expectations can be set up by chaining ResponseActions.andExpect(RequestMatcher) calls.andRespond(ResponseCreator), possibly by using the default ResponseCreator implementations provided in
ResponseCreators (which can be statically imported).RestTemplate as normal, either directly of through client code.verify().
| Modifier and Type | Method and Description |
|---|---|
static MockRestServiceServer |
createServer(org.springframework.web.client.support.RestGatewaySupport gatewaySupport)
Creates a
MockRestServiceServer instance based on the given RestGatewaySupport. |
static MockRestServiceServer |
createServer(org.springframework.web.client.RestTemplate restTemplate)
Creates a
MockRestServiceServer instance based on the given RestTemplate. |
ResponseActions |
expect(RequestMatcher requestMatcher)
Records an expectation specified by the given
RequestMatcher. |
void |
verify()
Verifies that all expectations were met.
|
public static MockRestServiceServer createServer(org.springframework.web.client.RestTemplate restTemplate)
MockRestServiceServer instance based on the given RestTemplate.restTemplate - the RestTemplatepublic static MockRestServiceServer createServer(org.springframework.web.client.support.RestGatewaySupport gatewaySupport)
MockRestServiceServer instance based on the given RestGatewaySupport.gatewaySupport - the client classpublic ResponseActions expect(RequestMatcher requestMatcher)
RequestMatcher. Returns a ResponseActions object
that allows for creating the response, or to set up more expectations.requestMatcher - the request matcher expectedpublic void verify()
AssertionError - in case of unmet expectationsCopyright © 2016. All rights reserved.