9

When I try to mock a javax.ws.rs.core Response I get a error message:

Unable to create a JAX-RS runtime Delegate

Why does this happen?

 Response response = Mockito.mock(Response.class);

But when I try to mock a HttpServletResponse there is no issue with that!

 HttpServletResponse response1 = Mockito.mock(HttpServletResponse.class);
Qiu
  • 5,651
  • 10
  • 49
  • 56
meteor
  • 2,518
  • 4
  • 38
  • 52

1 Answers1

4

You can try with a fake response like this:

ResponseBuilder responseBuilder = Response.ok();
when(client.form(any(Form.class))).thenReturn(responseBuilder.entity("his is a string").build();

In this snippet "when" is a mockito method, and responseBuilder object return a simple string.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Tomas Pinto
  • 121
  • 6