MyHttpServletRequestWrapper extends HttpServletRequestWrapper { @Override public String getPathInfo() { if (pathInfo != null) { return pathInfo; } try { String svnFileUrl = getRequestURI().substring( PathUtils.removeDuplicatedPrependedSlash(getContextPath() + "/svn").length()); pathInfo = SVNEncodingUtil.uriEncode(URLDecoder.decode(svnFileUrl, "UTF-8")); return pathInfo; } catch (UnsupportedEncodingException e) { return null; } } MyHttpServletRequestWrapper(HttpServletRequest request); @Override String getPathInfo();  }
@Test public void testHandleRequest() { HttpServletRequest req = new MockHttpServletRequest("GET", "http: wrapper = new MyHttpServletRequestWrapper(req) { public String getRequestURI() { return "/hello/svn/admin/한글"; } @Override public String getContextPath() { return "/hello"; } }; String path = wrapper.getPathInfo(); assertThat(path, is("/admin/%ED%95%9C%EA%B8%80")); }
@Test public void testHandleRequest3() throws UnsupportedEncodingException { String testURI = "/hello/svnadmin/admin/한글"; testURI = URLEncoder.encode(testURI, "UTF-8"); HttpServletRequest req = new MockHttpServletRequest("GET", testURI); wrapper = new MyHttpServletRequestWrapper(req) { public String getRequestURI() { return "/hello/svn/admin/한글"; } @Override public String getContextPath() { return "/hello"; } }; String path = wrapper.getPathInfo(); assertThat(path, is("/admin/%ED%95%9C%EA%B8%80")); }
@Test public void testHandleRequest2() { HttpServletRequest req = new MockHttpServletRequest("GET", "http: wrapper = new MyHttpServletRequestWrapper(req) { public String getRequestURI() { return "/hello/svnadmin/admin"; } @Override public String getContextPath() { return "/hello"; } }; String path = wrapper.getPathInfo(); assertThat(path, is("admin/admin")); }