@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
			throws IOException, ServletException {
		if (!(request instanceof HttpServletRequest)) {
			super.doFilter(request, response, chain);
			return;
		}
		final HttpServletRequest httpRequest = (HttpServletRequest) request;

		registerSessionIfNeeded(httpRequest);
		super.doFilter(request, response, chain);
		// si logout on prend en compte de suite la destruction de la session
		unregisterSessionIfNeeded(httpRequest);
	}
@Test
	public void testWithSessionCreated() throws IOException, ServletException {
		final int sessionCount = SessionListener.getSessionCount();
		final HttpServletRequest request = createNiceMock(HttpServletRequest.class);
		final HttpServletResponse response = createNiceMock(HttpServletResponse.class);
		final FilterChain chain = createNiceMock(FilterChain.class);
		expect(request.getRequestURI()).andReturn(CONTEXT_PATH + TEST_REQUEST).anyTimes();
		expect(request.getContextPath()).andReturn(CONTEXT_PATH).anyTimes();

		final HttpSession session = createNiceMock(HttpSession.class);
		expect(request.isRequestedSessionIdValid()).andReturn(true).anyTimes();
		expect(request.getSession(false)).andReturn(session).anyTimes();
		expect(request.getLocale()).andReturn(Locale.FRANCE).anyTimes();
		expect(session.getId()).andReturn("1234567890").anyTimes();

		replay(request);
		replay(response);
		replay(chain);
		replay(session);
		pluginMonitoringFilter.doFilter(request, response, chain);
		assertEquals("sessionCount", sessionCount + 1, SessionListener.getSessionCount());
		pluginMonitoringFilter.doFilter(request, response, chain);
		assertEquals("sessionCount", sessionCount + 1, SessionListener.getSessionCount());
		verify(request);
		verify(response);
		verify(chain);
		verify(session);
	}