コード例 #1
0
  @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());
  }
コード例 #2
0
  @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());
  }
コード例 #3
0
  @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());
  }