@Test
public void testEquals() 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.equals(host1));
    Assert.assertFalse(host1.equals(host2));
    Assert.assertFalse(host1.equals(host3));
    Assert.assertTrue(host2.equals(host4));
    Assert.assertTrue(host2.equals(host5));
    Assert.assertFalse(host5.equals(host6));
    Assert.assertFalse(host7.equals(host8));
    Assert.assertTrue(!host7.equals(host9));
    Assert.assertFalse(host1.equals(null));
    Assert.assertFalse(host1.equals("http://somehost"));
    Assert.assertFalse(host9.equals("http://somehost"));
    Assert.assertFalse(host8.equals(host9));
    Assert.assertTrue(host9.equals(host10));
    Assert.assertFalse(host9.equals(host11));
}