use of org.springframework.web.servlet.handler.PathPatternsParameterizedTest in project spring-framework by spring-projects.
the class UriTemplateServletAnnotationControllerHandlerMethodTests method customRegex.
@PathPatternsParameterizedTest
void customRegex(boolean usePathPatterns) throws Exception {
initDispatcherServlet(CustomRegexController.class, usePathPatterns);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/42;q=1;q=2");
MockHttpServletResponse response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getContentAsString()).isEqualTo(!usePathPatterns ? "test-42-;q=1;q=2-[1, 2]" : "test-42--[1, 2]");
}
use of org.springframework.web.servlet.handler.PathPatternsParameterizedTest in project spring-framework by spring-projects.
the class UriTemplateServletAnnotationControllerHandlerMethodTests method variableNamesWithUrlExtension.
// gh-13187
@PathPatternsParameterizedTest
void variableNamesWithUrlExtension(boolean usePathPatterns) throws Exception {
initDispatcherServlet(VariableNamesController.class, usePathPatterns, wac -> {
if (!usePathPatterns) {
RootBeanDefinition mappingDef = new RootBeanDefinition(RequestMappingHandlerMapping.class);
mappingDef.getPropertyValues().add("useSuffixPatternMatch", true);
wac.registerBeanDefinition("handlerMapping", mappingDef);
}
});
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/test/foo.json");
MockHttpServletResponse response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getContentAsString()).isEqualTo(!usePathPatterns ? "foo-foo" : "foo-foo.json");
}
use of org.springframework.web.servlet.handler.PathPatternsParameterizedTest in project spring-framework by spring-projects.
the class UriTemplateServletAnnotationControllerHandlerMethodTests method explicitSubPath.
@PathPatternsParameterizedTest
void explicitSubPath(boolean usePathPatterns) throws Exception {
initDispatcherServlet(ExplicitSubPathController.class, usePathPatterns);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hotels/42");
MockHttpServletResponse response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getContentAsString()).isEqualTo("test-42");
}
use of org.springframework.web.servlet.handler.PathPatternsParameterizedTest in project spring-framework by spring-projects.
the class UriTemplateServletAnnotationControllerHandlerMethodTests method ambiguous.
@PathPatternsParameterizedTest
void ambiguous(boolean usePathPatterns) throws Exception {
initDispatcherServlet(AmbiguousUriTemplateController.class, usePathPatterns);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hotels/new");
MockHttpServletResponse response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getContentAsString()).isEqualTo("specific");
}
use of org.springframework.web.servlet.handler.PathPatternsParameterizedTest in project spring-framework by spring-projects.
the class UriTemplateServletAnnotationControllerHandlerMethodTests method typeConversionError.
@PathPatternsParameterizedTest
void typeConversionError(boolean usePathPatterns) throws Exception {
initDispatcherServlet(SimpleUriTemplateController.class, usePathPatterns);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo.xml");
MockHttpServletResponse response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getStatus()).as("Invalid response status code").isEqualTo(HttpServletResponse.SC_BAD_REQUEST);
}
Aggregations