From fdb31cd715f4a8811fbbe0b541b54ee5f65fa8df Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 29 Apr 2016 10:56:26 +0200 Subject: [PATCH] Check actual cache value for unwrapped Optional Issue: SPR-14230 --- .../java/org/springframework/cache/CacheReproTests.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java b/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java index 06729f9eb9..729bb61dfd 100644 --- a/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java +++ b/spring-context/src/test/java/org/springframework/cache/CacheReproTests.java @@ -137,10 +137,17 @@ public class CacheReproTests { public void spr14230AdaptsToOptional() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Spr14230Config.class); Spr14230Service bean = context.getBean(Spr14230Service.class); + Cache cache = context.getBean(CacheManager.class).getCache("itemCache"); TestBean tb = new TestBean("tb1"); bean.insertItem(tb); assertSame(tb, bean.findById("tb1").get()); + assertSame(tb, cache.get("tb1").get()); + + cache.clear(); + TestBean tb2 = bean.findById("tb1").get(); + assertNotSame(tb, tb2); + assertSame(tb2, cache.get("tb1").get()); }