From ee1ecc7d1ccf16689e1caa7fe5c0f34d046df0d8 Mon Sep 17 00:00:00 2001 From: "k.kedron" Date: Mon, 17 Jun 2019 11:33:35 +0200 Subject: Fixed import in OnapLoggerAuditTest and OnapLoggerGenericTest. Changed the import IOnapLogConfiguration to use new OnapLogConfiguration class after changes in 89570. Issue-ID: SDC-2327 Signed-off-by: Krystian Kedron Change-Id: I23651fb475a2e2543ba8ceb2b531424c9538ebca --- .../sdc/common/onaplog/OnapLoggerAuditTest.java | 73 +++++++++++----------- .../sdc/common/onaplog/OnapLoggerGenericTest.java | 11 ++-- 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/src/test/java/org/onap/sdc/common/onaplog/OnapLoggerAuditTest.java b/src/test/java/org/onap/sdc/common/onaplog/OnapLoggerAuditTest.java index 160a45f..49ca61a 100644 --- a/src/test/java/org/onap/sdc/common/onaplog/OnapLoggerAuditTest.java +++ b/src/test/java/org/onap/sdc/common/onaplog/OnapLoggerAuditTest.java @@ -42,7 +42,6 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.sdc.common.onaplog.Enums.LogLevel; import org.onap.sdc.common.onaplog.Enums.OnapLoggerErrorCode; import org.onap.sdc.common.onaplog.Enums.Severity; -import org.onap.sdc.common.onaplog.interfaces.IOnapLogConfiguration; import org.slf4j.MDC; import uk.org.lidalia.slf4jtest.LoggingEvent; @@ -124,6 +123,8 @@ public class OnapLoggerAuditTest { validateAuditLog(LogLevel.WARN, logs.get(1)); validateAuditLog(LogLevel.INFO, logs.get(2)); validateAuditLog(LogLevel.DEBUG, logs.get(3)); + + MDC.clear(); } private void setupMDC(OnapLoggerAudit audit) { @@ -147,22 +148,22 @@ public class OnapLoggerAuditTest { } private void validateMDC() { - assertEquals(SERVER_FQDN, MDC.get(IOnapLogConfiguration.MDC_SERVER_FQDN)); - assertEquals(AUTO_SERVER_IP_ADDRESS, MDC.get(IOnapLogConfiguration.MDC_SERVER_IP_ADDRESS)); - assertEquals(INSTANCE_UUID, MDC.get(IOnapLogConfiguration.MDC_INSTANCE_UUID)); - assertEquals(TEST_CLASS_NAME, MDC.get(IOnapLogConfiguration.MDC_CLASS_NAME)); - assertEquals(PROCESS_KEY, MDC.get(IOnapLogConfiguration.MDC_PROCESS_KEY)); - assertEquals(String.valueOf(ALERT_SEVERITY), MDC.get(IOnapLogConfiguration.MDC_ALERT_SEVERITY)); - assertEquals(CUSTOM_FIELD1, MDC.get(IOnapLogConfiguration.MDC_OPT_FIELD1)); - assertEquals(CUSTOM_FIELD2, MDC.get(IOnapLogConfiguration.MDC_OPT_FIELD2)); - assertEquals(CUSTOM_FIELD3, MDC.get(IOnapLogConfiguration.MDC_OPT_FIELD3)); - assertEquals(CUSTOM_FIELD4, MDC.get(IOnapLogConfiguration.MDC_OPT_FIELD4)); - assertEquals(REMOTE_HOST, MDC.get(IOnapLogConfiguration.MDC_REMOTE_HOST)); - assertEquals(SERVICE_NAME, MDC.get(IOnapLogConfiguration.MDC_SERVICE_NAME)); - assertEquals(PARENT_NAME, MDC.get(IOnapLogConfiguration.MDC_PARTNER_NAME)); - assertEquals(String.valueOf(RESPONSE_CODE), MDC.get(IOnapLogConfiguration.MDC_RESPONSE_CODE)); - assertEquals(SERVICE_INSTANCE_ID, MDC.get(IOnapLogConfiguration.MDC_SERVICE_INSTANCE_ID)); - assertEquals(KEY_REQUEST_ID, MDC.get(IOnapLogConfiguration.MDC_KEY_REQUEST_ID)); + assertEquals(SERVER_FQDN, MDC.get(OnapLogConfiguration.MDC_SERVER_FQDN)); + assertEquals(AUTO_SERVER_IP_ADDRESS, MDC.get(OnapLogConfiguration.MDC_SERVER_IP_ADDRESS)); + assertEquals(INSTANCE_UUID, MDC.get(OnapLogConfiguration.MDC_INSTANCE_UUID)); + assertEquals(TEST_CLASS_NAME, MDC.get(OnapLogConfiguration.MDC_CLASS_NAME)); + assertEquals(PROCESS_KEY, MDC.get(OnapLogConfiguration.MDC_PROCESS_KEY)); + assertEquals(String.valueOf(ALERT_SEVERITY), MDC.get(OnapLogConfiguration.MDC_ALERT_SEVERITY)); + assertEquals(CUSTOM_FIELD1, MDC.get(OnapLogConfiguration.MDC_OPT_FIELD1)); + assertEquals(CUSTOM_FIELD2, MDC.get(OnapLogConfiguration.MDC_OPT_FIELD2)); + assertEquals(CUSTOM_FIELD3, MDC.get(OnapLogConfiguration.MDC_OPT_FIELD3)); + assertEquals(CUSTOM_FIELD4, MDC.get(OnapLogConfiguration.MDC_OPT_FIELD4)); + assertEquals(REMOTE_HOST, MDC.get(OnapLogConfiguration.MDC_REMOTE_HOST)); + assertEquals(SERVICE_NAME, MDC.get(OnapLogConfiguration.MDC_SERVICE_NAME)); + assertEquals(PARENT_NAME, MDC.get(OnapLogConfiguration.MDC_PARTNER_NAME)); + assertEquals(String.valueOf(RESPONSE_CODE), MDC.get(OnapLogConfiguration.MDC_RESPONSE_CODE)); + assertEquals(SERVICE_INSTANCE_ID, MDC.get(OnapLogConfiguration.MDC_SERVICE_INSTANCE_ID)); + assertEquals(KEY_REQUEST_ID, MDC.get(OnapLogConfiguration.MDC_KEY_REQUEST_ID)); } private void validateAuditLog(LogLevel logLevel, LoggingEvent log) { @@ -171,25 +172,25 @@ public class OnapLoggerAuditTest { assertNotNull(log.getTimestamp()); ImmutableMap mdc = log.getMdc(); - assertNotEquals(SERVER_FQDN, mdc.get(IOnapLogConfiguration.MDC_SERVER_FQDN)); - assertNotEquals(AUTO_SERVER_IP_ADDRESS, mdc.get(IOnapLogConfiguration.MDC_SERVER_IP_ADDRESS)); - - assertEquals(INSTANCE_UUID, mdc.get(IOnapLogConfiguration.MDC_INSTANCE_UUID)); - assertEquals(TEST_CLASS_NAME, mdc.get(IOnapLogConfiguration.MDC_CLASS_NAME)); - assertEquals(PROCESS_KEY, mdc.get(IOnapLogConfiguration.MDC_PROCESS_KEY)); - assertEquals(String.valueOf(ALERT_SEVERITY), mdc.get(IOnapLogConfiguration.MDC_ALERT_SEVERITY)); - assertEquals(CUSTOM_FIELD1, mdc.get(IOnapLogConfiguration.MDC_OPT_FIELD1)); - assertEquals(CUSTOM_FIELD2, mdc.get(IOnapLogConfiguration.MDC_OPT_FIELD2)); - assertEquals(CUSTOM_FIELD3, mdc.get(IOnapLogConfiguration.MDC_OPT_FIELD3)); - assertEquals(CUSTOM_FIELD4, mdc.get(IOnapLogConfiguration.MDC_OPT_FIELD4)); - assertEquals(REMOTE_HOST, mdc.get(IOnapLogConfiguration.MDC_REMOTE_HOST)); - assertEquals(SERVICE_NAME, mdc.get(IOnapLogConfiguration.MDC_SERVICE_NAME)); - assertEquals(PARENT_NAME, mdc.get(IOnapLogConfiguration.MDC_PARTNER_NAME)); - assertEquals(String.valueOf(RESPONSE_CODE), mdc.get(IOnapLogConfiguration.MDC_RESPONSE_CODE)); - assertEquals(SERVICE_INSTANCE_ID, mdc.get(IOnapLogConfiguration.MDC_SERVICE_INSTANCE_ID)); - assertEquals(KEY_REQUEST_ID, mdc.get(IOnapLogConfiguration.MDC_KEY_REQUEST_ID)); - - assertNotNull(mdc.get(IOnapLogConfiguration.MDC_BEGIN_TIMESTAMP)); + assertNotEquals(SERVER_FQDN, mdc.get(OnapLogConfiguration.MDC_SERVER_FQDN)); + assertNotEquals(AUTO_SERVER_IP_ADDRESS, mdc.get(OnapLogConfiguration.MDC_SERVER_IP_ADDRESS)); + + assertEquals(INSTANCE_UUID, mdc.get(OnapLogConfiguration.MDC_INSTANCE_UUID)); + assertEquals(TEST_CLASS_NAME, mdc.get(OnapLogConfiguration.MDC_CLASS_NAME)); + assertEquals(PROCESS_KEY, mdc.get(OnapLogConfiguration.MDC_PROCESS_KEY)); + assertEquals(String.valueOf(ALERT_SEVERITY), mdc.get(OnapLogConfiguration.MDC_ALERT_SEVERITY)); + assertEquals(CUSTOM_FIELD1, mdc.get(OnapLogConfiguration.MDC_OPT_FIELD1)); + assertEquals(CUSTOM_FIELD2, mdc.get(OnapLogConfiguration.MDC_OPT_FIELD2)); + assertEquals(CUSTOM_FIELD3, mdc.get(OnapLogConfiguration.MDC_OPT_FIELD3)); + assertEquals(CUSTOM_FIELD4, mdc.get(OnapLogConfiguration.MDC_OPT_FIELD4)); + assertEquals(REMOTE_HOST, mdc.get(OnapLogConfiguration.MDC_REMOTE_HOST)); + assertEquals(SERVICE_NAME, mdc.get(OnapLogConfiguration.MDC_SERVICE_NAME)); + assertEquals(PARENT_NAME, mdc.get(OnapLogConfiguration.MDC_PARTNER_NAME)); + assertEquals(String.valueOf(RESPONSE_CODE), mdc.get(OnapLogConfiguration.MDC_RESPONSE_CODE)); + assertEquals(SERVICE_INSTANCE_ID, mdc.get(OnapLogConfiguration.MDC_SERVICE_INSTANCE_ID)); + assertEquals(KEY_REQUEST_ID, mdc.get(OnapLogConfiguration.MDC_KEY_REQUEST_ID)); + + assertNotNull(mdc.get(OnapLogConfiguration.MDC_BEGIN_TIMESTAMP)); } class LoggerAdapter { diff --git a/src/test/java/org/onap/sdc/common/onaplog/OnapLoggerGenericTest.java b/src/test/java/org/onap/sdc/common/onaplog/OnapLoggerGenericTest.java index 57adcd3..76c33db 100644 --- a/src/test/java/org/onap/sdc/common/onaplog/OnapLoggerGenericTest.java +++ b/src/test/java/org/onap/sdc/common/onaplog/OnapLoggerGenericTest.java @@ -26,7 +26,6 @@ import static org.junit.Assert.assertNull; import com.google.common.collect.ImmutableList; import org.junit.Test; -import org.onap.sdc.common.onaplog.interfaces.IOnapLogConfiguration; import org.slf4j.MDC; import uk.org.lidalia.slf4jtest.LoggingEvent; @@ -47,9 +46,11 @@ public class OnapLoggerGenericTest { stopwatch.stop(); // then - assertNotNull(MDC.get(IOnapLogConfiguration.MDC_BEGIN_TIMESTAMP)); - assertNotNull(MDC.get(IOnapLogConfiguration.MDC_END_TIMESTAMP)); - assertNotNull(MDC.get(IOnapLogConfiguration.MDC_ELAPSED_TIME)); + assertNotNull(MDC.get(OnapLogConfiguration.MDC_BEGIN_TIMESTAMP)); + assertNotNull(MDC.get(OnapLogConfiguration.MDC_END_TIMESTAMP)); + assertNotNull(MDC.get(OnapLogConfiguration.MDC_ELAPSED_TIME)); + + MDC.clear(); } @Test @@ -70,6 +71,8 @@ public class OnapLoggerGenericTest { log = logs.get(1); assertEquals(ERROR, log.getLevel().name()); assertEquals(SECOND_ERROR_EXPECTED_MESSAGE, log.getMessage()); + + MDC.clear(); } @Test -- cgit 1.2.3-korg