use of org.apache.logging.log4j.test.appender.ListAppender in project logging-log4j2 by apache.
the class RoutesScriptAppenderTest method logAndCheck.
private void logAndCheck() {
final Marker marker = MarkerManager.getMarker("HEXDUMP");
final Logger logger = loggerContextRule.getLogger(RoutesScriptAppenderTest.class);
logger.error("Hello");
final ListAppender listAppender = getListAppender();
final List<LogEvent> list = listAppender.getEvents();
assertNotNull("No events generated", list);
assertTrue("Incorrect number of events. Expected 1, got " + list.size(), list.size() == 1);
logger.error("World");
assertTrue("Incorrect number of events. Expected 2, got " + list.size(), list.size() == 2);
logger.error(marker, "DEADBEEF");
assertTrue("Incorrect number of events. Expected 3, got " + list.size(), list.size() == 3);
}
use of org.apache.logging.log4j.test.appender.ListAppender in project logging-log4j2 by apache.
the class OptionalTest method verify.
private void verify(final String name, final String expected) {
final ListAppender listApp = CTX.getListAppender(name);
final List<String> events = listApp.getMessages();
assertTrue("Incorrect number of messages. Expected 1 Actual " + events.size(), events.size() == 1);
final String actual = events.get(0);
assertEquals("Incorrect message. Expected " + expected + ". Actual " + actual, expected, actual);
listApp.clear();
}
use of org.apache.logging.log4j.test.appender.ListAppender in project logging-log4j2 by apache.
the class CatchingTagTest 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.CatchingTagTest " + expected, events.get(0));
} finally {
listApp.clear();
}
}
use of org.apache.logging.log4j.test.appender.ListAppender in project logging-log4j2 by apache.
the class LoggerTest method verify.
private void verify(final String name, final String expected) {
final ListAppender listApp = ctx.getListAppender(name);
assertNotNull("Missing Appender", listApp);
final List<String> events = listApp.getMessages();
assertTrue("Incorrect number of messages. Expected 1 Actual " + events.size(), events.size() == 1);
final String actual = events.get(0);
assertEquals("Incorrect message. Expected " + expected + ". Actual " + actual, expected, actual);
listApp.clear();
}
use of org.apache.logging.log4j.test.appender.ListAppender in project logging-log4j2 by apache.
the class CallerInformationTest method testClassLogger.
@Test
public void testClassLogger() throws Exception {
final ListAppender app = ctx.getListAppender("Class").clear();
final Logger logger = LoggerFactory.getLogger("ClassLogger");
logger.info("Ignored message contents.");
logger.warn("Verifying the caller class is still correct.");
logger.error("Hopefully nobody breaks me!");
final List<String> messages = app.getMessages();
assertEquals("Incorrect number of messages.", 3, messages.size());
for (final String message : messages) {
assertEquals("Incorrect caller class name.", this.getClass().getName(), message);
}
}
Aggregations