Search in sources :

Example 1 with NoOpCache

use of org.springframework.cache.support.NoOpCache 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'");
}
Also used : Log(org.apache.commons.logging.Log) NoOpCache(org.springframework.cache.support.NoOpCache) Test(org.junit.jupiter.api.Test)

Example 2 with NoOpCache

use of org.springframework.cache.support.NoOpCache 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");
}
Also used : Log(org.apache.commons.logging.Log) NoOpCache(org.springframework.cache.support.NoOpCache) Test(org.junit.jupiter.api.Test)

Example 3 with NoOpCache

use of org.springframework.cache.support.NoOpCache 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);
}
Also used : Log(org.apache.commons.logging.Log) NoOpCache(org.springframework.cache.support.NoOpCache) Test(org.junit.jupiter.api.Test)

Example 4 with NoOpCache

use of org.springframework.cache.support.NoOpCache in project spring-framework by spring-projects.

the class LoggingCacheErrorHandlerTests method handlePutCacheErrorLogsAppropriateMessage.

@Test
void handlePutCacheErrorLogsAppropriateMessage() {
    Log logger = mock(Log.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'");
}
Also used : Log(org.apache.commons.logging.Log) NoOpCache(org.springframework.cache.support.NoOpCache) Test(org.junit.jupiter.api.Test)

Example 5 with NoOpCache

use of org.springframework.cache.support.NoOpCache in project spring-framework by spring-projects.

the class LoggingCacheErrorHandlerTests method handleEvictCacheErrorLogsAppropriateMessage.

@Test
void handleEvictCacheErrorLogsAppropriateMessage() {
    Log logger = mock(Log.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'");
}
Also used : Log(org.apache.commons.logging.Log) NoOpCache(org.springframework.cache.support.NoOpCache) Test(org.junit.jupiter.api.Test)

Aggregations

Log (org.apache.commons.logging.Log)5 Test (org.junit.jupiter.api.Test)5 NoOpCache (org.springframework.cache.support.NoOpCache)5