@Test
  public void testEditAdd() 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 info = RegionInfoBuilder.newBuilder(htd.getTableName()).setStartKey(row)
      .setEndKey(Bytes.toBytes(Bytes.toString(row) + "1")).build();
    final WAL log = wals.getWAL(info);

    final long txid = log.appendData(info, new WALKeyImpl(info.getEncodedNameAsBytes(),
      htd.getTableName(), EnvironmentEdgeManager.currentTime(), mvcc, scopes), cols);
    log.sync(txid);
    log.startCacheFlush(info.getEncodedNameAsBytes(), htd.getColumnFamilyNames());
    log.completeCacheFlush(info.getEncodedNameAsBytes(), HConstants.NO_SEQNUM);
    log.shutdown();
    Path filename = AbstractFSWALProvider.getCurrentFileName(log);
    // Now open a reader on the log and assert append worked.
    try (NoEOFWALStreamReader reader = NoEOFWALStreamReader.create(wals, fs, filename)) {
      // Above we added all columns on a single row so we only read one
      // entry in the below... thats why we have '1'.
      for (int i = 0; i < 1; i++) {
        WAL.Entry entry = reader.next(null);
        if (entry == null) break;
        WALKey key = entry.getKey();
        WALEdit val = entry.getEdit();
        assertTrue(Bytes.equals(info.getEncodedNameAsBytes(), key.getEncodedRegionName()));
        assertTrue(htd.getTableName().equals(key.getTableName()));
        Cell cell = val.getCells().get(0);
        assertTrue(Bytes.equals(row, 0, row.length, cell.getRowArray(), cell.getRowOffset(),
          cell.getRowLength()));
        assertEquals((byte) (i + '0'), CellUtil.cloneValue(cell)[0]);
        LOG.info(key + " " + val);
      }
    }
  }
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