+ more tests
This commit is contained in:
Costin Leau
2011-10-07 20:16:58 +00:00
parent a12ebbfded
commit 40d88fd991
7 changed files with 28 additions and 10 deletions

View File

@@ -20,13 +20,11 @@ import static org.junit.Assert.*;
import java.util.UUID;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.aop.framework.AopProxyUtils;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.interceptor.CacheInterceptor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -286,10 +284,4 @@ public abstract class AbstractAnnotationTests {
public void testClassUncheckedException() throws Exception {
testUncheckedThrowable(ccs);
}
@Test
public void testKeyStrategy() throws Exception {
CacheInterceptor bean = ctx.getBean("cacheAdviceClass", CacheInterceptor.class);
Assert.assertSame(ctx.getBean("keyGenerator"), bean.getKeyGenerator());
}
}

View File

@@ -16,6 +16,11 @@
package org.springframework.cache.config;
import junit.framework.Assert;
import org.junit.Test;
import org.springframework.cache.interceptor.CacheInterceptor;
/**
* @author Costin Leau
@@ -27,4 +32,10 @@ public class AnnotationNamespaceDrivenTests extends AbstractAnnotationTests {
return "/org/springframework/cache/config/annotationDrivenCacheNamespace.xml";
}
@Test
public void testKeyStrategy() throws Exception {
CacheInterceptor ci = ctx.getBean("org.springframework.cache.interceptor.CacheInterceptor#0",
CacheInterceptor.class);
Assert.assertSame(ctx.getBean("keyGenerator"), ci.getKeyGenerator());
}
}

View File

@@ -17,6 +17,7 @@
package org.springframework.cache.config;
/**
* @author Costin Leau
*/

View File

@@ -16,6 +16,10 @@
package org.springframework.cache.config;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.cache.interceptor.CacheInterceptor;
/**
* @author Costin Leau
@@ -27,4 +31,10 @@ public class CacheAdviceNamespaceTests extends AbstractAnnotationTests {
protected String getConfig() {
return "/org/springframework/cache/config/cache-advice.xml";
}
@Test
public void testKeyStrategy() throws Exception {
CacheInterceptor bean = ctx.getBean("cacheAdviceClass", CacheInterceptor.class);
Assert.assertSame(ctx.getBean("keyGenerator"), bean.getKeyGenerator());
}
}

View File

@@ -39,5 +39,7 @@
<bean id="service" class="org.springframework.cache.config.DefaultCacheableService"/>
<bean id="classService" class="org.springframework.cache.config.AnnotatedClassCacheableService"/>
<bean id="keyGenerator" class="org.springframework.cache.config.SomeKeyGenerator"/>
</beans>

View File

@@ -7,7 +7,7 @@
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
<cache:annotation-driven proxy-target-class="false" order="0"/>
<cache:annotation-driven proxy-target-class="false" order="0" key-generator="keyGenerator"/>
<aop:config>
<aop:advisor advice-ref="debugInterceptor" pointcut="execution(* *..CacheableService.*(..))" order="1"/>
@@ -27,4 +27,6 @@
<bean id="classService" class="org.springframework.cache.config.AnnotatedClassCacheableService"/>
<bean id="keyGenerator" class="org.springframework.cache.config.SomeKeyGenerator"/>
</beans>