public void testCharacterEncodingSetBeforeRequestWrappingAndActionService() throws Exception {
    MockServletContext servletContext = new MockServletContext();
    MockFilterConfig filterConfig = new MockFilterConfig(servletContext);
    MockHttpServletRequest req = new MockHttpServletRequest(servletContext);
    MockHttpServletResponse res = new MockHttpServletResponse();
    MockFilterChain chain = new MockFilterChain();
    final InnerDispatcher _dispatcher = new InnerDispatcher(servletContext);
    Dispatcher.setInstance(null);

    _dispatcher.setDefaultEncoding("UTF-16_DUMMY");

    FilterDispatcher filter =
        new FilterDispatcher() {
          protected Dispatcher createDispatcher(FilterConfig filterConfig) {
            return _dispatcher;
          }
        };
    filter.init(filterConfig);
    // set ActionMapper after init() as all dependencies will be injected in init()
    filter.setActionMapper(new InnerActionMapper());
    _dispatcher.setDefaultEncoding("UTF-16_DUMMY");
    filter.doFilter(req, res, chain);

    assertTrue(_dispatcher.wrappedRequest);
    assertTrue(_dispatcher.serviceRequest);
  }
  public void testIfActionMapperIsNullDontServiceAction() throws Exception {
    MockServletContext servletContext = new MockServletContext();
    MockFilterConfig filterConfig = new MockFilterConfig(servletContext);
    MockHttpServletRequest req = new MockHttpServletRequest(servletContext);
    MockHttpServletResponse res = new MockHttpServletResponse();
    MockFilterChain chain = new MockFilterChain();
    final NoOpDispatcher _dispatcher = new NoOpDispatcher(servletContext);
    ConfigurationManager confManager = new ConfigurationManager();
    confManager.setConfiguration(new DefaultConfiguration());
    _dispatcher.setConfigurationManager(confManager);
    Dispatcher.setInstance(_dispatcher);

    FilterDispatcher filter =
        new FilterDispatcher() {
          protected Dispatcher createDispatcher() {
            return _dispatcher;
          }
        };
    filter.init(filterConfig);
    filter.setActionMapper(null);
    filter.doFilter(req, res, chain);

    assertFalse(_dispatcher.serviceRequest);
  }