Ejemplo n.º 1
0
 @Test
 public void tryLock() {
   assertThat(temp.getRoot().list()).isEmpty();
   lock.tryLock();
   assertThat(temp.getRoot().toPath().resolve(".sonar_lock")).exists();
   lock.unlock();
 }
Ejemplo n.º 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();
  }
Ejemplo n.º 3
0
 @Test
 public void unlockWithoutLock() {
   lock.unlock();
 }
Ejemplo n.º 4
0
 @Test(expected = OverlappingFileLockException.class)
 public void error_2locks() {
   assertThat(temp.getRoot().list()).isEmpty();
   lock.lock();
   lock.lock();
 }