@Override
    protected void before() throws Throwable {
      this.path = new Path(testingUtility.getDataTestDirOnTestFS(), testName.getMethodName());
      HFile.WriterFactory factory =
        HFile.getWriterFactory(testingUtility.getConfiguration(), CacheConfig.DISABLED)
          .withPath(hfs, path).withFileContext(context);

      ExtendedCellBuilder cellBuilder =
        ExtendedCellBuilderFactory.create(CellBuilderType.DEEP_COPY);
      Random rand = new Random(Instant.now().toEpochMilli());
      byte[] family = Bytes.toBytes("f");
      try (HFile.Writer writer = factory.create()) {
        for (int i = 0; i < 40; i++) {
          byte[] row = RandomKeyValueUtil.randomOrderedFixedLengthKey(rand, i, 100);
          byte[] qualifier = RandomKeyValueUtil.randomRowOrQualifier(rand);
          byte[] value = RandomKeyValueUtil.randomValue(rand);
          ExtendedCell cell = cellBuilder.setType(Cell.Type.Put).setRow(row).setFamily(family)
            .setQualifier(qualifier).setValue(value).build();
          writer.append(cell);
          cellBuilder.clear();
        }
      }
    }
Enables writing and rewriting portions of the file backing an {@link HFileBlock}.
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileBlockHeaderCorruption.java