Search in sources :

Example 11 with ConcurrentMapCacheManager

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

the class CacheAutoConfigurationTests method cacheManagerBackOff.

@Test
public void cacheManagerBackOff() {
    load(CustomCacheManagerConfiguration.class);
    ConcurrentMapCacheManager cacheManager = validateCacheManager(ConcurrentMapCacheManager.class);
    assertThat(cacheManager.getCacheNames()).containsOnly("custom1");
}
Also used : ConcurrentMapCacheManager(org.springframework.cache.concurrent.ConcurrentMapCacheManager) Test(org.junit.Test)

Example 12 with ConcurrentMapCacheManager

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

the class SpringCacheBasedUserCacheTests method initCacheManaer.

@BeforeAll
public static void initCacheManaer() {
    cacheManager = new ConcurrentMapCacheManager();
    cacheManager.getCache("springbasedusercachetests");
}
Also used : ConcurrentMapCacheManager(org.springframework.cache.concurrent.ConcurrentMapCacheManager) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 13 with ConcurrentMapCacheManager

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

the class CacheManagerCustomizersTests method customizeSimpleCacheManager.

@Test
void customizeSimpleCacheManager() {
    CacheManagerCustomizers customizers = new CacheManagerCustomizers(Collections.singletonList(new CacheNamesCacheManagerCustomizer()));
    ConcurrentMapCacheManager cacheManager = new ConcurrentMapCacheManager();
    customizers.customize(cacheManager);
    assertThat(cacheManager.getCacheNames()).containsOnly("one", "two");
}
Also used : ConcurrentMapCacheManager(org.springframework.cache.concurrent.ConcurrentMapCacheManager) Test(org.junit.jupiter.api.Test)

Example 14 with ConcurrentMapCacheManager

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

the class CacheAutoConfigurationTests method simpleCacheExplicitWithCacheNames.

@Test
void simpleCacheExplicitWithCacheNames() {
    this.contextRunner.withUserConfiguration(DefaultCacheConfiguration.class).withPropertyValues("spring.cache.type=simple", "spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar").run((context) -> {
        ConcurrentMapCacheManager cacheManager = getCacheManager(context, ConcurrentMapCacheManager.class);
        assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
    });
}
Also used : ConcurrentMapCacheManager(org.springframework.cache.concurrent.ConcurrentMapCacheManager) Test(org.junit.jupiter.api.Test)

Example 15 with ConcurrentMapCacheManager

use of org.springframework.cache.concurrent.ConcurrentMapCacheManager 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)

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