@Test public void contextPathEmpty() throws Exception { this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/foo"); MockHttpServletRequest request = this.builder.buildRequest(this.servletContext); assertEquals("", request.getContextPath()); assertEquals("", request.getServletPath()); assertEquals("/foo", request.getPathInfo()); }
@Test public void contextPathServletPathInfo() throws Exception { this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/"); this.builder.servletPath("/index.html"); this.builder.pathInfo(null); MockHttpServletRequest request = this.builder.buildRequest(this.servletContext); assertEquals("", request.getContextPath()); assertEquals("/index.html", request.getServletPath()); assertNull(request.getPathInfo()); }
@Test public void contextPathServletPath() throws Exception { this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/travel/main/hotels/42"); this.builder.contextPath("/travel"); this.builder.servletPath("/main"); MockHttpServletRequest request = this.builder.buildRequest(this.servletContext); assertEquals("/travel", request.getContextPath()); assertEquals("/main", request.getServletPath()); assertEquals("/hotels/42", request.getPathInfo()); }