use of cn.taketoday.logging.Logger in project today-framework by TAKETODAY.
the class PerformanceMonitorInterceptorTests method testSunnyDayPathLogsPerformanceMetricsCorrectly.
@Test
public void testSunnyDayPathLogsPerformanceMetricsCorrectly() throws Throwable {
MethodInvocation mi = mock(MethodInvocation.class);
given(mi.getMethod()).willReturn(String.class.getMethod("toString", new Class[0]));
Logger log = mock(Logger.class);
PerformanceMonitorInterceptor interceptor = new PerformanceMonitorInterceptor(true);
interceptor.invokeUnderTrace(mi, log);
verify(log).trace(anyString());
}
use of cn.taketoday.logging.Logger in project today-framework by TAKETODAY.
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());
Logger log = mock(Logger.class);
PerformanceMonitorInterceptor interceptor = new PerformanceMonitorInterceptor(true);
assertThatIllegalArgumentException().isThrownBy(() -> interceptor.invokeUnderTrace(mi, log));
verify(log).trace(anyString());
}
use of cn.taketoday.logging.Logger in project today-framework by TAKETODAY.
the class LoggingCacheErrorHandlerTests method handleClearErrorLogsAppropriateMessage.
@Test
void handleClearErrorLogsAppropriateMessage() {
Logger logger = mock(Logger.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 cn.taketoday.logging.Logger in project today-framework by TAKETODAY.
the class LoggingCacheErrorHandlerTests method handleCacheErrorWithStacktrace.
@Test
void handleCacheErrorWithStacktrace() {
Logger logger = mock(Logger.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 cn.taketoday.logging.Logger in project today-framework by TAKETODAY.
the class LoggingCacheErrorHandlerTests method handlePutCacheErrorLogsAppropriateMessage.
@Test
void handlePutCacheErrorLogsAppropriateMessage() {
Logger logger = mock(Logger.class);
LoggingCacheErrorHandler handler = new LoggingCacheErrorHandler(logger, false);
handler.handleCachePutError(new RuntimeException(), new NoOpCache("NOOP"), "key", new Object());
verify(logger).warn("Cache 'NOOP' failed to put entry with key 'key'");
}
Aggregations