### Question:
RequestTrackingHostValve extends ValveBase { @Override public void invoke( final Request request, final Response response ) throws IOException, ServletException { final String requestId = getURIWithQueryString( request ); if(!_enabled.get() || !_msmContext.equals(request.getContext())) { getNext().invoke( request, response ); } else if ( _ignorePattern != null && _ignorePattern.matcher( requestId ).matches() ) { if(_log.isDebugEnabled()) { _log.debug( ">>>>>> Ignoring: " + requestId + " (requestedSessionId "+ request.getRequestedSessionId() +") ==================" ); } try { storeRequestThreadLocal( request ); request.setNote(REQUEST_IGNORED, Boolean.TRUE); getNext().invoke( request, response ); } finally { if(request.getNote(REQUEST_PROCESSED) == Boolean.TRUE) { final String sessionId = getSessionId(request, response); if(sessionId != null) { _sessionBackupService.requestFinished(sessionId, requestId); } } resetRequestThreadLocal(); } if(_log.isDebugEnabled()) { _log.debug( "<<<<<< Ignored: " + requestId + " ==================" ); } } else { request.setNote(REQUEST_PROCESS, Boolean.TRUE); if ( _log.isDebugEnabled() ) { _log.debug( ">>>>>> Request starting: " + requestId + " (requestedSessionId "+ request.getRequestedSessionId() +") ==================" ); } try { storeRequestThreadLocal( request ); getNext().invoke( request, response ); } finally { final Boolean sessionIdChanged = (Boolean) request.getNote(SESSION_ID_CHANGED); backupSession( request, response, sessionIdChanged == null ? false : sessionIdChanged.booleanValue() ); resetRequestThreadLocal(); } if ( _log.isDebugEnabled() ) { logDebugRequestSessionCookie( request ); logDebugResponseCookie( response ); _log.debug( "<<<<<< Request finished: " + requestId + " ==================" ); } } } RequestTrackingHostValve( @Nullable final String ignorePattern, @Nonnull final String sessionCookieName,
            @Nonnull final MemcachedSessionService sessionBackupService,
            @Nonnull final Statistics statistics,
            @Nonnull final AtomicBoolean enabled,
            @Nonnull final CurrentRequest currentRequest); boolean isIgnoredRequest(); @Override void invoke( final Request request, final Response response ); static final String REQUEST_PROCESS; static final String SESSION_ID_CHANGED; static final String REQUEST_PROCESSED; }### Answer:
@Test public final void testRequestFinishedShouldBeInvokedForIgnoredResources() throws IOException, ServletException { when( _request.getRequestedSessionId() ).thenReturn( "foo" ); when(_request.getRequestURI()).thenReturn("/pixel.gif"); _sessionTrackerValve.invoke( _request, _response ); verify( _service ).requestFinished( eq( "foo" ), anyString() ); }