Search in sources :

Example 6 with CacheInterceptor

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

the class AnnotationNamespaceDrivenTests method cacheResolver.

@Test
public void cacheResolver() {
    ConfigurableApplicationContext context = new GenericXmlApplicationContext("/org/springframework/cache/config/annotationDrivenCacheNamespace-resolver.xml");
    CacheInterceptor ci = context.getBean(CacheInterceptor.class);
    assertSame(context.getBean("cacheResolver"), ci.getCacheResolver());
    context.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) CacheInterceptor(org.springframework.cache.interceptor.CacheInterceptor) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) Test(org.junit.Test)

Example 7 with CacheInterceptor

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

the class AnnotationNamespaceDrivenTests method testKeyStrategy.

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

Example 8 with CacheInterceptor

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

the class AnnotationNamespaceDrivenTests method bothSetOnlyResolverIsUsed.

@Test
public void bothSetOnlyResolverIsUsed() {
    ConfigurableApplicationContext context = new GenericXmlApplicationContext("/org/springframework/cache/config/annotationDrivenCacheNamespace-manager-resolver.xml");
    CacheInterceptor ci = context.getBean(CacheInterceptor.class);
    assertSame(context.getBean("cacheResolver"), ci.getCacheResolver());
    context.close();
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) CacheInterceptor(org.springframework.cache.interceptor.CacheInterceptor) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) Test(org.junit.Test)

Example 9 with CacheInterceptor

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

the class CustomInterceptorTests method onlyOneInterceptorIsAvailable.

@Test
public void onlyOneInterceptorIsAvailable() {
    Map<String, CacheInterceptor> interceptors = this.ctx.getBeansOfType(CacheInterceptor.class);
    assertEquals("Only one interceptor should be defined", 1, interceptors.size());
    CacheInterceptor interceptor = interceptors.values().iterator().next();
    assertEquals("Custom interceptor not defined", TestCacheInterceptor.class, interceptor.getClass());
}
Also used : CacheInterceptor(org.springframework.cache.interceptor.CacheInterceptor) Test(org.junit.Test)

Example 10 with CacheInterceptor

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

the class EnableCachingTests method testCacheErrorHandler.

@Test
public void testCacheErrorHandler() {
    CacheInterceptor ci = this.ctx.getBean(CacheInterceptor.class);
    assertSame(this.ctx.getBean("errorHandler", CacheErrorHandler.class), ci.getErrorHandler());
}
Also used : CacheErrorHandler(org.springframework.cache.interceptor.CacheErrorHandler) SimpleCacheErrorHandler(org.springframework.cache.interceptor.SimpleCacheErrorHandler) 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