use of cn.taketoday.logging.Logger in project today-framework 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-framework 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-framework by TAKETODAY.
the class LoggingCacheErrorHandlerTests method handleGetCacheErrorLogsAppropriateMessage.
@Test
void handleGetCacheErrorLogsAppropriateMessage() {
Logger logger = mock(Logger.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 cn.taketoday.logging.Logger in project today-framework by TAKETODAY.
the class LambdaSafeTests method callbackWithLoggerShouldUseLogger.
@Test
@SuppressWarnings("unchecked")
void callbackWithLoggerShouldUseLogger() {
Logger logger = mock(Logger.class);
given(logger.isDebugEnabled()).willReturn(true);
GenericCallback<StringBuilder> callbackInstance = (s) -> fail("Should not get here");
String argument = "foo";
LambdaSafe.callback(GenericCallback.class, callbackInstance, argument).withLogger(logger).invoke((c) -> c.handle(argument));
verify(logger).debug(contains("Non-matching CharSequence type for callback LambdaSafeTests.GenericCallback"), any(Throwable.class));
}
use of cn.taketoday.logging.Logger in project today-framework by TAKETODAY.
the class ResourceHttpMessageWriter method writeResource.
private Mono<Void> writeResource(Resource resource, ResolvableType type, @Nullable MediaType mediaType, ReactiveHttpOutputMessage message, Map<String, Object> hints) {
HttpHeaders headers = message.getHeaders();
MediaType resourceMediaType = getResourceMediaType(mediaType, resource, hints);
headers.setContentType(resourceMediaType);
if (headers.getContentLength() < 0) {
long length = lengthOf(resource);
if (length != -1) {
headers.setContentLength(length);
}
}
return zeroCopy(resource, null, message, hints).orElseGet(() -> {
Mono<Resource> input = Mono.just(resource);
DataBufferFactory factory = message.bufferFactory();
Flux<DataBuffer> body = this.encoder.encode(input, factory, type, resourceMediaType, hints);
if (logger.isDebugEnabled()) {
body = body.doOnNext(buffer -> Hints.touchDataBuffer(buffer, hints, logger));
}
return message.writeWith(body);
});
}
Aggregations