HttpFilter extends GenericFilter { @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { if (request instanceof HttpServletRequest && response instanceof HttpServletResponse) { HttpServletRequest httpServletRequest = (HttpServletRequest) request; HttpServletResponse httpServletResponse = (HttpServletResponse) response; this.doFilter(httpServletRequest, httpServletResponse, chain); } else { throw new ServletException("not a HTTP request or a HTTP response"); } }  @Override void doFilter(ServletRequest request, ServletResponse response, FilterChain chain);  }
@Test void testDoFilter() throws Exception { HttpServletRequest request = null; HttpServletResponse response = null; FilterChain chain = new TestFilterChain(); HttpFilter filter = new TestHttpFilter(); filter.doFilter(request, response, chain); }