@Test
  public void testGetLocalHostLoopbackAddressNoExternalAddressFound() throws Exception {
    mockStatic(InetAddress.class, NetworkInterface.class);
    InetAddress inetAddressLocalHost = mock(InetAddress.class);
    when(inetAddressLocalHost.isLoopbackAddress()).thenReturn(true);
    when(InetAddress.getLocalHost()).thenReturn(inetAddressLocalHost);

    // network interfaces return addresses which are not external
    InetAddress linkLocalAddress = mock(InetAddress.class);
    when(linkLocalAddress.isLinkLocalAddress()).thenReturn(true);
    InetAddress loopbackAddress = mock(InetAddress.class);
    when(loopbackAddress.isLinkLocalAddress()).thenReturn(false);
    when(loopbackAddress.isLoopbackAddress()).thenReturn(true);
    NetworkInterface networkInterface0 = mock(NetworkInterface.class);
    when(networkInterface0.getInetAddresses()).thenReturn(
        Collections.enumeration(Arrays.asList(linkLocalAddress, loopbackAddress)));
    NetworkInterface networkInterface1 = mock(NetworkInterface.class);
    when(networkInterface1.getInetAddresses()).thenReturn(
        Collections.enumeration(Collections.singletonList(loopbackAddress)));
    when(NetworkInterface.getNetworkInterfaces()).thenReturn(
        Collections.enumeration(Arrays.asList(networkInterface0, networkInterface1)));

    assertEquals(inetAddressLocalHost, Util.getLocalHost());
  }
It's difficult to explicitly test having an actual version and using the fallback, due to the usage of methods of
 Class.
samza-core/src/test/java/org/apache/samza/util/TestUtil.java