RequestImpl implements Request { public List<String> getParameterNames() { setupEncoding(); return InternalUtils.toList(request.getParameterNames()); } RequestImpl(
            HttpServletRequest request,
            String applicationCharset,
            TapestrySessionFactory sessionFactory); List<String> getParameterNames(); List<String> getHeaderNames(); String getParameter(String name); String[] getParameters(String name); String getHeader(String name); String getPath(); String getContextPath(); boolean isSessionInvalidated(); Session getSession(boolean create); Locale getLocale(); long getDateHeader(String name); boolean isXHR(); boolean isSecure(); boolean isRequestedSessionIdValid(); Object getAttribute(String name); List<String> getAttributeNames(); void setAttribute(String name, Object value); String getMethod(); String getServerName(); int getLocalPort(); int getServerPort(); String getRemoteHost();  }
@Test public void used_encoding_from_request() throws Exception { HttpServletRequest sr = mockHttpServletRequest(); expect(sr.getCharacterEncoding()).andReturn("request-encoding"); sr.setCharacterEncoding("request-encoding"); expect(sr.getParameterNames()).andReturn(Collections.enumeration(Collections.EMPTY_LIST)); replay(); new RequestImpl(sr, "app-encoding-is-ignored", null).getParameterNames(); verify(); }
@Test public void set_encoding_success() throws Exception { HttpServletRequest sr = mockHttpServletRequest(); String encoding = "the-encoding"; sr.setCharacterEncoding(encoding); expect(sr.getCharacterEncoding()).andReturn(null); expect(sr.getParameterNames()).andReturn(Collections.enumeration(Collections.EMPTY_LIST)); replay(); new RequestImpl(sr, encoding, null).getParameterNames(); verify(); }
@Test public void set_encoding_failure() throws Exception { HttpServletRequest sr = mockHttpServletRequest(); String encoding = "the-encoding"; UnsupportedEncodingException exception = new UnsupportedEncodingException("Oops."); sr.setCharacterEncoding(encoding); setThrowable(exception); expect(sr.getCharacterEncoding()).andReturn(null); replay(); try { new RequestImpl(sr, encoding, null).getParameterNames(); unreachable(); } catch (RuntimeException ex) { assertSame(ex.getCause(), exception); } verify(); }