use of org.apache.qpid.server.logging.logback.LoggerNameAndLevelFilter in project qpid-broker-j by apache.
the class VirtualHostNameAndLevelLogInclusionRuleImplTest method testLoggerNameChangeNotAllowed.
public void testLoggerNameChangeNotAllowed() {
VirtualHostNameAndLevelLogInclusionRule<?> rule = createRule("org.apache.qpid", LogLevel.INFO);
LoggerNameAndLevelFilter filter = (LoggerNameAndLevelFilter) rule.asFilter();
assertEquals("Unexpected logger name", "org.apache.qpid", filter.getLoggerName());
try {
rule.setAttributes(Collections.<String, Object>singletonMap(BrokerNameAndLevelLogInclusionRule.LOGGER_NAME, "org.apache.qpid.foo"));
fail("IllegalConfigurationException is expected to throw on attempt to change logger name");
} catch (IllegalConfigurationException e) {
// pass
}
assertEquals("Unexpected logger name", "org.apache.qpid", filter.getLoggerName());
}
use of org.apache.qpid.server.logging.logback.LoggerNameAndLevelFilter in project qpid-broker-j by apache.
the class VirtualHostNameAndLevelLogInclusionRuleImplTest method testAsFilter.
public void testAsFilter() {
VirtualHostNameAndLevelLogInclusionRule<?> rule = createRule("org.apache.qpid", LogLevel.INFO);
Filter<ILoggingEvent> filter = rule.asFilter();
assertTrue("Unexpected filter instance", filter instanceof LoggerNameAndLevelFilter);
LoggerNameAndLevelFilter f = (LoggerNameAndLevelFilter) filter;
assertEquals("Unexpected log level", Level.INFO, f.getLevel());
assertEquals("Unexpected logger name", "org.apache.qpid", f.getLoggerName());
}
use of org.apache.qpid.server.logging.logback.LoggerNameAndLevelFilter in project qpid-broker-j by apache.
the class BrokerNameAndLevelLogInclusionRuleTest method testAsFilter.
public void testAsFilter() {
BrokerNameAndLevelLogInclusionRule<?> rule = createRule("org.apache.qpid", LogLevel.INFO);
Filter<ILoggingEvent> filter = rule.asFilter();
assertTrue("Unexpected filter instance", filter instanceof LoggerNameAndLevelFilter);
LoggerNameAndLevelFilter f = (LoggerNameAndLevelFilter) filter;
assertEquals("Unexpected log level", Level.INFO, f.getLevel());
assertEquals("Unexpected logger name", "org.apache.qpid", f.getLoggerName());
}
use of org.apache.qpid.server.logging.logback.LoggerNameAndLevelFilter in project qpid-broker-j by apache.
the class BrokerNameAndLevelLogInclusionRuleTest method testLoggerNameChangeNotAllowed.
public void testLoggerNameChangeNotAllowed() {
BrokerNameAndLevelLogInclusionRule<?> rule = createRule("org.apache.qpid", LogLevel.INFO);
LoggerNameAndLevelFilter filter = (LoggerNameAndLevelFilter) rule.asFilter();
assertEquals("Unexpected logger name", "org.apache.qpid", filter.getLoggerName());
try {
rule.setAttributes(Collections.<String, Object>singletonMap(BrokerNameAndLevelLogInclusionRule.LOGGER_NAME, "org.apache.qpid.foo"));
fail("IllegalConfigurationException is expected to throw on attempt to change logger name");
} catch (IllegalConfigurationException e) {
// pass
}
assertEquals("Unexpected logger name", "org.apache.qpid", filter.getLoggerName());
}
use of org.apache.qpid.server.logging.logback.LoggerNameAndLevelFilter in project qpid-broker-j by apache.
the class LoggerNameAndLevelFilterTest method testDecideForEmptyLoggerName.
public void testDecideForEmptyLoggerName() throws Exception {
LoggerNameAndLevelFilter filter = new LoggerNameAndLevelFilter("", Level.INFO);
ILoggingEvent event = mock(ILoggingEvent.class);
when(event.getLevel()).thenReturn(Level.INFO);
when(event.getLoggerName()).thenReturn("org.apache.qpid.server.foo");
assertEquals("Unexpected reply for matching log level and arbitrary logger name", FilterReply.ACCEPT, filter.decide(event));
when(event.getLoggerName()).thenReturn("org.apache.qpid.foo");
assertEquals("Unexpected reply for matching log level and arbitrary logger namel", FilterReply.ACCEPT, filter.decide(event));
when(event.getLevel()).thenReturn(Level.DEBUG);
assertEquals("Unexpected reply for non matching log level", FilterReply.NEUTRAL, filter.decide(event));
}
Aggregations