Search in sources :

Example 11 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 12 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)

Aggregations

CacheInterceptor (org.springframework.cache.interceptor.CacheInterceptor)12 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 Bean (org.springframework.context.annotation.Bean)2 Role (org.springframework.context.annotation.Role)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