@Test
public void testHashCode() {

    ByteBuf elemA = buffer(15);
    ByteBuf elemB = directBuffer(15);
    elemA.writeBytes(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 });
    elemB.writeBytes(new byte[] { 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9 });
    Set<ByteBuf> set = new HashSet<ByteBuf>();
    set.add(elemA);
    set.add(elemB);
    assertEquals(2, set.size());
    ByteBuf elemACopy = elemA.copy();
    assertTrue(set.contains(elemACopy));
    ByteBuf elemBCopy = elemB.copy();
    assertTrue(set.contains(elemBCopy));
    buffer.clear();
    buffer.writeBytes(elemA.duplicate());
    assertTrue(set.remove(buffer));
    assertFalse(set.contains(elemA));
    assertEquals(1, set.size());
    buffer.clear();
    buffer.writeBytes(elemB.duplicate());
    assertTrue(set.remove(buffer));
    assertFalse(set.contains(elemB));
    assertEquals(0, set.size());
    elemA.release();
    elemB.release();
    elemACopy.release();
    elemBCopy.release();
}