Search in sources :

Example 11 with FilterReply

use of ch.qos.logback.core.spi.FilterReply 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)

Example 12 with FilterReply

use of ch.qos.logback.core.spi.FilterReply in project qpid-broker-j by apache.

the class CompositeFilterTest method testDecideWithNeutralRule.

public void testDecideWithNeutralRule() {
    CompositeFilter compositeFilter = new CompositeFilter();
    compositeFilter.addLogInclusionRule(createRule(FilterReply.NEUTRAL));
    final ILoggingEvent loggingEvent = mock(ILoggingEvent.class);
    when(loggingEvent.getLevel()).thenReturn(Level.ERROR);
    FilterReply reply = compositeFilter.decide(loggingEvent);
    assertEquals("Unexpected reply with NEUTRAL 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 13 with FilterReply

use of ch.qos.logback.core.spi.FilterReply in project qpid-broker-j by apache.

the class Logback1027WorkaroundTurboFilterTest method testOneException.

public void testOneException() {
    Exception e = new Exception();
    final FilterReply reply = doDecide(e);
    assertEquals(FilterReply.NEUTRAL, reply);
    assertEquals(0, _snoopingAppender.getEvents().size());
}
Also used : FilterReply(ch.qos.logback.core.spi.FilterReply) LogbackException(ch.qos.logback.core.LogbackException)

Example 14 with FilterReply

use of ch.qos.logback.core.spi.FilterReply in project qpid-broker-j by apache.

the class PrincipalLogEventFilterTest method testNoPrincipal.

public void testNoPrincipal() {
    FilterReply reply = doFilter();
    assertEquals(FilterReply.DENY, reply);
}
Also used : FilterReply(ch.qos.logback.core.spi.FilterReply)

Example 15 with FilterReply

use of ch.qos.logback.core.spi.FilterReply in project qpid-broker-j by apache.

the class PrincipalLogEventFilterTest method testPrincipalMatches.

public void testPrincipalMatches() {
    _subject.getPrincipals().add(_principal);
    FilterReply reply = doFilter();
    assertEquals(FilterReply.NEUTRAL, reply);
}
Also used : FilterReply(ch.qos.logback.core.spi.FilterReply)

Aggregations

FilterReply (ch.qos.logback.core.spi.FilterReply)21 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)8 LogbackException (ch.qos.logback.core.LogbackException)5 CompositeFilter (org.apache.qpid.server.logging.logback.CompositeFilter)5 Subject (javax.security.auth.Subject)4 VirtualHostPrincipal (org.apache.qpid.server.virtualhost.VirtualHostPrincipal)4 Principal (java.security.Principal)3 PatternLayoutEncoder (ch.qos.logback.classic.encoder.PatternLayoutEncoder)1 ConsoleAppender (ch.qos.logback.core.ConsoleAppender)1 Context (ch.qos.logback.core.Context)1 ListAppender (ch.qos.logback.core.read.ListAppender)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 EventLogger (org.apache.qpid.server.logging.EventLogger)1 Logger (org.slf4j.Logger)1