public void testEqualsDoesNotDoHostnameResolution() throws Exception {
  for (  InetAddress inetAddress : InetAddress.getAllByName("localhost")) {
    String address=inetAddress.getHostAddress();
    if (inetAddress instanceof Inet6Address) {
      address="[" + address + "]";
    }
    URL urlByHostName=new URL("http://localhost/foo?bar=baz#quux");
    URL urlByAddress=new URL("http://" + address + "/foo?bar=baz#quux");
    assertFalse("Expected " + urlByHostName + " to not equal "+ urlByAddress,urlByHostName.equals(urlByAddress));
  }
}

public void testEqualsDoesNotDoHostnameResolution ( ) throws Exception { for ( InetAddress inetAddress : InetAddress . getAllByName ( "localhost" ) ) { String address = inetAddress . getHostAddress ( ) ; if ( inetAddress instanceof Inet6Address ) { address = "[" + address + "]" ; } URL urlByHostName = new URL ( "http://localhost/foo?bar=baz#quux" ) ; URL urlByAddress = new URL ( "http://" + address + "/foo?bar=baz#quux" ) ; assertFalse ( "Expected " + urlByHostName + " to not equal " + urlByAddress , urlByHostName . equals ( urlByAddress ) ) ; } }
android ' s url . equals ( ) works as if the network is down . this is different from the ri , which does potentially slow and inconsistent dns lookups in url . equals .
