@Test
  public void testIsWithinWorkingDir() throws IOException {
    Configuration conf = new Configuration();
    conf.set(HConstants.HBASE_DIR, "hdfs://localhost/root/");

    assertFalse(
      SnapshotDescriptionUtils.isWithinDefaultWorkingDir(new Path("hdfs://localhost/root/"), conf));
    assertFalse(SnapshotDescriptionUtils
      .isWithinDefaultWorkingDir(new Path("hdfs://localhost/root/.hbase-snapshotdir"), conf));
    assertFalse(SnapshotDescriptionUtils
      .isWithinDefaultWorkingDir(new Path("hdfs://localhost/root/.hbase-snapshot"), conf));
    assertFalse(SnapshotDescriptionUtils
      .isWithinDefaultWorkingDir(new Path("hdfs://localhost/.hbase-snapshot"), conf));
    assertFalse(SnapshotDescriptionUtils
      .isWithinDefaultWorkingDir(new Path("hdfs://localhost/.hbase-snapshot/.tmp"), conf));
    assertFalse(
      SnapshotDescriptionUtils.isWithinDefaultWorkingDir(new Path("hdfs://localhost/root"), conf));
    assertTrue(SnapshotDescriptionUtils
      .isWithinDefaultWorkingDir(new Path("hdfs://localhost/root/.hbase-snapshot/.tmp"), conf));
    assertTrue(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
      new Path("hdfs://localhost/root/.hbase-snapshot/.tmp/snapshot"), conf));

    assertFalse(SnapshotDescriptionUtils
      .isWithinDefaultWorkingDir(new Path("s3://localhost/root/.hbase-snapshot/"), conf));
    assertFalse(
      SnapshotDescriptionUtils.isWithinDefaultWorkingDir(new Path("s3://localhost/root"), conf));
    assertFalse(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
      new Path("s3://localhost/root/.hbase-snapshot/.tmp/snapshot"), conf));

    // for local mode
    conf = HBaseConfiguration.create();
    String hbsaeDir = conf.get(HConstants.HBASE_DIR);

    assertFalse(
      SnapshotDescriptionUtils.isWithinDefaultWorkingDir(new Path("file:" + hbsaeDir + "/"), conf));
    assertFalse(SnapshotDescriptionUtils
      .isWithinDefaultWorkingDir(new Path("file:" + hbsaeDir + "/.hbase-snapshotdir"), conf));
    assertFalse(SnapshotDescriptionUtils
      .isWithinDefaultWorkingDir(new Path("file:" + hbsaeDir + "/.hbase-snapshot"), conf));
    assertFalse(
      SnapshotDescriptionUtils.isWithinDefaultWorkingDir(new Path("file:/.hbase-snapshot"), conf));
    assertFalse(SnapshotDescriptionUtils
      .isWithinDefaultWorkingDir(new Path("file:/.hbase-snapshot/.tmp"), conf));
    assertFalse(
      SnapshotDescriptionUtils.isWithinDefaultWorkingDir(new Path("file:" + hbsaeDir), conf));
    assertTrue(SnapshotDescriptionUtils
      .isWithinDefaultWorkingDir(new Path("file:" + hbsaeDir + "/.hbase-snapshot/.tmp"), conf));
    assertTrue(SnapshotDescriptionUtils.isWithinDefaultWorkingDir(
      new Path("file:" + hbsaeDir + "/.hbase-snapshot/.tmp/snapshot"), conf));
  }
Test that we throw an exception if there is no working snapshot directory when we attempt to
'complete' the snapshot
@throws Exception on failure
hbase-server/src/test/java/org/apache/hadoop/hbase/snapshot/TestSnapshotDescriptionUtils.java