LogHelper { public static void trace(Logger logger, String msg) { if (logger == null) { return; } if (logger.isTraceEnabled()) { logger.trace(msg); } } 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 testTrace() throws Exception { Logger logger = Mockito.mock(Logger.class); when(logger.isTraceEnabled()).thenReturn(true); LogHelper.trace(logger, "trace"); verify(logger).trace("trace"); Throwable t = new RuntimeException(); LogHelper.trace(logger, t); verify(logger).trace(t); LogHelper.trace(logger, "trace", t); verify(logger).trace("trace", t); }