class 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;
    }

}

class TestStatusController {

    private MonitoredServiceStub monitoredService;
    private StatusController impl;
    private MockHttpServletRequest req;
    private MockHttpServletResponse 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);
    }

}