org.springframework.cache.jcache.support.TestableCacheKeyGenerator Java Examples

The following examples show how to use org.springframework.cache.jcache.support.TestableCacheKeyGenerator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AnnotationCacheOperationSourceTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void customKeyGeneratorSpringBean() {
	TestableCacheKeyGenerator bean = new TestableCacheKeyGenerator();
	beanFactory.registerSingleton("fooBar", bean);
	CacheResultOperation operation =
			getCacheOperation(CacheResultOperation.class, CustomService.class, name.getMethodName(), Long.class);
	assertEquals(defaultCacheResolver, operation.getCacheResolver());
	assertNull(operation.getExceptionCacheResolver());
	KeyGeneratorAdapter adapter = (KeyGeneratorAdapter) operation.getKeyGenerator();
	assertSame(bean, adapter.getTarget()); // take bean from context
}
 
Example #2
Source File: AnnotationCacheOperationSourceTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void customKeyGeneratorAndCacheResolver() {
	CacheResultOperation operation = getCacheOperation(CacheResultOperation.class,
			CustomServiceWithDefaults.class, name.getMethodName(), Long.class);
	assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class);
	assertJCacheResolver(operation.getExceptionCacheResolver(), null);
	assertCacheKeyGenerator(operation.getKeyGenerator(), TestableCacheKeyGenerator.class);
}
 
Example #3
Source File: AnnotationCacheOperationSourceTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void customKeyGeneratorAndCacheResolverWithExceptionName() {
	CacheResultOperation operation = getCacheOperation(CacheResultOperation.class,
			CustomServiceWithDefaults.class, name.getMethodName(), Long.class);
	assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class);
	assertJCacheResolver(operation.getExceptionCacheResolver(), TestableCacheResolver.class);
	assertCacheKeyGenerator(operation.getKeyGenerator(), TestableCacheKeyGenerator.class);
}
 
Example #4
Source File: AnnotationCacheOperationSourceTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void customKeyGenerator() {
	CacheResultOperation operation =
			getCacheOperation(CacheResultOperation.class, CustomService.class, name.getMethodName(), Long.class);
	assertEquals(defaultCacheResolver, operation.getCacheResolver());
	assertNull(operation.getExceptionCacheResolver());
	assertCacheKeyGenerator(operation.getKeyGenerator(), TestableCacheKeyGenerator.class);
}
 
Example #5
Source File: AnnotationCacheOperationSourceTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void customKeyGenerator() {
	CacheResultOperation operation =
			getCacheOperation(CacheResultOperation.class, CustomService.class, name.getMethodName(), Long.class);
	assertEquals(defaultCacheResolver, operation.getCacheResolver());
	assertNull(operation.getExceptionCacheResolver());
	assertCacheKeyGenerator(operation.getKeyGenerator(), TestableCacheKeyGenerator.class);
}
 
Example #6
Source File: AnnotationCacheOperationSourceTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void customKeyGeneratorSpringBean() {
	TestableCacheKeyGenerator bean = new TestableCacheKeyGenerator();
	beanFactory.registerSingleton("fooBar", bean);
	CacheResultOperation operation =
			getCacheOperation(CacheResultOperation.class, CustomService.class, name.getMethodName(), Long.class);
	assertEquals(defaultCacheResolver, operation.getCacheResolver());
	assertNull(operation.getExceptionCacheResolver());
	KeyGeneratorAdapter adapter = (KeyGeneratorAdapter) operation.getKeyGenerator();
	assertSame(bean, adapter.getTarget()); // take bean from context
}
 
Example #7
Source File: AnnotationCacheOperationSourceTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void customKeyGeneratorAndCacheResolver() {
	CacheResultOperation operation = getCacheOperation(CacheResultOperation.class,
			CustomServiceWithDefaults.class, name.getMethodName(), Long.class);
	assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class);
	assertJCacheResolver(operation.getExceptionCacheResolver(), null);
	assertCacheKeyGenerator(operation.getKeyGenerator(), TestableCacheKeyGenerator.class);
}
 
Example #8
Source File: AnnotationCacheOperationSourceTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void customKeyGeneratorAndCacheResolverWithExceptionName() {
	CacheResultOperation operation = getCacheOperation(CacheResultOperation.class,
			CustomServiceWithDefaults.class, name.getMethodName(), Long.class);
	assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class);
	assertJCacheResolver(operation.getExceptionCacheResolver(), TestableCacheResolver.class);
	assertCacheKeyGenerator(operation.getKeyGenerator(), TestableCacheKeyGenerator.class);
}
 
Example #9
Source File: AnnotationCacheOperationSourceTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void customKeyGeneratorAndCacheResolverWithExceptionName() {
	CacheResultOperation operation = getCacheOperation(CacheResultOperation.class,
			CustomServiceWithDefaults.class, name.getMethodName(), Long.class);
	assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class);
	assertJCacheResolver(operation.getExceptionCacheResolver(), TestableCacheResolver.class);
	assertCacheKeyGenerator(operation.getKeyGenerator(), TestableCacheKeyGenerator.class);
}
 
