Search in sources :

Example 6 with FilterReply

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

the class Logback1027WorkaroundTurboFilterTest method testInitCauseRecursion.

public void testInitCauseRecursion() throws Exception {
    Exception e1 = new Exception();
    Exception e2 = new Exception();
    e2.initCause(e1);
    e1.initCause(e2);
    final FilterReply reply = doDecide(e1);
    assertEquals(FilterReply.DENY, reply);
    assertEquals(1, _snoopingAppender.getEvents().size());
}
Also used : FilterReply(ch.qos.logback.core.spi.FilterReply) LogbackException(ch.qos.logback.core.LogbackException)

Example 7 with FilterReply

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

the class Logback1027WorkaroundTurboFilterTest method testNoRecursion.

public void testNoRecursion() {
    Exception e1 = new Exception();
    Exception e2 = new Exception();
    Exception e3 = new Exception();
    e2.addSuppressed(e3);
    e1.addSuppressed(e2);
    e1.initCause(e3);
    final FilterReply reply = doDecide(e1);
    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 8 with FilterReply

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

the class VirtualHostLogEventExcludingFilterTest method testDecideOnNoVirtualHostPrincipalInSubjectAndVirtualHostLogEventNotExcluded.

public void testDecideOnNoVirtualHostPrincipalInSubjectAndVirtualHostLogEventNotExcluded() throws Exception {
    Subject subject = new Subject();
    subject.getPrincipals().add(mock(Principal.class));
    FilterReply reply = doTestDecide(subject);
    assertEquals("Unexpected reply for BrokerLogger#virtualHostLogEventExcluded=false and no VH principal in subject", FilterReply.NEUTRAL, reply);
}
Also used : FilterReply(ch.qos.logback.core.spi.FilterReply) Subject(javax.security.auth.Subject) VirtualHostPrincipal(org.apache.qpid.server.virtualhost.VirtualHostPrincipal) Principal(java.security.Principal)

Example 9 with FilterReply

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

the class VirtualHostLogEventExcludingFilterTest method testDecideOnVirtualHostLogEventNotExcludedAndNullSubject.

public void testDecideOnVirtualHostLogEventNotExcludedAndNullSubject() throws Exception {
    FilterReply reply = _filter.decide(_loggingEvent);
    assertEquals(" BrokerLogger#virtualHostLogEventExcluded=false and subject=null", FilterReply.NEUTRAL, reply);
    assertNull("Subject should not be set in test environment", Subject.getSubject(AccessController.getContext()));
}
Also used : FilterReply(ch.qos.logback.core.spi.FilterReply)

Example 10 with FilterReply

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

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