Search in sources :

Example 6 with LoggerContextSource

use of org.apache.logging.log4j.core.test.junit.LoggerContextSource in project logging-log4j2 by apache.

the class ShutdownCallbackRegistryTest method testShutdownCallbackRegistry.

@Test
@LoggerContextSource("ShutdownCallbackRegistryTest.xml")
public void testShutdownCallbackRegistry(final LoggerContext context) {
    assertTrue(context.isStarted(), "LoggerContext should be started");
    assertThat(Registry.CALLBACKS, hasSize(1));
    Registry.shutdown();
    assertTrue(context.isStopped(), "LoggerContext should be stopped");
    assertThat(Registry.CALLBACKS, hasSize(0));
    final ContextSelector selector = ((Log4jContextFactory) LogManager.getFactory()).getSelector();
    assertThat(selector.getLoggerContexts(), not(hasItem(context)));
}
Also used : Log4jContextFactory(org.apache.logging.log4j.core.impl.Log4jContextFactory) ContextSelector(org.apache.logging.log4j.core.selector.ContextSelector) Test(org.junit.jupiter.api.Test) LoggerContextSource(org.apache.logging.log4j.core.test.junit.LoggerContextSource)

Example 7 with LoggerContextSource

use of org.apache.logging.log4j.core.test.junit.LoggerContextSource in project logging-log4j2 by apache.

the class ConfigurationFactoryTest method xml.

@Test
@LoggerContextSource("log4j-test1.xml")
void xml(final LoggerContext context) throws IOException {
    checkConfiguration(context);
    final Path logFile = Paths.get("target", "test-xml.log");
    checkFileLogger(context, logFile);
}
Also used : Path(java.nio.file.Path) Test(org.junit.jupiter.api.Test) LoggerContextSource(org.apache.logging.log4j.core.test.junit.LoggerContextSource)

Example 8 with LoggerContextSource

use of org.apache.logging.log4j.core.test.junit.LoggerContextSource in project logging-log4j2 by apache.

the class ConfigurationFactoryTest method yaml.

@Test
@Tag("yaml")
@LoggerContextSource("log4j-test1.yaml")
void yaml(final LoggerContext context) throws IOException {
    checkConfiguration(context);
    final Path logFile = Paths.get("target", "test-yaml.log");
    checkFileLogger(context, logFile);
}
Also used : Path(java.nio.file.Path) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag) LoggerContextSource(org.apache.logging.log4j.core.test.junit.LoggerContextSource)

Example 9 with LoggerContextSource

use of org.apache.logging.log4j.core.test.junit.LoggerContextSource in project logging-log4j2 by apache.

the class ConfigurationFactoryTest method json.

@Test
@Tag("json")
@LoggerContextSource("log4j-test1.json")
void json(final LoggerContext context) throws IOException {
    checkConfiguration(context);
    final Path logFile = Paths.get("target", "test-json.log");
    checkFileLogger(context, logFile);
}
Also used : Path(java.nio.file.Path) Test(org.junit.jupiter.api.Test) Tag(org.junit.jupiter.api.Tag) LoggerContextSource(org.apache.logging.log4j.core.test.junit.LoggerContextSource)

Example 10 with LoggerContextSource

use of org.apache.logging.log4j.core.test.junit.LoggerContextSource in project logging-log4j2 by apache.

the class ConfigurationFactoryTest method properties.

@Test
@LoggerContextSource("log4j-test1.properties")
void properties(final LoggerContext context) throws IOException {
    checkConfiguration(context);
    final Path logFile = Paths.get("target", "test-properties.log");
    checkFileLogger(context, logFile);
}
Also used : Path(java.nio.file.Path) Test(org.junit.jupiter.api.Test) LoggerContextSource(org.apache.logging.log4j.core.test.junit.LoggerContextSource)

Aggregations

LoggerContextSource (org.apache.logging.log4j.core.test.junit.LoggerContextSource)26 Test (org.junit.jupiter.api.Test)26 Logger (org.apache.logging.log4j.Logger)14 Path (java.nio.file.Path)9 Filter (org.apache.logging.log4j.core.Filter)7 Appender (org.apache.logging.log4j.core.Appender)4 LoggerConfig (org.apache.logging.log4j.core.config.LoggerConfig)4 ThresholdFilter (org.apache.logging.log4j.core.filter.ThresholdFilter)4 ListAppender (org.apache.logging.log4j.core.test.appender.ListAppender)4 Collection (java.util.Collection)2 ExtendedLogger (org.apache.logging.log4j.spi.ExtendedLogger)2 StatusLogger (org.apache.logging.log4j.status.StatusLogger)2 IndexedReadOnlyStringMap (org.apache.logging.log4j.util.IndexedReadOnlyStringMap)2 Tag (org.junit.jupiter.api.Tag)2 Row (com.datastax.driver.core.Row)1 Session (com.datastax.driver.core.Session)1 Field (java.lang.reflect.Field)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 UUID (java.util.UUID)1