-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: testIssues in the test moduleIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
Mattias Severson opened SPR-11822 and commented
It would be useful if the MockRestServiceServer
could be extended to support clients that uses AsyncRestTemplate
, e.g.
AsyncRestTemplate asyncRestTemplate = new AsyncRestTemplate();
MockRestServiceServer mockServer = MockRestServiceServer.createServer(asyncRestTemplate);
mockServer.expect(requestTo("/hotels/42")).andExpect(method(HttpMethod.GET))
.andRespond(withSuccess("{ \"id\" : \"42\", \"name\" : \"Holiday Inn\"}", MediaType.APPLICATION_JSON));
ListenableFuture<ResponseEntity<Hotel>> entity = asyncRestTemplate.getForEntity("/hotels/{id}", Hotel.class, 42);
Hotel hotel = entity.get().getBody();
// Use the hotel instance...
mockServer.verify();
The above example was inspired by the example in the JavaDoc of MockRestServiceServer. Another approach would be to create a separate MockAsyncRestServiceServer
.
Affects: 4.0.5
Referenced from: commits 49e960c
Metadata
Metadata
Assignees
Labels
in: testIssues in the test moduleIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement