@Test
  public void ensureAlreadyCommitedResponsesSafelyExit() throws Exception {
    doReturn(true).when(response).isCommitted();

    filter.doFilter(request, response, chain);
    verify(scope, VerificationModeFactory.noMoreInteractions()).enter();
  }
 @Test
 public void ensureFilterExitsScopeOnError() throws Exception {
   doThrow(new ServletException()).when(chain).doFilter(request, response);
   try {
     filter.doFilter(request, response, chain);
     fail("Expected an exception to be thrown.");
   } catch (ServletException e) {
     // Expected. We want to make sure that our scope is properly
     // exited.
   }
   verify(scope).enter();
   verify(scope).exit();
 }
 @Test
 public void ensureFilterEntersAndExitsScope() throws Exception {
   filter.doFilter(request, response, chain);
   verify(scope).enter();
   verify(scope).exit();
 }