use of net.javacrumbs.shedlock.core.LockProvider in project ShedLock by lukas-krecan.
the class AbstractSchedulerConfig method lockProvider.
@Bean
public LockProvider lockProvider() {
LockProvider lockProvider = mock(LockProvider.class);
when(lockProvider.lock(any())).thenReturn(Optional.of(mock(SimpleLock.class)));
return lockProvider;
}
use of net.javacrumbs.shedlock.core.LockProvider in project ShedLock by lukas-krecan.
the class MongoLockProviderIntegrationTest method shouldLockWhenDocumentRemovedExternally.
@Test
public void shouldLockWhenDocumentRemovedExternally() {
LockProvider provider = getLockProvider();
assertThat(provider.lock(lockConfig(LOCK_NAME1))).isNotEmpty();
assertLocked(LOCK_NAME1);
DeleteResult result = getLockCollection().deleteOne(eq(ID, LOCK_NAME1));
assumeThat(result.getDeletedCount()).isEqualTo(1);
assertThat(provider.lock(lockConfig(LOCK_NAME1))).isNotEmpty();
assertLocked(LOCK_NAME1);
}
use of net.javacrumbs.shedlock.core.LockProvider in project ShedLock by lukas-krecan.
the class ReactiveStreamsMongoLockProviderIntegrationTest method shouldLockWhenDocumentRemovedExternally.
@Test
public void shouldLockWhenDocumentRemovedExternally() {
LockProvider provider = getLockProvider();
assertThat(provider.lock(lockConfig(LOCK_NAME1))).isNotEmpty();
assertLocked(LOCK_NAME1);
DeleteResult result = execute(getLockCollection().deleteOne(eq(ID, LOCK_NAME1)));
assumeThat(result.getDeletedCount()).isEqualTo(1);
assertThat(provider.lock(lockConfig(LOCK_NAME1))).isNotEmpty();
assertLocked(LOCK_NAME1);
}
use of net.javacrumbs.shedlock.core.LockProvider in project ShedLock by lukas-krecan.
the class MultiTenancyLockProviderIntegrationTest method shouldUseDifferDatabaseForEachTennant.
@Test
void shouldUseDifferDatabaseForEachTennant() {
LockProvider lockProvider = getLockProvider();
Optional<SimpleLock> lock1 = lockProvider.lock(LOCK_CONFIGURATION);
assertThat(lock1).isNotEmpty();
assertThat(h2TestUtils.getLockInfo(LOCK_NAME).getLockUntil()).isAfter(ClockProvider.now());
assertThatThrownBy(() -> hsqlTestUtils.getLockedUntil(LOCK_NAME)).isInstanceOf(EmptyResultDataAccessException.class);
lock1.get().unlock();
Optional<SimpleLock> lock2 = lockProvider.lock(LOCK_CONFIGURATION);
assertThat(lock2).isNotEmpty();
assertThat(hsqlTestUtils.getLockInfo(LOCK_NAME).getLockUntil()).isAfter(ClockProvider.now());
lock2.get().unlock();
}
use of net.javacrumbs.shedlock.core.LockProvider 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();
}
Aggregations