@Test public void testHashCode() throws Exception { final HttpHost host1 = new HttpHost("http", "somehost", 8080); final HttpHost host2 = new HttpHost("http", "somehost", 80); final HttpHost host3 = new HttpHost("http", "someotherhost", 8080); final HttpHost host4 = new HttpHost("http", "somehost", 80); final HttpHost host5 = new HttpHost("http", "SomeHost", 80); final HttpHost host6 = new HttpHost("myhttp", "SomeHost", 80); final HttpHost host7 = new HttpHost( "http", InetAddress.getByAddress("127.0.0.1", new byte[] {127,0,0,1}), 80); final HttpHost host8 = new HttpHost("http", "127.0.0.1", 80); final HttpHost host9 = new HttpHost( "http", InetAddress.getByAddress("somehost",new byte[] {127,0,0,1}), 80); final HttpHost host10 = new HttpHost( "http", InetAddress.getByAddress(new byte[] {127,0,0,1}), "somehost", 80); final HttpHost host11 = new HttpHost( "http", InetAddress.getByAddress("someotherhost",new byte[] {127,0,0,1}), 80); Assert.assertTrue(host1.hashCode() == host1.hashCode()); Assert.assertTrue(host1.hashCode() != host2.hashCode()); Assert.assertTrue(host1.hashCode() != host3.hashCode()); Assert.assertTrue(host2.hashCode() == host4.hashCode()); Assert.assertTrue(host2.hashCode() == host5.hashCode()); Assert.assertTrue(host5.hashCode() != host6.hashCode()); Assert.assertTrue(host7.hashCode() != host8.hashCode()); Assert.assertTrue(host8.hashCode() != host9.hashCode()); Assert.assertTrue(host9.hashCode() == host10.hashCode()); Assert.assertTrue(host10.hashCode() != host11.hashCode()); Assert.assertTrue(host9.hashCode() != host11.hashCode()); }