use of nl.nn.adapterframework.testutil.TestAppender in project iaf by ibissource.
the class TestLogMessages method hidePasswordInLogMessages.
@Test
public void hidePasswordInLogMessages() {
TestAppender appender = TestAppender.newBuilder().useIbisPatternLayout(PATTERN).build();
TestAppender.addToRootLogger(appender);
IbisMaskingLayout.addToGlobalReplace("(?<=password=\").+?(?=\")");
try {
log.debug(TEST_REGEX_IN);
List<String> logEvents = appender.getLogLines();
assertEquals(1, logEvents.size());
String message = logEvents.get(0);
assertEquals("DEBUG - " + TEST_REGEX_OUT, message);
} finally {
IbisMaskingLayout.cleanGlobalReplace();
TestAppender.removeAppender(appender);
}
}
use of nl.nn.adapterframework.testutil.TestAppender in project iaf by ibissource.
the class TestLogMessages method dontLogDebugAndInfoLevelsWhenThreadFilterIsActive.
@Test
public void dontLogDebugAndInfoLevelsWhenThreadFilterIsActive() {
TestAppender appender = TestAppender.newBuilder().useIbisPatternLayout(PATTERN).useIbisThreadFilter("HIDE-HERE").build();
TestAppender.addToRootLogger(appender);
String threadName = Thread.currentThread().getName();
try {
Thread.currentThread().setName("HIDE-HERE");
log.debug("my beautiful debug message");
log.info("my beautiful info message");
log.warn("my beautiful warning message");
log.error("my beautiful error message");
Thread.currentThread().setName("LOG-ALL");
log.debug("some message");
log.info("some message");
log.warn("some message");
log.error("some message");
List<String> logEvents = appender.getLogLines();
assertEquals(6, logEvents.size());
assertEquals("WARN - my beautiful warning message", logEvents.get(0));
assertEquals("ERROR - my beautiful error message", logEvents.get(1));
} finally {
Thread.currentThread().setName(threadName);
TestAppender.removeAppender(appender);
}
}
use of nl.nn.adapterframework.testutil.TestAppender in project iaf by ibissource.
the class TestLogMessages method testUnicodeCharactersInMessage.
@Test
public void testUnicodeCharactersInMessage() {
TestAppender appender = TestAppender.newBuilder().useIbisPatternLayout(PATTERN).build();
TestAppender.addToRootLogger(appender);
try {
log.debug("my beautiful unicode debug aâΔع你好ಡತ message for me & you --> \\\"world\\\"");
List<String> logEvents = appender.getLogLines();
assertEquals(1, logEvents.size());
String message = logEvents.get(0);
assertEquals("DEBUG - my beautiful unicode debug aâΔع你好ಡತ message for me & you --> \\\"world\\\"", message);
} finally {
IbisMaskingLayout.cleanGlobalReplace();
TestAppender.removeAppender(appender);
}
}
use of nl.nn.adapterframework.testutil.TestAppender in project iaf by ibissource.
the class TestLogMessages method testCdataInMessage.
@Test
public void testCdataInMessage() {
TestAppender appender = TestAppender.newBuilder().useIbisPatternLayout(PATTERN).build();
TestAppender.addToRootLogger(appender);
try {
log.debug("my beautiful <![CDATA[debug]]> for me & you --> \"world\"");
List<String> logEvents = appender.getLogLines();
assertEquals(1, logEvents.size());
String message = logEvents.get(0);
assertEquals("DEBUG - my beautiful <![CDATA[debug]]> for me & you --> \"world\"", message);
} finally {
IbisMaskingLayout.cleanGlobalReplace();
TestAppender.removeAppender(appender);
}
}
Aggregations