use of org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap in project spring-framework by bluecrow1986.
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 by bluecrow1986.
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 by bluecrow1986.
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 by spring-projects.
the class ModelAndViewMethodReturnValueHandlerTests method handleRedirectAttributesWithCustomPrefix.
@Test
public void handleRedirectAttributesWithCustomPrefix() throws Exception {
RedirectAttributesModelMap redirectAttributes = new RedirectAttributesModelMap();
mavContainer.setRedirectModel(redirectAttributes);
ModelAndView mav = new ModelAndView("myRedirect:viewName", "attrName", "attrValue");
handler.setRedirectPatterns("myRedirect:*");
handler.handleReturnValue(mav, returnParamModelAndView, mavContainer, webRequest);
ModelMap model = mavContainer.getModel();
assertThat(mavContainer.getViewName()).isEqualTo("myRedirect:viewName");
assertThat(model.get("attrName")).isEqualTo("attrValue");
assertThat(model).isSameAs(redirectAttributes);
}
use of org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap in project spring-framework by spring-projects.
the class ViewNameMethodReturnValueHandlerTests method returnViewCustomRedirect.
@Test
public void returnViewCustomRedirect() throws Exception {
ModelMap redirectModel = new RedirectAttributesModelMap();
this.mavContainer.setRedirectModel(redirectModel);
this.handler.setRedirectPatterns("myRedirect:*");
this.handler.handleReturnValue("myRedirect:testView", this.param, this.mavContainer, this.webRequest);
assertThat(this.mavContainer.getViewName()).isEqualTo("myRedirect:testView");
assertThat(this.mavContainer.getModel()).isSameAs(redirectModel);
}
Aggregations