Search in sources :

Example 1 with MockCacheManager

use of org.springframework.boot.autoconfigure.cache.support.MockCachingProvider.MockCacheManager in project spring-boot by spring-projects.

the class CacheAutoConfigurationTests method jCacheCacheWithCachesAndCustomConfig.

@Test
void jCacheCacheWithCachesAndCustomConfig() {
    String cachingProviderFqn = MockCachingProvider.class.getName();
    this.contextRunner.withUserConfiguration(JCacheCustomConfiguration.class).withPropertyValues("spring.cache.type=jcache", "spring.cache.jcache.provider=" + cachingProviderFqn, "spring.cache.cacheNames[0]=one", "spring.cache.cacheNames[1]=two").run((context) -> {
        JCacheCacheManager cacheManager = getCacheManager(context, JCacheCacheManager.class);
        assertThat(cacheManager.getCacheNames()).containsOnly("one", "two");
        CompleteConfiguration<?, ?> defaultCacheConfiguration = context.getBean(CompleteConfiguration.class);
        MockCacheManager mockCacheManager = (MockCacheManager) cacheManager.getCacheManager();
        assertThat(mockCacheManager.getConfigurations()).containsEntry("one", defaultCacheConfiguration).containsEntry("two", defaultCacheConfiguration);
    });
}
Also used : MockCacheManager(org.springframework.boot.autoconfigure.cache.support.MockCachingProvider.MockCacheManager) JCacheCacheManager(org.springframework.cache.jcache.JCacheCacheManager) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 MockCacheManager (org.springframework.boot.autoconfigure.cache.support.MockCachingProvider.MockCacheManager)1 JCacheCacheManager (org.springframework.cache.jcache.JCacheCacheManager)1