use of net.javacrumbs.shedlock.core.SimpleLock in project ShedLock by lukas-krecan.
the class KeepAliveLockProviderTest method shouldExtendMultipleTimes.
@Test
void shouldExtendMultipleTimes() {
SimpleLock extendedLock = mock(SimpleLock.class);
mockExtension(originalLock, Optional.of(extendedLock));
mockExtension(extendedLock, Optional.of(extendedLock));
Optional<SimpleLock> lock = provider.lock(lockConfiguration);
assertThat(lock).isNotNull();
tickMs(1_500);
verify(originalLock).extend(lockConfiguration.getLockAtMostFor(), ofMillis(500));
tickMs(1_500);
verify(extendedLock).extend(lockConfiguration.getLockAtMostFor(), ZERO);
lock.get().unlock();
verify(extendedLock).unlock();
tickMs(10_000);
verifyNoMoreInteractions(originalLock);
}
use of net.javacrumbs.shedlock.core.SimpleLock in project ShedLock by lukas-krecan.
the class AbstractExtensibleLockProviderIntegrationTest method shouldBeAbleToExtendAtLeast.
@Test
public void shouldBeAbleToExtendAtLeast() {
SimpleLock lock = lock(Duration.ofSeconds(10));
SimpleLock newLock = extendLock(lock);
newLock.unlock();
assertLocked(LOCK_NAME1);
}
use of net.javacrumbs.shedlock.core.SimpleLock in project ShedLock by lukas-krecan.
the class AbstractExtensibleLockProviderIntegrationTest method lockCanNotBeUnlockedAfterExtending.
@Test
public void lockCanNotBeUnlockedAfterExtending() {
SimpleLock lock = lock(Duration.ofSeconds(10));
extendLock(lock);
assertInvalidLock(lock::unlock);
}
use of net.javacrumbs.shedlock.core.SimpleLock in project ShedLock by lukas-krecan.
the class AbstractLockProviderIntegrationTest method shouldBeAbleToLockRightAfterUnlock.
@Test
public void shouldBeAbleToLockRightAfterUnlock() {
LockConfiguration lockConfiguration = lockConfig(LOCK_NAME1);
for (int i = 0; i < 10; i++) {
Optional<SimpleLock> lock = getLockProvider().lock(lockConfiguration);
assertThat(lock).describedAs("Successfully locked").isNotEmpty();
assertThat(getLockProvider().lock(lockConfiguration)).isEmpty();
assertThat(lock).isNotEmpty();
lock.get().unlock();
}
}
use of net.javacrumbs.shedlock.core.SimpleLock in project ShedLock by lukas-krecan.
the class AbstractStorageBasedLockProviderIntegrationTest method lockShouldSurviveCacheClearingInTheMiddle.
@Test
public void lockShouldSurviveCacheClearingInTheMiddle() {
StorageBasedLockProvider provider = getLockProvider();
LockConfiguration configuration = lockConfig(LOCK_NAME1);
Optional<SimpleLock> lock = provider.lock(configuration);
assertThat(lock).isPresent();
provider.clearCache();
// lock is still locked
assertThat(provider.lock(lockConfig(LOCK_NAME1))).isEmpty();
lock.get().unlock();
}
Aggregations