* @throws Exception
*/
public void testServerAddressHashEquals()
throws Exception
{
ServerAddress sa1 = new ServerAddress("127.0.0.1", 4445, false, 60, null);
ServerAddress sa2 = new ServerAddress("127.0.0.1", 4445, false, 61, null);
assertEquals(sa1, sa2);
assertEquals(sa1.hashCode(), sa2.hashCode());
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(sa1);
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
sa2 = (ServerAddress) ois.readObject();
assertEquals(sa1, sa2);
assertEquals(sa1.hashCode(), sa2.hashCode());
// Different tcpNoDelay should not be equal
sa2 = new ServerAddress("127.0.0.1", 4445, true, 61, null);
assertNotSame(sa1, sa2);
// Different ports should not be equal
sa2 = new ServerAddress("127.0.0.1", 4446, false, 60, null);
assertNotSame(sa1, sa2);
// Different host should not be equal
sa2 = new ServerAddress("127.0.0.2", 4445, false, 60, null);
assertNotSame(sa1, sa2);
}