use of org.springframework.integration.redis.rules.RedisAvailable in project spring-integration by spring-projects.
the class RedisMessageGroupStoreTests method testMultipleInstancesOfGroupStore.
@Test
@RedisAvailable
public void testMultipleInstancesOfGroupStore() {
RedisConnectionFactory jcf = getConnectionFactoryForTest();
RedisMessageStore store1 = new RedisMessageStore(jcf);
RedisMessageStore store2 = new RedisMessageStore(jcf);
store1.removeMessageGroup(this.groupId);
Message<?> message = new GenericMessage<>("1");
store1.addMessagesToGroup(this.groupId, message);
MessageGroup messageGroup = store2.addMessageToGroup(this.groupId, new GenericMessage<>("2"));
assertEquals(2, messageGroup.getMessages().size());
RedisMessageStore store3 = new RedisMessageStore(jcf);
store3.removeMessagesFromGroup(this.groupId, message);
messageGroup = store3.getMessageGroup(this.groupId);
assertEquals(1, messageGroup.getMessages().size());
}
use of org.springframework.integration.redis.rules.RedisAvailable in project spring-integration by spring-projects.
the class RedisMessageGroupStoreTests method testNonExistingEmptyMessageGroup.
@Test
@RedisAvailable
public void testNonExistingEmptyMessageGroup() {
RedisConnectionFactory jcf = getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
MessageGroup messageGroup = store.getMessageGroup(this.groupId);
assertNotNull(messageGroup);
assertTrue(messageGroup instanceof SimpleMessageGroup);
assertEquals(0, messageGroup.size());
}
use of org.springframework.integration.redis.rules.RedisAvailable in project spring-integration by spring-projects.
the class RedisMessageGroupStoreTests method testMessageGroupUpdatedDateChangesWithEachAddedMessage.
@Test
@RedisAvailable
public void testMessageGroupUpdatedDateChangesWithEachAddedMessage() throws Exception {
RedisConnectionFactory jcf = getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
Message<?> message = new GenericMessage<>("Hello");
MessageGroup messageGroup = store.addMessageToGroup(this.groupId, message);
assertEquals(1, messageGroup.size());
long createdTimestamp = messageGroup.getTimestamp();
long updatedTimestamp = messageGroup.getLastModified();
assertEquals(createdTimestamp, updatedTimestamp);
Thread.sleep(10);
message = new GenericMessage<>("Hello");
messageGroup = store.addMessageToGroup(this.groupId, message);
createdTimestamp = messageGroup.getTimestamp();
updatedTimestamp = messageGroup.getLastModified();
assertTrue(updatedTimestamp > createdTimestamp);
// make sure the store is properly rebuild from Redis
store = new RedisMessageStore(jcf);
messageGroup = store.getMessageGroup(this.groupId);
assertEquals(2, messageGroup.size());
}
use of org.springframework.integration.redis.rules.RedisAvailable in project spring-integration by spring-projects.
the class RedisMessageGroupStoreTests method testRemoveNonExistingMessageFromTheGroup.
@Test
@RedisAvailable
public void testRemoveNonExistingMessageFromTheGroup() {
RedisConnectionFactory jcf = getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
MessageGroup messageGroup = store.getMessageGroup(this.groupId);
store.addMessagesToGroup(messageGroup.getGroupId(), new GenericMessage<>("1"));
store.removeMessagesFromGroup(this.groupId, new GenericMessage<>("2"));
}
use of org.springframework.integration.redis.rules.RedisAvailable in project spring-integration by spring-projects.
the class RedisLockRegistryTests method testExpireTwoRegistries.
@Test
@RedisAvailable
public void testExpireTwoRegistries() throws Exception {
RedisLockRegistry registry1 = new RedisLockRegistry(this.getConnectionFactoryForTest(), this.registryKey, 100);
RedisLockRegistry registry2 = new RedisLockRegistry(this.getConnectionFactoryForTest(), this.registryKey, 100);
Lock lock1 = registry1.obtain("foo");
Lock lock2 = registry2.obtain("foo");
assertTrue(lock1.tryLock());
assertFalse(lock2.tryLock());
waitForExpire("foo");
assertTrue(lock2.tryLock());
assertFalse(lock1.tryLock());
}
Aggregations