11

For testing I want to create a mockup of InboundJaxrsResponse, or any class extending javax.ws.rs.core.Response and implementing readEntity() methods. This proves rather difficult. Is there a library ready to do it, or is there a way I don't see? My searches don't turn out anything.

1 Answer 1

3

In this thread you see an example of using Mockito to mock the readEntity() call:

Response response = mock(Response.class);
when(response.readEntity(InputStream.class)).thenReturn(ClassLoader.getSystemResourceAsStream("example_response.xml");

Hope this helps, and if not, can you explain what problems you run into?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.