@Test public void testNoInteraction() throws IOException, ServletException{ HttpServletRequest req = mockRequest(null, null); HttpServletResponse res = Mockito.mock(HttpServletResponse.class); FilterChain chain = Mockito.mock(FilterChain.class); new GzipFilter().doFilter(req, res, chain); Mockito.verify(chain).doFilter(Mockito.same(req), Mockito.same(res)); }
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException{ HttpServletRequest req = (HttpServletRequest)request; HttpServletResponse res = (HttpServletResponse)response; if("gzip".equalsIgnoreCase(req.getHeader("Content-Encoding"))){ req = new GzipMessageRequest(req); } if(String.valueOf(req.getHeader("Accept-Encoding")).toLowerCase().contains("gzip")){ res = new GzipMessageResponse(res); res.setHeader("Content-Encoding", "gzip"); } chain.doFilter(req, res); }
GzipFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException{ HttpServletRequest req = (HttpServletRequest)request; HttpServletResponse res = (HttpServletResponse)response; if("gzip".equalsIgnoreCase(req.getHeader("Content-Encoding"))){ req = new GzipMessageRequest(req); } if(String.valueOf(req.getHeader("Accept-Encoding")).toLowerCase().contains("gzip")){ res = new GzipMessageResponse(res); res.setHeader("Content-Encoding", "gzip"); } chain.doFilter(req, res); } }
GzipFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException{ HttpServletRequest req = (HttpServletRequest)request; HttpServletResponse res = (HttpServletResponse)response; if("gzip".equalsIgnoreCase(req.getHeader("Content-Encoding"))){ req = new GzipMessageRequest(req); } if(String.valueOf(req.getHeader("Accept-Encoding")).toLowerCase().contains("gzip")){ res = new GzipMessageResponse(res); res.setHeader("Content-Encoding", "gzip"); } chain.doFilter(req, res); }  }
GzipFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException{ HttpServletRequest req = (HttpServletRequest)request; HttpServletResponse res = (HttpServletResponse)response; if("gzip".equalsIgnoreCase(req.getHeader("Content-Encoding"))){ req = new GzipMessageRequest(req); } if(String.valueOf(req.getHeader("Accept-Encoding")).toLowerCase().contains("gzip")){ res = new GzipMessageResponse(res); res.setHeader("Content-Encoding", "gzip"); } chain.doFilter(req, res); }  @Override void init(FilterConfig filterConfig); @Override void doFilter(ServletRequest request, ServletResponse response, FilterChain chain); @Override void destroy(); }
GzipFilter implements Filter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException{ HttpServletRequest req = (HttpServletRequest)request; HttpServletResponse res = (HttpServletResponse)response; if("gzip".equalsIgnoreCase(req.getHeader("Content-Encoding"))){ req = new GzipMessageRequest(req); } if(String.valueOf(req.getHeader("Accept-Encoding")).toLowerCase().contains("gzip")){ res = new GzipMessageResponse(res); res.setHeader("Content-Encoding", "gzip"); } chain.doFilter(req, res); }  @Override void init(FilterConfig filterConfig); @Override void doFilter(ServletRequest request, ServletResponse response, FilterChain chain); @Override void destroy();  }