Search in sources :

Example 1 with NamedCacheResolver

use of cn.taketoday.cache.interceptor.NamedCacheResolver in project today-infrastructure by TAKETODAY.

the class JCacheInterceptorTests method noCacheCouldBeResolved.

@Test
public void noCacheCouldBeResolved() {
    JCacheInterceptor interceptor = createInterceptor(createOperationSource(// Returns empty list
    cacheManager, // Returns empty list
    new NamedCacheResolver(cacheManager), defaultExceptionCacheResolver, defaultKeyGenerator));
    AnnotatedJCacheableService service = new AnnotatedJCacheableService(cacheManager.getCache("default"));
    Method m = ReflectionUtils.findMethod(AnnotatedJCacheableService.class, "cache", String.class);
    assertThatIllegalStateException().isThrownBy(() -> interceptor.execute(dummyInvoker, service, m, new Object[] { "myId" })).withMessageContaining("Cache could not have been resolved for");
}
Also used : Method(java.lang.reflect.Method) NamedCacheResolver(cn.taketoday.cache.interceptor.NamedCacheResolver) Test(org.junit.jupiter.api.Test)

Example 2 with NamedCacheResolver

use of cn.taketoday.cache.interceptor.NamedCacheResolver in project today-infrastructure by TAKETODAY.

the class JCacheInterceptorTests method severalCachesNotSupported.

@Test
public void severalCachesNotSupported() {
    JCacheInterceptor interceptor = createInterceptor(createOperationSource(cacheManager, new NamedCacheResolver(cacheManager, "default", "simpleCache"), defaultExceptionCacheResolver, defaultKeyGenerator));
    AnnotatedJCacheableService service = new AnnotatedJCacheableService(cacheManager.getCache("default"));
    Method m = ReflectionUtils.findMethod(AnnotatedJCacheableService.class, "cache", String.class);
    assertThatIllegalStateException().isThrownBy(() -> interceptor.execute(dummyInvoker, service, m, new Object[] { "myId" })).withMessageContaining("JSR-107 only supports a single cache");
}
Also used : Method(java.lang.reflect.Method) NamedCacheResolver(cn.taketoday.cache.interceptor.NamedCacheResolver) Test(org.junit.jupiter.api.Test)

Example 3 with NamedCacheResolver

use of cn.taketoday.cache.interceptor.NamedCacheResolver in project today-framework by TAKETODAY.

the class JCacheInterceptorTests method severalCachesNotSupported.

@Test
public void severalCachesNotSupported() {
    JCacheInterceptor interceptor = createInterceptor(createOperationSource(cacheManager, new NamedCacheResolver(cacheManager, "default", "simpleCache"), defaultExceptionCacheResolver, defaultKeyGenerator));
    AnnotatedJCacheableService service = new AnnotatedJCacheableService(cacheManager.getCache("default"));
    Method m = ReflectionUtils.findMethod(AnnotatedJCacheableService.class, "cache", String.class);
    assertThatIllegalStateException().isThrownBy(() -> interceptor.execute(dummyInvoker, service, m, new Object[] { "myId" })).withMessageContaining("JSR-107 only supports a single cache");
}
Also used : Method(java.lang.reflect.Method) NamedCacheResolver(cn.taketoday.cache.interceptor.NamedCacheResolver) Test(org.junit.jupiter.api.Test)

Example 4 with NamedCacheResolver

use of cn.taketoday.cache.interceptor.NamedCacheResolver in project today-framework by TAKETODAY.

the class JCacheInterceptorTests method noCacheCouldBeResolved.

@Test
public void noCacheCouldBeResolved() {
    JCacheInterceptor interceptor = createInterceptor(createOperationSource(// Returns empty list
    cacheManager, // Returns empty list
    new NamedCacheResolver(cacheManager), defaultExceptionCacheResolver, defaultKeyGenerator));
    AnnotatedJCacheableService service = new AnnotatedJCacheableService(cacheManager.getCache("default"));
    Method m = ReflectionUtils.findMethod(AnnotatedJCacheableService.class, "cache", String.class);
    assertThatIllegalStateException().isThrownBy(() -> interceptor.execute(dummyInvoker, service, m, new Object[] { "myId" })).withMessageContaining("Cache could not have been resolved for");
}
Also used : Method(java.lang.reflect.Method) NamedCacheResolver(cn.taketoday.cache.interceptor.NamedCacheResolver) Test(org.junit.jupiter.api.Test)

Aggregations

NamedCacheResolver (cn.taketoday.cache.interceptor.NamedCacheResolver)4 Method (java.lang.reflect.Method)4 Test (org.junit.jupiter.api.Test)4