use of org.apache.commons.logging.Log in project spring-framework by spring-projects.
the class PerformanceMonitorInterceptorTests method testExceptionPathStillLogsPerformanceMetricsCorrectly.
@Test
public void testExceptionPathStillLogsPerformanceMetricsCorrectly() throws Throwable {
MethodInvocation mi = mock(MethodInvocation.class);
given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[0]));
given(mi.proceed()).willThrow(new IllegalArgumentException());
Log log = mock(Log.class);
PerformanceMonitorInterceptor interceptor = new PerformanceMonitorInterceptor(true);
assertThatIllegalArgumentException().isThrownBy(() -> interceptor.invokeUnderTrace(mi, log));
verify(log).trace(anyString());
}
use of org.apache.commons.logging.Log in project spring-framework by spring-projects.
the class LoggingCacheErrorHandlerTests method handleGetCacheErrorLogsAppropriateMessage.
@Test
void handleGetCacheErrorLogsAppropriateMessage() {
Log logger = mock(Log.class);
LoggingCacheErrorHandler handler = new LoggingCacheErrorHandler(logger, false);
handler.handleCacheGetError(new RuntimeException(), new NoOpCache("NOOP"), "key");
verify(logger).warn("Cache 'NOOP' failed to get entry with key 'key'");
}
use of org.apache.commons.logging.Log in project spring-framework by spring-projects.
the class LoggingCacheErrorHandlerTests method handleClearErrorLogsAppropriateMessage.
@Test
void handleClearErrorLogsAppropriateMessage() {
Log logger = mock(Log.class);
LoggingCacheErrorHandler handler = new LoggingCacheErrorHandler(logger, false);
handler.handleCacheClearError(new RuntimeException(), new NoOpCache("NOOP"));
verify(logger).warn("Cache 'NOOP' failed to clear entries");
}
use of org.apache.commons.logging.Log in project spring-framework by spring-projects.
the class LoggingCacheErrorHandlerTests method handleCacheErrorWithStacktrace.
@Test
void handleCacheErrorWithStacktrace() {
Log logger = mock(Log.class);
LoggingCacheErrorHandler handler = new LoggingCacheErrorHandler(logger, true);
RuntimeException exception = new RuntimeException();
handler.handleCacheGetError(exception, new NoOpCache("NOOP"), "key");
verify(logger).warn("Cache 'NOOP' failed to get entry with key 'key'", exception);
}
use of org.apache.commons.logging.Log in project spring-framework by spring-projects.
the class DecoderHttpMessageReader method initLogger.
private static void initLogger(Decoder<?> decoder) {
if (decoder instanceof AbstractDecoder && decoder.getClass().getName().startsWith("org.springframework.core.codec")) {
Log logger = HttpLogging.forLog(((AbstractDecoder<?>) decoder).getLogger());
((AbstractDecoder<?>) decoder).setLogger(logger);
}
}
Aggregations