use of org.springframework.web.servlet.handler.PathPatternsParameterizedTest in project spring-framework by spring-projects.
the class UrlFilenameViewControllerTests method withPlainFilename.
@PathPatternsParameterizedTest
void withPlainFilename(Function<String, MockHttpServletRequest> requestFactory) throws Exception {
UrlFilenameViewController controller = new UrlFilenameViewController();
MockHttpServletRequest request = requestFactory.apply("/index");
ModelAndView mv = controller.handleRequest(request, new MockHttpServletResponse());
assertThat(mv.getViewName()).isEqualTo("index");
assertThat(mv.getModel().isEmpty()).isTrue();
}
use of org.springframework.web.servlet.handler.PathPatternsParameterizedTest in project spring-framework by spring-projects.
the class UrlFilenameViewControllerTests method withContextMapping.
@PathPatternsParameterizedTest
void withContextMapping(Function<String, MockHttpServletRequest> requestFactory) throws Exception {
UrlFilenameViewController controller = new UrlFilenameViewController();
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myapp/docs/cvs/commit.html");
request.setContextPath("/myapp");
ServletRequestPathUtils.parseAndCache(request);
ModelAndView mv = controller.handleRequest(request, new MockHttpServletResponse());
assertThat(mv.getViewName()).isEqualTo("docs/cvs/commit");
assertThat(mv.getModel().isEmpty()).isTrue();
}
use of org.springframework.web.servlet.handler.PathPatternsParameterizedTest in project spring-framework by spring-projects.
the class UrlFilenameViewControllerTests method withPrefixAndSuffix.
@PathPatternsParameterizedTest
void withPrefixAndSuffix(Function<String, MockHttpServletRequest> requestFactory) throws Exception {
UrlFilenameViewController controller = new UrlFilenameViewController();
controller.setPrefix("mypre_");
controller.setSuffix("_mysuf");
MockHttpServletRequest request = requestFactory.apply("/index.html");
ModelAndView mv = controller.handleRequest(request, new MockHttpServletResponse());
assertThat(mv.getViewName()).isEqualTo("mypre_index_mysuf");
assertThat(mv.getModel().isEmpty()).isTrue();
}
use of org.springframework.web.servlet.handler.PathPatternsParameterizedTest in project spring-framework by spring-projects.
the class UrlFilenameViewControllerTests method nestedPathisUsedAsViewName_InBreakingChangeFromSpring12Line.
/**
* This is the expected behavior, and it now has a test to prove it.
* https://opensource.atlassian.com/projects/spring/browse/SPR-2789
*/
@PathPatternsParameterizedTest
void nestedPathisUsedAsViewName_InBreakingChangeFromSpring12Line(Function<String, MockHttpServletRequest> requestFactory) throws Exception {
UrlFilenameViewController controller = new UrlFilenameViewController();
MockHttpServletRequest request = requestFactory.apply("/products/view.html");
ModelAndView mv = controller.handleRequest(request, new MockHttpServletResponse());
assertThat(mv.getViewName()).isEqualTo("products/view");
assertThat(mv.getModel().isEmpty()).isTrue();
}
use of org.springframework.web.servlet.handler.PathPatternsParameterizedTest in project spring-framework by spring-projects.
the class ServletAnnotationControllerHandlerMethodTests method unmappedPathMapping.
// gh-22543
@PathPatternsParameterizedTest
void unmappedPathMapping(boolean usePathPatterns) throws Exception {
initDispatcherServlet(UnmappedPathController.class, usePathPatterns);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/bogus-unmapped");
MockHttpServletResponse response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getStatus()).isEqualTo(404);
request = new MockHttpServletRequest("GET", "");
response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentAsString()).isEqualTo("get");
}
Aggregations