Search in sources :

Example 1 with MockHttpServletMapping

use of org.springframework.web.testfixture.servlet.MockHttpServletMapping in project spring-framework by spring-projects.

the class ServletRequestPathUtilsTests method testParseAndCache.

private void testParseAndCache(String requestUri, String contextPath, String servletPath, String pathWithinApplication) {
    MockHttpServletRequest request = new MockHttpServletRequest("GET", requestUri);
    request.setContextPath(contextPath);
    request.setServletPath(servletPath);
    request.setHttpServletMapping(new MockHttpServletMapping(pathWithinApplication, contextPath, "myServlet", MappingMatch.PATH));
    RequestPath requestPath = ServletRequestPathUtils.parseAndCache(request);
    assertThat(requestPath.contextPath().value()).isEqualTo(contextPath);
    assertThat(requestPath.pathWithinApplication().value()).isEqualTo(pathWithinApplication);
}
Also used : RequestPath(org.springframework.http.server.RequestPath) MockHttpServletMapping(org.springframework.web.testfixture.servlet.MockHttpServletMapping) MockHttpServletRequest(org.springframework.web.testfixture.servlet.MockHttpServletRequest)

Aggregations

RequestPath (org.springframework.http.server.RequestPath)1 MockHttpServletMapping (org.springframework.web.testfixture.servlet.MockHttpServletMapping)1 MockHttpServletRequest (org.springframework.web.testfixture.servlet.MockHttpServletRequest)1