diff options
Diffstat (limited to 'common-logging/src/test/java/org/onap/policy/common/logging/flexlogger')
5 files changed, 159 insertions, 108 deletions
diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/EelfLoggerTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/EelfLoggerTest.java index 6d6399b2..a7e835ce 100644 --- a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/EelfLoggerTest.java +++ b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/EelfLoggerTest.java @@ -17,21 +17,29 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.policy.common.logging.flexlogger; import static com.att.eelf.configuration.Configuration.MDC_KEY_REQUEST_ID; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import static org.onap.policy.common.logging.util.TestUtils.overrideStaticField; + +import com.att.eelf.configuration.EELFLogger; + import java.util.UUID; + import org.junit.Test; import org.mockito.Mockito; import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.eelf.PolicyLogger; import org.slf4j.MDC; -import com.att.eelf.configuration.EELFLogger; public class EelfLoggerTest { - + EelfLogger eelfLogger = new EelfLogger("EelfLoggerTest", "transactionId"); @Test @@ -72,7 +80,7 @@ public class EelfLoggerTest { public void testEelfLoggerStringString() { new EelfLogger("EelfLoggerTest", "transactionId"); assertEquals("transactionId", PolicyLogger.getTransId()); - } + } @Test public void testSetAndGetTransId() { @@ -128,7 +136,7 @@ public class EelfLoggerTest { Mockito.when(mockLogger.isDebugEnabled()).thenReturn(false).thenReturn(true); assertFalse(eelfLogger.isDebugEnabled()); assertTrue(eelfLogger.isDebugEnabled()); - + } @Test @@ -193,7 +201,8 @@ public class EelfLoggerTest { EELFLogger mockLogger = Mockito.mock(EELFLogger.class); overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger); eelfLogger.debug("message", new NullPointerException()); - Mockito.verify(mockLogger).debug((MessageCodes)Mockito.any(), Mockito.startsWith("message:java.lang.NullPointerException")); + Mockito.verify(mockLogger).debug((MessageCodes) Mockito.any(), + Mockito.startsWith("message:java.lang.NullPointerException")); } @Test @@ -201,7 +210,8 @@ public class EelfLoggerTest { EELFLogger mockLogger = Mockito.mock(EELFLogger.class); overrideStaticField(PolicyLogger.class, "errorLogger", mockLogger); eelfLogger.error("message", new NullPointerException()); - Mockito.verify(mockLogger).error((MessageCodes)Mockito.any(), Mockito.startsWith("message:java.lang.NullPointerException")); + Mockito.verify(mockLogger).error((MessageCodes) Mockito.any(), + Mockito.startsWith("message:java.lang.NullPointerException")); eelfLogger.error("message", new NullPointerException()); } @@ -210,7 +220,8 @@ public class EelfLoggerTest { EELFLogger mockLogger = Mockito.mock(EELFLogger.class); overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger); eelfLogger.info("message", new NullPointerException()); - Mockito.verify(mockLogger).info((MessageCodes)Mockito.any(), Mockito.startsWith("message:java.lang.NullPointerException")); + Mockito.verify(mockLogger).info((MessageCodes) Mockito.any(), + Mockito.startsWith("message:java.lang.NullPointerException")); } @Test @@ -218,7 +229,8 @@ public class EelfLoggerTest { EELFLogger mockLogger = Mockito.mock(EELFLogger.class); overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger); eelfLogger.warn("message", new NullPointerException()); - Mockito.verify(mockLogger).warn((MessageCodes)Mockito.any(), Mockito.startsWith("message:java.lang.NullPointerException")); + Mockito.verify(mockLogger).warn((MessageCodes) Mockito.any(), + Mockito.startsWith("message:java.lang.NullPointerException")); } @Test @@ -254,7 +266,7 @@ public class EelfLoggerTest { public void testRecordAuditEventEndStringStringString() { eelfLogger.recordAuditEventStart("eventId"); assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get("eventId")); - + eelfLogger.recordAuditEventEnd("eventId", "rule", "policyVersion"); assertNull(PolicyLogger.getEventTracker().getEventInfo().get("eventId")); } @@ -273,7 +285,7 @@ public class EelfLoggerTest { public void testRecordAuditEventEndStringString() { eelfLogger.recordAuditEventStart("eventId"); assertNotNull(PolicyLogger.getEventTracker().getEventInfo().get("eventId")); - + eelfLogger.recordAuditEventEnd("eventId", "rule"); assertNull(PolicyLogger.getEventTracker().getEventInfo().get("eventId")); } @@ -306,7 +318,8 @@ public class EelfLoggerTest { EELFLogger mockLogger = Mockito.mock(EELFLogger.class); overrideStaticField(PolicyLogger.class, "metricsLogger", mockLogger); eelfLogger.metrics(1); - Mockito.verify(mockLogger).info(Mockito.eq(MessageCodes.RULE_METRICS_INFO), Mockito.anyString(), Mockito.eq("1")); + Mockito.verify(mockLogger).info(Mockito.eq(MessageCodes.RULE_METRICS_INFO), Mockito.anyString(), + Mockito.eq("1")); } @Test @@ -314,7 +327,8 @@ public class EelfLoggerTest { EELFLogger mockLogger = Mockito.mock(EELFLogger.class); overrideStaticField(PolicyLogger.class, "errorLogger", mockLogger); eelfLogger.error(MessageCodes.GENERAL_ERROR, new NullPointerException(), "str1", "str2"); - Mockito.verify(mockLogger).error((MessageCodes)Mockito.any(), Mockito.startsWith("str1:str2:java.lang.NullPointerException")); + Mockito.verify(mockLogger).error((MessageCodes) Mockito.any(), + Mockito.startsWith("str1:str2:java.lang.NullPointerException")); } @Test @@ -323,7 +337,7 @@ public class EelfLoggerTest { overrideStaticField(PolicyLogger.class, "errorLogger", mockLogger); eelfLogger.error(MessageCodes.GENERAL_ERROR, "str1", "str2"); Mockito.verify(mockLogger).error(MessageCodes.GENERAL_ERROR, "str1", "str2"); - + } @Test @@ -345,8 +359,9 @@ public class EelfLoggerTest { EELFLogger mockLogger = Mockito.mock(EELFLogger.class); overrideStaticField(PolicyLogger.class, "debugLogger", mockLogger); eelfLogger.warn(MessageCodes.GENERAL_ERROR, new NullPointerException(), "str1", "str2"); - Mockito.verify(mockLogger).warn((MessageCodes)Mockito.any(), Mockito.startsWith("str1:str2:java.lang.NullPointerException")); - + Mockito.verify(mockLogger).warn((MessageCodes) Mockito.any(), + Mockito.startsWith("str1:str2:java.lang.NullPointerException")); + } @Test diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/FlexLoggerTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/FlexLoggerTest.java index af7edcab..57afc9f7 100644 --- a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/FlexLoggerTest.java +++ b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/FlexLoggerTest.java @@ -17,13 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.policy.common.logging.flexlogger; -import static org.junit.Assert.*; -import static org.onap.policy.common.logging.util.TestUtils.*; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertSame; +import static org.onap.policy.common.logging.util.TestUtils.overrideStaticField; + import java.io.IOException; import java.util.HashSet; import java.util.Set; + import org.junit.Test; import org.onap.policy.common.logging.flexlogger.FlexLogger.PropertiesCallBack; @@ -32,81 +36,81 @@ public class FlexLoggerTest { @Test public void testGetLoggerClassOfQEelf() { overrideStaticField(FlexLogger.class, "loggerType", LoggerType.EELF); - Logger logger = FlexLogger.getLogger((Class)null); - assertSame(logger, FlexLogger.getLogger((Class)null)); - assertNotEquals(logger, FlexLogger.getLogger(String.class)); + Logger logger = FlexLogger.getLogger((Class) null); + assertSame(logger, FlexLogger.getLogger((Class) null)); + assertNotEquals(logger, FlexLogger.getLogger(String.class)); } - + @Test public void testGetLoggerClassOfQLog4j() { overrideStaticField(FlexLogger.class, "loggerType", LoggerType.LOG4J); Logger logger = FlexLogger.getLogger(this.getClass()); assertSame(logger, FlexLogger.getLogger(this.getClass())); } - + @Test public void testGetLoggerClassOfQSystemOut() { overrideStaticField(FlexLogger.class, "loggerType", LoggerType.SYSTEMOUT); Logger logger = FlexLogger.getLogger(this.getClass()); assertSame(logger, FlexLogger.getLogger(this.getClass())); } - + @Test public void testGetLoggerStringEelf() { overrideStaticField(FlexLogger.class, "loggerType", LoggerType.EELF); Logger logger = FlexLogger.getLogger("str1"); assertSame(logger, FlexLogger.getLogger("str1")); } - + @Test public void testGetLoggerStringLog4j() { overrideStaticField(FlexLogger.class, "loggerType", LoggerType.LOG4J); Logger logger = FlexLogger.getLogger("str1"); assertSame(logger, FlexLogger.getLogger("str1")); } - + @Test public void testGetLoggerStringSystemOut() { overrideStaticField(FlexLogger.class, "loggerType", LoggerType.SYSTEMOUT); Logger logger = FlexLogger.getLogger("str1"); assertSame(logger, FlexLogger.getLogger("str1")); } - + @Test public void testGetLoggerClassOfQBooleanEelf() { overrideStaticField(FlexLogger.class, "loggerType", LoggerType.EELF); Logger logger = FlexLogger.getLogger(this.getClass(), true); assertSame(logger, FlexLogger.getLogger(this.getClass(), true)); } - + @Test public void testGetLoggerClassOfQBooleanLog4j() { overrideStaticField(FlexLogger.class, "loggerType", LoggerType.LOG4J); Logger logger = FlexLogger.getLogger(this.getClass(), true); assertSame(logger, FlexLogger.getLogger(this.getClass(), true)); } - + @Test public void testGetLoggerClassOfQBooleanSystemOut() { overrideStaticField(FlexLogger.class, "loggerType", LoggerType.SYSTEMOUT); Logger logger = FlexLogger.getLogger(this.getClass(), true); assertSame(logger, FlexLogger.getLogger(this.getClass(), true)); } - + @Test public void testGetLoggerStringBooleanEelf() { overrideStaticField(FlexLogger.class, "loggerType", LoggerType.EELF); Logger logger = FlexLogger.getLogger("str1", true); assertSame(logger, FlexLogger.getLogger("str1", true)); } - + @Test public void testGetLoggerStringBooleanLog4j() { overrideStaticField(FlexLogger.class, "loggerType", LoggerType.LOG4J); Logger logger = FlexLogger.getLogger("str1", true); assertSame(logger, FlexLogger.getLogger("str1", true)); } - + @Test public void testGetLoggerStringBooleanSystemOut() { overrideStaticField(FlexLogger.class, "loggerType", LoggerType.SYSTEMOUT); @@ -118,15 +122,15 @@ public class FlexLoggerTest { public void testGetClassName() { assertNotEquals("FlexLogger", new FlexLogger().getClassName()); } - + @Test - public void testPropertiesCallBack() throws IOException{ - PropertiesCallBack propertiesCallBack = new PropertiesCallBack("name"); + public void testPropertiesCallBack() throws IOException { Set<String> changedKeys = new HashSet<>(); changedKeys.add("debugLogger.level"); changedKeys.add("metricsLogger.level"); changedKeys.add("error.level"); changedKeys.add("audit.level"); + PropertiesCallBack propertiesCallBack = new PropertiesCallBack("name"); propertiesCallBack.propertiesChanged(PropertyUtil.getProperties("config/policyLogger.properties"), changedKeys); } diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/Logger4JTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/Logger4JTest.java index 3650b18a..852e7f1b 100644 --- a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/Logger4JTest.java +++ b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/Logger4JTest.java @@ -17,10 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.policy.common.logging.flexlogger; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + import java.util.UUID; + import org.apache.log4j.Logger; import org.apache.log4j.Priority; import org.junit.Test; @@ -29,7 +36,7 @@ import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.util.TestUtils; public class Logger4JTest { - + private Logger4J logger4J = new Logger4J("str1", "Logger4JTest"); @Test @@ -215,7 +222,8 @@ public class Logger4JTest { TestUtils.overrideField(Logger4J.class, logger4J, "log", logger); logger4J.setTransId("transactionId"); logger4J.error(MessageCodes.GENERAL_ERROR, new NullPointerException(), "str1", "str2"); - Mockito.verify(logger).error("transactionId|Logger4JTest|MessageCodes :" + MessageCodes.GENERAL_ERROR + "[str1, str2]"); + Mockito.verify(logger) + .error("transactionId|Logger4JTest|MessageCodes :" + MessageCodes.GENERAL_ERROR + "[str1, str2]"); } @Test @@ -224,7 +232,8 @@ public class Logger4JTest { TestUtils.overrideField(Logger4J.class, logger4J, "log", logger); logger4J.setTransId("transactionId"); logger4J.error(MessageCodes.GENERAL_ERROR, "str1", "str2"); - Mockito.verify(logger).error("transactionId|Logger4JTest|MessageCode:" + MessageCodes.GENERAL_ERROR + "[str1, str2]"); + Mockito.verify(logger) + .error("transactionId|Logger4JTest|MessageCode:" + MessageCodes.GENERAL_ERROR + "[str1, str2]"); } @Test @@ -232,7 +241,7 @@ public class Logger4JTest { String returnedTransactionId = logger4J.postMDCInfoForEvent("transactionId"); assertEquals("transactionId", returnedTransactionId); } - + @Test public void testPostMDCInfoForEventEmptyString() { String returnedTransactionId = logger4J.postMDCInfoForEvent(""); diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/PropertyUtilTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/PropertyUtilTest.java index b4fd5362..d97df4ce 100644 --- a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/PropertyUtilTest.java +++ b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/PropertyUtilTest.java @@ -17,98 +17,105 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.policy.common.logging.flexlogger; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; import java.util.Set; + import org.junit.After; import org.junit.Before; import org.junit.Test; import org.onap.policy.common.logging.flexlogger.PropertyUtil.Listener; public class PropertyUtilTest { - + private static final File FILE = new File("target/test.properties"); private TestListener testListener = new TestListener(); - + + /** + * Perform test case set up. + */ @Before - public void setUp() throws IOException{ + public void setUp() throws IOException { FileOutputStream fileOutputStream = new FileOutputStream(FILE); Properties properties = new Properties(); properties.put("testProperty", "testValue"); properties.store(fileOutputStream, ""); fileOutputStream.close(); } - + @After - public void tearDown() throws IOException{ + public void tearDown() throws IOException { PropertyUtil.stopListening(FILE, testListener); FILE.delete(); - } - + } + @Test - public void testGetProperties() throws IOException{ + public void testGetProperties() throws IOException { FileOutputStream fileOutputStream = new FileOutputStream(FILE); Properties properties = new Properties(); properties.put("testProperty", "testValue"); properties.store(fileOutputStream, ""); fileOutputStream.close(); - + Properties readProperties = PropertyUtil.getProperties(FILE, testListener); assertEquals("testValue", readProperties.getProperty("testProperty")); } - + @Test - public void testPropertiesChanged() throws IOException, InterruptedException{ + public void testPropertiesChanged() throws IOException, InterruptedException { PropertyUtil.getProperties(FILE, testListener); - + FileOutputStream fileOutputStream = new FileOutputStream(FILE); Properties newProperties = new Properties(); newProperties.put("testProperty", "testValueNew"); newProperties.store(fileOutputStream, ""); - + assertTrue(testListener.isPropertiesChangedInvoked()); - + } - + @Test - public void testStopListening() throws IOException{ + public void testStopListening() throws IOException { FileOutputStream fileOutputStream = new FileOutputStream(FILE); Properties properties = new Properties(); properties.put("testProperty", "testValue"); properties.store(fileOutputStream, ""); - + Properties readProperties = PropertyUtil.getProperties(FILE, testListener); assertEquals("testValue", readProperties.getProperty("testProperty")); - + PropertyUtil.stopListening(FILE, testListener); - + properties.put("testProperty", "testValueNew"); properties.store(fileOutputStream, ""); fileOutputStream.close(); readProperties = PropertyUtil.getProperties(FILE, testListener); - // If stopListening did not remove the listener, the properties file will not be re-read until poll expires and + // If stopListening did not remove the listener, the properties file will not be re-read + // until poll expires and // hence "testValue" will be returned here instead of "testNewValue" - assertEquals("testValueNew", readProperties.getProperty("testProperty")); + assertEquals("testValueNew", readProperties.getProperty("testProperty")); } - + private class TestListener implements Listener { - + boolean propertiesChangedInvoked = false; @Override public void propertiesChanged(Properties properties, Set<String> changedKeys) { propertiesChangedInvoked = true; } - - public boolean isPropertiesChangedInvoked() throws InterruptedException{ - for (int i =0; i<20; i++){ - if (propertiesChangedInvoked){ + + public boolean isPropertiesChangedInvoked() throws InterruptedException { + for (int i = 0; i < 20; i++) { + if (propertiesChangedInvoked) { return true; } Thread.sleep(1000); diff --git a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/SystemOutLoggerTest.java b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/SystemOutLoggerTest.java index ceec3cce..cd16a3fd 100644 --- a/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/SystemOutLoggerTest.java +++ b/common-logging/src/test/java/org/onap/policy/common/logging/flexlogger/SystemOutLoggerTest.java @@ -17,19 +17,25 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.policy.common.logging.flexlogger; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import com.att.eelf.configuration.EELFLogger.Level; + import java.io.ByteArrayOutputStream; import java.io.PrintStream; import java.util.UUID; + import org.junit.Test; import org.onap.policy.common.logging.eelf.MessageCodes; import org.onap.policy.common.logging.eelf.PolicyLogger; -import com.att.eelf.configuration.EELFLogger.Level; public class SystemOutLoggerTest { - + SystemOutLogger systemOutLogger = new SystemOutLogger("SystemOutLoggerTest"); @Test @@ -48,7 +54,7 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { systemOutLogger.setTransId("transactionId"); System.setOut(ps); systemOutLogger.debug("message"); @@ -64,7 +70,7 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { systemOutLogger.setTransId("transactionId"); System.setOut(ps); systemOutLogger.error("message"); @@ -80,7 +86,7 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { systemOutLogger.setTransId("transactionId"); System.setOut(ps); systemOutLogger.info("message"); @@ -96,7 +102,7 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { systemOutLogger.setTransId("transactionId"); System.setOut(ps); systemOutLogger.warn("message"); @@ -112,7 +118,7 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { systemOutLogger.setTransId("transactionId"); System.setOut(ps); systemOutLogger.trace("message"); @@ -188,7 +194,7 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { systemOutLogger.setTransId("transactionId"); System.setOut(ps); systemOutLogger.audit("message"); @@ -204,7 +210,7 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { systemOutLogger.setTransId("transactionId"); System.setOut(ps); systemOutLogger.recordAuditEventStart("eventId"); @@ -220,7 +226,7 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { UUID uuid = UUID.randomUUID(); System.setOut(ps); systemOutLogger.recordAuditEventStart(uuid); @@ -236,7 +242,7 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { System.setOut(ps); systemOutLogger.recordAuditEventEnd("eventId", "rule", "policyVersion"); assertTrue(baos.toString().contains("SystemOutLoggerTest : eventId:rule:policyVersion")); @@ -251,7 +257,7 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { UUID uuid = UUID.randomUUID(); System.setOut(ps); systemOutLogger.recordAuditEventEnd(uuid, "rule", "policyVersion"); @@ -267,7 +273,7 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { System.setOut(ps); systemOutLogger.recordAuditEventEnd("eventId", "rule"); assertTrue(baos.toString().contains("SystemOutLoggerTest : eventId:rule")); @@ -282,7 +288,7 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { UUID uuid = UUID.randomUUID(); System.setOut(ps); systemOutLogger.recordAuditEventEnd(uuid, "rule"); @@ -298,7 +304,7 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { System.setOut(ps); systemOutLogger.recordMetricEvent("eventId", "rule"); assertTrue(baos.toString(), baos.toString().contains("SystemOutLoggerTest : eventId:eventIdmessage:rule")); @@ -313,7 +319,7 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { UUID uuid = UUID.randomUUID(); System.setOut(ps); systemOutLogger.recordMetricEvent(uuid, "str1"); @@ -329,7 +335,7 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { System.setOut(ps); systemOutLogger.metrics("message"); assertTrue(baos.toString().contains("SystemOutLoggerTest : message")); @@ -344,10 +350,11 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { System.setOut(ps); systemOutLogger.error(MessageCodes.ERROR_DATA_ISSUE, new NullPointerException(), "str1", "str2"); - assertTrue(baos.toString().contains("SystemOutLoggerTest : MessageCodes :" + MessageCodes.ERROR_DATA_ISSUE + "[str1, str2]")); + assertTrue(baos.toString() + .contains("SystemOutLoggerTest : MessageCodes :" + MessageCodes.ERROR_DATA_ISSUE + "[str1, str2]")); } finally { System.out.flush(); System.setOut(old); @@ -359,11 +366,12 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { System.setOut(ps); systemOutLogger.setTransId("transactionId"); systemOutLogger.error(MessageCodes.ERROR_DATA_ISSUE, "str1", "str2"); - assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : MessageCode:" + MessageCodes.ERROR_DATA_ISSUE + "[str1, str2]")); + assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : MessageCode:" + + MessageCodes.ERROR_DATA_ISSUE + "[str1, str2]")); } finally { System.out.flush(); System.setOut(old); @@ -380,11 +388,12 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { System.setOut(ps); systemOutLogger.setTransId("transactionId"); systemOutLogger.warn(MessageCodes.ERROR_DATA_ISSUE, "str1", "str2"); - assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : MessageCodes:" + MessageCodes.ERROR_DATA_ISSUE + "[str1, str2]")); + assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : MessageCodes:" + + MessageCodes.ERROR_DATA_ISSUE + "[str1, str2]")); } finally { System.out.flush(); System.setOut(old); @@ -396,11 +405,12 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { System.setOut(ps); systemOutLogger.setTransId("transactionId"); systemOutLogger.warn(MessageCodes.ERROR_DATA_ISSUE, new NullPointerException(), "str1", "str2"); - assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : MessageCodes:" + MessageCodes.ERROR_DATA_ISSUE + "[str1, str2]")); + assertTrue(baos.toString().contains("transactionId|SystemOutLoggerTest : MessageCodes:" + + MessageCodes.ERROR_DATA_ISSUE + "[str1, str2]")); } finally { System.out.flush(); System.setOut(old); @@ -412,15 +422,16 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { System.setOut(ps); systemOutLogger.setTransId("transactionId"); systemOutLogger.debug(1, new NullPointerException()); - assertTrue(baos.toString(), baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException")); + assertTrue(baos.toString(), + baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException")); } finally { System.out.flush(); System.setOut(old); - } + } } @Test @@ -428,11 +439,12 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { System.setOut(ps); systemOutLogger.setTransId("transactionId"); systemOutLogger.error(1, new NullPointerException()); - assertTrue(baos.toString(), baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException")); + assertTrue(baos.toString(), + baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException")); } finally { System.out.flush(); System.setOut(old); @@ -444,11 +456,12 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { System.setOut(ps); systemOutLogger.setTransId("transactionId"); systemOutLogger.info(1, new NullPointerException()); - assertTrue(baos.toString(), baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException")); + assertTrue(baos.toString(), + baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException")); } finally { System.out.flush(); System.setOut(old); @@ -460,11 +473,12 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { System.setOut(ps); systemOutLogger.setTransId("transactionId"); systemOutLogger.warn(1, new NullPointerException()); - assertTrue(baos.toString(), baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException")); + assertTrue(baos.toString(), + baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException")); } finally { System.out.flush(); System.setOut(old); @@ -476,11 +490,12 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { System.setOut(ps); systemOutLogger.setTransId("transactionId"); systemOutLogger.trace(1, new NullPointerException()); - assertTrue(baos.toString(), baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException")); + assertTrue(baos.toString(), + baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException")); } finally { System.out.flush(); System.setOut(old); @@ -492,11 +507,12 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { System.setOut(ps); systemOutLogger.setTransId("transactionId"); systemOutLogger.audit(1, new NullPointerException()); - assertTrue(baos.toString(), baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException")); + assertTrue(baos.toString(), + baos.toString().contains("transactionId|SystemOutLoggerTest : 1:java.lang.NullPointerException")); } finally { System.out.flush(); System.setOut(old); @@ -513,7 +529,7 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { System.setOut(ps); systemOutLogger.postMDCInfoForTriggeredRule("transactionId"); assertTrue(baos.toString(), baos.toString().contains("transactionId")); @@ -528,7 +544,7 @@ public class SystemOutLoggerTest { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); PrintStream old = System.out; - try{ + try { System.setOut(ps); systemOutLogger.postMDCInfoForEvent(1); assertTrue(baos.toString(), baos.toString().contains("1")); |