Rename default to testCache in Cache related tests

This simply renames the default cache from "default" to "testCache" as
this might be a reserved names for third party cache providers.
This commit is contained in:
Stephane Nicoll
2014-07-16 17:22:24 +02:00
parent bbfc31b11f
commit 35226695eb
16 changed files with 126 additions and 127 deletions

View File

@@ -27,7 +27,7 @@ import org.springframework.cache.annotation.Caching;
* @author Costin Leau
* @author Phillip Webb
*/
@Cacheable("default")
@Cacheable("testCache")
public class AnnotatedClassCacheableService implements CacheableService<Object> {
private final AtomicLong counter = new AtomicLong();
@@ -49,94 +49,94 @@ public class AnnotatedClassCacheableService implements CacheableService<Object>
}
@Override
@CacheEvict("default")
@CacheEvict("testCache")
public void invalidate(Object arg1) {
}
@Override
@CacheEvict("default")
@CacheEvict("testCache")
public void evictWithException(Object arg1) {
throw new RuntimeException("exception thrown - evict should NOT occur");
}
@Override
@CacheEvict(value = "default", allEntries = true)
@CacheEvict(value = "testCache", allEntries = true)
public void evictAll(Object arg1) {
}
@Override
@CacheEvict(value = "default", beforeInvocation = true)
@CacheEvict(value = "testCache", beforeInvocation = true)
public void evictEarly(Object arg1) {
throw new RuntimeException("exception thrown - evict should still occur");
}
@Override
@CacheEvict(value = "default", key = "#p0")
@CacheEvict(value = "testCache", key = "#p0")
public void evict(Object arg1, Object arg2) {
}
@Override
@CacheEvict(value = "default", key = "#p0", beforeInvocation = true)
@CacheEvict(value = "testCache", key = "#p0", beforeInvocation = true)
public void invalidateEarly(Object arg1, Object arg2) {
throw new RuntimeException("exception thrown - evict should still occur");
}
@Override
@Cacheable(value = "default", key = "#p0")
@Cacheable(value = "testCache", key = "#p0")
public Object key(Object arg1, Object arg2) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default")
@Cacheable(value = "testCache")
public Object varArgsKey(Object... args) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", key = "#root.methodName + #root.caches[0].name")
@Cacheable(value = "testCache", key = "#root.methodName + #root.caches[0].name")
public Object name(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", key = "#root.methodName + #root.method.name + #root.targetClass + #root.target")
@Cacheable(value = "testCache", key = "#root.methodName + #root.method.name + #root.targetClass + #root.target")
public Object rootVars(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", keyGenerator = "customKyeGenerator")
@Cacheable(value = "testCache", keyGenerator = "customKyeGenerator")
public Object customKeyGenerator(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", keyGenerator = "unknownBeanName")
@Cacheable(value = "testCache", keyGenerator = "unknownBeanName")
public Object unknownCustomKeyGenerator(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", cacheManager = "customCacheManager")
@Cacheable(value = "testCache", cacheManager = "customCacheManager")
public Object customCacheManager(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", cacheManager = "unknownBeanName")
@Cacheable(value = "testCache", cacheManager = "unknownBeanName")
public Object unknownCustomCacheManager(Object arg1) {
return counter.getAndIncrement();
}
@Override
@CachePut("default")
@CachePut("testCache")
public Object update(Object arg1) {
return counter.getAndIncrement();
}
@Override
@CachePut(value = "default", condition = "#arg.equals(3)")
@CachePut(value = "testCache", condition = "#arg.equals(3)")
public Object conditionalUpdate(Object arg) {
return arg;
}

View File

@@ -35,118 +35,118 @@ public class DefaultCacheableService implements CacheableService<Long> {
private final AtomicLong nullInvocations = new AtomicLong();
@Override
@Cacheable("default")
@Cacheable("testCache")
public Long cache(Object arg1) {
return counter.getAndIncrement();
}
@Override
@CacheEvict("default")
@CacheEvict("testCache")
public void invalidate(Object arg1) {
}
@Override
@CacheEvict("default")
@CacheEvict("testCache")
public void evictWithException(Object arg1) {
throw new RuntimeException("exception thrown - evict should NOT occur");
}
@Override
@CacheEvict(value = "default", allEntries = true)
@CacheEvict(value = "testCache", allEntries = true)
public void evictAll(Object arg1) {
}
@Override
@CacheEvict(value = "default", beforeInvocation = true)
@CacheEvict(value = "testCache", beforeInvocation = true)
public void evictEarly(Object arg1) {
throw new RuntimeException("exception thrown - evict should still occur");
}
@Override
@CacheEvict(value = "default", key = "#p0")
@CacheEvict(value = "testCache", key = "#p0")
public void evict(Object arg1, Object arg2) {
}
@Override
@CacheEvict(value = "default", key = "#p0", beforeInvocation = true)
@CacheEvict(value = "testCache", key = "#p0", beforeInvocation = true)
public void invalidateEarly(Object arg1, Object arg2) {
throw new RuntimeException("exception thrown - evict should still occur");
}
@Override
@Cacheable(value = "default", condition = "#classField == 3")
@Cacheable(value = "testCache", condition = "#classField == 3")
public Long conditional(int classField) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", unless = "#result > 10")
@Cacheable(value = "testCache", unless = "#result > 10")
public Long unless(int arg) {
return (long) arg;
}
@Override
@Cacheable(value = "default", key = "#p0")
@Cacheable(value = "testCache", key = "#p0")
public Long key(Object arg1, Object arg2) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default")
@Cacheable(value = "testCache")
public Long varArgsKey(Object... args) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", key = "#root.methodName")
@Cacheable(value = "testCache", key = "#root.methodName")
public Long name(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", key = "#root.methodName + #root.method.name + #root.targetClass + #root.target")
@Cacheable(value = "testCache", key = "#root.methodName + #root.method.name + #root.targetClass + #root.target")
public Long rootVars(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", keyGenerator = "customKeyGenerator")
@Cacheable(value = "testCache", keyGenerator = "customKeyGenerator")
public Long customKeyGenerator(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", keyGenerator = "unknownBeanName")
@Cacheable(value = "testCache", keyGenerator = "unknownBeanName")
public Long unknownCustomKeyGenerator(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", cacheManager = "customCacheManager")
@Cacheable(value = "testCache", cacheManager = "customCacheManager")
public Long customCacheManager(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", cacheManager = "unknownBeanName")
@Cacheable(value = "testCache", cacheManager = "unknownBeanName")
public Long unknownCustomCacheManager(Object arg1) {
return counter.getAndIncrement();
}
@Override
@CachePut("default")
@CachePut("testCache")
public Long update(Object arg1) {
return counter.getAndIncrement();
}
@Override
@CachePut(value = "default", condition = "#arg.equals(3)")
@CachePut(value = "testCache", condition = "#arg.equals(3)")
public Long conditionalUpdate(Object arg) {
return Long.valueOf(arg.toString());
}
@Override
@Cacheable("default")
@Cacheable("testCache")
public Long nullValue(Object arg1) {
nullInvocations.incrementAndGet();
return null;
@@ -158,13 +158,13 @@ public class DefaultCacheableService implements CacheableService<Long> {
}
@Override
@Cacheable("default")
@Cacheable("testCache")
public Long throwChecked(Object arg1) throws Exception {
throw new Exception(arg1.toString());
}
@Override
@Cacheable("default")
@Cacheable("testCache")
public Long throwUnchecked(Object arg1) {
throw new UnsupportedOperationException(arg1.toString());
}

View File

@@ -28,7 +28,7 @@
<property name="caches">
<set>
<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean">
<property name="name" value="default"/>
<property name="name" value="testCache"/>
</bean>
<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean">
<property name="name" value="primary"/>
@@ -46,7 +46,7 @@
<property name="caches">
<set>
<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean">
<property name="name" value="default"/>
<property name="name" value="testCache"/>
</bean>
</set>
</property>