Commit b86241ca authored by Stephane Nicoll's avatar Stephane Nicoll

Upgrade to Ehcache 3.1.1

Closes gh-6418
parent a6f443a9
......@@ -250,6 +250,11 @@
<artifactId>undertow-websockets-jsr</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
......
......@@ -41,6 +41,7 @@ import com.hazelcast.cache.HazelcastCachingProvider;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.spring.cache.HazelcastCacheManager;
import net.sf.ehcache.Status;
import org.ehcache.jsr107.EhcacheCachingProvider;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.jcache.embedded.JCachingProvider;
import org.infinispan.spring.provider.SpringEmbeddedCacheManager;
......@@ -372,7 +373,7 @@ public class CacheAutoConfigurationTests {
}
@Test
public void ehCacheCacheWithCaches() {
public void ehcacheCacheWithCaches() {
load(DefaultCacheConfiguration.class, "spring.cache.type=ehcache");
EhCacheCacheManager cacheManager = validateCacheManager(
EhCacheCacheManager.class);
......@@ -382,13 +383,13 @@ public class CacheAutoConfigurationTests {
}
@Test
public void ehCacheCacheWithCustomizers() {
public void ehcacheCacheWithCustomizers() {
testCustomizers(DefaultCacheAndCustomizersConfiguration.class, "ehcache",
"allCacheManagerCustomizer", "ehCacheCacheManagerCustomizer");
"allCacheManagerCustomizer", "ehcacheCacheManagerCustomizer");
}
@Test
public void ehCacheCacheWithConfig() {
public void ehcacheCacheWithConfig() {
load(DefaultCacheConfiguration.class, "spring.cache.type=ehcache",
"spring.cache.ehcache.config=cache/ehcache-override.xml");
EhCacheCacheManager cacheManager = validateCacheManager(
......@@ -398,7 +399,7 @@ public class CacheAutoConfigurationTests {
}
@Test
public void ehCacheCacheWithExistingCacheManager() {
public void ehcacheCacheWithExistingCacheManager() {
load(EhCacheCustomCacheManager.class, "spring.cache.type=ehcache");
EhCacheCacheManager cacheManager = validateCacheManager(
EhCacheCacheManager.class);
......@@ -406,6 +407,31 @@ public class CacheAutoConfigurationTests {
.isEqualTo(this.context.getBean("customEhCacheCacheManager"));
}
@Test
public void ehcache3AsJCacheWithCaches() {
String cachingProviderFqn = EhcacheCachingProvider.class.getName();
load(DefaultCacheConfiguration.class, "spring.cache.type=jcache",
"spring.cache.jcache.provider=" + cachingProviderFqn,
"spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar");
JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);
assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
}
@Test
public void ehcache3AsJCacheWithConfig() throws IOException {
String cachingProviderFqn = EhcacheCachingProvider.class.getName();
String configLocation = "ehcache3.xml";
load(DefaultCacheConfiguration.class, "spring.cache.type=jcache",
"spring.cache.jcache.provider=" + cachingProviderFqn,
"spring.cache.jcache.config=" + configLocation);
JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);
Resource configResource = new ClassPathResource(configLocation);
assertThat(cacheManager.getCacheManager().getURI())
.isEqualTo(configResource.getURI());
assertThat(cacheManager.getCacheNames()).containsOnly("foo", "bar");
}
@Test
public void hazelcastCacheExplicit() {
load(DefaultCacheConfiguration.class, "spring.cache.type=hazelcast");
......@@ -1036,7 +1062,7 @@ public class CacheAutoConfigurationTests {
}
@Bean
public CacheManagerCustomizer<EhCacheCacheManager> ehCacheCacheManagerCustomizer() {
public CacheManagerCustomizer<EhCacheCacheManager> ehcacheCacheManagerCustomizer() {
return new CacheManagerTestCustomizer<EhCacheCacheManager>() {
};
}
......
<config
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://www.ehcache.org/v3'
xmlns:jsr107='http://www.ehcache.org/v3/jsr107'
xsi:schemaLocation="
http://www.ehcache.org/v3 http://www.ehcache.org/schema/ehcache-core-3.1.xsd
http://www.ehcache.org/v3/jsr107 http://www.ehcache.org/schema/ehcache-107-ext-3.1.xsd">
<cache-template name="example">
<heap unit="entries">200</heap>
</cache-template>
<cache alias="foo" uses-template="example">
<expiry>
<ttl unit="seconds">600</ttl>
</expiry>
<jsr107:mbeans enable-statistics="true"/>
</cache>
<cache alias="bar" uses-template="example">
<expiry>
<ttl unit="seconds">400</ttl>
</expiry>
</cache>
</config>
\ No newline at end of file
......@@ -69,7 +69,7 @@
<dom4j.version>1.6.1</dom4j.version>
<dropwizard-metrics.version>3.1.2</dropwizard-metrics.version>
<ehcache.version>2.10.2.2.21</ehcache.version>
<ehcache3.version>3.1.0</ehcache3.version>
<ehcache3.version>3.1.1</ehcache3.version>
<embedded-mongo.version>1.50.5</embedded-mongo.version>
<flyway.version>3.2.1</flyway.version>
<freemarker.version>2.3.24-incubating</freemarker.version>
......
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