Search in sources :

Example 16 with CacheOperation

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

the class AnnotationCacheOperationSourceTests method singleComposedAnnotation.

@Test
public void singleComposedAnnotation() throws Exception {
    Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "singleComposed", 2);
    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"));
}
Also used : CacheOperation(org.springframework.cache.interceptor.CacheOperation) CacheableOperation(org.springframework.cache.interceptor.CacheableOperation) Test(org.junit.Test)

Example 17 with CacheOperation

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

the class AnnotationCacheOperationSourceTests method fullClassLevelWithCustomCacheResolver.

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

Example 18 with CacheOperation

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

the class AnnotationCacheOperationSourceTests method partialClassLevelWithCustomCacheResolver.

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

Example 19 with CacheOperation

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

the class AnnotationCacheOperationSourceTests method cacheConfigFromInterface.

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

Example 20 with CacheOperation

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

the class AnnotationCacheOperationSourceTests method cacheAnnotationOverride.

@Test
public void cacheAnnotationOverride() {
    Collection<CacheOperation> ops = getOps(InterfaceCacheConfig.class, "interfaceCacheableOverride");
    assertSame(1, ops.size());
    CacheOperation cacheOperation = ops.iterator().next();
    assertTrue(cacheOperation instanceof CacheableOperation);
}
Also used : CacheOperation(org.springframework.cache.interceptor.CacheOperation) CacheableOperation(org.springframework.cache.interceptor.CacheableOperation) 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