Search in sources :

Example 1 with CacheInterceptor

use of org.springframework.cache.interceptor.CacheInterceptor in project spring-framework by spring-projects.

the class EnableCachingTests method bothSetOnlyResolverIsUsed.

@Test
public void bothSetOnlyResolverIsUsed() {
    ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(FullCachingConfig.class);
    CacheInterceptor ci = context.getBean(CacheInterceptor.class);
    assertSame(context.getBean("cacheResolver"), ci.getCacheResolver());
    assertSame(context.getBean("keyGenerator"), ci.getKeyGenerator());
    context.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) CacheInterceptor(org.springframework.cache.interceptor.CacheInterceptor) Test(org.junit.Test)

Example 2 with CacheInterceptor

use of org.springframework.cache.interceptor.CacheInterceptor in project spring-framework by spring-projects.

the class EnableCachingTests method testKeyStrategy.

@Test
public void testKeyStrategy() {
    CacheInterceptor ci = this.ctx.getBean(CacheInterceptor.class);
    assertSame(this.ctx.getBean("keyGenerator", KeyGenerator.class), ci.getKeyGenerator());
}
Also used : CacheInterceptor(org.springframework.cache.interceptor.CacheInterceptor) KeyGenerator(org.springframework.cache.interceptor.KeyGenerator) Test(org.junit.Test)

Example 3 with CacheInterceptor

use of org.springframework.cache.interceptor.CacheInterceptor in project spring-framework by spring-projects.

the class EnableCachingTests method emptyConfigSupport.

@Test
public void emptyConfigSupport() {
    ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EmptyConfigSupportConfig.class);
    CacheInterceptor ci = context.getBean(CacheInterceptor.class);
    assertNotNull(ci.getCacheResolver());
    assertEquals(SimpleCacheResolver.class, ci.getCacheResolver().getClass());
    assertSame(context.getBean(CacheManager.class), ((SimpleCacheResolver) ci.getCacheResolver()).getCacheManager());
    context.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) NoOpCacheManager(org.springframework.cache.support.NoOpCacheManager) CacheManager(org.springframework.cache.CacheManager) CacheInterceptor(org.springframework.cache.interceptor.CacheInterceptor) Test(org.junit.Test)

Example 4 with CacheInterceptor

use of org.springframework.cache.interceptor.CacheInterceptor in project spring-framework by spring-projects.

the class AnnotationNamespaceDrivenTests method testCacheErrorHandler.

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

Example 5 with CacheInterceptor

use of org.springframework.cache.interceptor.CacheInterceptor in project spring-framework by spring-projects.

the class CacheAdviceNamespaceTests method testKeyStrategy.

@Test
public void testKeyStrategy() throws Exception {
    CacheInterceptor bean = this.ctx.getBean("cacheAdviceClass", CacheInterceptor.class);
    Assert.assertSame(this.ctx.getBean("keyGenerator"), bean.getKeyGenerator());
}
Also used : CacheInterceptor(org.springframework.cache.interceptor.CacheInterceptor) Test(org.junit.Test)

Aggregations

CacheInterceptor (org.springframework.cache.interceptor.CacheInterceptor)11 Test (org.junit.Test)10 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)4 CacheErrorHandler (org.springframework.cache.interceptor.CacheErrorHandler)2 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)2 GenericXmlApplicationContext (org.springframework.context.support.GenericXmlApplicationContext)2 CacheManager (org.springframework.cache.CacheManager)1 KeyGenerator (org.springframework.cache.interceptor.KeyGenerator)1 SimpleCacheErrorHandler (org.springframework.cache.interceptor.SimpleCacheErrorHandler)1 NoOpCacheManager (org.springframework.cache.support.NoOpCacheManager)1 Bean (org.springframework.context.annotation.Bean)1 Role (org.springframework.context.annotation.Role)1