|
We recently had some issues about specific WARN messages being misfired, generally these are trivial to solve but it's hard to verify the changes and make sure we have regression tests.
I'm working on a little helper which should simplify this task.
This is how a test could look like:
public class LoggingRuleTest {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, SessionImpl.class.getName());
@Rule
public LoggerInspectionRule logInspection = new LoggerInspectionRule( LOG );
@Test
public void testRule() {
Triggerable triggerable = logInspection.watchForLogMessages( "HHH000008:" );
Assert.assertFalse( triggerable.wasTriggered() );
LOG.autoFlushWillNotWork(); Assert.assertTrue( triggerable.wasTriggered() );
triggerable.reset();
Assert.assertFalse( triggerable.wasTriggered() );
}
}
|