Commit ad57d99f authored by Stephane Nicoll's avatar Stephane Nicoll

Cleanup HazelcastInstance in test

If a JCache provider is started with hazelcast and the default settings,
the underlying `HazelcastInstance` is disposed at the end of the
process, not when the `CacheManager` is closed.

This commit fixes the only test that use such setup.

See also https://github.com/hazelcast/hazelcast/issues/7606

Closes gh-5209
parent 5d1ee87e
...@@ -24,6 +24,7 @@ import java.util.Collections; ...@@ -24,6 +24,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.cache.Caching;
import javax.cache.configuration.CompleteConfiguration; import javax.cache.configuration.CompleteConfiguration;
import javax.cache.configuration.MutableConfiguration; import javax.cache.configuration.MutableConfiguration;
import javax.cache.expiry.CreatedExpiryPolicy; import javax.cache.expiry.CreatedExpiryPolicy;
...@@ -468,12 +469,17 @@ public class CacheAutoConfigurationTests { ...@@ -468,12 +469,17 @@ public class CacheAutoConfigurationTests {
@Test @Test
public void hazelcastAsJCacheWithCaches() { public void hazelcastAsJCacheWithCaches() {
String cachingProviderFqn = HazelcastCachingProvider.class.getName(); String cachingProviderFqn = HazelcastCachingProvider.class.getName();
load(DefaultCacheConfiguration.class, "spring.cache.type=jcache", try {
"spring.cache.jcache.provider=" + cachingProviderFqn, load(DefaultCacheConfiguration.class, "spring.cache.type=jcache",
"spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar"); "spring.cache.jcache.provider=" + cachingProviderFqn,
JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class); "spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar");
assertThat(cacheManager.getCacheNames(), containsInAnyOrder("foo", "bar")); JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);
assertThat(cacheManager.getCacheNames(), hasSize(2)); assertThat(cacheManager.getCacheNames(), containsInAnyOrder("foo", "bar"));
assertThat(cacheManager.getCacheNames(), hasSize(2));
}
finally {
Caching.getCachingProvider(cachingProviderFqn).close();
}
} }
@Test @Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment