I've made a basic test for servlet to test it's response status code, but it doesn't work - it's always 0, although I've set the response status code inside the servlet to 200.
public class TestMyServlet extends Mockito {
@Test
public void test() throws Exception {
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
when(request.getParameter("test")).thenReturn("1");
new MyServlet().doPost(request, response);
System.out.println(response.isCommited()); // false
System.out.println(response.getContentType()); // null
System.out.println(response.getStatus()); // 0
}
}
How to let this work?
Aucun commentaire:
Enregistrer un commentaire