From b86241cae06c9bf293b64adbe5999282a088cd28 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 19 Jul 2016 11:35:57 +0200 Subject: [PATCH] Upgrade to Ehcache 3.1.1 Closes gh-6418 --- spring-boot-autoconfigure/pom.xml | 5 +++ .../cache/CacheAutoConfigurationTests.java | 38 ++++++++++++++++--- .../src/test/resources/ehcache3.xml | 26 +++++++++++++ spring-boot-dependencies/pom.xml | 2 +- 4 files changed, 64 insertions(+), 7 deletions(-) create mode 100644 spring-boot-autoconfigure/src/test/resources/ehcache3.xml diff --git a/spring-boot-autoconfigure/pom.xml b/spring-boot-autoconfigure/pom.xml index e51abb7c1f..00cf7eef4c 100755 --- a/spring-boot-autoconfigure/pom.xml +++ b/spring-boot-autoconfigure/pom.xml @@ -250,6 +250,11 @@ undertow-websockets-jsr true + + org.ehcache + ehcache + true + org.freemarker freemarker diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java index 5709dc6da8..959b2a17b3 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java @@ -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 ehCacheCacheManagerCustomizer() { + public CacheManagerCustomizer ehcacheCacheManagerCustomizer() { return new CacheManagerTestCustomizer() { }; } diff --git a/spring-boot-autoconfigure/src/test/resources/ehcache3.xml b/spring-boot-autoconfigure/src/test/resources/ehcache3.xml new file mode 100644 index 0000000000..12ab645b9f --- /dev/null +++ b/spring-boot-autoconfigure/src/test/resources/ehcache3.xml @@ -0,0 +1,26 @@ + + + + 200 + + + + + 600 + + + + + + + 400 + + + + \ No newline at end of file diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml index 9b02e93a66..58e609f737 100644 --- a/spring-boot-dependencies/pom.xml +++ b/spring-boot-dependencies/pom.xml @@ -69,7 +69,7 @@ 1.6.1 3.1.2 2.10.2.2.21 - 3.1.0 + 3.1.1 1.50.5 3.2.1 2.3.24-incubating