static boolean isLocalhost(String hostname, String ipAddress) {
        try {
            return isLocalhostWithLoopbackIpAddress(hostname, ipAddress) || isLocalhostWithNonLoopbackIpAddress(ipAddress);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
@Test
    public void shouldDetermineIfAddressIsLocal() throws UnknownHostException {
        InetAddress local;

        try {
            local = InetAddress.getLocalHost();
        }
        catch (UnknownHostException e) {
            local = InetAddress.getByName("localhost");
        }

        assertThat("Localhost (" + local.getHostName() + ") should be a local address.", SystemUtil.isLocalhost(local.getHostAddress()), is(true));
    }