List of usage examples for org.springframework.integration.redis.util RedisLockRegistry RedisLockRegistry
public RedisLockRegistry(RedisConnectionFactory connectionFactory, String registryKey)
From source file:org.springframework.integration.redis.util.RedisLockRegistryTests.java
@Test @RedisAvailable//from w w w. jav a 2 s . c o m public void testEquals() throws Exception { RedisConnectionFactory connectionFactory = this.getConnectionFactoryForTest(); RedisLockRegistry registry1 = new RedisLockRegistry(connectionFactory, this.registryKey); registry1.setUseWeakReferences(true); RedisLockRegistry registry2 = new RedisLockRegistry(connectionFactory, this.registryKey); RedisLockRegistry registry3 = new RedisLockRegistry(connectionFactory, this.registryKey2); Lock lock1 = registry1.obtain("foo"); Lock lock2 = registry1.obtain("foo"); assertEquals(lock1, lock2); lock1.lock(); lock2.lock(); assertEquals(lock1, lock2); lock1.unlock(); lock2.unlock(); assertEquals(lock1, lock2); lock1 = registry1.obtain("foo"); lock2 = registry2.obtain("foo"); assertNotEquals(lock1, lock2); lock1.lock(); assertFalse(lock2.tryLock()); lock1.unlock(); lock1 = registry1.obtain("foo"); lock2 = registry3.obtain("foo"); assertNotEquals(lock1, lock2); lock1.lock(); lock2.lock(); lock1.unlock(); lock2.unlock(); }