LogHelper { public static void warn(Logger logger, String msg, Throwable e) { if (logger == null) { return; } if (logger.isWarnEnabled()) { logger.warn(msg, e); } } private  LogHelper(); static void trace(Logger logger, String msg); static void trace(Logger logger, Throwable throwable); static void trace(Logger logger, String msg, Throwable e); static void debug(Logger logger, String msg); static void debug(Logger logger, Throwable e); static void debug(Logger logger, String msg, Throwable e); static void info(Logger logger, String msg); static void info(Logger logger, Throwable e); static void info(Logger logger, String msg, Throwable e); static void warn(Logger logger, String msg, Throwable e); static void warn(Logger logger, String msg); static void warn(Logger logger, Throwable e); static void error(Logger logger, Throwable e); static void error(Logger logger, String msg); static void error(Logger logger, String msg, Throwable e);  }
@Test public void testWarn() throws Exception { Logger logger = Mockito.mock(Logger.class); when(logger.isWarnEnabled()).thenReturn(true); LogHelper.warn(logger, "warn"); verify(logger).warn("warn"); Throwable t = new RuntimeException(); LogHelper.warn(logger, t); verify(logger).warn(t); LogHelper.warn(logger, "warn", t); verify(logger).warn("warn", t); }