ServerExitRequestHandler implements RequestHandler { @Override public HttpResponse processRequest(HttpRequest request) { String path = request.getPath(); if (!HttpServer.EXIT_URL.equals(path)) { log.error(this + " cannot handle " + request); return new HttpResponse(HttpStatusCode.INTERNAL_SERVER_ERROR); } log.info("\"" + HttpServer.EXIT_URL + "\" special URL identified, initiating server shutdown ..."); server.exit(500L); return new HttpResponse(HttpStatusCode.OK); } ServerExitRequestHandler(HttpServer server); @Override boolean accepts(HttpRequest request); @Override HttpResponse processRequest(HttpRequest request); @Override String toString();  }
@Test public void inappropriateUrl() throws Exception { ServerExitRequestHandler h = getRequestHandlerToTest(); HttpRequest r = new HttpRequest(HttpMethod.GET, "/something"); HttpResponse resp = h.processRequest(r); assertEquals(HttpStatusCode.INTERNAL_SERVER_ERROR, resp.getStatusCode()); }