@Test
public void testGetRemoteAddressLoopBackSingleXFFInvalidIP() {

    HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class);
    Mockito.when(httpServletRequest.getRemoteAddr()).thenReturn("127.0.0.1");
    Mockito.when(httpServletRequest.getHeader("X-Forwarded-For")).thenReturn("1.2.300.4")
            .thenReturn("testip").thenReturn(";s=signature");
    assertEquals(ServletRequestUtil.getRemoteAddress(httpServletRequest), "127.0.0.1");
    assertEquals(ServletRequestUtil.getRemoteAddress(httpServletRequest), "127.0.0.1");
    assertEquals(ServletRequestUtil.getRemoteAddress(httpServletRequest), "127.0.0.1");
}