コード例 #1
0
 @Test
 public void hazelcastCacheExplicit() {
   load(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(), containsInAnyOrder("defaultCache"));
   assertThat(cacheManager.getCacheNames(), hasSize(1));
   assertThat(
       this.context.getBean(HazelcastInstance.class), equalTo(getHazelcastInstance(cacheManager)));
 }
コード例 #2
0
 @Test
 public void hazelcastCacheWithConfig() throws IOException {
   load(
       DefaultCacheConfiguration.class,
       "spring.cache.type=hazelcast",
       "spring.cache.hazelcast.config=org/springframework/boot/autoconfigure/cache/hazelcast-specific.xml");
   HazelcastInstance hazelcastInstance = this.context.getBean(HazelcastInstance.class);
   HazelcastCacheManager cacheManager = validateCacheManager(HazelcastCacheManager.class);
   HazelcastInstance actual = getHazelcastInstance(cacheManager);
   assertThat(actual, sameInstance(hazelcastInstance));
   assertThat(
       actual.getConfig().getConfigurationUrl(),
       equalTo(
           new ClassPathResource(
                   "org/springframework/boot/autoconfigure/cache/hazelcast-specific.xml")
               .getURL()));
   cacheManager.getCache("foobar");
   assertThat(cacheManager.getCacheNames(), containsInAnyOrder("foobar"));
   assertThat(cacheManager.getCacheNames(), hasSize(1));
 }