Search in sources :

Example 96 with RequestContext

use of cn.taketoday.web.RequestContext in project today-infrastructure by TAKETODAY.

the class UrlFilenameViewControllerTests method withPlainFilename.

@PathPatternsParameterizedTest
void withPlainFilename(Function<String, RequestContext> requestFactory) throws Exception {
    UrlFilenameViewController controller = new UrlFilenameViewController();
    RequestContext request = requestFactory.apply("/index");
    ModelAndView mv = controller.handleRequest(request);
    assertThat(mv.getViewName()).isEqualTo("index");
    assertThat(mv.getModel().isEmpty()).isTrue();
}
Also used : ModelAndView(cn.taketoday.web.view.ModelAndView) RequestContext(cn.taketoday.web.RequestContext) ServletRequestContext(cn.taketoday.web.servlet.ServletRequestContext) MockServletRequestContext(cn.taketoday.web.servlet.MockServletRequestContext) PathPatternsParameterizedTest(cn.taketoday.web.view.PathPatternsParameterizedTest)

Example 97 with RequestContext

use of cn.taketoday.web.RequestContext in project today-infrastructure by TAKETODAY.

the class UrlFilenameViewControllerTests method withFilenameAndMatrixVariables.

@PathPatternsParameterizedTest
void withFilenameAndMatrixVariables(Function<String, RequestContext> requestFactory) throws Exception {
    UrlFilenameViewController controller = new UrlFilenameViewController();
    RequestContext request = requestFactory.apply("/index;a=A;b=B");
    ModelAndView mv = controller.handleRequest(request);
    assertThat(mv.getViewName()).isEqualTo("index");
    assertThat(mv.getModel().isEmpty()).isTrue();
}
Also used : ModelAndView(cn.taketoday.web.view.ModelAndView) RequestContext(cn.taketoday.web.RequestContext) ServletRequestContext(cn.taketoday.web.servlet.ServletRequestContext) MockServletRequestContext(cn.taketoday.web.servlet.MockServletRequestContext) PathPatternsParameterizedTest(cn.taketoday.web.view.PathPatternsParameterizedTest)

Example 98 with RequestContext

use of cn.taketoday.web.RequestContext in project today-infrastructure by TAKETODAY.

the class UrlFilenameViewControllerTests method multiLevel.

@PathPatternsParameterizedTest
void multiLevel(Function<String, RequestContext> requestFactory) throws Exception {
    UrlFilenameViewController controller = new UrlFilenameViewController();
    RequestContext request = requestFactory.apply("/docs/cvs/commit.html");
    ModelAndView mv = controller.handleRequest(request);
    assertThat(mv.getViewName()).isEqualTo("docs/cvs/commit");
    assertThat(mv.getModel().isEmpty()).isTrue();
}
Also used : ModelAndView(cn.taketoday.web.view.ModelAndView) RequestContext(cn.taketoday.web.RequestContext) ServletRequestContext(cn.taketoday.web.servlet.ServletRequestContext) MockServletRequestContext(cn.taketoday.web.servlet.MockServletRequestContext) PathPatternsParameterizedTest(cn.taketoday.web.view.PathPatternsParameterizedTest)

Example 99 with RequestContext

use of cn.taketoday.web.RequestContext in project today-infrastructure by TAKETODAY.

the class UrlFilenameViewControllerTests method withFlashAttributes.

@PathPatternsParameterizedTest
void withFlashAttributes(Function<String, RequestContext> requestFactory) throws Exception {
    UrlFilenameViewController controller = new UrlFilenameViewController();
    RequestContext request = requestFactory.apply("/index");
    request.setAttribute(RedirectModel.INPUT_ATTRIBUTE, new RedirectModel("name", "value"));
    ModelAndView mv = controller.handleRequest(request);
    assertThat(mv.getViewName()).isEqualTo("index");
    assertThat(mv.getModel().size()).isEqualTo(1);
    assertThat(mv.getModel().get("name")).isEqualTo("value");
}
Also used : RedirectModel(cn.taketoday.web.view.RedirectModel) ModelAndView(cn.taketoday.web.view.ModelAndView) RequestContext(cn.taketoday.web.RequestContext) ServletRequestContext(cn.taketoday.web.servlet.ServletRequestContext) MockServletRequestContext(cn.taketoday.web.servlet.MockServletRequestContext) PathPatternsParameterizedTest(cn.taketoday.web.view.PathPatternsParameterizedTest)

Example 100 with RequestContext

use of cn.taketoday.web.RequestContext in project today-infrastructure 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();
}
Also used : ModelAndView(cn.taketoday.web.view.ModelAndView) RequestContext(cn.taketoday.web.RequestContext) ServletRequestContext(cn.taketoday.web.servlet.ServletRequestContext) MockServletRequestContext(cn.taketoday.web.servlet.MockServletRequestContext) PathPatternsParameterizedTest(cn.taketoday.web.view.PathPatternsParameterizedTest)

Aggregations

RequestContext (cn.taketoday.web.RequestContext)109 ServletRequestContext (cn.taketoday.web.servlet.ServletRequestContext)65 MockServletRequestContext (cn.taketoday.web.servlet.MockServletRequestContext)46 Test (org.junit.jupiter.api.Test)42 ModelAndView (cn.taketoday.web.view.ModelAndView)22 PathPatternsParameterizedTest (cn.taketoday.web.view.PathPatternsParameterizedTest)22 HashMap (java.util.HashMap)22 MockHttpServletRequest (cn.taketoday.web.mock.MockHttpServletRequest)12 MockHttpServletRequest (cn.taketoday.web.testfixture.servlet.MockHttpServletRequest)12 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)12 HttpServletResponse (jakarta.servlet.http.HttpServletResponse)12 WebServletApplicationContext (cn.taketoday.web.servlet.WebServletApplicationContext)10 MockHttpServletResponse (cn.taketoday.web.mock.MockHttpServletResponse)9 MockHttpServletResponse (cn.taketoday.web.testfixture.servlet.MockHttpServletResponse)9 Map (java.util.Map)8 Properties (java.util.Properties)8 MockServletContext (cn.taketoday.web.mock.MockServletContext)6 WebSession (cn.taketoday.web.session.WebSession)6 MockServletContext (cn.taketoday.web.testfixture.servlet.MockServletContext)6 View (cn.taketoday.web.view.View)6