use of ch.qos.logback.classic.turbo.TurboFilter in project sling by apache.
the class ITFilterSupport method testTurboFilter.
@Test
public void testTurboFilter() throws Exception {
TestAppender ta = registerAppender("turbofilter", "TestAppender");
org.slf4j.Logger bar = LoggerFactory.getLogger("turbofilter.foo.bar");
assertTrue(bar.isDebugEnabled());
bar.debug("Test");
assertEquals(1, ta.events.size());
SimpleTurboFilter stf = new SimpleTurboFilter();
ServiceRegistration sr = bundleContext.registerService(TurboFilter.class.getName(), stf, null);
delay();
assertNotNull("Filter should have context set", stf.getContext());
assertTrue("Filter should be started", stf.isStarted());
ta.events.clear();
//Filter would reject calls for this logger hence it should not be false
assertFalse(bar.isDebugEnabled());
//No events should be logged as filter would have rejected that
bar.debug("Test");
assertTrue(ta.events.isEmpty());
//Now unregister and earlier asserts should work
sr.unregister();
delay();
ta.events.clear();
assertTrue(bar.isDebugEnabled());
bar.debug("Test");
assertEquals(1, ta.events.size());
}
Aggregations