当我尝试模拟
javax.ws.rs.core响应时,我收到一条错误消息:
Unable to create a JAX-RS runtime Delegate
为什么会这样?
Response response = Mockito.mock(Response.class);
但是当我尝试模拟HttpServletResponse时,没有问题!
HttpServletResponse response1 = Mockito.mock(HttpServletResponse.class);
解决方法
您可以尝试这样的假响应:
ResponseBuilder responseBuilder = Response.ok(); when(client.form(any(Form.class))).thenReturn(responseBuilder.entity("his is a string").build();
在此片段“when”是mockito方法,而responseBuilder对象返回一个简单的字符串.