Пример #1
0
    @Test
    public void RequestGuidHandler() {
      final LogArgumentGroupExtractor extractor =
          LogArgumentGroupExtractor.instance(
              "", "", "", "", LogFormatArgument.TRACE_GUID.toString());

      httpLogFormatter.setLogic(extractor, formatter);

      assertTrue(formatter.getLogic() instanceof TraceGuidHandler);
    }
Пример #2
0
    @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));
    }