Search in sources :

Example 1 with CompositeFilter

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);
}
Also used : CompositeFilter(org.apache.qpid.server.logging.logback.CompositeFilter) FilterReply(ch.qos.logback.core.spi.FilterReply) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent)

Example 2 with CompositeFilter

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");
}
Also used : CompositeFilter(org.apache.qpid.server.logging.logback.CompositeFilter)

Example 3 with CompositeFilter

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));
}
Also used : CompositeFilter(org.apache.qpid.server.logging.logback.CompositeFilter) FilterReply(ch.qos.logback.core.spi.FilterReply) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent)

Example 4 with CompositeFilter

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);
}
Also used : CompositeFilter(org.apache.qpid.server.logging.logback.CompositeFilter) FilterReply(ch.qos.logback.core.spi.FilterReply) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent)

Example 5 with CompositeFilter

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));
}
Also used : CompositeFilter(org.apache.qpid.server.logging.logback.CompositeFilter) FilterReply(ch.qos.logback.core.spi.FilterReply) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent)

Aggregations

CompositeFilter (org.apache.qpid.server.logging.logback.CompositeFilter)6 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)5 FilterReply (ch.qos.logback.core.spi.FilterReply)5