コード例 #1
0
 /** 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();
 }
コード例 #2
0
  /** 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();
  }