diff options
Diffstat (limited to 'vid-app-common/src/test/java/org/onap/vid/logging/ApacheClientMetricInterceptorTest.java')
-rw-r--r-- | vid-app-common/src/test/java/org/onap/vid/logging/ApacheClientMetricInterceptorTest.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/logging/ApacheClientMetricInterceptorTest.java b/vid-app-common/src/test/java/org/onap/vid/logging/ApacheClientMetricInterceptorTest.java index 43f986501..0463581dc 100644 --- a/vid-app-common/src/test/java/org/onap/vid/logging/ApacheClientMetricInterceptorTest.java +++ b/vid-app-common/src/test/java/org/onap/vid/logging/ApacheClientMetricInterceptorTest.java @@ -27,6 +27,8 @@ import org.apache.http.HttpResponse; import org.apache.http.ProtocolVersion; import org.apache.http.client.methods.HttpGet; import org.apache.http.message.BasicHttpResponse; +import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.slf4j.MDC; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -42,6 +44,7 @@ public class ApacheClientMetricInterceptorTest { interceptor = new ApacheClientMetricInterceptor() {}; request = new HttpGet(path); response = new BasicHttpResponse(new ProtocolVersion("a",1,2), 200, "ok"); + MDC.clear(); } @Test @@ -74,4 +77,17 @@ public class ApacheClientMetricInterceptorTest { public void testGetTargetEntity() { assertNull(interceptor.getTargetEntity(request)); } + + @Test + protected void testAdditionalPre() { + request.addHeader(ONAPLogConstants.Headers.INVOCATION_ID, "123"); + interceptor.additionalPre(request, request); + assertEquals(MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID), "123"); + } + + @Test + protected void whenThereIsNoInvocationIdHeader_thenMdcValueIsNull() { + interceptor.additionalPre(request, request); + assertNull(MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID)); + } } |