@Test
    public void shouldParseExclusiveStatusCodeRestrictions() {
      final HttpLogFormatter formatter = new HttpLogFormatter("%!401,403U");
      final String expected = "http://some.place.net/u/r/l";

      assertEquals(expected, formatter.format(request, response));
      when(response.getStatus()).thenReturn(401);
      assertEquals("-", formatter.format(request, response));
    }
    @Test
    public void shouldPreserveStringFormatting() {
      final HttpLogFormatter formatter = new HttpLogFormatter("%%log output%% %U");
      final String expected = "%log output% http://some.place.net/u/r/l";

      assertEquals(expected, formatter.format(request, response));
    }
    @Test
    public void shouldParseCustomTimeFormat() {
      final String customDateFormatRegex = "\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}";

      final HttpLogFormatter formatter = new HttpLogFormatter("%{yyyy-MM-dd HH:mm:ss}t");

      assertEquals(1, formatter.getHandlerList().size());
      assertTrue(Pattern.matches(customDateFormatRegex, formatter.format(request, response)));
    }
    @Test
    public void shouldParseSimpleTimeFormat() {
      final String defaultDateFormatRegex = "\\d{2}-\\d{2}-\\d{4}-\\d{2}:\\d{2}:\\d{2}\\.\\d{3}";

      final HttpLogFormatter formatter = new HttpLogFormatter("%t");

      assertEquals(1, formatter.getHandlerList().size());
      assertTrue(Pattern.matches(defaultDateFormatRegex, formatter.format(request, response)));
    }
    @Test
    public void shouldCorrectlyConstructRequestLine() {
      when(request.getProtocol()).thenReturn("HTTP/1.1");
      when(request.getRequestURI()).thenReturn("/index.html");
      when(request.getMethod()).thenReturn("GET");

      final HttpLogFormatter formatter = new HttpLogFormatter("%r");
      final String expected = "GET /index.html HTTP/1.1";

      assertEquals(expected, formatter.format(request, response));
    }
    @Test
    public void shouldReplaceTokenWithRequestGuid() {
      final HttpLogFormatter formatter =
          new HttpLogFormatter("%" + LogFormatArgument.TRACE_GUID.toString());
      final String expected = "test-guid";

      Vector<String> reqGuidValues = new Vector<>();
      reqGuidValues.add("test-guid");

      when(request.getHeaders(CommonHttpHeader.TRACE_GUID.toString()))
          .thenReturn(reqGuidValues.elements());

      assertEquals(expected, formatter.format(request, response));
    }