Search in sources :

Example 1 with CacheManagerDescriptor

use of org.springframework.boot.actuate.cache.CachesEndpoint.CacheManagerDescriptor in project spring-boot by spring-projects.

the class CachesEndpointTests method allCachesWithSingleCacheManager.

@Test
void allCachesWithSingleCacheManager() {
    CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test", new ConcurrentMapCacheManager("a", "b")));
    Map<String, CacheManagerDescriptor> allDescriptors = endpoint.caches().getCacheManagers();
    assertThat(allDescriptors).containsOnlyKeys("test");
    CacheManagerDescriptor descriptors = allDescriptors.get("test");
    assertThat(descriptors.getCaches()).containsOnlyKeys("a", "b");
    assertThat(descriptors.getCaches().get("a").getTarget()).isEqualTo(ConcurrentHashMap.class.getName());
    assertThat(descriptors.getCaches().get("b").getTarget()).isEqualTo(ConcurrentHashMap.class.getName());
}
Also used : CacheManagerDescriptor(org.springframework.boot.actuate.cache.CachesEndpoint.CacheManagerDescriptor) ConcurrentMapCacheManager(org.springframework.cache.concurrent.ConcurrentMapCacheManager) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Test(org.junit.jupiter.api.Test)

Example 2 with CacheManagerDescriptor

use of org.springframework.boot.actuate.cache.CachesEndpoint.CacheManagerDescriptor in project spring-boot by spring-projects.

the class CachesEndpointTests method allCachesWithSeveralCacheManagers.

@Test
void allCachesWithSeveralCacheManagers() {
    Map<String, CacheManager> cacheManagers = new LinkedHashMap<>();
    cacheManagers.put("test", new ConcurrentMapCacheManager("a", "b"));
    cacheManagers.put("another", new ConcurrentMapCacheManager("a", "c"));
    CachesEndpoint endpoint = new CachesEndpoint(cacheManagers);
    Map<String, CacheManagerDescriptor> allDescriptors = endpoint.caches().getCacheManagers();
    assertThat(allDescriptors).containsOnlyKeys("test", "another");
    assertThat(allDescriptors.get("test").getCaches()).containsOnlyKeys("a", "b");
    assertThat(allDescriptors.get("another").getCaches()).containsOnlyKeys("a", "c");
}
Also used : CacheManagerDescriptor(org.springframework.boot.actuate.cache.CachesEndpoint.CacheManagerDescriptor) ConcurrentMapCacheManager(org.springframework.cache.concurrent.ConcurrentMapCacheManager) SimpleCacheManager(org.springframework.cache.support.SimpleCacheManager) ConcurrentMapCacheManager(org.springframework.cache.concurrent.ConcurrentMapCacheManager) CacheManager(org.springframework.cache.CacheManager) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 CacheManagerDescriptor (org.springframework.boot.actuate.cache.CachesEndpoint.CacheManagerDescriptor)2 ConcurrentMapCacheManager (org.springframework.cache.concurrent.ConcurrentMapCacheManager)2 LinkedHashMap (java.util.LinkedHashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CacheManager (org.springframework.cache.CacheManager)1 SimpleCacheManager (org.springframework.cache.support.SimpleCacheManager)1