/** Test ensureValid returns true after acquire */
 public void testValidAfterAcquire() throws IOException {
   Path tempPath = createTempDir();
   Directory dir = getDirectory(tempPath);
   Lock l = dir.obtainLock("commit");
   l.ensureValid(); // no exception
   l.close();
   dir.close();
 }
  /** Test ensureValid throws exception after close */
  public void testInvalidAfterClose() throws IOException {
    Path tempPath = createTempDir();
    Directory dir = getDirectory(tempPath);

    Lock l = dir.obtainLock("commit");
    l.close();

    expectThrows(
        AlreadyClosedException.class,
        () -> {
          l.ensureValid();
        });

    dir.close();
  }