use of net.javacrumbs.shedlock.core.SimpleLock in project ShedLock by lukas-krecan.
the class AbstractLockProviderIntegrationTest method shouldLockTwiceInARow.
@Test
public void shouldLockTwiceInARow() {
LockProvider lockProvider = getLockProvider();
Optional<SimpleLock> lock1 = lockProvider.lock(lockConfig(LOCK_NAME1));
assertThat(lock1).isNotEmpty();
lock1.get().unlock();
Optional<SimpleLock> lock2 = lockProvider.lock(lockConfig(LOCK_NAME1));
assertThat(lock2).isNotEmpty();
lock2.get().unlock();
}
use of net.javacrumbs.shedlock.core.SimpleLock in project ShedLock by lukas-krecan.
the class AbstractLockProviderIntegrationTest method shouldNotReturnSecondLock.
@Test
public void shouldNotReturnSecondLock() {
LockProvider lockProvider = getLockProvider();
Optional<SimpleLock> lock = lockProvider.lock(lockConfig(LOCK_NAME1));
assertThat(lock).isNotEmpty();
assertThat(lockProvider.lock(lockConfig(LOCK_NAME1))).isEmpty();
lock.get().unlock();
}
use of net.javacrumbs.shedlock.core.SimpleLock in project ShedLock by lukas-krecan.
the class AbstractLockProviderIntegrationTest method doTestTimeout.
protected void doTestTimeout(Duration lockAtMostFor) throws InterruptedException {
LockConfiguration configWithShortTimeout = lockConfig(LOCK_NAME1, lockAtMostFor, Duration.ZERO);
Optional<SimpleLock> lock1 = getLockProvider().lock(configWithShortTimeout);
assertThat(lock1).isNotEmpty();
sleep(lockAtMostFor.toMillis() * 2);
assertUnlocked(LOCK_NAME1);
Optional<SimpleLock> lock2 = getLockProvider().lock(lockConfig(LOCK_NAME1, Duration.ofMillis(50), Duration.ZERO));
assertThat(lock2).isNotEmpty();
lock2.get().unlock();
}
Aggregations