Search in sources :

Example 1 with CacheInterceptor

use of cn.taketoday.cache.interceptor.CacheInterceptor in project today-infrastructure by TAKETODAY.

the class CacheAdviceNamespaceTests method testKeyStrategy.

@Test
public void testKeyStrategy() {
    CacheInterceptor bean = this.ctx.getBean("cacheAdviceClass", CacheInterceptor.class);
    assertThat(bean.getKeyGenerator()).isSameAs(this.ctx.getBean("keyGenerator"));
}
Also used : CacheInterceptor(cn.taketoday.cache.interceptor.CacheInterceptor) Test(org.junit.jupiter.api.Test)

Example 2 with CacheInterceptor

use of cn.taketoday.cache.interceptor.CacheInterceptor in project today-infrastructure by TAKETODAY.

the class AnnotationNamespaceDrivenTests method cacheResolver.

@Test
public void cacheResolver() {
    try {
        ConfigurableApplicationContext context = new GenericXmlApplicationContext("cn/taketoday/cache/config/annotationDrivenCacheNamespace-resolver.xml");
        CacheInterceptor ci = context.getBean(CacheInterceptor.class);
        assertThat(ci.getCacheResolver()).isSameAs(context.getBean("cacheResolver"));
        context.close();
    } catch (Throwable e) {
        e.printStackTrace();
    }
}
Also used : ConfigurableApplicationContext(cn.taketoday.context.ConfigurableApplicationContext) CacheInterceptor(cn.taketoday.cache.interceptor.CacheInterceptor) GenericXmlApplicationContext(cn.taketoday.context.support.GenericXmlApplicationContext) Test(org.junit.jupiter.api.Test)

Example 3 with CacheInterceptor

use of cn.taketoday.cache.interceptor.CacheInterceptor in project today-infrastructure by TAKETODAY.

the class ProxyCachingConfiguration method cacheInterceptor.

@Bean
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
public CacheInterceptor cacheInterceptor(CacheOperationSource cacheOperationSource) {
    CacheInterceptor interceptor = new CacheInterceptor();
    interceptor.configure(this.errorHandler, this.keyGenerator, this.cacheResolver, this.cacheManager);
    interceptor.setCacheOperationSource(cacheOperationSource);
    return interceptor;
}
Also used : CacheInterceptor(cn.taketoday.cache.interceptor.CacheInterceptor) Role(cn.taketoday.context.annotation.Role) Bean(cn.taketoday.context.annotation.Bean)

Example 4 with CacheInterceptor

use of cn.taketoday.cache.interceptor.CacheInterceptor in project today-framework by TAKETODAY.

the class EnableCachingTests method emptyConfigSupport.

@Test
public void emptyConfigSupport() {
    ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EmptyConfigSupportConfig.class);
    CacheInterceptor ci = context.getBean(CacheInterceptor.class);
    assertThat(ci.getCacheResolver()).isNotNull();
    assertThat(ci.getCacheResolver().getClass()).isEqualTo(SimpleCacheResolver.class);
    assertThat(((SimpleCacheResolver) ci.getCacheResolver()).getCacheManager()).isSameAs(context.getBean(CacheManager.class));
    context.close();
}
Also used : ConfigurableApplicationContext(cn.taketoday.context.ConfigurableApplicationContext) AnnotationConfigApplicationContext(cn.taketoday.context.annotation.AnnotationConfigApplicationContext) NoOpCacheManager(cn.taketoday.cache.support.NoOpCacheManager) CacheManager(cn.taketoday.cache.CacheManager) SimpleCacheResolver(cn.taketoday.cache.interceptor.SimpleCacheResolver) CacheInterceptor(cn.taketoday.cache.interceptor.CacheInterceptor) Test(org.junit.jupiter.api.Test)

Example 5 with CacheInterceptor

use of cn.taketoday.cache.interceptor.CacheInterceptor in project today-framework by TAKETODAY.

the class AnnotationNamespaceDrivenTests method testCacheErrorHandler.

@Test
public void testCacheErrorHandler() {
    CacheInterceptor ci = this.ctx.getBean("cn.taketoday.cache.interceptor.CacheInterceptor#0", CacheInterceptor.class);
    assertThat(ci.getErrorHandler()).isSameAs(this.ctx.getBean("errorHandler", CacheErrorHandler.class));
}
Also used : CacheErrorHandler(cn.taketoday.cache.interceptor.CacheErrorHandler) CacheInterceptor(cn.taketoday.cache.interceptor.CacheInterceptor) Test(org.junit.jupiter.api.Test)

Aggregations

CacheInterceptor (cn.taketoday.cache.interceptor.CacheInterceptor)22 Test (org.junit.jupiter.api.Test)20 ConfigurableApplicationContext (cn.taketoday.context.ConfigurableApplicationContext)8 CacheErrorHandler (cn.taketoday.cache.interceptor.CacheErrorHandler)4 AnnotationConfigApplicationContext (cn.taketoday.context.annotation.AnnotationConfigApplicationContext)4 GenericXmlApplicationContext (cn.taketoday.context.support.GenericXmlApplicationContext)4 CacheManager (cn.taketoday.cache.CacheManager)2 KeyGenerator (cn.taketoday.cache.interceptor.KeyGenerator)2 SimpleCacheErrorHandler (cn.taketoday.cache.interceptor.SimpleCacheErrorHandler)2 SimpleCacheResolver (cn.taketoday.cache.interceptor.SimpleCacheResolver)2 NoOpCacheManager (cn.taketoday.cache.support.NoOpCacheManager)2 Bean (cn.taketoday.context.annotation.Bean)2 Role (cn.taketoday.context.annotation.Role)2 SomeCustomKeyGenerator (cn.taketoday.contextsupport.testfixture.cache.SomeCustomKeyGenerator)2 SomeKeyGenerator (cn.taketoday.contextsupport.testfixture.cache.SomeKeyGenerator)2