Marek
Marek

Reputation: 7433

Mock up InboundJaxrsResponse

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.

Upvotes: 11

Views: 3168

Answers (1)

Oscar Scholten
Oscar Scholten

Reputation: 590

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?

Upvotes: 3

Related Questions