Ejemplo n.º 1
0
  @Test
  public void hyphenReplacesContentSizeForEmptyResponses() throws Exception {
    request.remoteIp("192.168.0.1").method(DELETE).uri("/logout");
    apacheCommonLogger.connectTo(
        new Application() {
          public void handle(Request request, Response response) throws Exception {
            response.body("");
            response.status(NO_CONTENT);
          }
        });

    apacheCommonLogger.handle(request, response);

    logRecords.assertEntries(contains(containsString("\"DELETE /logout HTTP/1.1\" 204 -")));
  }
Ejemplo n.º 2
0
  @Test
  public void logsRequestsServedInApacheCommonLogFormat() throws Exception {
    request.method(GET).uri("/products?keyword=dogs");
    apacheCommonLogger.connectTo(
        new Application() {
          public void handle(Request request, Response response) throws Exception {
            response.body("a response with a size of 28");
            response.status(HttpStatus.OK);
          }
        });

    apacheCommonLogger.handle(request, response);

    logRecords.assertEntries(
        contains(
            "192.168.0.1 - - [27/Jun/2012:18:04:00 +0100] \"GET /products?keyword=dogs HTTP/1.1\" 200 28"));
  }