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:
		
							parent
							
								
									bbfc31b11f
								
							
						
					
					
						commit
						35226695eb
					
				|  | @ -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; | ||||
| 	} | ||||
|  |  | |||
|  | @ -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()); | ||||
| 	} | ||||
|  |  | |||
|  | @ -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> | ||||
|  |  | |||
|  | @ -49,8 +49,6 @@ public abstract class AbstractAnnotationTests { | |||
| 
 | ||||
| 	protected CacheManager cm; | ||||
| 
 | ||||
| 	protected CacheManager customCm; | ||||
| 
 | ||||
| 	/** @return a refreshed application context */ | ||||
| 	protected abstract ConfigurableApplicationContext getApplicationContext(); | ||||
| 
 | ||||
|  | @ -60,10 +58,9 @@ public abstract class AbstractAnnotationTests { | |||
| 		cs = ctx.getBean("service", CacheableService.class); | ||||
| 		ccs = ctx.getBean("classService", CacheableService.class); | ||||
| 		cm = ctx.getBean("cacheManager", CacheManager.class); | ||||
| 		customCm = ctx.getBean("customCacheManager", CacheManager.class); | ||||
| 
 | ||||
| 		Collection<String> cn = cm.getCacheNames(); | ||||
| 		assertTrue(cn.contains("default")); | ||||
| 		assertTrue(cn.contains("testCache")); | ||||
| 		assertTrue(cn.contains("secondary")); | ||||
| 		assertTrue(cn.contains("primary")); | ||||
| 	} | ||||
|  | @ -179,7 +176,7 @@ public abstract class AbstractAnnotationTests { | |||
| 		assertSame(r1, r2); | ||||
| 		assertNotSame(r1, r10); | ||||
| 		service.evictAll(new Object()); | ||||
| 		Cache cache = cm.getCache("default"); | ||||
| 		Cache cache = cm.getCache("testCache"); | ||||
| 		assertNull(cache.get(o1)); | ||||
| 		assertNull(cache.get(o2)); | ||||
| 
 | ||||
|  | @ -202,7 +199,7 @@ public abstract class AbstractAnnotationTests { | |||
| 	} | ||||
| 
 | ||||
| 	public void testUnlessExpression(CacheableService<?> service) throws Exception { | ||||
| 		Cache cache = cm.getCache("default"); | ||||
| 		Cache cache = cm.getCache("testCache"); | ||||
| 		cache.clear(); | ||||
| 		service.unless(10); | ||||
| 		service.unless(11); | ||||
|  | @ -249,7 +246,7 @@ public abstract class AbstractAnnotationTests { | |||
| 		Object key = new Object(); | ||||
| 		Object r1 = service.name(key); | ||||
| 		assertSame(r1, service.name(key)); | ||||
| 		Cache cache = cm.getCache("default"); | ||||
| 		Cache cache = cm.getCache("testCache"); | ||||
| 		// assert the method name is used | ||||
| 		assertNotNull(cache.get(keyName)); | ||||
| 	} | ||||
|  | @ -258,7 +255,7 @@ public abstract class AbstractAnnotationTests { | |||
| 		Object key = new Object(); | ||||
| 		Object r1 = service.rootVars(key); | ||||
| 		assertSame(r1, service.rootVars(key)); | ||||
| 		Cache cache = cm.getCache("default"); | ||||
| 		Cache cache = cm.getCache("testCache"); | ||||
| 		// assert the method name is used | ||||
| 		String expectedKey = "rootVarsrootVars" + AopProxyUtils.ultimateTargetClass(service) + service; | ||||
| 		assertNotNull(cache.get(expectedKey)); | ||||
|  | @ -292,7 +289,7 @@ public abstract class AbstractAnnotationTests { | |||
| 
 | ||||
| 	public void testCacheUpdate(CacheableService<?> service) { | ||||
| 		Object o = new Object(); | ||||
| 		Cache cache = cm.getCache("default"); | ||||
| 		Cache cache = cm.getCache("testCache"); | ||||
| 		assertNull(cache.get(o)); | ||||
| 		Object r1 = service.update(o); | ||||
| 		assertSame(r1, cache.get(o).get()); | ||||
|  | @ -307,7 +304,7 @@ public abstract class AbstractAnnotationTests { | |||
| 		Integer one = Integer.valueOf(1); | ||||
| 		Integer three = Integer.valueOf(3); | ||||
| 
 | ||||
| 		Cache cache = cm.getCache("default"); | ||||
| 		Cache cache = cm.getCache("testCache"); | ||||
| 		assertEquals(one, Integer.valueOf(service.conditionalUpdate(one).toString())); | ||||
| 		assertNull(cache.get(one)); | ||||
| 
 | ||||
|  | @ -567,7 +564,7 @@ public abstract class AbstractAnnotationTests { | |||
| 
 | ||||
| 	@Test | ||||
| 	public void testClassMethodName() throws Exception { | ||||
| 		testMethodName(ccs, "namedefault"); | ||||
| 		testMethodName(ccs, "nametestCache"); | ||||
| 	} | ||||
| 
 | ||||
| 	@Test | ||||
|  | @ -585,7 +582,7 @@ public abstract class AbstractAnnotationTests { | |||
| 		Object param = new Object(); | ||||
| 		Object r1 = cs.customKeyGenerator(param); | ||||
| 		assertSame(r1, cs.customKeyGenerator(param)); | ||||
| 		Cache cache = cm.getCache("default"); | ||||
| 		Cache cache = cm.getCache("testCache"); | ||||
| 		// Checks that the custom keyGenerator was used | ||||
| 		Object expectedKey = SomeCustomKeyGenerator.generateKey("customKeyGenerator", param); | ||||
| 		assertNotNull(cache.get(expectedKey)); | ||||
|  | @ -604,10 +601,12 @@ public abstract class AbstractAnnotationTests { | |||
| 
 | ||||
| 	@Test | ||||
| 	public void testCustomCacheManager() { | ||||
| 		CacheManager customCm = ctx.getBean("customCacheManager", CacheManager.class); | ||||
| 		Object key = new Object(); | ||||
| 		Object r1 = cs.customCacheManager(key); | ||||
| 		assertSame(r1, cs.customCacheManager(key)); | ||||
| 		Cache cache = customCm.getCache("default"); | ||||
| 
 | ||||
| 		Cache cache = customCm.getCache("testCache"); | ||||
| 		assertNotNull(cache.get(key)); | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
|  | @ -28,7 +28,7 @@ import org.springframework.cache.annotation.Caching; | |||
|  * @author Phillip Webb | ||||
|  * @author Stephane Nicoll | ||||
|  */ | ||||
| @Cacheable("default") | ||||
| @Cacheable("testCache") | ||||
| public class AnnotatedClassCacheableService implements CacheableService<Object> { | ||||
| 
 | ||||
| 	private final AtomicLong counter = new AtomicLong(); | ||||
|  | @ -46,100 +46,100 @@ public class AnnotatedClassCacheableService implements CacheableService<Object> | |||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	@Cacheable(value = "default", unless = "#result > 10") | ||||
| 	@Cacheable(value = "testCache", unless = "#result > 10") | ||||
| 	public Object unless(int arg) { | ||||
| 		return arg; | ||||
| 	} | ||||
| 
 | ||||
| 	@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; | ||||
| 	} | ||||
|  |  | |||
|  | @ -92,7 +92,7 @@ public class CustomInterceptorTests { | |||
| 
 | ||||
| 		@Bean | ||||
| 		public CacheManager cacheManager() { | ||||
| 			return CacheTestUtils.createSimpleCacheManager("default", "primary", "secondary"); | ||||
| 			return CacheTestUtils.createSimpleCacheManager("testCache", "primary", "secondary"); | ||||
| 		} | ||||
| 
 | ||||
| 		@Bean | ||||
|  |  | |||
|  | @ -36,118 +36,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; | ||||
|  | @ -159,13 +159,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()); | ||||
| 	} | ||||
|  |  | |||
|  | @ -43,7 +43,7 @@ public class EnableCachingIntegrationTests { | |||
| 	private void fooGetSimple(ApplicationContext context, FooService service) { | ||||
| 		CacheManager cacheManager = context.getBean(CacheManager.class); | ||||
| 
 | ||||
| 		Cache cache = cacheManager.getCache("default"); | ||||
| 		Cache cache = cacheManager.getCache("testCache"); | ||||
| 
 | ||||
| 		Object key = new Object(); | ||||
| 		assertCacheMiss(key, cache); | ||||
|  | @ -57,7 +57,7 @@ public class EnableCachingIntegrationTests { | |||
| 		@Override | ||||
| 		@Bean | ||||
| 		public CacheManager cacheManager() { | ||||
| 			return CacheTestUtils.createSimpleCacheManager("default"); | ||||
| 			return CacheTestUtils.createSimpleCacheManager("testCache"); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|  | @ -85,7 +85,7 @@ public class EnableCachingIntegrationTests { | |||
| 		public Object getSimple(Object key); | ||||
| 	} | ||||
| 
 | ||||
| 	@CacheConfig(cacheNames = "default") | ||||
| 	@CacheConfig(cacheNames = "testCache") | ||||
| 	private static class FooServiceImpl implements FooService { | ||||
| 		private final AtomicLong counter = new AtomicLong(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -149,7 +149,7 @@ public class EnableCachingTests extends AbstractAnnotationTests { | |||
| 		@Override | ||||
| 		@Bean | ||||
| 		public CacheManager cacheManager() { | ||||
| 			return CacheTestUtils.createSimpleCacheManager("default", "primary", "secondary"); | ||||
| 			return CacheTestUtils.createSimpleCacheManager("testCache", "primary", "secondary"); | ||||
| 		} | ||||
| 
 | ||||
| 		@Bean | ||||
|  | @ -181,7 +181,7 @@ public class EnableCachingTests extends AbstractAnnotationTests { | |||
| 
 | ||||
| 		@Bean | ||||
| 		public CacheManager customCacheManager() { | ||||
| 			return CacheTestUtils.createSimpleCacheManager("default"); | ||||
| 			return CacheTestUtils.createSimpleCacheManager("testCache"); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
|  | @ -26,7 +26,7 @@ import java.lang.reflect.Method; | |||
|  * | ||||
|  * @author Stephane Nicoll | ||||
|  */ | ||||
| final class SomeCustomKeyGenerator implements KeyGenerator { | ||||
| public final class SomeCustomKeyGenerator implements KeyGenerator { | ||||
| 
 | ||||
|     @Override | ||||
|     public Object generate(Object target, Method method, Object... params) { | ||||
|  |  | |||
|  | @ -27,7 +27,7 @@ | |||
| 	<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager"> | ||||
| 		<property name="caches"> | ||||
| 			<set> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="default"/> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="testCache"/> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="primary"/> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="secondary"/> | ||||
| 			</set> | ||||
|  | @ -47,7 +47,7 @@ | |||
| 	<bean id="customCacheManager" class="org.springframework.cache.support.SimpleCacheManager"> | ||||
| 		<property name="caches"> | ||||
| 			<set> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="default"/> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="testCache"/> | ||||
| 			</set> | ||||
| 		</property> | ||||
| 	</bean> | ||||
|  |  | |||
|  | @ -11,7 +11,7 @@ | |||
| 	<bean id="customCacheManager" class="org.springframework.cache.support.SimpleCacheManager"> | ||||
| 		<property name="caches"> | ||||
| 			<set> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="default"/> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="testCache"/> | ||||
| 			</set> | ||||
| 		</property> | ||||
| 	</bean> | ||||
|  |  | |||
|  | @ -13,7 +13,7 @@ | |||
| 				<property name="caches"> | ||||
| 					<set> | ||||
| 						<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" | ||||
| 							  p:name="default"/> | ||||
| 							  p:name="testCache"/> | ||||
| 					</set> | ||||
| 				</property> | ||||
| 			</bean> | ||||
|  |  | |||
|  | @ -17,7 +17,7 @@ | |||
| 	<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager"> | ||||
| 		<property name="caches"> | ||||
| 			<set> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="default"/> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="testCache"/> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="primary"/> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="secondary"/> | ||||
| 			</set> | ||||
|  | @ -39,7 +39,7 @@ | |||
| 	<bean id="customCacheManager" class="org.springframework.cache.support.SimpleCacheManager"> | ||||
| 		<property name="caches"> | ||||
| 			<set> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="default"/> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="testCache"/> | ||||
| 			</set> | ||||
| 		</property> | ||||
| 	</bean> | ||||
|  |  | |||
|  | @ -7,7 +7,7 @@ | |||
| 	<import resource="cache-advice.xml"/> | ||||
| 
 | ||||
| 	<cache:advice id="cacheAdviceInvalid" cache-manager="cacheManager"> | ||||
| 		<cache:caching cache="default"> | ||||
| 		<cache:caching cache="testCache"> | ||||
| 			<cache:cacheable method="someFakeMethod" key="#root.methodName" key-generator="unknownBeanName"/> | ||||
| 		</cache:caching> | ||||
| 	</cache:advice> | ||||
|  |  | |||
|  | @ -8,7 +8,7 @@ | |||
|        		http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd"> | ||||
| 
 | ||||
| 	<cache:advice id="cacheAdviceInterface" cache-manager="cacheManager"> | ||||
| 		<cache:caching cache="default"> | ||||
| 		<cache:caching cache="testCache"> | ||||
| 			<cache:cacheable method="cache"/> | ||||
| 			<cache:cacheable method="conditional" condition="#classField == 3"/> | ||||
| 			<cache:cacheable method="unless" unless="#result > 10"/> | ||||
|  | @ -20,17 +20,17 @@ | |||
| 			<cache:cacheable method="unknownCustomKeyGenerator" key-generator="unknownBeanName"/> | ||||
| 			<cache:cacheable method="customCacheManager" cache-manager="customCacheManager"/> | ||||
| 			<cache:cacheable method="unknownCustomCacheManager" cache-manager="unknownBeanName"/> | ||||
| 			<cache:cacheable method="nullValue" cache="default"/> | ||||
| 			<cache:cacheable method="nullValue" cache="testCache"/> | ||||
| 		</cache:caching> | ||||
| 		<cache:caching> | ||||
| 			<cache:cache-evict method="invalidate" cache="default"/> | ||||
| 			<cache:cache-evict method="evict" key="#p0" cache="default"/> | ||||
| 			<cache:cache-evict method="evictWithException" cache="default"/> | ||||
| 			<cache:cache-evict method="evictEarly" cache="default" before-invocation="true"/> | ||||
| 			<cache:cache-evict method="invalidateEarly" key="#p0" cache="default" before-invocation="true"/> | ||||
| 			<cache:cache-evict method="evictAll" cache="default" all-entries="true"/> | ||||
| 			<cache:cache-evict method="invalidate" cache="testCache"/> | ||||
| 			<cache:cache-evict method="evict" key="#p0" cache="testCache"/> | ||||
| 			<cache:cache-evict method="evictWithException" cache="testCache"/> | ||||
| 			<cache:cache-evict method="evictEarly" cache="testCache" before-invocation="true"/> | ||||
| 			<cache:cache-evict method="invalidateEarly" key="#p0" cache="testCache" before-invocation="true"/> | ||||
| 			<cache:cache-evict method="evictAll" cache="testCache" all-entries="true"/> | ||||
| 		</cache:caching> | ||||
| 		<cache:caching cache="default"> | ||||
| 		<cache:caching cache="testCache"> | ||||
| 			<cache:cache-put method="update"/> | ||||
| 			<cache:cache-put method="conditionalUpdate" condition="#arg.equals(3)"/> | ||||
| 		</cache:caching> | ||||
|  | @ -55,7 +55,7 @@ | |||
| 	</cache:advice> | ||||
| 
 | ||||
| 	<cache:advice id="cacheAdviceClass" cache-manager="cacheManager" key-generator="keyGenerator"> | ||||
| 		<cache:caching cache="default"> | ||||
| 		<cache:caching cache="testCache"> | ||||
| 			<cache:cacheable method="key" key="#p0"/> | ||||
| 			<cache:cacheable method="varArgsKey"/> | ||||
| 			<cache:cacheable method="nam*" key="#root.methodName + #root.caches[0].name"/> | ||||
|  | @ -66,14 +66,14 @@ | |||
| 			<cache:cacheable method="null*"/> | ||||
| 		</cache:caching> | ||||
| 		<cache:caching> | ||||
| 			<cache:cache-evict method="invalidate" cache="default"/> | ||||
| 			<cache:cache-evict method="evict" key="#p0" cache="default"/> | ||||
| 			<cache:cache-evict method="evictWithException" cache="default"/> | ||||
| 			<cache:cache-evict method="evictEarly" cache="default" before-invocation="true"/> | ||||
| 			<cache:cache-evict method="invalidateEarly" key="#p0" cache="default" before-invocation="true"/> | ||||
| 			<cache:cache-evict method="evictAll" cache="default" all-entries="true"/> | ||||
| 			<cache:cache-evict method="invalidate" cache="testCache"/> | ||||
| 			<cache:cache-evict method="evict" key="#p0" cache="testCache"/> | ||||
| 			<cache:cache-evict method="evictWithException" cache="testCache"/> | ||||
| 			<cache:cache-evict method="evictEarly" cache="testCache" before-invocation="true"/> | ||||
| 			<cache:cache-evict method="invalidateEarly" key="#p0" cache="testCache" before-invocation="true"/> | ||||
| 			<cache:cache-evict method="evictAll" cache="testCache" all-entries="true"/> | ||||
| 		</cache:caching> | ||||
| 		<cache:caching cache="default"> | ||||
| 		<cache:caching cache="testCache"> | ||||
| 			<cache:cache-put method="update"/> | ||||
| 			<cache:cache-put method="conditionalUpdate" condition="#arg.equals(3)"/> | ||||
| 		</cache:caching> | ||||
|  | @ -102,7 +102,7 @@ | |||
| 	<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager"> | ||||
| 		<property name="caches"> | ||||
| 			<set> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="default"/> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="testCache"/> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="primary"/> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="secondary"/> | ||||
| 			</set> | ||||
|  | @ -116,7 +116,7 @@ | |||
| 	<bean id="customCacheManager" class="org.springframework.cache.support.SimpleCacheManager"> | ||||
| 		<property name="caches"> | ||||
| 			<set> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="default"/> | ||||
| 				<bean class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean" p:name="testCache"/> | ||||
| 			</set> | ||||
| 		</property> | ||||
| 	</bean> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue