### Question:
FelixLoggerBridge extends Logger { protected void doLog(org.osgi.framework.ServiceReference serviceReference, int level, java.lang.String message, java.lang.Throwable throwable) { if (serviceReference != null) message = "Service " + serviceReference + ": " + message; switch (level) { case LOG_DEBUG: log.debug(message); break; case LOG_ERROR: if (throwable != null) { if ((throwable instanceof BundleException) && (((BundleException) throwable).getNestedException() != null)) { throwable = ((BundleException) throwable).getNestedException(); } log.error(message, throwable); } else log.error(message); break; case LOG_INFO: logInfoUnlessLame(message); break; case LOG_WARNING: if (throwable != null) { if (throwable instanceof ClassNotFoundException && isClassNotFoundsWeCareAbout(throwable)) { log.debug("Class not found in bundle: " + message); } else if (throwable instanceof ResourceNotFoundException) { log.trace("Resource not found in bundle: " + message); } } else { logInfoUnlessLame(message); } break; default: log.debug("UNKNOWN[" + level + "]: " + message); } } FelixLoggerBridge(org.slf4j.Logger log); boolean isClassNotFoundsWeCareAbout(Throwable t);  }### Answer:
@Test public void testClassNotFound() { when(log.isInfoEnabled()).thenReturn(true); FelixLoggerBridge bridge = new FelixLoggerBridge(log); bridge.doLog(null, Logger.LOG_WARNING, "foo", new ClassNotFoundException("foo")); verify(log).debug("Class not found in bundle: foo"); }
@Test public void testClassNotFoundOnDebug() { when(log.isInfoEnabled()).thenReturn(true); FelixLoggerBridge bridge = new FelixLoggerBridge(log); bridge.doLog(null, Logger.LOG_WARNING, "*** foo", new ClassNotFoundException("*** foo", new ClassNotFoundException("bar"))); verify(log).debug("Class not found in bundle: *** foo"); }
@Test public void testFrameworkLogInfo() { when(log.isInfoEnabled()).thenReturn(true); FelixLoggerBridge bridge = new FelixLoggerBridge(log); bridge.doLog(null, Logger.LOG_INFO, "foo", null); verify(log).info("foo"); }
@Test public void testLameClassNotFound() { when(log.isInfoEnabled()).thenReturn(true); FelixLoggerBridge bridge = new FelixLoggerBridge(log); verify(log).isDebugEnabled(); verify(log).isInfoEnabled(); bridge.doLog(null, Logger.LOG_WARNING, "org.springframework.foo", new ClassNotFoundException("org.springframework.foo")); verifyNoMoreInteractions(log); }
@Test public void testLameClassNotFoundInDebug() { when(log.isInfoEnabled()).thenReturn(true); FelixLoggerBridge bridge = new FelixLoggerBridge(log); verify(log).isDebugEnabled(); verify(log).isInfoEnabled(); bridge.doLog(null, Logger.LOG_WARNING, "*** org.springframework.foo", new ClassNotFoundException("*** org.springframework.foo", new ClassNotFoundException("org.springframework.foo"))); verifyNoMoreInteractions(log); }
@Test public void testResourceNotFound() { when(log.isInfoEnabled()).thenReturn(true); FelixLoggerBridge bridge = new FelixLoggerBridge(log); bridge.doLog(null, Logger.LOG_WARNING, "foo", new ResourceNotFoundException("foo")); verify(log).trace("Resource not found in bundle: foo"); }