use of org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap in project spring-framework-debug by Joker-5.
the class ModelAndViewMethodReturnValueHandlerTests method handleRedirectAttributesWithViewName.
@Test
public void handleRedirectAttributesWithViewName() throws Exception {
RedirectAttributesModelMap redirectAttributes = new RedirectAttributesModelMap();
mavContainer.setRedirectModel(redirectAttributes);
ModelAndView mav = new ModelAndView("redirect:viewName", "attrName", "attrValue");
handler.handleReturnValue(mav, returnParamModelAndView, mavContainer, webRequest);
ModelMap model = mavContainer.getModel();
assertThat(mavContainer.getViewName()).isEqualTo("redirect:viewName");
assertThat(model.get("attrName")).isEqualTo("attrValue");
assertThat(model).isSameAs(redirectAttributes);
}
use of org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap in project spring-framework-debug by Joker-5.
the class ViewNameMethodReturnValueHandlerTests method returnViewNameRedirect.
@Test
public void returnViewNameRedirect() throws Exception {
ModelMap redirectModel = new RedirectAttributesModelMap();
this.mavContainer.setRedirectModel(redirectModel);
this.handler.handleReturnValue("redirect:testView", this.param, this.mavContainer, this.webRequest);
assertThat(this.mavContainer.getViewName()).isEqualTo("redirect:testView");
assertThat(this.mavContainer.getModel()).isSameAs(redirectModel);
}
use of org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap in project spring-framework-debug by Joker-5.
the class ViewNameMethodReturnValueHandlerTests method returnViewRedirectWithCustomRedirectPattern.
@Test
public void returnViewRedirectWithCustomRedirectPattern() throws Exception {
ModelMap redirectModel = new RedirectAttributesModelMap();
this.mavContainer.setRedirectModel(redirectModel);
this.handler.setRedirectPatterns("myRedirect:*");
this.handler.handleReturnValue("redirect:testView", this.param, this.mavContainer, this.webRequest);
assertThat(this.mavContainer.getViewName()).isEqualTo("redirect:testView");
assertThat(this.mavContainer.getModel()).isSameAs(redirectModel);
}
use of org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap in project spring-framework-debug by Joker-5.
the class ViewMethodReturnValueHandlerTests method returnViewRedirect.
@Test
public void returnViewRedirect() throws Exception {
RedirectView redirectView = new RedirectView("testView");
ModelMap redirectModel = new RedirectAttributesModelMap();
this.mavContainer.setRedirectModel(redirectModel);
MethodParameter param = createReturnValueParam("view");
this.handler.handleReturnValue(redirectView, param, this.mavContainer, this.webRequest);
assertThat(this.mavContainer.getView()).isSameAs(redirectView);
assertThat(this.mavContainer.getModel()).as("Should have switched to the RedirectModel").isSameAs(redirectModel);
}
use of org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap in project spring-framework-5.2.9.RELEASE by somepeopleHavingDream.
the class ViewMethodReturnValueHandlerTests method returnViewRedirect.
@Test
public void returnViewRedirect() throws Exception {
RedirectView redirectView = new RedirectView("testView");
ModelMap redirectModel = new RedirectAttributesModelMap();
this.mavContainer.setRedirectModel(redirectModel);
MethodParameter param = createReturnValueParam("view");
this.handler.handleReturnValue(redirectView, param, this.mavContainer, this.webRequest);
assertThat(this.mavContainer.getView()).isSameAs(redirectView);
assertThat(this.mavContainer.getModel()).as("Should have switched to the RedirectModel").isSameAs(redirectModel);
}
Aggregations