### Question:
CrossOriginHandler extends AbstractHandler { @Override public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setHeader("Server", "Cougar 2 - " + CougarVersion.getVersion()); ((Request) request).setHandled(true); crossOriginFilter.doFilter(request, response, continuationChain); } CrossOriginHandler(final String allowedOrigins, final String allowedMethods, final String allowedHeaders,
                              final String preflightMaxAge, final String allowCredentials, final String exposedHeaders); @Override void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response);  }### Answer:
@Test public void testHandlerSetsServerHeaderInTheResponse() throws Exception { final CrossOriginHandler victim = new CrossOriginHandler("betfair.com", "GET,POST,HEAD", "X-Requested-With,Content-Type,Accept,Origin", "1800", "true", ""); final MockJettyRequest req = mock(MockJettyRequest.class); final MockJettyResponse res = mock(MockJettyResponse.class); victim.handle("/", req, req, res); verify(res, times(1)).setHeader(eq("Server"), eq("Cougar 2 - " + CougarVersion.getVersion())); }
@Test public void testHandlerMarksRequestAsHandledByDefault() throws Exception { final CrossOriginHandler victim = new CrossOriginHandler("betfair.com", "GET,POST,HEAD", "X-Requested-With,Content-Type,Accept,Origin", "1800", "true", ""); final MockJettyRequest req = mock(MockJettyRequest.class); final MockJettyResponse res = mock(MockJettyResponse.class); victim.handle("/", req, req, res); verify(req, times(1)).setHandled(eq(true)); verify(req, times(1)).setHandled(eq(false)); }