use of org.apache.logging.log4j.core.appender.FailoverAppender in project logging-log4j2 by apache.
the class ValidatingPluginWithFailoverTest method setUp.
@SuppressWarnings("unchecked")
@BeforeEach
public void setUp() throws Exception {
final PluginManager manager = new PluginManager(Core.CATEGORY_NAME);
manager.collectPlugins();
plugin = (PluginType<FailoverAppender>) manager.getPluginType("failover");
assertNotNull(plugin, "Rebuild this module to make sure annotation processing kicks in.");
AppenderRef appenderRef = AppenderRef.createAppenderRef("List", Level.ALL, null);
node = new Node(null, "failover", plugin);
Node failoversNode = new Node(node, "Failovers", manager.getPluginType("Failovers"));
Node appenderRefNode = new Node(failoversNode, "appenderRef", manager.getPluginType("appenderRef"));
appenderRefNode.getAttributes().put("ref", "file");
appenderRefNode.setObject(appenderRef);
failoversNode.getChildren().add(appenderRefNode);
failoversNode.setObject(FailoversPlugin.createFailovers(appenderRef));
node.getAttributes().put("primary", "CONSOLE");
node.getAttributes().put("name", "Failover");
node.getChildren().add(failoversNode);
}
use of org.apache.logging.log4j.core.appender.FailoverAppender in project logging-log4j2 by apache.
the class ValidatingPluginWithFailoverTest method testDoesNotLog_NoParameterThatMatchesElement_message.
@Test
public void testDoesNotLog_NoParameterThatMatchesElement_message() {
final StatusListener listener = mock(StatusListener.class);
when(listener.getStatusLevel()).thenReturn(Level.WARN);
// @formatter:off
final PluginBuilder builder = new PluginBuilder(plugin).setConfiguration(new NullConfiguration()).setConfigurationNode(node);
// @formatter:on
StatusLogger.getLogger().registerListener(listener);
final FailoverAppender failoverAppender = (FailoverAppender) builder.build();
verify(listener, times(1)).getStatusLevel();
verify(listener, never()).log(any(StatusData.class));
verifyNoMoreInteractions(listener);
assertNotNull(failoverAppender);
assertEquals("Failover", failoverAppender.getName());
}
Aggregations