@Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
            throws IOException, ServletException {
        RequestContext requestContext = RequestContextHolder.getContext();
        try {
            requestContext.getBasicContext().setRequestProtocol(BasicContext.HTTP_PROTOCOL);
            HttpServletRequest request = (HttpServletRequest) servletRequest;
            setRequestTarget(request, requestContext);
            setEncoding(request, requestContext);
            setAddressContext(request, requestContext);
            setOtherBasicContext(request, requestContext);
            filterChain.doFilter(servletRequest, servletResponse);
        } finally {
            RequestContextHolder.removeContext();
        }
    }
@Test
    public void testDoFilterSetsCorrectContextValues() throws Exception {
        MockNextFilter nextFilter = new MockNextFilter("testApp", "GBK");
        filter.doFilter(servletRequest, servletResponse, new MockFilterChain(servlet, nextFilter));
        if (null != nextFilter.error) {
            throw nextFilter.error;
        }
    }