@Test public void testHashCodeMethod() { // Create an instance... final AciServerDetails details1 = new AciServerDetails(); details1.setHost("host1.example.com"); details1.setPort(5790); details1.setCharsetName("UTF-8"); // Create an instance... final AciServerDetails details2 = new AciServerDetails(); details2.setHost("host1.example.com"); details2.setPort(5790); details2.setCharsetName("UTF-8"); // Create yet another instance... final AciServerDetails details3 = new AciServerDetails(); details3.setHost("host2.example.com"); details3.setPort(5790); details3.setCharsetName("UTF-8"); // Assert that 1 & 2 are the same and 1 & 3 and 2 & 3 are different... assertThat("Hash codes should be equal", details1.hashCode() == details2.hashCode(), is(true)); assertThat( "Hash codes should not be equal", details1.hashCode() == details3.hashCode(), is(false)); assertThat( "Hash codes should not be equal", details2.hashCode() == details3.hashCode(), is(false)); details1.setEncryptionCodec(new TestEncryptionCodec()); assertThat(details1.hashCode() == details2.hashCode(), is(false)); details2.setEncryptionCodec(new TestEncryptionCodec()); assertThat(details1.hashCode() == details2.hashCode(), is(true)); }