@Test
public void testFindConnectingAddressWhenGetLocalHostThrows() throws Exception {

	PowerMockito.mockStatic(InetAddress.class);
	Mockito.when(InetAddress.getLocalHost()).thenThrow(new UnknownHostException()).thenCallRealMethod();
	final InetAddress loopbackAddress = Inet4Address.getByName("127.0.0.1");
	Thread socketServerThread;
	try (ServerSocket socket = new ServerSocket(0, 1, loopbackAddress)) {
		// Make sure that the thread will eventually die even if something else goes wrong
		socket.setSoTimeout(10_000);
		socketServerThread = new Thread(new Runnable() {
			@Override
			public void run() {
				try {
					socket.accept();
				} catch (IOException e) {
					// ignore
				}
			}
		});
		socketServerThread.start();
		final InetSocketAddress socketAddress = new InetSocketAddress(loopbackAddress, socket.getLocalPort());
		final InetAddress address = ConnectionUtils.findConnectingAddress(
			socketAddress, 2000, 400);
		PowerMockito.verifyStatic();
		// Make sure we got an address via alternative means
		assertNotNull(address);
	}
}