@Test
public void test() throws Exception {

  when(request.getHeader(HttpHeaders.CONTENT_ENCODING)).thenReturn(contentEncoding);
  when(request.getInputStream()).thenReturn(new ServletInputStreamWrapper(new ByteArrayInputStream(inputBytes)));
  ArgumentCaptor<HttpServletRequest> requestCaptor = ArgumentCaptor.forClass(HttpServletRequest.class);
  doNothing().when(chain).doFilter(requestCaptor.capture(), any(ServletResponse.class));
  filter.doFilter(request, response, chain);
  HttpServletRequest outputRequest = requestCaptor.getValue();
  byte[] outputBytes = toByteArray(outputRequest.getInputStream());
  assertTrue(Arrays.equals(outputBytes, TEST_BYTES));
}