Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -83,11 +83,11 @@ public class CacheReproTests {
|
||||
|
||||
String key = "1";
|
||||
Object result = bean.getSimple("1");
|
||||
verify(cache, times(1)).get(key); // first call: cache miss
|
||||
verify(cache, times(1)).get(key); // first call: cache miss
|
||||
|
||||
Object cachedResult = bean.getSimple("1");
|
||||
assertSame(result, cachedResult);
|
||||
verify(cache, times(2)).get(key); // second call: cache hit
|
||||
verify(cache, times(2)).get(key); // second call: cache hit
|
||||
|
||||
context.close();
|
||||
}
|
||||
@@ -100,11 +100,11 @@ public class CacheReproTests {
|
||||
|
||||
String key = "1";
|
||||
Object result = bean.getNeverCache("1");
|
||||
verify(cache, times(0)).get(key); // no cache hit at all, caching disabled
|
||||
verify(cache, times(0)).get(key); // no cache hit at all, caching disabled
|
||||
|
||||
Object cachedResult = bean.getNeverCache("1");
|
||||
assertNotSame(result, cachedResult);
|
||||
verify(cache, times(0)).get(key); // caching disabled
|
||||
verify(cache, times(0)).get(key); // caching disabled
|
||||
|
||||
context.close();
|
||||
}
|
||||
@@ -114,8 +114,9 @@ public class CacheReproTests {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Spr13081Config.class);
|
||||
MyCacheResolver cacheResolver = context.getBean(MyCacheResolver.class);
|
||||
Spr13081Service bean = context.getBean(Spr13081Service.class);
|
||||
|
||||
assertNull(cacheResolver.getCache("foo").get("foo"));
|
||||
Object result = bean.getSimple("foo"); // cache name = id
|
||||
Object result = bean.getSimple("foo"); // cache name = id
|
||||
assertEquals(result, cacheResolver.getCache("foo").get("foo").get());
|
||||
}
|
||||
|
||||
@@ -124,7 +125,6 @@ public class CacheReproTests {
|
||||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Spr13081Config.class);
|
||||
Spr13081Service bean = context.getBean(Spr13081Service.class);
|
||||
|
||||
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage(MyCacheResolver.class.getName());
|
||||
bean.getSimple(null);
|
||||
@@ -245,6 +245,7 @@ public class CacheReproTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public static class Spr13081Config extends CachingConfigurerSupport {
|
||||
@@ -259,9 +260,9 @@ public class CacheReproTests {
|
||||
public Spr13081Service service() {
|
||||
return new Spr13081Service();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static class MyCacheResolver extends AbstractCacheResolver {
|
||||
|
||||
public MyCacheResolver() {
|
||||
@@ -282,6 +283,7 @@ public class CacheReproTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class Spr13081Service {
|
||||
|
||||
@Cacheable
|
||||
|
||||
Reference in New Issue
Block a user