use of org.apache.logging.log4j.test.appender.ListAppender in project logging-log4j2 by apache.
the class LoggingMessageTagSupportTest method verify.
private void verify(final String expected) {
final ListAppender listApp = context.getListAppender("List");
final List<String> events = listApp.getMessages();
try {
assertEquals("Incorrect number of messages.", 1, events.size());
assertEquals("Incorrect message.", "o.a.l.l.t.LoggingMessageTagSupportTest " + expected, events.get(0));
} finally {
listApp.clear();
}
}
use of org.apache.logging.log4j.test.appender.ListAppender in project logging-log4j2 by apache.
the class EnterTagTest method verify.
private void verify(final String expected) {
final ListAppender listApp = context.getListAppender("List");
final List<String> events = listApp.getMessages();
try {
assertEquals("Incorrect number of messages.", 1, events.size());
assertEquals("Incorrect message.", "o.a.l.l.t.EnterTagTest " + expected, events.get(0));
} finally {
listApp.clear();
}
}
use of org.apache.logging.log4j.test.appender.ListAppender in project logging-log4j2 by apache.
the class ExitTagTest method verify.
private void verify(final String expected) {
final ListAppender listApp = context.getListAppender("List");
final List<String> events = listApp.getMessages();
try {
assertEquals("Incorrect number of messages.", 1, events.size());
assertEquals("Incorrect message.", "o.a.l.l.t.ExitTagTest " + expected, events.get(0));
} finally {
listApp.clear();
}
}
use of org.apache.logging.log4j.test.appender.ListAppender in project logging-log4j2 by apache.
the class AbstractScriptFilterTest method testGroovyFilter.
@Test
public void testGroovyFilter() throws Exception {
final Logger logger = LogManager.getLogger("TestGroovyFilter");
logger.traceEntry();
logger.info("This should not be logged");
ThreadContext.put("UserId", "JohnDoe");
logger.info("This should be logged");
ThreadContext.clearMap();
final ListAppender app = getContext().getListAppender("List");
try {
final List<String> messages = app.getMessages();
assertNotNull("No Messages", messages);
assertTrue("Incorrect number of messages. Expected 2, Actual " + messages.size(), messages.size() == 2);
} finally {
app.clear();
}
}
use of org.apache.logging.log4j.test.appender.ListAppender in project logging-log4j2 by apache.
the class AbstractScriptFilterTest method testJavascriptFilter.
@Test
public void testJavascriptFilter() throws Exception {
final Logger logger = LogManager.getLogger("TestJavaScriptFilter");
logger.traceEntry();
logger.info("This should not be logged");
ThreadContext.put("UserId", "JohnDoe");
logger.info("This should be logged");
ThreadContext.clearMap();
final ListAppender app = getContext().getListAppender("List");
final List<String> messages = app.getMessages();
try {
assertNotNull("No Messages", messages);
assertTrue("Incorrect number of messages. Expected 2, Actual " + messages.size(), messages.size() == 2);
} finally {
app.clear();
}
}
Aggregations