aboutsummaryrefslogtreecommitdiffstats
path: root/common-app-logging
diff options
context:
space:
mode:
Diffstat (limited to 'common-app-logging')
-rw-r--r--common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandler.java4
-rw-r--r--common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java21
2 files changed, 20 insertions, 5 deletions
diff --git a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandler.java b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandler.java
index eb1646c612..3deb115f4b 100644
--- a/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandler.java
+++ b/common-app-logging/src/main/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandler.java
@@ -27,7 +27,7 @@ public class LogFieldsMdcHandler implements ILogFieldsHandler {
return instanceMdcWrapper;
}
- private final static String dateFormatPattern = "yyyy-MM-dd HH:mm:ss.SSSz";
+ private final static String dateFormatPattern = "yyyy-MM-dd'T'HH:mm:ss.SSSz";
private final DateTimeFormatter dateTimeFormatter = DateTimeFormatter
.ofPattern(dateFormatPattern);
protected static Logger log = LoggerFactory.getLogger(LogFieldsMdcHandler.class.getName());
@@ -494,4 +494,4 @@ public class LogFieldsMdcHandler implements ILogFieldsHandler {
String requestId = LoggerBase.generateKeyRequestId();
LogFieldsMdcHandler.getInstance().setKeyRequestId(requestId);
}
-} \ No newline at end of file
+}
diff --git a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java
index c6b854ea06..334a1edee6 100644
--- a/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java
+++ b/common-app-logging/src/test/java/org/openecomp/sdc/common/log/elements/LogFieldsMdcHandlerTest.java
@@ -20,14 +20,20 @@
package org.openecomp.sdc.common.log.elements;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_CLASS_NAME;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_END_TIMESTAMP;
+import static org.openecomp.sdc.common.log.api.ILogConfiguration.MDC_OPT_FIELD1;
+
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
import org.junit.Before;
import org.junit.Test;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.slf4j.MDC;
-import static org.junit.Assert.*;
-import static org.openecomp.sdc.common.log.api.ILogConfiguration.*;
-
public class LogFieldsMdcHandlerTest {
private LogFieldsMdcHandler ecompMdcWrapper;
@@ -70,6 +76,15 @@ public class LogFieldsMdcHandlerTest {
}
@Test
+ public void stopTimer_shouldTimestampsBeIsoFormat() {
+ ecompMdcWrapper.startAuditTimer();
+ ecompMdcWrapper.stopAuditTimer();
+ // Expect no exceptions thrown
+ ZonedDateTime.parse(MDC.get(ONAPLogConstants.MDCs.ENTRY_TIMESTAMP), DateTimeFormatter.ISO_ZONED_DATE_TIME);
+ ZonedDateTime.parse(MDC.get(MDC_END_TIMESTAMP), DateTimeFormatter.ISO_ZONED_DATE_TIME);
+ }
+
+ @Test
public void clear_shouldRemoveAllMandatoryAndOptionalFields_And_OnlyThem(){
ecompMdcWrapper.setClassName("class1");
ecompMdcWrapper.setPartnerName("partner1");