public void testCreateRequest() throws Exception { MockHttpServletRequestImpl request = context_.createRequest("/hello.html"); assertEquals("1", "/s2jsf-example", request.getContextPath()); assertEquals("2", "/hello.html", request.getServletPath()); request = context_.createRequest("/hello.html?aaa=hoge"); assertEquals("3", "aaa=hoge", request.getQueryString()); }
public MockHttpServletRequest createRequest(String path) { String queryString = null; int question = path.indexOf('?'); if (question >= 0) { queryString = path.substring(question + 1); path = path.substring(0, question); } MockHttpServletRequestImpl request = new MockHttpServletRequestImpl(this, path); request.setQueryString(queryString); return request; }