use of org.springframework.web.servlet.handler.PathPatternsParameterizedTest in project spring-framework by spring-projects.
the class UriTemplateServletAnnotationControllerHandlerMethodTests method crud.
@PathPatternsParameterizedTest
void crud(boolean usePathPatterns) throws Exception {
initDispatcherServlet(CrudController.class, usePathPatterns);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/hotels");
MockHttpServletResponse response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getContentAsString()).isEqualTo("list");
request = new MockHttpServletRequest("GET", "/hotels/");
response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getContentAsString()).isEqualTo("list");
request = new MockHttpServletRequest("POST", "/hotels");
response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getContentAsString()).isEqualTo("create");
request = new MockHttpServletRequest("GET", "/hotels/42");
response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getContentAsString()).isEqualTo("show-42");
request = new MockHttpServletRequest("GET", "/hotels/42/");
response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getContentAsString()).isEqualTo("show-42");
request = new MockHttpServletRequest("PUT", "/hotels/42");
response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getContentAsString()).isEqualTo("createOrUpdate-42");
request = new MockHttpServletRequest("DELETE", "/hotels/42");
response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getContentAsString()).isEqualTo("remove-42");
}
use of org.springframework.web.servlet.handler.PathPatternsParameterizedTest in project spring-framework by spring-projects.
the class DefaultRequestToViewNameTranslatorTests method testGetViewNameWithSuffix.
@PathPatternsParameterizedTest
void testGetViewNameWithSuffix(Function<String, MockHttpServletRequest> requestFactory) {
final String suffix = ".fiona";
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME);
this.translator.setSuffix(suffix);
assertViewName(request, VIEW_NAME + suffix);
}
use of org.springframework.web.servlet.handler.PathPatternsParameterizedTest in project spring-framework by spring-projects.
the class DefaultRequestToViewNameTranslatorTests method testGetViewNameLeavesExtensionIfSoConfigured.
@PathPatternsParameterizedTest
void testGetViewNameLeavesExtensionIfSoConfigured(Function<String, MockHttpServletRequest> requestFactory) {
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME + EXTENSION);
this.translator.setStripExtension(false);
assertViewName(request, VIEW_NAME + EXTENSION);
}
use of org.springframework.web.servlet.handler.PathPatternsParameterizedTest in project spring-framework by spring-projects.
the class DefaultRequestToViewNameTranslatorTests method testGetViewNameLeavesTrailingSlashIfSoConfigured.
@PathPatternsParameterizedTest
void testGetViewNameLeavesTrailingSlashIfSoConfigured(Function<String, MockHttpServletRequest> requestFactory) {
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME + "/");
this.translator.setStripTrailingSlash(false);
assertViewName(request, VIEW_NAME + "/");
}
use of org.springframework.web.servlet.handler.PathPatternsParameterizedTest in project spring-framework by spring-projects.
the class DefaultRequestToViewNameTranslatorTests method testGetViewNameWithPrefix.
@PathPatternsParameterizedTest
void testGetViewNameWithPrefix(Function<String, MockHttpServletRequest> requestFactory) {
final String prefix = "fiona_";
MockHttpServletRequest request = requestFactory.apply(VIEW_NAME);
this.translator.setPrefix(prefix);
assertViewName(request, prefix + VIEW_NAME);
}
Aggregations