BgpServerConfigurationImpl implements BgpServerConfiguration { @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((serverConfiguration == null) ? 0 : serverConfiguration .hashCode()); return result; } BgpServerConfigurationImpl();  BgpServerConfigurationImpl(ServerConfiguration serverConfiguration); @Override ServerConfiguration getServerConfiguration(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testHashCode() throws Exception { BgpServerConfigurationImpl server1 = new BgpServerConfigurationImpl(new ServerConfigurationImpl(InetAddress.getByName("192.168.4.1"), 100)); BgpServerConfigurationImpl server2 = new BgpServerConfigurationImpl(new ServerConfigurationImpl(InetAddress.getByName("192.168.4.1"), 100)); BgpServerConfigurationImpl server3 = new BgpServerConfigurationImpl(new ServerConfigurationImpl(InetAddress.getByName("192.168.4.2"), 100)); BgpServerConfigurationImpl server4 = new BgpServerConfigurationImpl(new ServerConfigurationImpl(InetAddress.getByName("192.168.4.1"), 200)); Assert.assertEquals(server1.hashCode(), server2.hashCode()); Assert.assertFalse(server1.hashCode() == server3.hashCode()); Assert.assertFalse(server1.hashCode() == server4.hashCode()); }