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

    byte[] externalAddressBytes = new byte[]{0, 1, 2, 3, 4, 5};
    InetAddress externalAddress = mock(InetAddress.class);
    when(externalAddress.isLinkLocalAddress()).thenReturn(false);
    when(externalAddress.isLoopbackAddress()).thenReturn(false);
    when(externalAddress.getAddress()).thenReturn(externalAddressBytes);

    NetworkInterface networkInterface = mock(NetworkInterface.class);
    when(networkInterface.getInetAddresses()).thenReturn(
        Collections.enumeration(Collections.singletonList(externalAddress)));
    when(NetworkInterface.getNetworkInterfaces()).thenReturn(
        Collections.enumeration(Collections.singletonList(networkInterface)));

    InetAddress finalInetAddress = mock(InetAddress.class);
    when(InetAddress.getByAddress(aryEq(externalAddressBytes))).thenReturn(finalInetAddress);

    assertEquals(finalInetAddress, 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