use of cn.taketoday.web.RequestContext in project today-framework by TAKETODAY.
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, RequestContext> requestFactory) throws Exception {
UrlFilenameViewController controller = new UrlFilenameViewController();
RequestContext request = requestFactory.apply("/products/view.html");
ModelAndView mv = controller.handleRequest(request);
assertThat(mv.getViewName()).isEqualTo("products/view");
assertThat(mv.getModel().isEmpty()).isTrue();
}
use of cn.taketoday.web.RequestContext in project today-framework by TAKETODAY.
the class UrlFilenameViewControllerTests method multiLevelMappingWithFallback.
@PathPatternsParameterizedTest
void multiLevelMappingWithFallback(Function<String, RequestContext> requestFactory) throws Exception {
UrlFilenameViewController controller = new UrlFilenameViewController();
RequestContext request = requestFactory.apply("/docs/cvs/commit.html");
exposePathInMapping(request, "/docs/cvs/commit.html");
ModelAndView mv = controller.handleRequest(request);
assertThat(mv.getViewName()).isEqualTo("docs/cvs/commit");
assertThat(mv.getModel().isEmpty()).isTrue();
}
use of cn.taketoday.web.RequestContext in project today-framework by TAKETODAY.
the class WebContentInterceptorTests method mappedCacheConfigurationOverridesGlobal.
@Test
void mappedCacheConfigurationOverridesGlobal() throws Exception {
Properties mappings = new Properties();
mappings.setProperty("/*/*handle.vm", "-1");
interceptor.setCacheSeconds(10);
interceptor.setCacheMappings(mappings);
RequestContext request = requestFactory.apply("/example/adminhandle.vm");
interceptor.beforeProcess(request, handler);
List<String> cacheControlHeaders = response.getHeaders("Cache-Control");
assertThat(cacheControlHeaders).isEmpty();
request = requestFactory.apply("/example/bingo.html");
interceptor.beforeProcess(request, handler);
cacheControlHeaders = response.getHeaders("Cache-Control");
assertThat(cacheControlHeaders).contains("max-age=10");
}
use of cn.taketoday.web.RequestContext in project today-framework by TAKETODAY.
the class UrlFilenameViewControllerTests method withSuffix.
@PathPatternsParameterizedTest
void withSuffix(Function<String, RequestContext> requestFactory) throws Exception {
UrlFilenameViewController controller = new UrlFilenameViewController();
controller.setSuffix("_mysuf");
RequestContext request = requestFactory.apply("/index.html");
ModelAndView mv = controller.handleRequest(request);
assertThat(mv.getViewName()).isEqualTo("index_mysuf");
assertThat(mv.getModel().isEmpty()).isTrue();
}
use of cn.taketoday.web.RequestContext in project today-framework by TAKETODAY.
the class UrlFilenameViewControllerTests method multiLevelWithMapping.
@PathPatternsParameterizedTest
void multiLevelWithMapping(Function<String, RequestContext> requestFactory) throws Exception {
UrlFilenameViewController controller = new UrlFilenameViewController();
RequestContext request = requestFactory.apply("/cvs/commit.html");
ModelAndView mv = controller.handleRequest(request);
assertThat(mv.getViewName()).isEqualTo("cvs/commit");
assertThat(mv.getModel().isEmpty()).isTrue();
}
Aggregations