}
@Test(groups="fast")
public void positiveCase() throws Exception {
MockServletContext ctx = StripesTestFixture.getServletContext();
MockRoundtrip trip = new MockRoundtrip(ctx, FlashScopeTests.class);
trip.addParameter("foo", "foo123");
trip.execute();
String url = trip.getDestination();
Matcher matcher = FLASH_ID_REGEX.matcher(url);
Assert.assertTrue(matcher.matches(),
"Redirect URL should contain request parameter for flash scope id.");
Assert.assertEquals("foo123", trip.getRequest().getAttribute("foo"),
"FlashScope should have inserted 'foo' into a request attribute.");
MockRoundtrip trip2 = new MockRoundtrip
(ctx, FlashScopeTests.class, (MockHttpSession) trip.getRequest().getSession());
// Get the flash scope ID from the redirect URL and add it back as a parameter
String id = matcher.group(1);
trip2.addParameter(StripesConstants.URL_KEY_FLASH_SCOPE_ID, id);
Assert.assertNull(trip2.getRequest().getAttribute("foo"),
"Request attribute 'foo' should not exist prior to request.");
trip2.execute("DoNothing");
Assert.assertEquals("foo123", trip2.getRequest().getAttribute("foo"),
"Request attribute 'foo' should have been set by FlashScope.");
Assert.assertEquals(FlashScope.getAllFlashScopes(trip2.getRequest()).size(), 0,
"FlashScope should have been removed from session after use.");
// Test flashing an ActionBean
MockRoundtrip trip3 = new MockRoundtrip(ctx, FlashScopeTests.class, (MockHttpSession) trip
.getRequest().getSession());
// Get the flash scope ID from the redirect URL and add it back as a parameter
trip3.addParameter(StripesConstants.URL_KEY_FLASH_SCOPE_ID, id);
trip3.execute("FlashBean");
try {
ActionBeanContext tmp = trip3.getActionBean(getClass()).getContext();
HttpServletResponse response = tmp.getResponse();
HttpServletRequest request = tmp.getRequest();
Assert.assertNotNull(request);
Assert.assertNotNull(response);
Assert.assertTrue(Proxy.class.isAssignableFrom(response.getClass()));