use of cn.taketoday.cache.jcache.interceptor.DefaultJCacheOperationSource in project today-infrastructure by TAKETODAY.
the class JCacheJavaConfigTests method fullCachingConfig.
@Test
public void fullCachingConfig() throws Exception {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(FullCachingConfig.class);
DefaultJCacheOperationSource cos = context.getBean(DefaultJCacheOperationSource.class);
assertThat(cos.getKeyGenerator()).isSameAs(context.getBean(KeyGenerator.class));
assertThat(cos.getCacheResolver()).isSameAs(context.getBean("cacheResolver", CacheResolver.class));
assertThat(cos.getExceptionCacheResolver()).isSameAs(context.getBean("exceptionCacheResolver", CacheResolver.class));
JCacheInterceptor interceptor = context.getBean(JCacheInterceptor.class);
assertThat(interceptor.getErrorHandler()).isSameAs(context.getBean("errorHandler", CacheErrorHandler.class));
context.close();
}
use of cn.taketoday.cache.jcache.interceptor.DefaultJCacheOperationSource in project today-infrastructure by TAKETODAY.
the class JCacheJavaConfigTests method exceptionCacheResolverLazilyRequired.
@Test
public void exceptionCacheResolverLazilyRequired() {
try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(NoExceptionCacheResolverConfig.class)) {
DefaultJCacheOperationSource cos = context.getBean(DefaultJCacheOperationSource.class);
assertThat(cos.getCacheResolver()).isSameAs(context.getBean("cacheResolver"));
JCacheableService<?> service = context.getBean(JCacheableService.class);
service.cache("id");
// This call requires the cache manager to be set
assertThatIllegalStateException().isThrownBy(() -> service.cacheWithException("test", false));
}
}
use of cn.taketoday.cache.jcache.interceptor.DefaultJCacheOperationSource in project today-infrastructure by TAKETODAY.
the class JCacheJavaConfigTests method bothSetOnlyResolverIsUsed.
@Test
public void bothSetOnlyResolverIsUsed() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(FullCachingConfigSupport.class);
DefaultJCacheOperationSource cos = context.getBean(DefaultJCacheOperationSource.class);
assertThat(cos.getCacheResolver()).isSameAs(context.getBean("cacheResolver"));
assertThat(cos.getKeyGenerator()).isSameAs(context.getBean("keyGenerator"));
assertThat(cos.getExceptionCacheResolver()).isSameAs(context.getBean("exceptionCacheResolver"));
context.close();
}
use of cn.taketoday.cache.jcache.interceptor.DefaultJCacheOperationSource in project today-framework by TAKETODAY.
the class JCacheJavaConfigTests method emptyConfigSupport.
@Test
public void emptyConfigSupport() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EmptyConfigSupportConfig.class);
DefaultJCacheOperationSource cos = context.getBean(DefaultJCacheOperationSource.class);
assertThat(cos.getCacheResolver()).isNotNull();
assertThat(cos.getCacheResolver().getClass()).isEqualTo(SimpleCacheResolver.class);
assertThat(((SimpleCacheResolver) cos.getCacheResolver()).getCacheManager()).isSameAs(context.getBean(CacheManager.class));
assertThat(cos.getExceptionCacheResolver()).isNull();
context.close();
}
use of cn.taketoday.cache.jcache.interceptor.DefaultJCacheOperationSource in project today-framework by TAKETODAY.
the class JCacheJavaConfigTests method bothSetOnlyResolverIsUsed.
@Test
public void bothSetOnlyResolverIsUsed() {
ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(FullCachingConfigSupport.class);
DefaultJCacheOperationSource cos = context.getBean(DefaultJCacheOperationSource.class);
assertThat(cos.getCacheResolver()).isSameAs(context.getBean("cacheResolver"));
assertThat(cos.getKeyGenerator()).isSameAs(context.getBean("keyGenerator"));
assertThat(cos.getExceptionCacheResolver()).isSameAs(context.getBean("exceptionCacheResolver"));
context.close();
}
Aggregations