StaticResourceServlet extends HttpServlet { static boolean isClientCompressionSupported(final HttpServletRequest req) { return StringUtils.contains(req.getHeader("Accept-Encoding"), "gzip"); }    }
@Test public void isClientCompressionSupported() { final HttpServletRequest request = Mockito .mock(HttpServletRequest.class); Mockito.when(request.getHeader("Accept-Encoding")).thenReturn( "gzip, deflate"); Assert.assertTrue(StaticResourceServlet .isClientCompressionSupported(request)); }
@Test public void isClientCompressionSupportedWithoutHeader() { final HttpServletRequest request = Mockito .mock(HttpServletRequest.class); Mockito.when(request.getHeader("Accept-Encoding")).thenReturn(null); Assert.assertFalse(StaticResourceServlet .isClientCompressionSupported(request)); }