CacheFilter implements Filter { public boolean shouldCompress(String requestUri) { String uri = requestUri.toLowerCase(); return checkSuffixes(uri, zipSuffixes); }  @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 testShouldCompress() { CacheFilter cf = new CacheFilter(); Assert.assertTrue(cf.shouldCompress("/blabla.js")); Assert.assertTrue(cf.shouldCompress("/blabla.html")); Assert.assertTrue(cf.shouldCompress("/blabla.css")); Assert.assertFalse(cf.shouldCompress("/blabla.jpg")); Assert.assertFalse(cf.shouldCompress("/blabla.jpeg")); Assert.assertFalse(cf.shouldCompress("/blabla.gif")); Assert.assertFalse(cf.shouldCompress("/blabla.png")); Assert.assertTrue(cf.shouldCompress("/blabla.JS")); Assert.assertTrue(cf.shouldCompress("/blabla.HtML")); Assert.assertTrue(cf.shouldCompress("/blabla.CsS")); Assert.assertFalse(cf.shouldCompress("/blabla.JPG")); Assert.assertFalse(cf.shouldCompress("/blabla.JPeG")); Assert.assertFalse(cf.shouldCompress("/blabla.GIF")); Assert.assertFalse(cf.shouldCompress("/blabla.PNG")); }