@Test
public void testLogContext() throws IOException, ServletException {

    // prepare data
    final HttpServletRequest req = new MockHttpServletRequest("GET", "www.openhubframework.org");
    ServletResponse res = new MockHttpServletResponse();
    FilterChain chain = new MockFilterChain() {
        @Override
        public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
            super.doFilter(request, response);
            // I have to verify it here because context values are reset at the end of filter processing
            assertThat(LogContext.getContextValue(CTX_REQUEST_URI), is(req.getRequestURI()));
            assertThat(LogContext.getContextValue(CTX_REQUEST_ID), notNullValue());
            assertThat(LogContext.getContextValue(CTX_SESSION_ID), nullValue()); // session is not created
        }
    };
    // action
    LogContextFilter filter = new LogContextFilter();
    filter.doFilter(req, res, chain);
    // verify
    assertThat(req.getCharacterEncoding(), is("UTF-8"));
}