private ByteBuff getBufferWithChecksum(HFileBlock block) throws IOException {
    ByteBuff buf = block.getBufferReadOnly();

    int numBytes =
      (int) ChecksumUtil.numBytes(buf.remaining(), block.getHFileContext().getBytesPerChecksum());
    byte[] checksum = new byte[numBytes];
    ChecksumUtil.generateChecksums(buf.array(), 0, buf.limit(), checksum, 0,
      block.getHFileContext().getChecksumType(), block.getBytesPerChecksum());

    ByteBuff bufWithChecksum = ByteBuffAllocator.HEAP.allocate(buf.limit() + numBytes);
    bufWithChecksum.put(buf.array(), 0, buf.limit());
    bufWithChecksum.put(checksum);

    return bufWithChecksum.rewind();
  }
HFileBlock buffer does not include checksum because it is discarded after verifying upon
reading from disk. We artificially add a checksum onto the buffer for use in testing that
ChecksumUtil.validateChecksum works for SingleByteBuff and MultiByteBuff in
{@link #verifySBBCheckSum(ByteBuff)} and {@link #verifyMBBCheckSum(ByteBuff)}
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestChecksum.java