### Question:
CacheBase implements ApplicationContextAware { protected void verifyReturnTypeIsList(final Method method, final Class annotationClass) { if (verifyTypeIsList(method.getReturnType())) { return; } throw new InvalidAnnotationException(String.format( "The annotation [%s] is only valid on a method that returns a [%s]. " + "[%s] does not fulfill this requirement.", ReadThroughMultiCache.class.getName(), List.class.getName(), method.toString() )); }  void setApplicationContext(ApplicationContext applicationContext); void setCache(MemcachedClientIF cache); void setMethodStore(CacheKeyMethodStore methodStore); void setDefaultKeyProvider(KeyProvider defaultKeyProvider);  }### Answer:
@Test public void testReturnTypeChecking() throws Exception { Method method = null; method = ReturnTypeCheck.class.getMethod("checkA", null); cut.verifyReturnTypeIsList(method, CacheKeyMethod.class); method = ReturnTypeCheck.class.getMethod("checkB", null); cut.verifyReturnTypeIsList(method, CacheKeyMethod.class); method = ReturnTypeCheck.class.getMethod("checkC", null); cut.verifyReturnTypeIsList(method, CacheKeyMethod.class); method = ReturnTypeCheck.class.getMethod("checkD", null); cut.verifyReturnTypeIsList(method, CacheKeyMethod.class); try { method = ReturnTypeCheck.class.getMethod("checkE", null); cut.verifyReturnTypeIsList(method, CacheKeyMethod.class); fail("Expected Exception."); } catch (InvalidAnnotationException ex) { assertTrue(ex.getMessage().indexOf("requirement") != -1); } }