@Test public void test20DoPostSetErrorException() throws IOException { PolicyManagerServlet servlet = new PolicyManagerServlet(); HttpServletRequest mockRequest = Mockito.mock(HttpServletRequest.class); HttpServletResponse mockResponse = Mockito.mock(HttpServletResponse.class); doThrow(IOException.class).when(mockRequest).getReader(); doThrow(IOException.class).when(mockResponse).sendError(any(Integer.class), any(String.class)); servlet.doPost(mockRequest, mockResponse); verify(mockRequest).getReader(); }
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) { LOGGER.debug("doPost"); try { if (isMultipartContent(request)) { uploadFile(request, response); } else { fileOperation(request, response); } } catch (Exception e) { try { setError(e, response); } catch (Exception e1) { LOGGER.error(EXCEPTION_OCCURED + e1); } } }
PolicyManagerServlet extends HttpServlet { @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) { LOGGER.debug("doPost"); try { if (isMultipartContent(request)) { uploadFile(request, response); } else { fileOperation(request, response); } } catch (Exception e) { try { setError(e, response); } catch (Exception e1) { LOGGER.error(EXCEPTION_OCCURED + e1); } } } }
PolicyManagerServlet extends HttpServlet { @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) { LOGGER.debug("doPost"); try { if (isMultipartContent(request)) { uploadFile(request, response); } else { fileOperation(request, response); } } catch (Exception e) { try { setError(e, response); } catch (Exception e1) { LOGGER.error(EXCEPTION_OCCURED + e1); } } }  }
PolicyManagerServlet extends HttpServlet { @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) { LOGGER.debug("doPost"); try { if (isMultipartContent(request)) { uploadFile(request, response); } else { fileOperation(request, response); } } catch (Exception e) { try { setError(e, response); } catch (Exception e1) { LOGGER.error(EXCEPTION_OCCURED + e1); } } }  static synchronized void setPolicyController(PolicyController policyController); static JsonArray getPolicyNames(); static void setPolicyNames(JsonArray policyNames); static List<String> getServiceTypeNamesList(); @Override void init(ServletConfig servletConfig); static void setTestUserId(String testUserId); }
PolicyManagerServlet extends HttpServlet { @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) { LOGGER.debug("doPost"); try { if (isMultipartContent(request)) { uploadFile(request, response); } else { fileOperation(request, response); } } catch (Exception e) { try { setError(e, response); } catch (Exception e1) { LOGGER.error(EXCEPTION_OCCURED + e1); } } }  static synchronized void setPolicyController(PolicyController policyController); static JsonArray getPolicyNames(); static void setPolicyNames(JsonArray policyNames); static List<String> getServiceTypeNamesList(); @Override void init(ServletConfig servletConfig); static void setTestUserId(String testUserId);  }