Search in sources :

Example 6 with NullConfiguration

use of org.apache.logging.log4j.core.config.NullConfiguration in project logging-log4j2 by apache.

the class PatternParserTest method testNanoPatternLongChangesNanoClockFactoryMode.

@Test
public void testNanoPatternLongChangesNanoClockFactoryMode() {
    final Configuration config = new NullConfiguration();
    assertTrue(config.getNanoClock() instanceof DummyNanoClock);
    final PatternParser pp = new PatternParser(config, KEY, null);
    assertTrue(config.getNanoClock() instanceof DummyNanoClock);
    pp.parse("%m");
    assertTrue(config.getNanoClock() instanceof DummyNanoClock);
    pp.parse("%N");
    assertTrue(config.getNanoClock() instanceof SystemNanoClock);
}
Also used : SystemNanoClock(org.apache.logging.log4j.core.util.SystemNanoClock) NullConfiguration(org.apache.logging.log4j.core.config.NullConfiguration) Configuration(org.apache.logging.log4j.core.config.Configuration) DummyNanoClock(org.apache.logging.log4j.core.util.DummyNanoClock) NullConfiguration(org.apache.logging.log4j.core.config.NullConfiguration) Test(org.junit.Test)

Example 7 with NullConfiguration

use of org.apache.logging.log4j.core.config.NullConfiguration in project logging-log4j2 by apache.

the class PatternParserTest method testNanoPatternShortChangesConfigurationNanoClock.

@Test
public void testNanoPatternShortChangesConfigurationNanoClock() {
    final Configuration config = new NullConfiguration();
    assertTrue(config.getNanoClock() instanceof DummyNanoClock);
    final PatternParser pp = new PatternParser(config, KEY, null);
    assertTrue(config.getNanoClock() instanceof DummyNanoClock);
    pp.parse("%m");
    assertTrue(config.getNanoClock() instanceof DummyNanoClock);
    // this changes the config clock
    pp.parse("%nano");
    assertTrue(config.getNanoClock() instanceof SystemNanoClock);
}
Also used : SystemNanoClock(org.apache.logging.log4j.core.util.SystemNanoClock) NullConfiguration(org.apache.logging.log4j.core.config.NullConfiguration) Configuration(org.apache.logging.log4j.core.config.Configuration) DummyNanoClock(org.apache.logging.log4j.core.util.DummyNanoClock) NullConfiguration(org.apache.logging.log4j.core.config.NullConfiguration) Test(org.junit.Test)

Example 8 with NullConfiguration

use of org.apache.logging.log4j.core.config.NullConfiguration in project logging-log4j2 by apache.

the class ValidatingPluginWithTypedBuilderTest method testNonNullValue.

@Test
public void testNonNullValue() throws Exception {
    node.getAttributes().put("name", "foo");
    // @formatter:off
    final ValidatingPluginWithTypedBuilder validatingPlugin = (ValidatingPluginWithTypedBuilder) new PluginBuilder(plugin).withConfiguration(new NullConfiguration()).withConfigurationNode(node).build();
    // @formatter:on
    assertNotNull(validatingPlugin);
    assertEquals("foo", validatingPlugin.getName());
}
Also used : ValidatingPluginWithTypedBuilder(org.apache.logging.log4j.core.config.plugins.validation.ValidatingPluginWithTypedBuilder) PluginBuilder(org.apache.logging.log4j.core.config.plugins.util.PluginBuilder) NullConfiguration(org.apache.logging.log4j.core.config.NullConfiguration) Test(org.junit.Test)

Example 9 with NullConfiguration

use of org.apache.logging.log4j.core.config.NullConfiguration in project logging-log4j2 by apache.

the class ValidatingPluginWithGenericSubclassFoo1BuilderTest method testNullDefaultValue.

@Test
public void testNullDefaultValue() throws Exception {
    final PluginWithGenericSubclassFoo1Builder validatingPlugin = (PluginWithGenericSubclassFoo1Builder) new PluginBuilder(plugin).withConfiguration(new NullConfiguration()).withConfigurationNode(node).build();
    assertNull(validatingPlugin);
}
Also used : PluginWithGenericSubclassFoo1Builder(org.apache.logging.log4j.core.config.plugins.validation.PluginWithGenericSubclassFoo1Builder) PluginBuilder(org.apache.logging.log4j.core.config.plugins.util.PluginBuilder) NullConfiguration(org.apache.logging.log4j.core.config.NullConfiguration) Test(org.junit.Test)

Example 10 with NullConfiguration

use of org.apache.logging.log4j.core.config.NullConfiguration in project logging-log4j2 by apache.

the class ValidatingPluginWithGenericSubclassFoo1BuilderTest method testNonNullValue.

@Test
public void testNonNullValue() throws Exception {
    node.getAttributes().put("thing", "thing1");
    node.getAttributes().put("foo1", "foo1");
    final PluginWithGenericSubclassFoo1Builder validatingPlugin = (PluginWithGenericSubclassFoo1Builder) new PluginBuilder(plugin).withConfiguration(new NullConfiguration()).withConfigurationNode(node).build();
    assertNotNull(validatingPlugin);
    assertEquals("thing1", validatingPlugin.getThing());
    assertEquals("foo1", validatingPlugin.getFoo1());
}
Also used : PluginWithGenericSubclassFoo1Builder(org.apache.logging.log4j.core.config.plugins.validation.PluginWithGenericSubclassFoo1Builder) PluginBuilder(org.apache.logging.log4j.core.config.plugins.util.PluginBuilder) NullConfiguration(org.apache.logging.log4j.core.config.NullConfiguration) Test(org.junit.Test)

Aggregations

NullConfiguration (org.apache.logging.log4j.core.config.NullConfiguration)11 Test (org.junit.Test)10 PluginBuilder (org.apache.logging.log4j.core.config.plugins.util.PluginBuilder)8 Configuration (org.apache.logging.log4j.core.config.Configuration)2 PluginWithGenericSubclassFoo1Builder (org.apache.logging.log4j.core.config.plugins.validation.PluginWithGenericSubclassFoo1Builder)2 ValidatingPlugin (org.apache.logging.log4j.core.config.plugins.validation.ValidatingPlugin)2 ValidatingPluginWithGenericBuilder (org.apache.logging.log4j.core.config.plugins.validation.ValidatingPluginWithGenericBuilder)2 ValidatingPluginWithTypedBuilder (org.apache.logging.log4j.core.config.plugins.validation.ValidatingPluginWithTypedBuilder)2 DummyNanoClock (org.apache.logging.log4j.core.util.DummyNanoClock)2 SystemNanoClock (org.apache.logging.log4j.core.util.SystemNanoClock)2 DemoAppender (org.apache.logging.log4j.perf.util.DemoAppender)1