提交 8abb3150 编写于 作者: C Chris Beams

Fix cache generics warnings; polish whitespace

上级 1533822b
...@@ -31,16 +31,16 @@ import org.springframework.context.support.ClassPathXmlApplicationContext; ...@@ -31,16 +31,16 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
/** /**
* Abstract annotation test (containing several reusable methods). * Abstract annotation test (containing several reusable methods).
* *
* @author Costin Leau * @author Costin Leau
*/ */
public abstract class AbstractAnnotationTests { public abstract class AbstractAnnotationTests {
protected ApplicationContext ctx; protected ApplicationContext ctx;
protected CacheableService cs; protected CacheableService<?> cs;
protected CacheableService ccs; protected CacheableService<?> ccs;
protected CacheManager cm; protected CacheManager cm;
...@@ -58,9 +58,8 @@ public abstract class AbstractAnnotationTests { ...@@ -58,9 +58,8 @@ public abstract class AbstractAnnotationTests {
assertTrue(cn.contains("primary")); assertTrue(cn.contains("primary"));
} }
public void testCacheable(CacheableService service) throws Exception { public void testCacheable(CacheableService<?> service) throws Exception {
Object o1 = new Object(); Object o1 = new Object();
Object o2 = new Object();
Object r1 = service.cache(o1); Object r1 = service.cache(o1);
Object r2 = service.cache(o1); Object r2 = service.cache(o1);
...@@ -70,9 +69,8 @@ public abstract class AbstractAnnotationTests { ...@@ -70,9 +69,8 @@ public abstract class AbstractAnnotationTests {
assertSame(r1, r3); assertSame(r1, r3);
} }
public void testInvalidate(CacheableService service) throws Exception { public void testInvalidate(CacheableService<?> service) throws Exception {
Object o1 = new Object(); Object o1 = new Object();
Object o2 = new Object();
Object r1 = service.cache(o1); Object r1 = service.cache(o1);
Object r2 = service.cache(o1); Object r2 = service.cache(o1);
...@@ -85,9 +83,8 @@ public abstract class AbstractAnnotationTests { ...@@ -85,9 +83,8 @@ public abstract class AbstractAnnotationTests {
assertSame(r3, r4); assertSame(r3, r4);
} }
public void testInvalidateWKey(CacheableService service) throws Exception { public void testInvalidateWKey(CacheableService<?> service) throws Exception {
Object o1 = new Object(); Object o1 = new Object();
Object o2 = new Object();
Object r1 = service.cache(o1); Object r1 = service.cache(o1);
Object r2 = service.cache(o1); Object r2 = service.cache(o1);
...@@ -100,7 +97,7 @@ public abstract class AbstractAnnotationTests { ...@@ -100,7 +97,7 @@ public abstract class AbstractAnnotationTests {
assertSame(r3, r4); assertSame(r3, r4);
} }
public void testConditionalExpression(CacheableService service) public void testConditionalExpression(CacheableService<?> service)
throws Exception { throws Exception {
Object r1 = service.conditional(4); Object r1 = service.conditional(4);
Object r2 = service.conditional(4); Object r2 = service.conditional(4);
...@@ -113,7 +110,7 @@ public abstract class AbstractAnnotationTests { ...@@ -113,7 +110,7 @@ public abstract class AbstractAnnotationTests {
assertSame(r3, r4); assertSame(r3, r4);
} }
public void testKeyExpression(CacheableService service) throws Exception { public void testKeyExpression(CacheableService<?> service) throws Exception {
Object r1 = service.key(5, 1); Object r1 = service.key(5, 1);
Object r2 = service.key(5, 2); Object r2 = service.key(5, 2);
...@@ -125,7 +122,7 @@ public abstract class AbstractAnnotationTests { ...@@ -125,7 +122,7 @@ public abstract class AbstractAnnotationTests {
assertNotSame(r3, r4); assertNotSame(r3, r4);
} }
public void testNullValue(CacheableService service) throws Exception { public void testNullValue(CacheableService<?> service) throws Exception {
Object key = new Object(); Object key = new Object();
assertNull(service.nullValue(key)); assertNull(service.nullValue(key));
int nr = service.nullInvocations().intValue(); int nr = service.nullInvocations().intValue();
...@@ -135,7 +132,7 @@ public abstract class AbstractAnnotationTests { ...@@ -135,7 +132,7 @@ public abstract class AbstractAnnotationTests {
assertEquals(nr + 1, service.nullInvocations().intValue()); assertEquals(nr + 1, service.nullInvocations().intValue());
} }
public void testMethodName(CacheableService service, String keyName) public void testMethodName(CacheableService<?> service, String keyName)
throws Exception { throws Exception {
Object key = new Object(); Object key = new Object();
Object r1 = service.name(key); Object r1 = service.name(key);
...@@ -145,7 +142,7 @@ public abstract class AbstractAnnotationTests { ...@@ -145,7 +142,7 @@ public abstract class AbstractAnnotationTests {
assertNotNull(cache.get(keyName)); assertNotNull(cache.get(keyName));
} }
public void testRootVars(CacheableService service) { public void testRootVars(CacheableService<?> service) {
Object key = new Object(); Object key = new Object();
Object r1 = service.rootVars(key); Object r1 = service.rootVars(key);
assertSame(r1, service.rootVars(key)); assertSame(r1, service.rootVars(key));
...@@ -155,7 +152,7 @@ public abstract class AbstractAnnotationTests { ...@@ -155,7 +152,7 @@ public abstract class AbstractAnnotationTests {
assertNotNull(cache.get(expectedKey)); assertNotNull(cache.get(expectedKey));
} }
public void testCheckedThrowable(CacheableService service) throws Exception { public void testCheckedThrowable(CacheableService<?> service) throws Exception {
String arg = UUID.randomUUID().toString(); String arg = UUID.randomUUID().toString();
try { try {
service.throwChecked(arg); service.throwChecked(arg);
...@@ -165,7 +162,7 @@ public abstract class AbstractAnnotationTests { ...@@ -165,7 +162,7 @@ public abstract class AbstractAnnotationTests {
} }
} }
public void testUncheckedThrowable(CacheableService service) throws Exception { public void testUncheckedThrowable(CacheableService<?> service) throws Exception {
try { try {
service.throwUnchecked(Long.valueOf(1)); service.throwUnchecked(Long.valueOf(1));
fail("Excepted exception"); fail("Excepted exception");
...@@ -176,12 +173,12 @@ public abstract class AbstractAnnotationTests { ...@@ -176,12 +173,12 @@ public abstract class AbstractAnnotationTests {
} }
} }
public void testNullArg(CacheableService service) { public void testNullArg(CacheableService<?> service) {
Object r1 = service.cache(null); Object r1 = service.cache(null);
assertSame(r1, service.cache(null)); assertSame(r1, service.cache(null));
} }
public void testCacheUpdate(CacheableService service) { public void testCacheUpdate(CacheableService<?> service) {
Object o = new Object(); Object o = new Object();
Cache cache = cm.getCache("default"); Cache cache = cm.getCache("default");
assertNull(cache.get(o)); assertNull(cache.get(o));
...@@ -194,7 +191,7 @@ public abstract class AbstractAnnotationTests { ...@@ -194,7 +191,7 @@ public abstract class AbstractAnnotationTests {
assertSame(r2, cache.get(o).get()); assertSame(r2, cache.get(o).get());
} }
public void testConditionalCacheUpdate(CacheableService service) { public void testConditionalCacheUpdate(CacheableService<?> service) {
Integer one = Integer.valueOf(1); Integer one = Integer.valueOf(1);
Integer three = Integer.valueOf(3); Integer three = Integer.valueOf(3);
...@@ -206,7 +203,7 @@ public abstract class AbstractAnnotationTests { ...@@ -206,7 +203,7 @@ public abstract class AbstractAnnotationTests {
assertEquals(three, Integer.valueOf(cache.get(three).get().toString())); assertEquals(three, Integer.valueOf(cache.get(three).get().toString()));
} }
public void testMultiCache(CacheableService service) { public void testMultiCache(CacheableService<?> service) {
Object o1 = new Object(); Object o1 = new Object();
Object o2 = new Object(); Object o2 = new Object();
...@@ -232,7 +229,7 @@ public abstract class AbstractAnnotationTests { ...@@ -232,7 +229,7 @@ public abstract class AbstractAnnotationTests {
assertSame(r4, secondary.get(o2).get()); assertSame(r4, secondary.get(o2).get());
} }
public void testMultiEvict(CacheableService service) { public void testMultiEvict(CacheableService<?> service) {
Object o1 = new Object(); Object o1 = new Object();
Object r1 = service.multiCache(o1); Object r1 = service.multiCache(o1);
...@@ -258,7 +255,7 @@ public abstract class AbstractAnnotationTests { ...@@ -258,7 +255,7 @@ public abstract class AbstractAnnotationTests {
assertSame(r4, secondary.get(o1).get()); assertSame(r4, secondary.get(o1).get());
} }
public void testMultiPut(CacheableService service) { public void testMultiPut(CacheableService<?> service) {
Object o = Integer.valueOf(1); Object o = Integer.valueOf(1);
Cache primary = cm.getCache("primary"); Cache primary = cm.getCache("primary");
...@@ -278,7 +275,7 @@ public abstract class AbstractAnnotationTests { ...@@ -278,7 +275,7 @@ public abstract class AbstractAnnotationTests {
assertSame(r2, secondary.get(o).get()); assertSame(r2, secondary.get(o).get());
} }
public void testMultiCacheAndEvict(CacheableService service) { public void testMultiCacheAndEvict(CacheableService<?> service) {
String methodName = "multiCacheAndEvict"; String methodName = "multiCacheAndEvict";
Cache primary = cm.getCache("primary"); Cache primary = cm.getCache("primary");
...@@ -299,7 +296,7 @@ public abstract class AbstractAnnotationTests { ...@@ -299,7 +296,7 @@ public abstract class AbstractAnnotationTests {
assertNull(secondary.get(key)); assertNull(secondary.get(key));
} }
public void testMultiConditionalCacheAndEvict(CacheableService service) { public void testMultiConditionalCacheAndEvict(CacheableService<?> service) {
Cache primary = cm.getCache("primary"); Cache primary = cm.getCache("primary");
Cache secondary = cm.getCache("secondary"); Cache secondary = cm.getCache("secondary");
Object key = Integer.valueOf(1); Object key = Integer.valueOf(1);
......
...@@ -27,7 +27,7 @@ import org.springframework.cache.annotation.Cacheable; ...@@ -27,7 +27,7 @@ import org.springframework.cache.annotation.Cacheable;
* @author Costin Leau * @author Costin Leau
*/ */
@Cacheable("default") @Cacheable("default")
public class AnnotatedClassCacheableService implements CacheableService { public class AnnotatedClassCacheableService implements CacheableService<Object> {
private final AtomicLong counter = new AtomicLong(); private final AtomicLong counter = new AtomicLong();
public static final AtomicLong nullInvocations = new AtomicLong(); public static final AtomicLong nullInvocations = new AtomicLong();
......
...@@ -21,7 +21,6 @@ import junit.framework.Assert; ...@@ -21,7 +21,6 @@ import junit.framework.Assert;
import org.junit.Test; import org.junit.Test;
import org.springframework.cache.interceptor.CacheInterceptor; import org.springframework.cache.interceptor.CacheInterceptor;
/** /**
* @author Costin Leau * @author Costin Leau
*/ */
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
package org.springframework.cache.config; package org.springframework.cache.config;
/** /**
* @author Costin Leau * @author Costin Leau
*/ */
......
...@@ -20,13 +20,11 @@ import org.junit.Assert; ...@@ -20,13 +20,11 @@ import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.springframework.cache.interceptor.CacheInterceptor; import org.springframework.cache.interceptor.CacheInterceptor;
/** /**
* @author Costin Leau * @author Costin Leau
*/ */
public class CacheAdviceNamespaceTests extends AbstractAnnotationTests { public class CacheAdviceNamespaceTests extends AbstractAnnotationTests {
@Override @Override
protected String getConfig() { protected String getConfig() {
return "/org/springframework/cache/config/cache-advice.xml"; return "/org/springframework/cache/config/cache-advice.xml";
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
package org.springframework.cache.config; package org.springframework.cache.config;
/** /**
* Basic service interface. * Basic service interface.
* *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册