use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-integration by spring-projects.
the class RedisMetadataStoreTests method testGetValueFromMetadataStore.
@Test
@RedisAvailable
public void testGetValueFromMetadataStore() {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf, "testMetadata");
metadataStore.put("RedisMetadataStoreTests-GetValue", "Hello Redis");
String retrievedValue = metadataStore.get("RedisMetadataStoreTests-GetValue");
assertEquals("Hello Redis", retrievedValue);
}
use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-integration by spring-projects.
the class RedisMetadataStoreTests method testGetValueWithNullKeyFromMetadataStore.
@Test
@RedisAvailable
public void testGetValueWithNullKeyFromMetadataStore() {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf, "testMetadata");
try {
metadataStore.get(null);
} catch (IllegalArgumentException e) {
assertEquals("'key' must not be null.", e.getMessage());
return;
}
fail("Expected an IllegalArgumentException to be thrown.");
}
use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-integration by spring-projects.
the class RedisPublishingMessageHandlerTests method testRedisPublishingMessageHandler.
@Test
@RedisAvailable
public void testRedisPublishingMessageHandler() throws Exception {
int numToTest = 10;
String topic = "si.test.channel";
final CountDownLatch latch = new CountDownLatch(numToTest * 2);
RedisConnectionFactory connectionFactory = this.getConnectionFactoryForTest();
MessageListenerAdapter listener = new MessageListenerAdapter();
listener.setDelegate(new Listener(latch));
listener.setSerializer(new StringRedisSerializer());
listener.afterPropertiesSet();
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
container.afterPropertiesSet();
container.addMessageListener(listener, Collections.<Topic>singletonList(new ChannelTopic(topic)));
container.start();
this.awaitContainerSubscribed(container);
final RedisPublishingMessageHandler handler = new RedisPublishingMessageHandler(connectionFactory);
handler.setTopicExpression(new LiteralExpression(topic));
for (int i = 0; i < numToTest; i++) {
handler.handleMessage(MessageBuilder.withPayload("test-" + i).build());
}
for (int i = 0; i < numToTest; i++) {
handler.handleMessage(MessageBuilder.withPayload(("test-" + i).getBytes()).build());
}
assertTrue(latch.await(10, TimeUnit.SECONDS));
container.stop();
}
use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-integration by spring-projects.
the class RedisStoreOutboundChannelAdapterIntegrationTests method setup.
@Before
@After
public void setup() {
RedisConnectionFactory jcf = getConnectionFactoryForTest();
this.redisTemplate.setConnectionFactory(jcf);
this.redisTemplate.afterPropertiesSet();
this.redisTemplate.delete("pepboys");
this.redisTemplate.delete("foo");
this.redisTemplate.delete("bar");
this.redisTemplate.delete("presidents");
}
use of org.springframework.data.redis.connection.RedisConnectionFactory in project spring-integration by spring-projects.
the class RedisAvailableTests method getConnectionFactoryForTest.
protected RedisConnectionFactory getConnectionFactoryForTest() {
if (this.connectionFactory != null) {
return this.connectionFactory;
}
RedisConnectionFactory connectionFactory = RedisAvailableRule.connectionFactoryResource.get();
this.connectionFactory = connectionFactory;
return connectionFactory;
}
Aggregations