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