private byte[] getSomeKey(int rowId) {
    KeyValue kv = new KeyValue(Bytes.toBytes(String.format(localFormatter, Integer.valueOf(rowId))),
      Bytes.toBytes("family"), Bytes.toBytes("qual"), HConstants.LATEST_TIMESTAMP, Type.Put);
    return kv.getKey();
  }
Create a truncated hfile and verify that exception thrown.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFile.java