use of org.springframework.web.servlet.FlashMap in project spring-framework by spring-projects.
the class RedirectViewUriTemplateTests method setUp.
@BeforeEach
public void setUp() {
this.request = new MockHttpServletRequest();
this.response = new MockHttpServletResponse();
this.request.setAttribute(DispatcherServlet.OUTPUT_FLASH_MAP_ATTRIBUTE, new FlashMap());
this.request.setAttribute(DispatcherServlet.FLASH_MAP_MANAGER_ATTRIBUTE, new SessionFlashMapManager());
}
use of org.springframework.web.servlet.FlashMap in project spring-framework by spring-projects.
the class RedirectViewTests method setUp.
@BeforeEach
public void setUp() throws Exception {
this.request = new MockHttpServletRequest();
this.request.setContextPath("/context");
this.request.setCharacterEncoding(WebUtils.DEFAULT_CHARACTER_ENCODING);
this.request.setAttribute(DispatcherServlet.OUTPUT_FLASH_MAP_ATTRIBUTE, new FlashMap());
this.request.setAttribute(DispatcherServlet.FLASH_MAP_MANAGER_ATTRIBUTE, new SessionFlashMapManager());
this.response = new MockHttpServletResponse();
}
use of org.springframework.web.servlet.FlashMap in project spring-framework by spring-projects.
the class RequestMappingHandlerAdapterTests method setAlwaysUseRedirectAttributes.
@Test
public void setAlwaysUseRedirectAttributes() throws Exception {
HandlerMethodArgumentResolver redirectAttributesResolver = new RedirectAttributesMethodArgumentResolver();
HandlerMethodArgumentResolver modelResolver = new ModelMethodProcessor();
HandlerMethodReturnValueHandler viewHandler = new ViewNameMethodReturnValueHandler();
this.handlerAdapter.setArgumentResolvers(Arrays.asList(redirectAttributesResolver, modelResolver));
this.handlerAdapter.setReturnValueHandlers(Collections.singletonList(viewHandler));
this.handlerAdapter.setIgnoreDefaultModelOnRedirect(true);
this.handlerAdapter.afterPropertiesSet();
this.request.setAttribute(DispatcherServlet.OUTPUT_FLASH_MAP_ATTRIBUTE, new FlashMap());
HandlerMethod handlerMethod = handlerMethod(new RedirectAttributeController(), "handle", Model.class);
ModelAndView mav = this.handlerAdapter.handle(request, response, handlerMethod);
assertThat(mav.getModel().isEmpty()).as("Without RedirectAttributes arg, model should be empty").isTrue();
}
use of org.springframework.web.servlet.FlashMap in project spring-framework by spring-projects.
the class FlashAttributeResultMatchersTests method getStubMvcResult.
private StubMvcResult getStubMvcResult() {
FlashMap flashMap = new FlashMap();
flashMap.put("good", "good");
StubMvcResult mvcResult = new StubMvcResult(null, null, null, null, null, flashMap, null);
return mvcResult;
}
use of org.springframework.web.servlet.FlashMap in project spring-framework by spring-projects.
the class MockHttpServletRequestBuilderTests method flashAttribute.
@Test
void flashAttribute() {
this.builder.flashAttr("foo", "bar");
MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);
FlashMap flashMap = new SessionFlashMapManager().retrieveAndUpdate(request, null);
assertThat((Object) flashMap).isNotNull();
assertThat(flashMap.get("foo")).isEqualTo("bar");
}
Aggregations