CacheFilter implements Filter { public boolean shouldNotCache(String requestUri) { String uri = requestUri.toLowerCase(); return checkContains(uri, noCacheIdentifiers) || checkSuffixes(uri, noCacheSuffixes); }  @Override void destroy(); @Override void init(FilterConfig config); @Override @edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "AvoidUsingHardCodedIP", justification = "double-safe check on localhost, ease configuration for development") void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain); boolean shouldCache(String requestUri); boolean shouldNotCache(String requestUri); boolean shouldCompress(String requestUri); boolean checkContains(String uri, String[] patterns); boolean checkSuffixes(String uri, String[] patterns); boolean checkPrefixes(String uri, String[] patterns); @Api static void configureNoCaching(HttpServletResponse response); static final String CACHE_DURATION_IN_SECONDS; static final String CACHE_IDENTIFIERS; static final String CACHE_SUFFIXES; static final String NO_CACHE_IDENTIFIERS; static final String NO_CACHE_SUFFIXES; static final String ZIP_SUFFIXES; static final String SKIP_PREFIXES; static final String PARAMETER_SPLIT_REGEX; static final String LOCALHOST_NAME; static final String LOCALHOST_IP_V4; static final String LOCALHOST_IP_V6; }
@Test public void testShouldNotCache() { CacheFilter cf = new CacheFilter(); Assert.assertTrue(cf.shouldNotCache("/bla.nocache.jpg")); Assert.assertTrue(cf.shouldNotCache("/bla.nocache.jpeg")); Assert.assertFalse(cf.shouldNotCache("/blabla.jpg")); Assert.assertFalse(cf.shouldNotCache("/blabla.jpeg")); Assert.assertFalse(cf.shouldNotCache("/blabla.html")); Assert.assertTrue(cf.shouldNotCache("/bla.nocache.jpg")); Assert.assertTrue(cf.shouldNotCache("/bla.nocache.jpeg")); Assert.assertFalse(cf.shouldNotCache("/blabla.JPG")); Assert.assertFalse(cf.shouldNotCache("/blabla.JPEG")); Assert.assertFalse(cf.shouldNotCache("/blabla.HTML")); Assert.assertTrue(cf.shouldNotCache("/bla.NOCACHE.jpg")); Assert.assertTrue(cf.shouldNotCache("/bla.nocache.JPG")); Assert.assertTrue(cf.shouldNotCache("/bla.NOCACHE.jpeg")); Assert.assertTrue(cf.shouldNotCache("/bla.nocache.JPeG")); }