StatusController implements Controller { public ModelAndView handleRequest(HttpServletRequest req, HttpServletResponse resp) throws Exception { Status currentStatus = monitoredService.getServiceStatus().getStatus(); setResponseCode(currentStatus, resp); setAppropriateWarningHeaders(resp, currentStatus); setCachingHeaders(resp); writeOutCurrentStatusInResponseBody(resp, currentStatus); return null; } StatusController(MonitoredService monitoredService); ModelAndView handleRequest(HttpServletRequest req,
            HttpServletResponse resp);  }
@Test public void handlesRequestInternally() throws Exception { assertNull(impl.handleRequest(req, resp)); }
@Test public void setsWarningHeaderIfDegraded() throws Exception { monitoredService.setStatus(Status.DEGRADED); impl.handleRequest(req, resp); boolean found = false; for(Object val : resp.getHeaders("Warning")) { if ("199 jrugged \"Status degraded\"".equals(val)) { found = true; } } assertTrue(found); }
@Test public void setsNonCacheableHeaders() throws Exception { impl.handleRequest(req,resp); assertNotNull(resp.getHeader("Expires")); assertEquals(resp.getHeader("Date"), resp.getHeader("Expires")); assertEquals("no-cache", resp.getHeader("Cache-Control")); }