Search in sources :

Example 11 with CacheOperation

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

the class AnnotationCacheOperationSourceTests method customCacheResolverInherited.

@Test
public void customCacheResolverInherited() {
    Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "customCacheResolverInherited", 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 12 with CacheOperation

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

the class AnnotationCacheOperationSourceTests method multipleStereotypes.

@Test
public void multipleStereotypes() throws Exception {
    Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "multipleStereotype", 3);
    Iterator<CacheOperation> it = ops.iterator();
    assertTrue(it.next() instanceof CacheableOperation);
    CacheOperation next = it.next();
    assertTrue(next instanceof CacheEvictOperation);
    assertTrue(next.getCacheNames().contains("foo"));
    next = it.next();
    assertTrue(next instanceof CacheEvictOperation);
    assertTrue(next.getCacheNames().contains("bar"));
}
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 13 with CacheOperation

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

the class AnnotationCacheOperationSourceTests method validateNoCacheIsValid.

@Test
public void validateNoCacheIsValid() {
    // Valid as a CacheResolver might return the cache names to use with other info
    Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "noCacheNameSpecified");
    CacheOperation cacheOperation = ops.iterator().next();
    assertNotNull("cache names set must not be null", cacheOperation.getCacheNames());
    assertEquals("no cache names specified", 0, cacheOperation.getCacheNames().size());
}
Also used : CacheOperation(org.springframework.cache.interceptor.CacheOperation) Test(org.junit.Test)

Example 14 with CacheOperation

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

the class AnnotationCacheOperationSourceTests method fullClassLevelWithCustomCacheManager.

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

Example 15 with CacheOperation

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

the class AnnotationCacheOperationSourceTests method customKeyGenerator.

@Test
public void customKeyGenerator() {
    Collection<CacheOperation> ops = getOps(AnnotatedClass.class, "customKeyGenerator", 1);
    CacheOperation cacheOperation = ops.iterator().next();
    assertEquals("Custom key generator not set", "custom", cacheOperation.getKeyGenerator());
}
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