use of org.apache.qpid.server.logging.logback.CompositeFilter in project qpid-broker-j by apache.
the class CompositeFilterTest method testDecideWithAcceptRule.
public void testDecideWithAcceptRule() {
CompositeFilter compositeFilter = new CompositeFilter();
compositeFilter.addLogInclusionRule(createRule(FilterReply.ACCEPT));
final ILoggingEvent loggingEvent = mock(ILoggingEvent.class);
when(loggingEvent.getLevel()).thenReturn(Level.ERROR);
FilterReply reply = compositeFilter.decide(loggingEvent);
assertEquals("Unexpected reply with ACCEPT rule added", FilterReply.ACCEPT, reply);
}
use of org.apache.qpid.server.logging.logback.CompositeFilter in project qpid-broker-j by apache.
the class CompositeFilterTest method testAddLogInclusionRule.
public void testAddLogInclusionRule() {
CompositeFilter compositeFilter = new CompositeFilter();
LogBackLogInclusionRule rule = createRule(FilterReply.ACCEPT, "accept");
compositeFilter.addLogInclusionRule(rule);
verify(rule.asFilter()).setName("accept");
}
use of org.apache.qpid.server.logging.logback.CompositeFilter in project qpid-broker-j by apache.
the class CompositeFilterTest method testRemoveLogInclusionRule.
public void testRemoveLogInclusionRule() {
CompositeFilter compositeFilter = new CompositeFilter();
LogBackLogInclusionRule neutral = createRule(FilterReply.NEUTRAL, "neutral");
compositeFilter.addLogInclusionRule(neutral);
LogBackLogInclusionRule deny = createRule(FilterReply.DENY, "deny");
compositeFilter.addLogInclusionRule(deny);
LogBackLogInclusionRule accept = createRule(FilterReply.ACCEPT, "accept");
compositeFilter.addLogInclusionRule(accept);
FilterReply reply = compositeFilter.decide(mock(ILoggingEvent.class));
assertEquals("Unexpected reply", FilterReply.DENY, reply);
compositeFilter.removeLogInclusionRule(deny);
final ILoggingEvent loggingEvent = mock(ILoggingEvent.class);
when(loggingEvent.getLevel()).thenReturn(Level.ERROR);
FilterReply reply2 = compositeFilter.decide(loggingEvent);
assertEquals("Unexpected reply", FilterReply.ACCEPT, reply2);
verify(neutral.asFilter(), times(2)).decide(any(ILoggingEvent.class));
verify(deny.asFilter()).decide(any(ILoggingEvent.class));
verify(accept.asFilter()).decide(any(ILoggingEvent.class));
}
use of org.apache.qpid.server.logging.logback.CompositeFilter in project qpid-broker-j by apache.
the class CompositeFilterTest method testDecideWithNoRule.
public void testDecideWithNoRule() {
CompositeFilter compositeFilter = new CompositeFilter();
FilterReply reply = compositeFilter.decide(mock(ILoggingEvent.class));
assertEquals("Unexpected reply with no rule added", FilterReply.DENY, reply);
}
use of org.apache.qpid.server.logging.logback.CompositeFilter in project qpid-broker-j by apache.
the class CompositeFilterTest method testDecideWithMultipleRules.
public void testDecideWithMultipleRules() {
CompositeFilter compositeFilter = new CompositeFilter();
LogBackLogInclusionRule neutral = createRule(FilterReply.NEUTRAL);
compositeFilter.addLogInclusionRule(neutral);
LogBackLogInclusionRule deny = createRule(FilterReply.DENY);
compositeFilter.addLogInclusionRule(deny);
LogBackLogInclusionRule accept = createRule(FilterReply.ACCEPT);
compositeFilter.addLogInclusionRule(accept);
FilterReply reply = compositeFilter.decide(mock(ILoggingEvent.class));
assertEquals("Unexpected reply", FilterReply.DENY, reply);
verify(neutral.asFilter()).decide(any(ILoggingEvent.class));
verify(deny.asFilter()).decide(any(ILoggingEvent.class));
verify(accept.asFilter(), never()).decide(any(ILoggingEvent.class));
}
Aggregations