@Test
public void prioritiseXForwardedForHeader() throws Exception {

  underTest.doFilter(request, response, chain);
  verify(chain).doFilter(captor.capture(), eq(response));
  HttpServletRequest captured = captor.getValue();
  when(request.getHeader("x-forwarded-for")).thenReturn("1.2.3.4");
  assertThat(captured.getRemoteAddr(), is("1.2.3.4"));
}