Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend MockRestServiceServer to support AsyncRestTemplate [SPR-11822] #16442

Closed
spring-projects-issues opened this issue May 27, 2014 · 1 comment
Closed

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented May 27, 2014

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

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Jun 28, 2014

Rossen Stoyanchev commented

Okay I've added something in commit 9aa53a.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants