Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 956
Marek Avatar asked Oct 17 '13 08:10

Marek


1 Answers

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?

like image 55
Oscar Scholten Avatar answered Sep 28 '22 01:09

Oscar Scholten