Code example for InetAddress

Methods: hashCode

0
        InetAddress addr1= InetAddress.getByAddress(new byte [] {127, 0, 0, 1});
        InetAddress addr2= InetAddress.getByAddress(new byte [] {127, 0, 0, 2});
        ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
        assertTrue(!(new ChannelBinding( addr1, addr2, 
                new byte [] { 0, 10, 20 })) 
                .equals(cb));
    } 
     
    public void testEquals_Negative_3_0() throws Exception { 
        byte data [] = { 0, 10, 20, 30};
        InetAddress addr1= InetAddress.getByAddress(new byte [] {127, 0, 0, 1});
        InetAddress addr2= InetAddress.getByAddress(new byte [] {127, 0, 0, 2});
        ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
        assertTrue(!(new ChannelBinding( InetAddress.getByAddress(new byte [] {127, 0, 0, 1}), 
                InetAddress.getByAddress(new byte [] {127, 0, 0, 2}), 
                new byte [] { 0, 10, 20 })) 
                .equals(cb));
    } 
     
    public void testEquals_Negative_4() throws Exception { 
        byte data [] = { 0, 10, 20};
        InetAddress addr1= InetAddress.getByAddress(new byte [] {127, 0, 0, 1});
        InetAddress addr2= InetAddress.getByAddress(new byte [] {127, 0, 0, 2});
        ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
        assertTrue(!(new ChannelBinding( InetAddress.getByAddress(new byte [] {127, 0, 0, 1}), 
                InetAddress.getByAddress(new byte [] {127, 0, 0, 1}), 
                new byte [] { 0, 10, 20 })) 
                .equals(cb));
    } 
     
    public void testEquals_Negative_5() throws Exception { 
        byte data [] = { 0, 10, 20};
        InetAddress addr1= InetAddress.getByAddress(new byte [] {127, 0, 0, 2});
        InetAddress addr2= InetAddress.getByAddress(new byte [] {127, 0, 0, 1});
        ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
        assertTrue(!(new ChannelBinding( InetAddress.getByAddress(new byte [] {127, 0, 0, 1}), 
                InetAddress.getByAddress(new byte [] {127, 0, 0, 1}), 
                new byte [] { 0, 10, 20 })) 
                .equals(cb));
    } 
     
    public void testEquals_Negative_6() throws Exception { 
        byte data [] = { 0, 10, 20};
        InetAddress addr1= InetAddress.getByAddress(new byte [] {127, 0, 0, 2});
        InetAddress addr2= InetAddress.getByAddress(new byte [] {127, 0, 0, 1});
        ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
        assertTrue(!(new ChannelBinding( null, 
                InetAddress.getByAddress(new byte [] {127, 0, 0, 1}), 
                new byte [] { 0, 10, 20 })) 
                .equals(cb));
    } 
     
    public void testHashCode() throws Exception { 
        byte data [] = { 0, 10, 20, 40, 50 };
        InetAddress addr1= InetAddress.getByAddress(new byte [] {127, 0, 0, 1});
        InetAddress addr2= InetAddress.getByAddress(new byte [] {127, 0, 0, 2});
        ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
        assertEquals(addr1.hashCode(), cb.hashCode());
    } 
    public void testHashCode_0() throws Exception { 
        byte data [] = { 0, 10, 20, 40, 50 };
        InetAddress addr= InetAddress.getByAddress(new byte [] {127, 0, 0, 1});
        ChannelBinding cb = new ChannelBinding(null, addr, data);