Search in sources :

Example 1 with HazelcastCacheManager

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"));
}
Also used : HazelcastCacheManager(com.hazelcast.spring.cache.HazelcastCacheManager) Test(org.junit.Test)

Example 2 with HazelcastCacheManager

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());
}
Also used : HazelcastCacheManager(com.hazelcast.spring.cache.HazelcastCacheManager) Test(org.junit.Test)

Example 3 with HazelcastCacheManager

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");
}
Also used : HazelcastCacheManager(com.hazelcast.spring.cache.HazelcastCacheManager) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClassPathResource(org.springframework.core.io.ClassPathResource) Test(org.junit.Test)

Aggregations

HazelcastCacheManager (com.hazelcast.spring.cache.HazelcastCacheManager)3 Test (org.junit.Test)3 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 ClassPathResource (org.springframework.core.io.ClassPathResource)1