Search in sources :

Example 16 with ConcurrentMapCacheManager

use of org.springframework.cache.concurrent.ConcurrentMapCacheManager in project spring-boot by spring-projects.

the class CachesEndpointTests method namedCacheWithSeveralCacheManagersWithCacheManagerFilter.

@Test
void namedCacheWithSeveralCacheManagersWithCacheManagerFilter() {
    Map<String, CacheManager> cacheManagers = new LinkedHashMap<>();
    cacheManagers.put("test", new ConcurrentMapCacheManager("b", "a"));
    cacheManagers.put("another", new ConcurrentMapCacheManager("c", "a"));
    CachesEndpoint endpoint = new CachesEndpoint(cacheManagers);
    CacheEntry entry = endpoint.cache("a", "test");
    assertThat(entry).isNotNull();
    assertThat(entry.getCacheManager()).isEqualTo("test");
    assertThat(entry.getName()).isEqualTo("a");
}
Also used : ConcurrentMapCacheManager(org.springframework.cache.concurrent.ConcurrentMapCacheManager) SimpleCacheManager(org.springframework.cache.support.SimpleCacheManager) ConcurrentMapCacheManager(org.springframework.cache.concurrent.ConcurrentMapCacheManager) CacheManager(org.springframework.cache.CacheManager) CacheEntry(org.springframework.boot.actuate.cache.CachesEndpoint.CacheEntry) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.jupiter.api.Test)

Example 17 with ConcurrentMapCacheManager

use of org.springframework.cache.concurrent.ConcurrentMapCacheManager in project spring-boot by spring-projects.

the class CachesEndpointTests method namedCacheWithWrongCacheManager.

@Test
void namedCacheWithWrongCacheManager() {
    Map<String, CacheManager> cacheManagers = new LinkedHashMap<>();
    cacheManagers.put("test", new ConcurrentMapCacheManager("b", "a"));
    cacheManagers.put("another", new ConcurrentMapCacheManager("c", "a"));
    CachesEndpoint endpoint = new CachesEndpoint(cacheManagers);
    CacheEntry entry = endpoint.cache("c", "test");
    assertThat(entry).isNull();
}
Also used : ConcurrentMapCacheManager(org.springframework.cache.concurrent.ConcurrentMapCacheManager) SimpleCacheManager(org.springframework.cache.support.SimpleCacheManager) ConcurrentMapCacheManager(org.springframework.cache.concurrent.ConcurrentMapCacheManager) CacheManager(org.springframework.cache.CacheManager) CacheEntry(org.springframework.boot.actuate.cache.CachesEndpoint.CacheEntry) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.jupiter.api.Test)

Aggregations

ConcurrentMapCacheManager (org.springframework.cache.concurrent.ConcurrentMapCacheManager)17 Test (org.junit.jupiter.api.Test)9 LinkedHashMap (java.util.LinkedHashMap)4 CacheEntry (org.springframework.boot.actuate.cache.CachesEndpoint.CacheEntry)4 CacheManager (org.springframework.cache.CacheManager)4 SimpleCacheManager (org.springframework.cache.support.SimpleCacheManager)4 Test (org.junit.Test)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 CacheManagerDescriptor (org.springframework.boot.actuate.cache.CachesEndpoint.CacheManagerDescriptor)2 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)2 Bean (org.springframework.context.annotation.Bean)2 BeforeClass (org.junit.BeforeClass)1