Search in sources :

Example 6 with CacheOperation

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

the class AnnotationCacheOperationSourceTests method fullClassLevelWithCustomKeyManager.

@Test
public void fullClassLevelWithCustomKeyManager() {
    Collection<CacheOperation> ops = getOps(AnnotatedClassWithFullDefault.class, "methodLevelKeyGenerator", 1);
    CacheOperation cacheOperation = ops.iterator().next();
    assertSharedConfig(cacheOperation, "custom", "", "classCacheResolver", "classCacheName");
}
Also used : CacheOperation(org.springframework.cache.interceptor.CacheOperation) Test(org.junit.Test)

Example 7 with CacheOperation

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

the class AnnotationCacheOperationSourceTests method customCacheResolver.

@Test
public void customCacheResolver() {
    Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "customCacheResolver", 1);
    CacheOperation cacheOperation = ops.iterator().next();
    assertEquals("Custom cache resolver not set", "custom", cacheOperation.getCacheResolver());
}
Also used : CacheOperation(org.springframework.cache.interceptor.CacheOperation) Test(org.junit.Test)

Example 8 with CacheOperation

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

the class AnnotationCacheOperationSourceTests method fullClassLevelWithCustomCacheName.

@Test
public void fullClassLevelWithCustomCacheName() {
    Collection<CacheOperation> ops = getOps(AnnotatedClassWithFullDefault.class, "methodLevelCacheName", 1);
    CacheOperation cacheOperation = ops.iterator().next();
    assertSharedConfig(cacheOperation, "classKeyGenerator", "", "classCacheResolver", "custom");
}
Also used : CacheOperation(org.springframework.cache.interceptor.CacheOperation) Test(org.junit.Test)

Example 9 with CacheOperation

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

the class AnnotationCacheOperationSourceTests method multipleComposedAnnotations.

@Test
public void multipleComposedAnnotations() throws Exception {
    Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "multipleComposed", 4);
    Iterator<CacheOperation> it = ops.iterator();
    CacheOperation cacheOperation = it.next();
    assertThat(cacheOperation, instanceOf(CacheableOperation.class));
    assertThat(cacheOperation.getCacheNames(), equalTo(Collections.singleton("directly declared")));
    assertThat(cacheOperation.getKey(), equalTo(""));
    cacheOperation = it.next();
    assertThat(cacheOperation, instanceOf(CacheableOperation.class));
    assertThat(cacheOperation.getCacheNames(), equalTo(Collections.singleton("composedCache")));
    assertThat(cacheOperation.getKey(), equalTo("composedKey"));
    cacheOperation = it.next();
    assertThat(cacheOperation, instanceOf(CacheableOperation.class));
    assertThat(cacheOperation.getCacheNames(), equalTo(Collections.singleton("foo")));
    assertThat(cacheOperation.getKey(), equalTo(""));
    cacheOperation = it.next();
    assertThat(cacheOperation, instanceOf(CacheEvictOperation.class));
    assertThat(cacheOperation.getCacheNames(), equalTo(Collections.singleton("composedCacheEvict")));
    assertThat(cacheOperation.getKey(), equalTo("composedEvictionKey"));
}
Also used : CacheEvictOperation(org.springframework.cache.interceptor.CacheEvictOperation) CacheOperation(org.springframework.cache.interceptor.CacheOperation) CacheableOperation(org.springframework.cache.interceptor.CacheableOperation) Test(org.junit.Test)

Example 10 with CacheOperation

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

the class AnnotationCacheOperationSourceTests method severalCacheConfigUseClosest.

@Test
public void severalCacheConfigUseClosest() {
    Collection<CacheOperation> ops = getOps(MultipleCacheConfig.class, "multipleCacheConfig");
    CacheOperation cacheOperation = ops.iterator().next();
    assertSharedConfig(cacheOperation, "", "", "", "myCache");
}
Also used : CacheOperation(org.springframework.cache.interceptor.CacheOperation) Test(org.junit.Test)

Aggregations

CacheOperation (org.springframework.cache.interceptor.CacheOperation)22 Test (org.junit.Test)21 CacheableOperation (org.springframework.cache.interceptor.CacheableOperation)5 CacheEvictOperation (org.springframework.cache.interceptor.CacheEvictOperation)3 Collection (java.util.Collection)1 TypedStringValue (org.springframework.beans.factory.config.TypedStringValue)1 ManagedMap (org.springframework.beans.factory.support.ManagedMap)1 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)1 CachePutOperation (org.springframework.cache.interceptor.CachePutOperation)1 Element (org.w3c.dom.Element)1