JUnitLogger extends AbstractLoggerAdapter implements ILogger { private void logMessage(final LogLevel level, final String message, final Throwable throwable) { if (LogLevel.ERROR.equals(level) && !isErrorEnabled()) { return; } else if (LogLevel.WARN.equals(level) && !isWarnEnabled()) { return; } else if (LogLevel.INFO.equals(level) && !isInfoEnabled()) { return; } else if (LogLevel.DEBUG.equals(level) && !isDebugEnabled()) { return; } else if (LogLevel.TRACE.equals(level) && !isTraceEnabled()) { return; } else { addMessage(new LogMessage(level, message, throwable)); } } JUnitLogger(); static IFactory<JUnitLogger> factory(); synchronized LogMessage peekLastMessage(); synchronized LogMessage popLastMessage(); synchronized int getMessageCount(); synchronized void reset(); boolean hasMessage(); void setEnabled(final boolean enabled); @Override boolean isTraceEnabled(); void setTraceEnabled(final boolean enabled); @Override boolean isDebugEnabled(); void setDebugEnabled(final boolean enabled); @Override boolean isInfoEnabled(); void setInfoEnabled(final boolean enabled); @Override boolean isWarnEnabled(); void setWarnEnabled(final boolean enabled); @Override boolean isErrorEnabled(); void setErrorEnabled(final boolean enabled); @Override void error(final String wrapperFQCN, final String message, final Throwable throwable); @Override void warn(final String wrapperFQCN, final String message, final Throwable throwable); @Override void info(final String wrapperFQCN, final String message, final Throwable throwable); @Override void debug(final String wrapperFQCN, final String message, final Throwable throwable); @Override void trace(final String wrapperFQCN, final String message, final Throwable throwable);  }
@Test public void testLogMessage() { final String logMessage = "FooMessage"; logger.trace(logMessage + 1); Assert.assertEquals(1, logger.getMessageCount()); logger.debug(logMessage + 2); Assert.assertEquals(2, logger.getMessageCount()); logger.info(logMessage + 3); Assert.assertEquals(3, logger.getMessageCount()); logger.warn(logMessage + 4); Assert.assertEquals(4, logger.getMessageCount()); logger.error(logMessage + 5); Assert.assertEquals(5, logger.getMessageCount()); logger.reset(); Assert.assertEquals(0, logger.getMessageCount()); }