use of com.hazelcast.spring.cache.HazelcastCacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method hazelcastCacheWithExistingHazelcastInstance.
@Test
public void hazelcastCacheWithExistingHazelcastInstance() {
load(HazelcastCustomHazelcastInstance.class, "spring.cache.type=hazelcast");
HazelcastCacheManager cacheManager = validateCacheManager(HazelcastCacheManager.class);
assertThat(cacheManager.getHazelcastInstance()).isEqualTo(this.context.getBean("customHazelcastInstance"));
}
use of com.hazelcast.spring.cache.HazelcastCacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method hazelcastCacheExplicit.
@Test
public void hazelcastCacheExplicit() {
// Fail
load(new Class[] { HazelcastAutoConfiguration.class, DefaultCacheConfiguration.class }, "spring.cache.type=hazelcast");
HazelcastCacheManager cacheManager = validateCacheManager(HazelcastCacheManager.class);
// NOTE: the hazelcast implementation knows about a cache in a lazy manner.
cacheManager.getCache("defaultCache");
assertThat(cacheManager.getCacheNames()).containsOnly("defaultCache");
assertThat(this.context.getBean(HazelcastInstance.class)).isEqualTo(cacheManager.getHazelcastInstance());
}
use of com.hazelcast.spring.cache.HazelcastCacheManager in project spring-boot by spring-projects.
the class CacheAutoConfigurationTests method hazelcastCacheWithHazelcastAutoConfiguration.
@Test
public void hazelcastCacheWithHazelcastAutoConfiguration() throws IOException {
String hazelcastConfig = "org/springframework/boot/autoconfigure/hazelcast/hazelcast-specific.xml";
load(new Class[] { HazelcastAutoConfiguration.class, DefaultCacheConfiguration.class }, "spring.cache.type=hazelcast", "spring.hazelcast.config=" + hazelcastConfig);
HazelcastCacheManager cacheManager = validateCacheManager(HazelcastCacheManager.class);
HazelcastInstance hazelcastInstance = this.context.getBean(HazelcastInstance.class);
assertThat(cacheManager.getHazelcastInstance()).isSameAs(hazelcastInstance);
assertThat(hazelcastInstance.getConfig().getConfigurationFile()).isEqualTo(new ClassPathResource(hazelcastConfig).getFile());
assertThat(cacheManager.getCache("foobar")).isNotNull();
assertThat(cacheManager.getCacheNames()).containsOnly("foobar");
}
Aggregations