Example #10
Source File: AnnotationCacheOperationSourceTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void customKeyGeneratorAndCacheResolver() {
	CacheResultOperation operation = getCacheOperation(CacheResultOperation.class,
			CustomServiceWithDefaults.class, name.getMethodName(), Long.class);
	assertJCacheResolver(operation.getCacheResolver(), TestableCacheResolver.class);
	assertJCacheResolver(operation.getExceptionCacheResolver(), null);
	assertCacheKeyGenerator(operation.getKeyGenerator(), TestableCacheKeyGenerator.class);
}
 
Example #11
Source File: AnnotationCacheOperationSourceTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void customKeyGeneratorSpringBean() {
	TestableCacheKeyGenerator bean = new TestableCacheKeyGenerator();
	beanFactory.registerSingleton("fooBar", bean);
	CacheResultOperation operation =
			getCacheOperation(CacheResultOperation.class, CustomService.class, name.getMethodName(), Long.class);
	assertEquals(defaultCacheResolver, operation.getCacheResolver());
	assertNull(operation.getExceptionCacheResolver());
	KeyGeneratorAdapter adapter = (KeyGeneratorAdapter) operation.getKeyGenerator();
	assertSame(bean, adapter.getTarget()); // take bean from context
}
 
Example #12
Source File: AnnotationCacheOperationSourceTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void customKeyGenerator() {
	CacheResultOperation operation =
			getCacheOperation(CacheResultOperation.class, CustomService.class, name.getMethodName(), Long.class);
	assertEquals(defaultCacheResolver, operation.getCacheResolver());
	assertNull(operation.getExceptionCacheResolver());
	assertCacheKeyGenerator(operation.getKeyGenerator(), TestableCacheKeyGenerator.class);
}
 
Example #13
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
@CacheResult(cacheKeyGenerator = TestableCacheKeyGenerator.class)
public Long cacheWithCustomKeyGenerator(String id, String anotherId) {
	return counter.getAndIncrement();
}
 
Example #14
Source File: AnnotatedJCacheableService.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
@CacheResult(cacheKeyGenerator = TestableCacheKeyGenerator.class)
public Long cacheWithCustomKeyGenerator(String id, String anotherId) {
	return counter.getAndIncrement();
}
 
Example #15
Source File: AnnotationCacheOperationSourceTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@CacheResult(cacheKeyGenerator = TestableCacheKeyGenerator.class)
public Object customKeyGeneratorSpringBean(Long id) {
	return null;
}
 
Example #16
Source File: AnnotationCacheOperationSourceTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@CacheResult(cacheKeyGenerator = TestableCacheKeyGenerator.class)
public Object customKeyGenerator(Long id) {
	return null;
}
 
Example #17
Source File: AnnotatedJCacheableService.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
@CacheResult(cacheKeyGenerator = TestableCacheKeyGenerator.class)
public Long cacheWithCustomKeyGenerator(String id, String anotherId) {
	return counter.getAndIncrement();
}
 
Example #18
Source File: AnnotatedJCacheableService.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
@CacheResult(cacheKeyGenerator = TestableCacheKeyGenerator.class)
public Long cacheWithCustomKeyGenerator(String id, String anotherId) {
	return counter.getAndIncrement();
}
 
Example #19
Source File: AnnotationCacheOperationSourceTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@CacheResult(cacheKeyGenerator = TestableCacheKeyGenerator.class)
public Object customKeyGeneratorSpringBean(Long id) {
	return null;
}
 
Example #20
Source File: AnnotationCacheOperationSourceTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@CacheResult(cacheKeyGenerator = TestableCacheKeyGenerator.class)
public Object customKeyGenerator(Long id) {
	return null;
}
 
Example #21
Source File: AnnotatedJCacheableService.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
@CacheResult(cacheKeyGenerator = TestableCacheKeyGenerator.class)
public Long cacheWithCustomKeyGenerator(String id, String anotherId) {
	return counter.getAndIncrement();
}
 
Example #22
Source File: AnnotatedJCacheableService.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
@CacheResult(cacheKeyGenerator = TestableCacheKeyGenerator.class)
public Long cacheWithCustomKeyGenerator(String id, String anotherId) {
	return counter.getAndIncrement();
}
 
Example #23
Source File: AnnotationCacheOperationSourceTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@CacheResult(cacheKeyGenerator = TestableCacheKeyGenerator.class)
public Object customKeyGeneratorSpringBean(Long id) {
	return null;
}
 
Example #24
Source File: AnnotationCacheOperationSourceTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@CacheResult(cacheKeyGenerator = TestableCacheKeyGenerator.class)
public Object customKeyGenerator(Long id) {
	return null;
}