ReindexController { @RequestMapping(value = "/reindex", method = RequestMethod.GET) public void reindex(final HttpServletResponse response) { indexTaskScheduler.runReindexOnDemand(); PrintWriter writer; try { writer = response.getWriter(); writer.write("Reindexing!"); writer.flush(); } catch (IOException e) { logger.info("error occurred when accessing /reindex", e); } }  @RequestMapping(value = "/reindex", method = RequestMethod.GET) void reindex(final HttpServletResponse response);  }
@Test public void testReindexShouldRunReindex() throws IOException { underTest.reindex(response); verify(indexTaskScheduler).runReindexOnDemand(); }
@Test public void testReindexShouldRunReindexThenExceptionRaisedInGetWriter() throws IOException { IOException exception = new IOException(); doThrow(exception).when(response).getWriter(); underTest.reindex(response); verify(indexTaskScheduler).runReindexOnDemand(); verify(logger).info("error occurred when accessing /reindex", exception); }