@Test public final void testDoGetSetsResponseTypeAndWritesResponseUsingLoadInformation() throws ServletException, IOException { given(response.getWriter()).willReturn(printWriter); underTest.doGet(request, response); verify(response).setContentType("application/json"); verify(printWriter).write(Mockito.anyString()); }
@Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("application/json"); PrintWriter out = resp.getWriter(); int deletedFilesCount = deletedFileProvider.getDeletedFilesCount(); int messagesCount = messageCounter.getCountOfMessages(); long responseQueueSize = queueSizeProvider.getResponseQueueSize(); long loggerQueueSize = queueSizeProvider.getLoggerQueueSize(); out.write("{\"deletedFilesCount\":" + deletedFilesCount + "," + "\"countOfMessages\":" + messagesCount + "," + "\"responseQueueSize\":" + responseQueueSize + "," + "\"loggerQueueSize\":" + loggerQueueSize + "}"); out.flush(); out.close(); }
LoadInformationServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("application/json"); PrintWriter out = resp.getWriter(); int deletedFilesCount = deletedFileProvider.getDeletedFilesCount(); int messagesCount = messageCounter.getCountOfMessages(); long responseQueueSize = queueSizeProvider.getResponseQueueSize(); long loggerQueueSize = queueSizeProvider.getLoggerQueueSize(); out.write("{\"deletedFilesCount\":" + deletedFilesCount + "," + "\"countOfMessages\":" + messagesCount + "," + "\"responseQueueSize\":" + responseQueueSize + "," + "\"loggerQueueSize\":" + loggerQueueSize + "}"); out.flush(); out.close(); } }
LoadInformationServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("application/json"); PrintWriter out = resp.getWriter(); int deletedFilesCount = deletedFileProvider.getDeletedFilesCount(); int messagesCount = messageCounter.getCountOfMessages(); long responseQueueSize = queueSizeProvider.getResponseQueueSize(); long loggerQueueSize = queueSizeProvider.getLoggerQueueSize(); out.write("{\"deletedFilesCount\":" + deletedFilesCount + "," + "\"countOfMessages\":" + messagesCount + "," + "\"responseQueueSize\":" + responseQueueSize + "," + "\"loggerQueueSize\":" + loggerQueueSize + "}"); out.flush(); out.close(); } @Autowired  LoadInformationServlet(QueueSizeProvider queueSizeProvider, DeletedFileProvider deletedFileProvider, MessageFileCounter messageCounter); }
LoadInformationServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("application/json"); PrintWriter out = resp.getWriter(); int deletedFilesCount = deletedFileProvider.getDeletedFilesCount(); int messagesCount = messageCounter.getCountOfMessages(); long responseQueueSize = queueSizeProvider.getResponseQueueSize(); long loggerQueueSize = queueSizeProvider.getLoggerQueueSize(); out.write("{\"deletedFilesCount\":" + deletedFilesCount + "," + "\"countOfMessages\":" + messagesCount + "," + "\"responseQueueSize\":" + responseQueueSize + "," + "\"loggerQueueSize\":" + loggerQueueSize + "}"); out.flush(); out.close(); } @Autowired  LoadInformationServlet(QueueSizeProvider queueSizeProvider, DeletedFileProvider deletedFileProvider, MessageFileCounter messageCounter);  }
LoadInformationServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("application/json"); PrintWriter out = resp.getWriter(); int deletedFilesCount = deletedFileProvider.getDeletedFilesCount(); int messagesCount = messageCounter.getCountOfMessages(); long responseQueueSize = queueSizeProvider.getResponseQueueSize(); long loggerQueueSize = queueSizeProvider.getLoggerQueueSize(); out.write("{\"deletedFilesCount\":" + deletedFilesCount + "," + "\"countOfMessages\":" + messagesCount + "," + "\"responseQueueSize\":" + responseQueueSize + "," + "\"loggerQueueSize\":" + loggerQueueSize + "}"); out.flush(); out.close(); } @Autowired  LoadInformationServlet(QueueSizeProvider queueSizeProvider, DeletedFileProvider deletedFileProvider, MessageFileCounter messageCounter);   }