コード例 #1
0
 @Test
 public void tryLock() {
   assertThat(temp.getRoot().list()).isEmpty();
   lock.tryLock();
   assertThat(temp.getRoot().toPath().resolve(".sonar_lock")).exists();
   lock.unlock();
 }
コード例 #2
0
  @Test
  public void errorTryLock() {
    lock = new DirectoryLock(Paths.get("non", "existing", "path"), mock(Logger.class));

    exception.expect(IllegalStateException.class);
    exception.expectMessage("Failed to create lock");
    lock.tryLock();
  }