@Test public void spr13081ConfigFailIfCacheResolverReturnsNullCacheName() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Spr13081Config.class); Spr13081Service bean = context.getBean(Spr13081Service.class); this.thrown.expect(IllegalStateException.class); this.thrown.expectMessage(MyCacheResolver.class.getName()); bean.getSimple(null); }
@Test public void spr13081ConfigNoCacheNameIsRequired() { 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 assertEquals(result, cacheResolver.getCache("foo").get("foo").get()); }