Search in sources :

Example 1 with CacheEntry

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

the class CachesEndpointTests method namedCacheWithUnknownCache.

@Test
void namedCacheWithUnknownCache() {
    CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test", new ConcurrentMapCacheManager("b", "a")));
    CacheEntry entry = endpoint.cache("unknown", null);
    assertThat(entry).isNull();
}
Also used : ConcurrentMapCacheManager(org.springframework.cache.concurrent.ConcurrentMapCacheManager) CacheEntry(org.springframework.boot.actuate.cache.CachesEndpoint.CacheEntry) Test(org.junit.jupiter.api.Test)

Example 2 with CacheEntry

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

the class CachesEndpointWebExtension method cache.

@ReadOperation
public WebEndpointResponse<CacheEntry> cache(@Selector String cache, @Nullable String cacheManager) {
    try {
        CacheEntry entry = this.delegate.cache(cache, cacheManager);
        int status = (entry != null) ? WebEndpointResponse.STATUS_OK : WebEndpointResponse.STATUS_NOT_FOUND;
        return new WebEndpointResponse<>(entry, status);
    } catch (NonUniqueCacheException ex) {
        return new WebEndpointResponse<>(WebEndpointResponse.STATUS_BAD_REQUEST);
    }
}
Also used : WebEndpointResponse(org.springframework.boot.actuate.endpoint.web.WebEndpointResponse) CacheEntry(org.springframework.boot.actuate.cache.CachesEndpoint.CacheEntry) ReadOperation(org.springframework.boot.actuate.endpoint.annotation.ReadOperation)

Example 3 with CacheEntry

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

the class CachesEndpointTests method namedCacheWithSingleCacheManager.

@Test
void namedCacheWithSingleCacheManager() {
    CachesEndpoint endpoint = new CachesEndpoint(Collections.singletonMap("test", new ConcurrentMapCacheManager("b", "a")));
    CacheEntry entry = endpoint.cache("a", null);
    assertThat(entry).isNotNull();
    assertThat(entry.getCacheManager()).isEqualTo("test");
    assertThat(entry.getName()).isEqualTo("a");
    assertThat(entry.getTarget()).isEqualTo(ConcurrentHashMap.class.getName());
}
Also used : ConcurrentMapCacheManager(org.springframework.cache.concurrent.ConcurrentMapCacheManager) CacheEntry(org.springframework.boot.actuate.cache.CachesEndpoint.CacheEntry) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Test(org.junit.jupiter.api.Test)

Example 4 with CacheEntry

use of org.springframework.boot.actuate.cache.CachesEndpoint.CacheEntry 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 5 with CacheEntry

use of org.springframework.boot.actuate.cache.CachesEndpoint.CacheEntry 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

CacheEntry (org.springframework.boot.actuate.cache.CachesEndpoint.CacheEntry)5 Test (org.junit.jupiter.api.Test)4 ConcurrentMapCacheManager (org.springframework.cache.concurrent.ConcurrentMapCacheManager)4 LinkedHashMap (java.util.LinkedHashMap)2 CacheManager (org.springframework.cache.CacheManager)2 SimpleCacheManager (org.springframework.cache.support.SimpleCacheManager)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ReadOperation (org.springframework.boot.actuate.endpoint.annotation.ReadOperation)1 WebEndpointResponse (org.springframework.boot.actuate.endpoint.web.WebEndpointResponse)1