@Test
  public void testAppend() throws IOException {
    int colCount = 10;
    TableDescriptor htd =
      TableDescriptorBuilder.newBuilder(TableName.valueOf(currentTest.getMethodName()))
        .setColumnFamily(ColumnFamilyDescriptorBuilder.of("column")).build();
    NavigableMap<byte[], Integer> scopes = new TreeMap<byte[], Integer>(Bytes.BYTES_COMPARATOR);
    for (byte[] fam : htd.getColumnFamilyNames()) {
      scopes.put(fam, 0);
    }
    byte[] row = Bytes.toBytes("row");
    final MultiVersionConcurrencyControl mvcc = new MultiVersionConcurrencyControl(1);
    // Write columns named 1, 2, 3, etc. and then values of single byte
    // 1, 2, 3...
    long timestamp = EnvironmentEdgeManager.currentTime();
    WALEdit cols = new WALEdit();
    for (int i = 0; i < colCount; i++) {
      cols.add(new KeyValue(row, Bytes.toBytes("column"), Bytes.toBytes(Integer.toString(i)),
        timestamp, new byte[] { (byte) (i + '0') }));
    }
    RegionInfo hri = RegionInfoBuilder.newBuilder(htd.getTableName()).build();
    final WAL log = wals.getWAL(hri);
    final long txid = log.appendData(hri, new WALKeyImpl(hri.getEncodedNameAsBytes(),
      htd.getTableName(), EnvironmentEdgeManager.currentTime(), mvcc, scopes), cols);
    log.sync(txid);
    log.startCacheFlush(hri.getEncodedNameAsBytes(), htd.getColumnFamilyNames());
    log.completeCacheFlush(hri.getEncodedNameAsBytes(), HConstants.NO_SEQNUM);
    log.shutdown();
    Path filename = AbstractFSWALProvider.getCurrentFileName(log);
    // Now open a reader on the log and assert append worked.
    try (WALStreamReader reader = wals.createStreamReader(fs, filename)) {
      WAL.Entry entry = reader.next();
      assertEquals(colCount, entry.getEdit().size());
      int idx = 0;
      for (Cell val : entry.getEdit().getCells()) {
        assertTrue(
          Bytes.equals(hri.getEncodedNameAsBytes(), entry.getKey().getEncodedRegionName()));
        assertTrue(htd.getTableName().equals(entry.getKey().getTableName()));
        assertTrue(Bytes.equals(row, 0, row.length, val.getRowArray(), val.getRowOffset(),
          val.getRowLength()));
        assertEquals((byte) (idx + '0'), CellUtil.cloneValue(val)[0]);
        System.out.println(entry.getKey() + " " + val);
        idx++;
      }
    }
  }
Tests that we can write out an edit, close, and then read it back in again.
hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALFactory.java