@Test(groups = { CONTEXTS, SERVLET })
@SpecAssertions({ @SpecAssertion(section = "6.7.1", id = "ba"), @SpecAssertion(section = "6.7.1", id = "bb"),
@SpecAssertion(section = "6.7.1", id = "bc") })
public void testRequestScopeIsDestroyedAfterServletRequest() throws Exception {
WebClient webClient = new WebClient();
webClient.setThrowExceptionOnFailingStatusCode(true);
// First request - response content contains SimpleRequestBean id
TextPage firstRequestResult = webClient.getPage(contextPath + "introspectRequest");
assertNotNull(firstRequestResult.getContent());
// Make a second request and make sure the same context is not there (compare SimpleRequestBean ids)
TextPage secondRequestResult = webClient.getPage(contextPath + "introspectRequest");
assertNotNull(secondRequestResult.getContent());
assertNotEquals(secondRequestResult.getContent().trim(), firstRequestResult.getContent().trim());
// Make sure request context is destroyed after service(), doFilter(), requestDestroyed()
webClient.getPage(contextPath + "introspectRequest?mode=collect");
ActionSequence correctSequence = new ActionSequence().add(IntrospectServlet.class.getName())
.add(IntrospectTestFilter.class.getName()).add(TestServletRequestListener.class.getName())
.add(ContextDestructionObserver.class.getName());
TextPage destroyRequestResult = webClient.getPage(contextPath + "introspectRequest?mode=verify");
assertNotNull(destroyRequestResult.getContent());
assertEquals(destroyRequestResult.getContent(), correctSequence.toString());
}