Add missing cache-resolver attribute
Prior to this commit, CacheResolver could not be configured through the XML namespace (i.e. cache:annotation-driven). This is now the case. Issue: SPR-11490
This commit is contained in:
@@ -16,13 +16,15 @@
|
||||
|
||||
package org.springframework.cache.jcache.config;
|
||||
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.cache.interceptor.CacheErrorHandler;
|
||||
import org.springframework.cache.jcache.interceptor.DefaultJCacheOperationSource;
|
||||
import org.springframework.cache.jcache.interceptor.JCacheInterceptor;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.support.GenericXmlApplicationContext;
|
||||
|
||||
/**
|
||||
@@ -36,6 +38,16 @@ public class JCacheNamespaceDrivenTests extends AbstractJCacheAnnotationTests {
|
||||
"/org/springframework/cache/jcache/config/jCacheNamespaceDriven.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cacheResolver() {
|
||||
ConfigurableApplicationContext context = new GenericXmlApplicationContext(
|
||||
"/org/springframework/cache/jcache/config/jCacheNamespaceDriven-resolver.xml");
|
||||
|
||||
DefaultJCacheOperationSource ci = context.getBean(DefaultJCacheOperationSource.class);
|
||||
assertSame(context.getBean("cacheResolver"), ci.getDefaultCacheResolver());
|
||||
context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCacheErrorHandler() {
|
||||
JCacheInterceptor ci = ctx.getBean(JCacheInterceptor.class);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:cache="http://www.springframework.org/schema/cache"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/cache
|
||||
http://www.springframework.org/schema/cache/spring-cache.xsd">
|
||||
|
||||
<cache:annotation-driven cache-manager="cacheManager" cache-resolver="cacheResolver"/>
|
||||
|
||||
<!-- We can't hid the cache manager completely as the exception cache resolver needs it -->
|
||||
<bean id="cacheManager" class="org.springframework.cache.support.SimpleCacheManager">
|
||||
<property name="caches">
|
||||
<set>
|
||||
<ref bean="defaultCache"/>
|
||||
</set>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="defaultCache"
|
||||
class="org.springframework.cache.concurrent.ConcurrentMapCacheFactoryBean">
|
||||
<property name="name" value="default"/>
|
||||
</bean>
|
||||
|
||||
<bean id="cacheResolver" class="org.springframework.cache.interceptor.SimpleCacheResolver">
|
||||
<property name="cacheManager" ref="cacheManager"/>
|
||||
</bean>
|
||||
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user