Search in sources :

Example 1 with CouchbaseCacheConfiguration

use of org.springframework.data.couchbase.cache.CouchbaseCacheConfiguration in project spring-boot by spring-projects.

the class CacheAutoConfigurationTests method couchbaseCacheWithCouchbaseCacheManagerBuilderCustomizer.

@Test
void couchbaseCacheWithCouchbaseCacheManagerBuilderCustomizer() {
    this.contextRunner.withUserConfiguration(CouchbaseConfiguration.class).withPropertyValues("spring.cache.type=couchbase", "spring.cache.couchbase.expiration=15s").withBean(CouchbaseCacheManagerBuilderCustomizer.class, () -> (builder) -> builder.cacheDefaults(CouchbaseCacheConfiguration.defaultCacheConfig().entryExpiry(java.time.Duration.ofSeconds(10)))).run((context) -> {
        CouchbaseCacheManager cacheManager = getCacheManager(context, CouchbaseCacheManager.class);
        CouchbaseCacheConfiguration couchbaseCacheConfiguration = getDefaultCouchbaseCacheConfiguration(cacheManager);
        assertThat(couchbaseCacheConfiguration.getExpiry()).isEqualTo(java.time.Duration.ofSeconds(10));
    });
}
Also used : CaffeineCacheManager(org.springframework.cache.caffeine.CaffeineCacheManager) SimpleCacheManager(org.springframework.cache.support.SimpleCacheManager) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RedisCacheConfiguration(org.springframework.data.redis.cache.RedisCacheConfiguration) ConcurrentMapCacheManager(org.springframework.cache.concurrent.ConcurrentMapCacheManager) BDDMockito.given(org.mockito.BDDMockito.given) MutableConfiguration(javax.cache.configuration.MutableConfiguration) MockCacheManager(org.springframework.boot.autoconfigure.cache.support.MockCachingProvider.MockCacheManager) Resource(org.springframework.core.io.Resource) CompleteConfiguration(javax.cache.configuration.CompleteConfiguration) Test(org.junit.jupiter.api.Test) BeanPostProcessor(org.springframework.beans.factory.config.BeanPostProcessor) Configuration(org.springframework.context.annotation.Configuration) List(java.util.List) CachingConfigurer(org.springframework.cache.annotation.CachingConfigurer) ConcurrentMapCache(org.springframework.cache.concurrent.ConcurrentMapCache) Hazelcast(com.hazelcast.core.Hazelcast) NoOpCacheManager(org.springframework.cache.support.NoOpCacheManager) Mockito.mock(org.mockito.Mockito.mock) CouchbaseCacheManager(org.springframework.data.couchbase.cache.CouchbaseCacheManager) Cache(org.springframework.cache.Cache) CouchbaseClientFactory(org.springframework.data.couchbase.CouchbaseClientFactory) ClassPathResource(org.springframework.core.io.ClassPathResource) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) CacheResolver(org.springframework.cache.interceptor.CacheResolver) ArrayList(java.util.ArrayList) HazelcastCacheManager(com.hazelcast.spring.cache.HazelcastCacheManager) BeanCreationException(org.springframework.beans.factory.BeanCreationException) CacheManager(org.springframework.cache.CacheManager) CaffeineCache(org.springframework.cache.caffeine.CaffeineCache) Duration(javax.cache.expiry.Duration) EnableCaching(org.springframework.cache.annotation.EnableCaching) CouchbaseCache(org.springframework.data.couchbase.cache.CouchbaseCache) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Caffeine(com.github.benmanes.caffeine.cache.Caffeine) CreatedExpiryPolicy(javax.cache.expiry.CreatedExpiryPolicy) AutoConfigurations(org.springframework.boot.autoconfigure.AutoConfigurations) Caching(javax.cache.Caching) Import(org.springframework.context.annotation.Import) RedisCacheManager(org.springframework.data.redis.cache.RedisCacheManager) ReflectionTestUtils(org.springframework.test.util.ReflectionTestUtils) RedisConnectionFactory(org.springframework.data.redis.connection.RedisConnectionFactory) CaffeineSpec(com.github.benmanes.caffeine.cache.CaffeineSpec) HazelcastAutoConfiguration(org.springframework.boot.autoconfigure.hazelcast.HazelcastAutoConfiguration) JCacheCacheManager(org.springframework.cache.jcache.JCacheCacheManager) MockCachingProvider(org.springframework.boot.autoconfigure.cache.support.MockCachingProvider) AssertableApplicationContext(org.springframework.boot.test.context.assertj.AssertableApplicationContext) Bean(org.springframework.context.annotation.Bean) CouchbaseCacheConfiguration(org.springframework.data.couchbase.cache.CouchbaseCacheConfiguration) Collections(java.util.Collections) ClassPathExclusions(org.springframework.boot.testsupport.classpath.ClassPathExclusions) CouchbaseCacheConfiguration(org.springframework.data.couchbase.cache.CouchbaseCacheConfiguration) CouchbaseCacheManager(org.springframework.data.couchbase.cache.CouchbaseCacheManager) Test(org.junit.jupiter.api.Test)

Aggregations

Caffeine (com.github.benmanes.caffeine.cache.Caffeine)1 CaffeineSpec (com.github.benmanes.caffeine.cache.CaffeineSpec)1 HazelcastServerCachingProvider (com.hazelcast.cache.impl.HazelcastServerCachingProvider)1 Hazelcast (com.hazelcast.core.Hazelcast)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 HazelcastCacheManager (com.hazelcast.spring.cache.HazelcastCacheManager)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Caching (javax.cache.Caching)1 CompleteConfiguration (javax.cache.configuration.CompleteConfiguration)1 MutableConfiguration (javax.cache.configuration.MutableConfiguration)1 CreatedExpiryPolicy (javax.cache.expiry.CreatedExpiryPolicy)1 Duration (javax.cache.expiry.Duration)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Test (org.junit.jupiter.api.Test)1 BDDMockito.given (org.mockito.BDDMockito.given)1 Mockito.mock (org.mockito.Mockito.mock)1 BeanCreationException (org.springframework.beans.factory.BeanCreationException)1 BeanPostProcessor (org.springframework.beans.factory.config.BeanPostProcessor)1