@Test
  public void testGetSplitEditFilesSorted() throws IOException {
    FileSystem fs = FileSystem.get(util.getConfiguration());
    Path regiondir = util.getDataTestDir("regiondir");
    fs.delete(regiondir, true);
    fs.mkdirs(regiondir);
    Path recoverededits = WALSplitUtil.getRegionDirRecoveredEditsDir(regiondir);
    String first = WALSplitUtil.formatRecoveredEditsFileName(-1);
    createFile(fs, recoverededits, first);
    createFile(fs, recoverededits, WALSplitUtil.formatRecoveredEditsFileName(0));
    createFile(fs, recoverededits, WALSplitUtil.formatRecoveredEditsFileName(1));
    createFile(fs, recoverededits, WALSplitUtil.formatRecoveredEditsFileName(11));
    createFile(fs, recoverededits, WALSplitUtil.formatRecoveredEditsFileName(2));
    createFile(fs, recoverededits, WALSplitUtil.formatRecoveredEditsFileName(50));
    String last = WALSplitUtil.formatRecoveredEditsFileName(Long.MAX_VALUE);
    createFile(fs, recoverededits, last);
    createFile(fs, recoverededits,
      Long.toString(Long.MAX_VALUE) + "." + EnvironmentEdgeManager.currentTime());

    final Configuration walConf = new Configuration(util.getConfiguration());
    CommonFSUtils.setRootDir(walConf, regiondir);
    (new WALFactory(walConf, "dummyLogName")).getWAL(null);

    NavigableSet<Path> files = WALSplitUtil.getSplitEditFilesSorted(fs, regiondir);
    assertEquals(7, files.size());
    assertEquals(files.pollFirst().getName(), first);
    assertEquals(files.pollLast().getName(), last);
    assertEquals(files.pollFirst().getName(), WALSplitUtil.formatRecoveredEditsFileName(0));
    assertEquals(files.pollFirst().getName(), WALSplitUtil.formatRecoveredEditsFileName(1));
    assertEquals(files.pollFirst().getName(), WALSplitUtil.formatRecoveredEditsFileName(2));
    assertEquals(files.pollFirst().getName(), WALSplitUtil.formatRecoveredEditsFileName(11));
  }
Assert that getSplitEditFilesSorted returns files in expected order and that it skips
moved-aside files.
hbase-server/src/test/java/org/apache/hadoop/hbase/wal/TestWALMethods.java