use of cn.taketoday.logging.Logger in project today-infrastructure by TAKETODAY.
the class FailFastProblemReporterTests method testWarn.
@Test
public void testWarn() throws Exception {
Problem problem = new Problem("VGER", new Location(new DescriptiveResource("here")), null, new IllegalArgumentException());
Logger log = mock(Logger.class);
FailFastProblemReporter reporter = new FailFastProblemReporter();
reporter.setLogger(log);
reporter.warning(problem);
verify(log).warn(any(), isA(IllegalArgumentException.class));
}
use of cn.taketoday.logging.Logger in project today-infrastructure 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-infrastructure 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-infrastructure by TAKETODAY.
the class LoggingCacheErrorHandlerTests method handleEvictCacheErrorLogsAppropriateMessage.
@Test
void handleEvictCacheErrorLogsAppropriateMessage() {
Logger logger = mock(Logger.class);
LoggingCacheErrorHandler handler = new LoggingCacheErrorHandler(logger, false);
handler.handleCacheEvictError(new RuntimeException(), new NoOpCache("NOOP"), "key");
verify(logger).warn("Cache 'NOOP' failed to evict entry with key 'key'");
}
use of cn.taketoday.logging.Logger in project today-infrastructure by TAKETODAY.
the class CustomizableTraceInterceptorTests method testSunnyDayPathLogsCorrectlyWithPrettyMuchAllPlaceholdersMatching.
@Test
public void testSunnyDayPathLogsCorrectlyWithPrettyMuchAllPlaceholdersMatching() throws Throwable {
MethodInvocation methodInvocation = mock(MethodInvocation.class);
given(methodInvocation.getMethod()).willReturn(String.class.getMethod("toString", new Class[0]));
given(methodInvocation.getThis()).willReturn(this);
given(methodInvocation.getArguments()).willReturn(new Object[] { "$ One \\$", 2L });
given(methodInvocation.proceed()).willReturn("Hello!");
Logger log = mock(Logger.class);
given(log.isTraceEnabled()).willReturn(true);
CustomizableTraceInterceptor interceptor = new StubCustomizableTraceInterceptor(log);
interceptor.setEnterMessage(new StringBuilder().append("Entering the '").append(CustomizableTraceInterceptor.PLACEHOLDER_METHOD_NAME).append("' method of the [").append(CustomizableTraceInterceptor.PLACEHOLDER_TARGET_CLASS_NAME).append("] class with the following args (").append(CustomizableTraceInterceptor.PLACEHOLDER_ARGUMENTS).append(") and arg types (").append(CustomizableTraceInterceptor.PLACEHOLDER_ARGUMENT_TYPES).append(").").toString());
interceptor.setExitMessage(new StringBuilder().append("Exiting the '").append(CustomizableTraceInterceptor.PLACEHOLDER_METHOD_NAME).append("' method of the [").append(CustomizableTraceInterceptor.PLACEHOLDER_TARGET_CLASS_SHORT_NAME).append("] class with the following args (").append(CustomizableTraceInterceptor.PLACEHOLDER_ARGUMENTS).append(") and arg types (").append(CustomizableTraceInterceptor.PLACEHOLDER_ARGUMENT_TYPES).append("), returning '").append(CustomizableTraceInterceptor.PLACEHOLDER_RETURN_VALUE).append("' and taking '").append(CustomizableTraceInterceptor.PLACEHOLDER_INVOCATION_TIME).append("' this long.").toString());
interceptor.invoke(methodInvocation);
verify(log, times(2)).trace(anyString());
}
Aggregations