use of cn.taketoday.web.view.ModelAndView in project today-infrastructure by TAKETODAY.
the class ParameterizableViewControllerTests method redirectView.
@Test
public void redirectView() throws Exception {
RedirectView view = new RedirectView("/foo");
this.controller.setView(view);
ModelAndView modelAndView = this.controller.handleRequest(this.context);
assertThat(modelAndView.getView()).isSameAs(view);
}
use of cn.taketoday.web.view.ModelAndView in project today-infrastructure by TAKETODAY.
the class ParameterizableViewControllerTests method defaultViewName.
//
@Test
public void defaultViewName() throws Exception {
ModelAndView modelAndView = this.controller.handleRequest(this.context);
assertThat(modelAndView.getViewName()).isNull();
}
use of cn.taketoday.web.view.ModelAndView in project today-infrastructure by TAKETODAY.
the class ParameterizableViewControllerTests method redirectStatusWithRedirectPrefix.
@Test
public void redirectStatusWithRedirectPrefix() throws Exception {
this.controller.setStatusCode(HttpStatus.PERMANENT_REDIRECT);
this.controller.setViewName("redirect:/foo");
ModelAndView modelAndView = this.controller.handleRequest(this.context);
assertThat(modelAndView.getViewName()).isEqualTo("redirect:/foo");
assertThat(this.response.getStatus()).as("3xx status should be left to RedirectView to set").isEqualTo(200);
assertThat(this.request.getAttribute(View.RESPONSE_STATUS_ATTRIBUTE)).isEqualTo(HttpStatus.PERMANENT_REDIRECT);
}
use of cn.taketoday.web.view.ModelAndView in project today-infrastructure by TAKETODAY.
the class ModelAndViewReturnValueHandler method handleModelAndView.
/**
* Resolve {@link ModelAndView} return type
*
* @since 2.3.3
*/
public final void handleModelAndView(RequestContext context, Object handler, @Nullable ModelAndView modelAndView) throws Exception {
if (modelAndView != null) {
View view = modelAndView.getView();
String viewName = modelAndView.getViewName();
BindingContext bindingContext = context.getBindingContext();
bindingContext.addAllAttributes(modelAndView.getModel());
if (viewName != null) {
delegate.renderView(context, viewName);
} else if (view != null) {
delegate.renderView(context, view);
}
}
}
use of cn.taketoday.web.view.ModelAndView 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();
}
Aggregations