Closed
Description
Craig Walls opened SPR-7951 and commented
This is based on the spring-test-mvc project that has been available on Github, as a separate project, for over a year. The project provides a fluent API for defining expected requests and setting the desired responses, as well as verifying that all expectations were met.
RestTemplate restTemplate = new RestTemplate()
MockRestServiceServer mockServer = MockRestServiceServer.createServer(restTemplate);
mockServer.expect(requestTo("/hotels/42")).andExpect(method(HttpMethod.GET))
.andRespond(withSuccess("{ \"id\" : \"42\", \"name\" : \"Holiday Inn\"}", MediaType.APPLICATION_JSON));
Hotel hotel = restTemplate.getForObject("/hotels/{id}", Hotel.class, 42);
// use the hotel instance...
mockServer.verify();
Affects: 3.1 M1
Issue Links:
- MockHttpRequest to support ClientRequestInterceptor testing [SPR-7995] #12650 MockHttpRequest to support ClientRequestInterceptor testing ("Cloned to")
- Add documentation for the Spring MVC Test support [SPR-9860] #14493 Add documentation for the Spring MVC Test support
- Add first class support for testing Spring MVC applications [SPR-9859] #14492 Add first class support for testing Spring MVC applications
- Release 1.0 spring-test-mvc [SPR-9211] #13849 Release 1.0 spring-test-mvc
Referenced from: commits 22bcb54, 2638dd5
6 votes, 10 watchers