MessageLoggingStatusServlet extends HttpServlet { @Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("application/json"); PrintWriter out = resp.getWriter(); boolean requestLogOn = messageLoggingToggle.isRequestLoggingOn(); boolean responseLogOn = messageLoggingToggle.isResponseLoggingOn(); out.write("{\"requestLogging\":" + requestLogOn + ",\"responseLogging\":" + responseLogOn + "}"); out.flush(); out.close(); } @Autowired  MessageLoggingStatusServlet(MessageLoggingToggle messageLoggingToggle);   }
@Test public final void testDoGetSetsResponseTypeAndWritesResponse() throws ServletException, IOException { given(response.getWriter()).willReturn(printWriter); given(messageLoggingToggle.isRequestLoggingOn()).willReturn(true); given(messageLoggingToggle.isResponseLoggingOn()).willReturn(true); underTest.doGet(request, response); verify(response).setContentType("application/json"); verify(messageLoggingToggle).isRequestLoggingOn(); verify(messageLoggingToggle).isResponseLoggingOn(); verify(printWriter).write("{\"requestLogging\":true,\"responseLogging\":true}"); }