use of org.springframework.cache.interceptor.NamedCacheResolver in project spring-framework by spring-projects.
the class JCacheInterceptorTests method severalCachesNotSupported.
@Test
public void severalCachesNotSupported() {
JCacheInterceptor interceptor = createInterceptor(createOperationSource(cacheManager, new NamedCacheResolver(cacheManager, "default", "simpleCache"), defaultExceptionCacheResolver, defaultKeyGenerator));
AnnotatedJCacheableService service = new AnnotatedJCacheableService(cacheManager.getCache("default"));
Method m = ReflectionUtils.findMethod(AnnotatedJCacheableService.class, "cache", String.class);
try {
interceptor.execute(dummyInvoker, service, m, new Object[] { "myId" });
} catch (IllegalStateException ex) {
assertTrue(ex.getMessage().contains("JSR-107 only supports a single cache"));
} catch (Throwable ex) {
fail("Unexpected: " + ex);
}
}
use of org.springframework.cache.interceptor.NamedCacheResolver in project spring-framework by spring-projects.
the class JCacheInterceptorTests method noCacheCouldBeResolved.
@Test
public void noCacheCouldBeResolved() {
JCacheInterceptor interceptor = createInterceptor(createOperationSource(// Returns empty list
cacheManager, // Returns empty list
new NamedCacheResolver(cacheManager), defaultExceptionCacheResolver, defaultKeyGenerator));
AnnotatedJCacheableService service = new AnnotatedJCacheableService(cacheManager.getCache("default"));
Method m = ReflectionUtils.findMethod(AnnotatedJCacheableService.class, "cache", String.class);
try {
interceptor.execute(dummyInvoker, service, m, new Object[] { "myId" });
} catch (IllegalStateException ex) {
assertTrue(ex.getMessage().contains("Cache could not have been resolved for"));
} catch (Throwable ex) {
fail("Unexpected: " + ex);
}
}
Aggregations