use of org.springframework.web.servlet.FlashMap in project spring-framework by spring-projects.
the class FlashMapManagerTests method flashAttributesWithQueryParamsWithSpace.
// SPR-12569
@Test
public void flashAttributesWithQueryParamsWithSpace() throws Exception {
String encodedValue = URLEncoder.encode("1 2", StandardCharsets.UTF_8);
FlashMap flashMap = new FlashMap();
flashMap.put("key", "value");
flashMap.setTargetRequestPath("/path");
flashMap.addTargetRequestParam("param", encodedValue);
this.request.setCharacterEncoding("UTF-8");
this.flashMapManager.saveOutputFlashMap(flashMap, this.request, this.response);
MockHttpServletRequest requestAfterRedirect = new MockHttpServletRequest("GET", "/path");
requestAfterRedirect.setQueryString("param=" + encodedValue);
requestAfterRedirect.addParameter("param", "1 2");
flashMap = this.flashMapManager.retrieveAndUpdate(requestAfterRedirect, new MockHttpServletResponse());
assertThatFlashMap(flashMap).isNotNull();
assertThat(flashMap.size()).isEqualTo(1);
assertThat(flashMap.get("key")).isEqualTo("value");
}
use of org.springframework.web.servlet.FlashMap in project spring-framework by spring-projects.
the class FlashMapManagerTests method saveOutputFlashMapEmpty.
@Test
public void saveOutputFlashMapEmpty() {
FlashMap flashMap = new FlashMap();
this.flashMapManager.saveOutputFlashMap(flashMap, this.request, this.response);
List<FlashMap> allMaps = this.flashMapManager.getFlashMaps();
assertThat(allMaps).isNull();
}
use of org.springframework.web.servlet.FlashMap in project spring-framework by spring-projects.
the class FlashMapManagerTests method saveOutputFlashMap.
@Test
public void saveOutputFlashMap() {
FlashMap flashMap = new FlashMap();
flashMap.put("name", "value");
// expire immediately so we can check expiration started
this.flashMapManager.setFlashMapTimeout(-1);
this.flashMapManager.saveOutputFlashMap(flashMap, this.request, this.response);
List<FlashMap> allMaps = this.flashMapManager.getFlashMaps();
assertThat(allMaps).isNotNull();
assertThatFlashMap(allMaps.get(0)).isSameAs(flashMap);
assertThat(flashMap.isExpired()).isTrue();
}
use of org.springframework.web.servlet.FlashMap in project spring-framework by spring-projects.
the class FlashMapManagerTests method retrieveAndUpdateMatchWithTrailingSlash.
@Test
public void retrieveAndUpdateMatchWithTrailingSlash() {
FlashMap flashMap = new FlashMap();
flashMap.put("key", "value");
flashMap.setTargetRequestPath("/path");
this.flashMapManager.setFlashMaps(Arrays.asList(flashMap));
this.request.setRequestURI("/path/");
FlashMap inputFlashMap = this.flashMapManager.retrieveAndUpdate(this.request, this.response);
assertThatFlashMap(inputFlashMap).isEqualTo(flashMap);
assertThat(this.flashMapManager.getFlashMaps().size()).as("Input FlashMap should have been removed").isEqualTo(0);
}
use of org.springframework.web.servlet.FlashMap in project spring-framework by spring-projects.
the class FlashMapManagerTests method saveOutputFlashMapDecodeTargetPath.
@Test
public void saveOutputFlashMapDecodeTargetPath() {
FlashMap flashMap = new FlashMap();
flashMap.put("key", "value");
flashMap.setTargetRequestPath("/once%20upon%20a%20time");
this.flashMapManager.saveOutputFlashMap(flashMap, this.request, this.response);
assertThat(flashMap.getTargetRequestPath()).isEqualTo("/once upon a time");
}
Aggregations