Spring's EhCache setup builds on EhCache 2.1+ now

Specifically, EhCacheFactoryBean extends CacheConfiguration now and therefore inherits all configuration properties of the underlying EhCache version. This reduces the need for catching up with new EhCache properties on our side.

Issue: SPR-8258
This commit is contained in:
Juergen Hoeller
2013-03-19 23:08:05 +01:00
parent e3fe9b1171
commit f2b79c80b0
3 changed files with 38 additions and 173 deletions

View File

@@ -79,7 +79,7 @@ public class EhCacheSupportTests extends TestCase {
}
private void doTestEhCacheFactoryBean(boolean useCacheManagerFb) throws Exception {
Cache cache = null;
Cache cache;
EhCacheManagerFactoryBean cacheManagerFb = null;
try {
EhCacheFactoryBean cacheFb = new EhCacheFactoryBean();
@@ -118,11 +118,9 @@ public class EhCacheSupportTests extends TestCase {
config = cache.getCacheConfiguration();
assertEquals("undefinedCache", cache.getName());
assertTrue("default maxElements is correct", config.getMaxElementsInMemory() == 10000);
assertTrue("default overflowToDisk is correct", config.isOverflowToDisk());
assertFalse("default eternal is correct", config.isEternal());
assertTrue("default timeToLive is correct", config.getTimeToLiveSeconds() == 120);
assertTrue("default timeToIdle is correct", config.getTimeToIdleSeconds() == 120);
assertTrue("default diskPersistent is correct", !config.isDiskPersistent());
assertTrue("default diskExpiryThreadIntervalSeconds is correct", config.getDiskExpiryThreadIntervalSeconds() == 120);
// overriding the default properties
@@ -132,10 +130,8 @@ public class EhCacheSupportTests extends TestCase {
}
cacheFb.setBeanName("undefinedCache2");
cacheFb.setMaxElementsInMemory(5);
cacheFb.setOverflowToDisk(false);
cacheFb.setTimeToLive(8);
cacheFb.setTimeToIdle(7);
cacheFb.setDiskPersistent(true);
cacheFb.setDiskExpiryThreadIntervalSeconds(10);
cacheFb.afterPropertiesSet();
cache = (Cache) cacheFb.getObject();
@@ -143,10 +139,8 @@ public class EhCacheSupportTests extends TestCase {
assertEquals("undefinedCache2", cache.getName());
assertTrue("overridden maxElements is correct", config.getMaxElementsInMemory() == 5);
assertFalse("overridden overflowToDisk is correct", config.isOverflowToDisk());
assertTrue("default timeToLive is correct", config.getTimeToLiveSeconds() == 8);
assertTrue("default timeToIdle is correct", config.getTimeToIdleSeconds() == 7);
assertTrue("overridden diskPersistent is correct", config.isDiskPersistent());
assertTrue("overridden diskExpiryThreadIntervalSeconds is correct", config.getDiskExpiryThreadIntervalSeconds() == 10);
}
finally {