use of org.apache.logging.log4j.core.test.appender.ListAppender in project logging-log4j2 by apache.
the class CallerInformationTest method testMethodLogger.
@Test
public void testMethodLogger() throws Exception {
final ListAppender app = ctx.getListAppender("Method").clear();
final Logger logger = Logger.getLogger("MethodLogger");
logger.info("More messages.");
logger.warning("CATASTROPHE INCOMING!");
logger.severe("ZOMBIES!!!");
logger.warning("brains~~~");
logger.info("Itchy. Tasty.");
final List<String> messages = app.getMessages();
assertEquals("Incorrect number of messages.", 5, messages.size());
for (final String message : messages) {
assertEquals("Incorrect caller method name.", "testMethodLogger", message);
}
}
use of org.apache.logging.log4j.core.test.appender.ListAppender in project logging-log4j2 by apache.
the class IoBuilderCallerInfoTesting method assertMessages.
public void assertMessages(final String msg, final int size, final String methodName) {
final ListAppender appender = ctx.getListAppender("ClassAndMethod");
assertEquals(msg + ".size", size, appender.getMessages().size());
for (final String message : appender.getMessages()) {
assertEquals(msg + " has incorrect caller info", this.getClass().getName() + '.' + methodName, message);
}
}
use of org.apache.logging.log4j.core.test.appender.ListAppender in project logging-log4j2 by apache.
the class IoBuilderTest method testNoArgBuilderCallerClassInfo.
@Test
public void testNoArgBuilderCallerClassInfo() throws Exception {
try (final PrintStream ps = IoBuilder.forLogger().buildPrintStream()) {
ps.println("discarded");
final ListAppender app = context.getListAppender("IoBuilderTest");
final List<String> messages = app.getMessages();
assertThat(messages, not(empty()));
assertThat(messages, hasSize(1));
final String message = messages.get(0);
assertThat(message, startsWith(getClass().getName() + ".testNoArgBuilderCallerClassInfo"));
app.clear();
}
}
use of org.apache.logging.log4j.core.test.appender.ListAppender in project logging-log4j2 by apache.
the class BasicArbiterTest method prodTest.
@Test
public void prodTest() {
System.setProperty("env", "prod");
loggerContext = Configurator.initialize(null, CONFIG);
assertNotNull(loggerContext);
Appender app = loggerContext.getConfiguration().getAppender("Out");
assertNotNull(app);
assertTrue(app instanceof ListAppender);
}
use of org.apache.logging.log4j.core.test.appender.ListAppender in project logging-log4j2 by apache.
the class SelectArbiterTest method prodTest.
@Test
public void prodTest() {
System.setProperty("env", "prod");
loggerContext = Configurator.initialize(null, CONFIG);
assertNotNull(loggerContext);
Appender app = loggerContext.getConfiguration().getAppender("Out");
assertNotNull(app);
assertTrue(app instanceof ListAppender);
}
Aggregations