@Override
  public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    HttpServletRequest httpServletRequest = (HttpServletRequest) request;
    HttpServletResponse httpServletResponse = (HttpServletResponse) response;
    String path = httpServletRequest.getRequestURI().replaceFirst(httpServletRequest.getContextPath(), "");
    if (!URL_PATTERN.matches(path)) {
      chain.doFilter(request, response);
      return;
    }
    httpServletResponse.setContentType(HTML);
    httpServletResponse.setCharacterEncoding(UTF_8.name().toLowerCase(ENGLISH));
    httpServletResponse.setHeader(CACHE_CONTROL_HEADER, CACHE_CONTROL_VALUE);

    String htmlContent = requireNonNull(webPagesCache.getContent(path));
    write(htmlContent, httpServletResponse.getOutputStream(), UTF_8);
  }
@Test
  public void return_web_page_content() throws Exception {
    String path = "/index.html";
    when(webPagesCache.getContent(path)).thenReturn("test");
    when(request.getRequestURI()).thenReturn(path);
    when(request.getContextPath()).thenReturn(TEST_CONTEXT);
    StringOutputStream outputStream = new StringOutputStream();
    when(response.getOutputStream()).thenReturn(outputStream);

    underTest.doFilter(request, response, chain);

    verify(response).setContentType("text/html");
    verify(response).setCharacterEncoding("utf-8");
    verify(response).setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
    assertThat(outputStream).hasToString("test");
  }