INT-3113: Use Lettuce Redis Client

* Ensure close connections after tests
* Remove `Thread.sleep` where it is possible

JIRA: https://jira.springsource.org/browse/INT-3113

INT-3113: Improve `RedisAvailableRule`

* Upgrade to Spring-Data-Redis-1.1.0
* Change Redis port to default one - 6379

Polish - add smart delay to SubscribableRedisChannelTests.pubSubChannelTest
This commit is contained in:
Artem Bilan
2013-10-10 00:20:26 +03:00
committed by Gary Russell
parent 36795e5ee8
commit 9367928fd7
26 changed files with 312 additions and 813 deletions

View File

@@ -59,12 +59,14 @@ subprojects { subproject ->
eaioUUIDVersion = '3.2'
ftpServerVersion = '1.0.6'
springVersionDefault = '3.1.4.RELEASE'
springVersion = project.hasProperty('springVersion') ? getProperty('springVersion') : springVersionDefault
springAmqpVersion = '1.2.0.RELEASE'
springDataMongoVersion = '1.1.1.RELEASE'
springDataRedisVersion = '1.0.5.RELEASE'
springDataRedisVersion = '1.1.0.RELEASE'
lettuceVersion = '2.3.3'
springGemfireVersion = '1.3.1.RELEASE'
springSecurityVersion = '3.1.3.RELEASE'
springSocialTwitterVersion = '1.0.5.RELEASE'
@@ -437,6 +439,7 @@ project('spring-integration-redis') {
exclude group: 'org.springframework', module: 'spring-tx'
}
testCompile project(":spring-integration-test")
testCompile "com.lambdaworks:lettuce:$lettuceVersion"
}
}
@@ -539,6 +542,7 @@ project('spring-integration-twitter') {
testCompile project(":spring-integration-test")
testCompile project(":spring-integration-redis")
testCompile project(":spring-integration-redis").sourceSets.test.output
testCompile "com.lambdaworks:lettuce:$lettuceVersion"
}
}

File diff suppressed because one or more lines are too long

View File

@@ -17,22 +17,25 @@ package org.springframework.integration.redis.channel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.integration.Message;
import org.springframework.integration.MessagingException;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.redis.rules.RedisAvailable;
@@ -42,39 +45,51 @@ import org.springframework.util.ReflectionUtils;
/**
* @author Oleg Zhurakousky
* @author Gary Russell
* @author Artem Bilan
* @since 2.0
*/
public class SubscribableRedisChannelTests extends RedisAvailableTests{
public class SubscribableRedisChannelTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void pubSubChanneTest() throws Exception{
JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
connectionFactory.setPort(7379);
connectionFactory.afterPropertiesSet();
public void pubSubChannelTest() throws Exception{
RedisConnectionFactory connectionFactory = this.getConnectionFactoryForTest();
SubscribableRedisChannel channel = new SubscribableRedisChannel(connectionFactory, "si.test.channel");
channel.setBeanFactory(mock(BeanFactory.class));
channel.afterPropertiesSet();
channel.start();
MessageHandler handler = mock(MessageHandler.class);
RedisConnection connection = TestUtils.getPropertyValue(channel, "container.subscriptionTask.connection",
RedisConnection.class);
int n = 0;
while (n++ < 100 && !connection.isSubscribed()) {
Thread.sleep(100);
}
assertTrue(n < 100);
final CountDownLatch latch = new CountDownLatch(3);
MessageHandler handler = new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
latch.countDown();
}
};
channel.subscribe(handler);
channel.send(new GenericMessage<String>("1"));
channel.send(new GenericMessage<String>("2"));
channel.send(new GenericMessage<String>("3"));
Thread.sleep(1000);
verify(handler, times(3)).handleMessage(Mockito.any(Message.class));
channel.stop();
assertTrue(latch.await(5, TimeUnit.SECONDS));
}
@Test
@RedisAvailable
public void dispatcherHasNoSubscribersTest() throws Exception{
JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
connectionFactory.setPort(7379);
connectionFactory.afterPropertiesSet();
RedisConnectionFactory connectionFactory = this.getConnectionFactoryForTest();
SubscribableRedisChannel channel = new SubscribableRedisChannel(connectionFactory, "si.test.channel.no.subs");
channel.setBeanName("dhnsChannel");

View File

@@ -12,8 +12,8 @@
<int-redis:publish-subscribe-channel id="redisChannel" topic-name="si.test.topic"
serializer="redisSerializer"/>
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="port" value="7379"/>
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory">
<property name="port" value="#{T(org.springframework.integration.redis.rules.RedisAvailableRule).REDIS_PORT}"/>
</bean>
<bean id="redisSerializer" class="org.springframework.data.redis.serializer.StringRedisSerializer"/>

View File

@@ -17,11 +17,15 @@
package org.springframework.integration.redis.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.integration.Message;
import org.springframework.integration.MessagingException;
@@ -36,6 +40,7 @@ import org.springframework.integration.test.util.TestUtils;
* @author Oleg Zhurakousky
* @author Gary Russell
* @author Gunnar Hillert
* @author Artem Bilan
*/
public class RedisChannelParserTests extends RedisAvailableTests{
@@ -44,8 +49,8 @@ public class RedisChannelParserTests extends RedisAvailableTests{
public void testPubSubChannelConfig(){
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("RedisChannelParserTests-context.xml", this.getClass());
SubscribableChannel redisChannel = context.getBean("redisChannel", SubscribableChannel.class);
JedisConnectionFactory connectionFactory =
TestUtils.getPropertyValue(redisChannel, "connectionFactory", JedisConnectionFactory.class);
RedisConnectionFactory connectionFactory =
TestUtils.getPropertyValue(redisChannel, "connectionFactory", RedisConnectionFactory.class);
RedisSerializer<?> redisSerializer = TestUtils.getPropertyValue(redisChannel, "serializer", RedisSerializer.class);
assertEquals(connectionFactory, context.getBean("redisConnectionFactory"));
assertEquals(redisSerializer, context.getBean("redisSerializer"));
@@ -65,20 +70,17 @@ public class RedisChannelParserTests extends RedisAvailableTests{
SubscribableChannel redisChannel = context.getBean("redisChannel", SubscribableChannel.class);
final Message<?> m = new GenericMessage<String>("Hello Redis");
final Marker marker = Mockito.mock(Marker.class);
final CountDownLatch latch = new CountDownLatch(1);
redisChannel.subscribe(new MessageHandler() {
public void handleMessage(Message<?> message) throws MessagingException {
assertEquals(m.getPayload(), message.getPayload());
marker.mark();
latch.countDown();
}
});
redisChannel.send(m);
Thread.sleep(1000);
Mockito.verify(marker, Mockito.times(1)).mark();
assertTrue(latch.await(2, TimeUnit.SECONDS));
context.stop();
}
interface Marker {
void mark();
}
}

View File

@@ -8,7 +8,7 @@
<int-redis:inbound-channel-adapter
id="adapter" topics="foo, bar" channel="receiveChannel" error-channel="testErrorChannel"
message-converter="testConverter"
message-converter="testConverter"
serializer="serializer"/>
<int:channel id="receiveChannel">
@@ -17,8 +17,8 @@
<int:channel id="testErrorChannel" />
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="port" value="7379" />
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory">
<property name="port" value="#{T(org.springframework.integration.redis.rules.RedisAvailableRule).REDIS_PORT}"/>
</bean>
<bean id="testConverter"
@@ -27,7 +27,7 @@
<int-redis:inbound-channel-adapter
id="autoChannel" topics="foo, bar" error-channel="testErrorChannel"
message-converter="testConverter" />
<bean id="serializer" class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
<int:bridge input-channel="autoChannel" output-channel="nullChannel"/>

View File

@@ -25,7 +25,7 @@ import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.ApplicationContext;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.redis.inbound.RedisInboundChannelAdapter;
@@ -44,7 +44,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class RedisInboundChannelAdapterParserTests extends RedisAvailableTests{
public class RedisInboundChannelAdapterParserTests extends RedisAvailableTests {
@Autowired
private ApplicationContext context;
@@ -71,16 +71,15 @@ public class RedisInboundChannelAdapterParserTests extends RedisAvailableTests{
@Test
@RedisAvailable
public void testInboundChannelAdapterMessaging() throws Exception{
JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
connectionFactory.setPort(7379);
connectionFactory.afterPropertiesSet();
public void testInboundChannelAdapterMessaging() throws Exception {
RedisConnectionFactory connectionFactory = this.getConnectionFactoryForTest();
connectionFactory.getConnection().publish("foo".getBytes(), "Hello Redis from foo".getBytes());
Thread.sleep(1000);
QueueChannel receiveChannel = context.getBean("receiveChannel", QueueChannel.class);
assertEquals("Hello Redis from foo", receiveChannel.receive(1000).getPayload());
assertEquals("Hello Redis from foo", receiveChannel.receive(2000).getPayload());
connectionFactory.getConnection().publish("bar".getBytes(), "Hello Redis from bar".getBytes());
assertEquals("Hello Redis from bar", receiveChannel.receive(1000).getPayload());
assertEquals("Hello Redis from bar", receiveChannel.receive(2000).getPayload());
}
@Test

View File

@@ -21,8 +21,8 @@
<int:queue/>
</int:channel>
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="port" value="7379"/>
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory">
<property name="port" value="#{T(org.springframework.integration.redis.rules.RedisAvailableRule).REDIS_PORT}"/>
</bean>
<bean id="testConverter" class="org.springframework.integration.redis.config.RedisOutboundChannelAdapterParserTests$TestMessageConverter"/>
@@ -30,7 +30,7 @@
<int:chain input-channel="redisOutboudChain">
<int-redis:outbound-channel-adapter topic="foo"/>
</int:chain>
<bean id="serializer" class="org.springframework.data.redis.serializer.StringRedisSerializer"/>
</beans>

View File

@@ -16,9 +16,8 @@
<int:poller fixed-rate="2000" max-messages-per-poll="10"/>
</int-redis:store-inbound-channel-adapter>
<bean id="redisConnectionFactory"
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="port" value="7379" />
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory">
<property name="port" value="#{T(org.springframework.integration.redis.rules.RedisAvailableRule).REDIS_PORT}"/>
</bean>
</beans>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2007-2011 the original author or authors
* Copyright 2007-2013 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,11 +16,17 @@
package org.springframework.integration.redis.inbound;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.integration.Message;
@@ -29,11 +35,6 @@ import org.springframework.integration.redis.rules.RedisAvailable;
import org.springframework.integration.redis.rules.RedisAvailableTests;
import org.springframework.integration.test.util.TestUtils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/**
* @author Mark Fisher
* @since 2.1
@@ -42,7 +43,7 @@ public class RedisInboundChannelAdapterTests extends RedisAvailableTests{
private final Log logger = LogFactory.getLog(this.getClass());
@Test
@Test
@RedisAvailable
public void testRedisInboundChannelAdapter() throws Exception {
for (int iteration = 0; iteration < 10; iteration ++) {
@@ -55,9 +56,7 @@ public class RedisInboundChannelAdapterTests extends RedisAvailableTests{
String redisChannelName = "testRedisInboundChannelAdapterChannel";
QueueChannel channel = new QueueChannel();
JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
connectionFactory.setPort(7379);
connectionFactory.afterPropertiesSet();
RedisConnectionFactory connectionFactory = this.getConnectionFactoryForTest();
RedisInboundChannelAdapter adapter = new RedisInboundChannelAdapter(connectionFactory);
adapter.setTopics("testRedisInboundChannelAdapterChannel");
@@ -87,7 +86,6 @@ public class RedisInboundChannelAdapterTests extends RedisAvailableTests{
assertEquals(numToTest, counter);
adapter.stop();
container.stop();
connectionFactory.destroy();
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,11 +19,12 @@ package org.springframework.integration.redis.inbound;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.support.collections.RedisList;
import org.springframework.data.redis.support.collections.RedisZSet;
import org.springframework.integration.Message;
@@ -34,6 +35,7 @@ import org.springframework.integration.redis.rules.RedisAvailableTests;
/**
* @author Oleg Zhurakousky
* @author Artem Bilan
* @since 2.2
*/
public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvailableTests{
@@ -42,7 +44,7 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
@RedisAvailable
@SuppressWarnings("unchecked")
public void testListInboundConfiguration() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
this.prepareList(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("list-inbound-adapter.xml", this.getClass());
SourcePollingChannelAdapter spca = context.getBean("listAdapter", SourcePollingChannelAdapter.class);
@@ -64,7 +66,7 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
@RedisAvailable
@SuppressWarnings("unchecked")
public void testListInboundConfigurationWithSynchronization() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
this.prepareList(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("list-inbound-adapter.xml", this.getClass());
SourcePollingChannelAdapter spca = context.getBean("listAdapterWithSynchronization", SourcePollingChannelAdapter.class);
@@ -87,7 +89,7 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
@RedisAvailable
@SuppressWarnings("unchecked")
public void testListInboundConfigurationWithSynchronizationAndTemplate() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
this.prepareList(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("list-inbound-adapter.xml", this.getClass());
SourcePollingChannelAdapter spca = context.getBean("listAdapterWithSynchronizationAndRedisTemplate", SourcePollingChannelAdapter.class);
@@ -110,7 +112,7 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
@RedisAvailable
@SuppressWarnings("unchecked")
public void testZsetInboundConfiguration(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
this.prepareZset(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("zset-inbound-adapter.xml", this.getClass());
SourcePollingChannelAdapter zsetAdapterNoScore =
@@ -136,7 +138,7 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
@RedisAvailable
@SuppressWarnings("unchecked")
public void testZsetInboundConfigurationWithScoreRange(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
this.prepareZset(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("zset-inbound-adapter.xml", this.getClass());
SourcePollingChannelAdapter zsetAdapterWithScoreRange =
@@ -162,7 +164,7 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
@RedisAvailable
@SuppressWarnings("unchecked")
public void testZsetInboundConfigurationWithSingleScore(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
this.prepareZset(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("zset-inbound-adapter.xml", this.getClass());
SourcePollingChannelAdapter zsetAdapterWithSingleScore =
@@ -188,7 +190,7 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
@RedisAvailable
@SuppressWarnings("unchecked")
public void testZsetInboundConfigurationWithSingleScoreAndSynchronization() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
this.prepareZset(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("zset-inbound-adapter.xml", this.getClass());
SourcePollingChannelAdapter zsetAdapterWithSingleScoreAndSynchronization =
@@ -199,31 +201,33 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
QueueChannel redisChannel = context.getBean("redisChannel", QueueChannel.class);
QueueChannel otherRedisChannel = context.getBean("otherRedisChannel", QueueChannel.class);
// get all 13 presidents
zsetAdapterNoScore.start();
Message<RedisZSet<Object>> message = (Message<RedisZSet<Object>>) redisChannel.receive(1000);
assertNotNull(message);
assertEquals(13, message.getPayload().size());
zsetAdapterNoScore.stop();
Thread.sleep(1000);
// get only presidents for 18th century
zsetAdapterWithSingleScoreAndSynchronization.start();
message = (Message<RedisZSet<Object>>) otherRedisChannel.receive(1000);
assertNotNull(message);
assertEquals(2, message.getPayload().rangeByScore(18, 18).size());
zsetAdapterWithSingleScoreAndSynchronization.stop();
Thread.sleep(1000);
// ... however other elements are still available 13-2=11
zsetAdapterNoScore.start();
message = (Message<RedisZSet<Object>>) redisChannel.receive(1000);
assertNotNull(message);
assertEquals(11, message.getPayload().size());
int n = 0;
while(n++ < 100 && message.getPayload().size() != 11) {
Thread.sleep(100);
}
assertTrue(n < 100);
zsetAdapterNoScore.stop();
context.close();
}

View File

@@ -25,7 +25,7 @@
<int:transactional synchronization-factory="syncFactory"/>
</int:poller>
</int-redis:store-inbound-channel-adapter>
<int-redis:store-inbound-channel-adapter id="listAdapterWithSynchronizationAndRollback"
connection-factory="redisConnectionFactory"
key-expression="'presidents'"
@@ -35,7 +35,7 @@
<int:transactional synchronization-factory="syncFactory"/>
</int:poller>
</int-redis:store-inbound-channel-adapter>
<int:channel id="redisFailChannel"/>
<int-redis:store-inbound-channel-adapter id="listAdapterWithSynchronizationAndRedisTemplate"
@@ -47,12 +47,12 @@
<int:transactional synchronization-factory="syncFactory"/>
</int:poller>
</int-redis:store-inbound-channel-adapter>
<int:transaction-synchronization-factory id="syncFactory">
<int:after-commit expression="#resource.attributes['store'].rename('bar')"/>
<int:after-rollback expression="#store.rename('baz')"/>
</int:transaction-synchronization-factory>
<int-redis:store-inbound-channel-adapter id="listAdapterWithSynchronizationBeforeCommit"
redis-template="redisTemplate"
key-expression="'presidents'"
@@ -62,11 +62,11 @@
<int:transactional synchronization-factory="syncFactory2"/>
</int:poller>
</int-redis:store-inbound-channel-adapter>
<int:channel id="adapterErrors">
<int:queue/>
</int:channel>
<int:transaction-synchronization-factory id="syncFactory2">
<int:before-commit expression="5/0"/>
</int:transaction-synchronization-factory>
@@ -85,10 +85,10 @@
<int:queue/>
</int:channel>
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="port" value="7379"/>
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory">
<property name="port" value="#{T(org.springframework.integration.redis.rules.RedisAvailableRule).REDIS_PORT}"/>
</bean>
<bean id="transactionManager" class="org.springframework.integration.transaction.PseudoTransactionManager"/>
</beans>

View File

@@ -13,7 +13,7 @@
channel="redisChannel"
auto-startup="false"
collection-type="ZSET">
<int:poller fixed-rate="1000" max-messages-per-poll="2"/>
<int:poller fixed-rate="1000"/>
</int-redis:store-inbound-channel-adapter>
<int-redis:store-inbound-channel-adapter id="zsetAdapterWithScoreRange"
@@ -31,7 +31,7 @@
channel="redisChannel"
auto-startup="false"
collection-type="ZSET">
<int:poller fixed-rate="1000" max-messages-per-poll="2"/>
<int:poller fixed-rate="1000"/>
</int-redis:store-inbound-channel-adapter>
<int-redis:store-inbound-channel-adapter id="zsetAdapterWithSingleScoreAndSynchronization"
@@ -40,11 +40,11 @@
channel="otherRedisChannel"
auto-startup="false"
collection-type="ZSET">
<int:poller fixed-rate="1000" max-messages-per-poll="2">
<int:poller fixed-rate="1000">
<int:transactional synchronization-factory="syncFactory"/>
</int:poller>
</int-redis:store-inbound-channel-adapter>
<int:transaction-synchronization-factory id="syncFactory">
<int:after-commit expression="payload.removeByScore(18, 18)"/>
</int:transaction-synchronization-factory>
@@ -57,10 +57,11 @@
<int:queue/>
</int:channel>
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="port" value="7379"/>
<bean id="redisConnectionFactory"
class="org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory">
<property name="port" value="#{T(org.springframework.integration.redis.rules.RedisAvailableRule).REDIS_PORT}"/>
</bean>
<bean id="transactionManager" class="org.springframework.integration.transaction.PseudoTransactionManager"/>
</beans>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2007-2011 the original author or authors
* Copyright 2007-2013 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,12 +16,15 @@
package org.springframework.integration.redis.outbound;
import static org.junit.Assert.assertTrue;
import java.util.Collections;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.Topic;
@@ -31,24 +34,20 @@ import org.springframework.integration.redis.rules.RedisAvailable;
import org.springframework.integration.redis.rules.RedisAvailableTests;
import org.springframework.integration.support.MessageBuilder;
import static org.junit.Assert.assertEquals;
/**
* @author Mark Fisher
* @since 2.1
*/
public class RedisPublishingMessageHandlerTests extends RedisAvailableTests{
public class RedisPublishingMessageHandlerTests extends RedisAvailableTests {
@Test
@Test
@RedisAvailable
public void testRedisPublishingMessageHandler() throws Exception {
int numToTest = 10;
String topic = "si.test.channel";
final CountDownLatch latch = new CountDownLatch(numToTest);
JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
connectionFactory.setPort(7379);
connectionFactory.afterPropertiesSet();
RedisConnectionFactory connectionFactory = this.getConnectionFactoryForTest();
MessageListenerAdapter listener = new MessageListenerAdapter();
listener.setDelegate(new Listener(latch));
@@ -67,8 +66,7 @@ public class RedisPublishingMessageHandlerTests extends RedisAvailableTests{
for (int i = 0; i < numToTest; i++) {
handler.handleMessage(MessageBuilder.withPayload("test-" + i).build());
}
latch.await(3, TimeUnit.SECONDS);
assertEquals(0, latch.getCount());
assertTrue(latch.await(3, TimeUnit.SECONDS));
container.stop();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2007-2012 the original author or authors
* Copyright 2007-2013 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,9 +27,9 @@ import java.util.Properties;
import java.util.Set;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@@ -63,7 +63,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test
@RedisAvailable
public void testListWithKeyAsHeader(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisList<String> redisList =
new DefaultRedisList<String>("pepboys", this.initTemplate(jcf, new StringRedisTemplate()));
@@ -84,7 +84,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test
@RedisAvailable
public void testListWithKeyAsHeaderSimple(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
StringRedisTemplate redisTemplate = new StringRedisTemplate();
RedisList<String> redisList =
@@ -103,7 +103,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test
@RedisAvailable
public void testListWithProvidedKey(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisList<String> redisList =
new DefaultRedisList<String>("pepboys", this.initTemplate(jcf, new StringRedisTemplate()));
assertEquals(0, redisList.size());
@@ -123,7 +123,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test
@RedisAvailable
public void testZsetSimplePayloadIncrement(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
StringRedisTemplate redisTemplate = new StringRedisTemplate();
RedisZSet<String> redisZSet =
@@ -148,7 +148,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test
@RedisAvailable
public void testZsetSimplePayloadOverwrite(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
StringRedisTemplate redisTemplate = new StringRedisTemplate();
RedisZSet<String> redisZSet =
@@ -176,7 +176,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test
@RedisAvailable
public void testZsetSimplePayloadIncrementBy2(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
StringRedisTemplate redisTemplate = new StringRedisTemplate();
RedisZSet<String> redisZSet =
@@ -204,7 +204,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test
@RedisAvailable
public void testZsetSimplePayloadOverwriteWithHeaderScore(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
StringRedisTemplate redisTemplate = new StringRedisTemplate();
RedisZSet<String> redisZSet =
@@ -233,7 +233,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test
@RedisAvailable
public void testMapToZsetWithProvidedKey(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisZSet<String> redisZset =
new DefaultRedisZSet<String>("presidents", this.initTemplate(jcf, new StringRedisTemplate()));
assertEquals(0, redisZset.size());
@@ -279,7 +279,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test
@RedisAvailable
public void testMapToMapWithProvidedKey(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMap<String, String> redisMap =
new DefaultRedisMap<String, String>("pepboys",
this.initTemplate(jcf, new StringRedisTemplate()));
@@ -308,7 +308,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test(expected=MessageHandlingException.class) // map key is not provided
@RedisAvailable
public void testMapToMapAsSingleEntryWithKeyAsHeaderFail(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMap<String, Map<String, String>> redisMap =
new DefaultRedisMap<String, Map<String, String>>("pepboys",
this.initTemplate(jcf, new RedisTemplate<String, Map<String, Map<String, String>>>()));
@@ -330,7 +330,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test(expected=MessageHandlingException.class) // key is not provided
@RedisAvailable
public void testMapToMapNoKey(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisTemplate<String, Map<String, Map<String, String>>> redisTemplate = new RedisTemplate<String, Map<String, Map<String, String>>>();
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
@@ -354,7 +354,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test
@RedisAvailable
public void testMapToMapAsSingleEntryWithKeyAsHeader(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisTemplate<String, Map<String, Map<String, String>>> redisTemplate = new RedisTemplate<String, Map<String, Map<String, String>>>();
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
@@ -384,7 +384,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test
@RedisAvailable
public void testStoreSimpleStringInMap(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
StringRedisTemplate redisTemplate = new StringRedisTemplate();
RedisMap<String, String> redisMap =
new DefaultRedisMap<String, String>("bar",
@@ -406,7 +406,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test
@RedisAvailable
public void testSetWithKeyAsHeader(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisSet<String> redisSet =
new DefaultRedisSet<String>("pepboys", this.initTemplate(jcf, new StringRedisTemplate()));
assertEquals(0, redisSet.size());
@@ -426,7 +426,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test
@RedisAvailable
public void testSetWithKeyAsHeaderSimple(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
StringRedisTemplate redisTemplate = new StringRedisTemplate();
RedisSet<String> redisSet =
new DefaultRedisSet<String>("foo", this.initTemplate(jcf, redisTemplate));
@@ -445,7 +445,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test
@RedisAvailable
public void testSetWithKeyAsHeaderNotParsed(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisTemplate<String, String> redisTemplate = new RedisTemplate<String, String>();
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
@@ -468,7 +468,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test
@RedisAvailable
public void testPojoIntoSet(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisSet<String> redisSet =
new DefaultRedisSet<String>("pepboys", this.initTemplate(jcf, new StringRedisTemplate()));
assertEquals(0, redisSet.size());
@@ -485,7 +485,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test
@RedisAvailable
public void testProperties(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisProperties redisProperties =
new RedisProperties("pepboys", this.initTemplate(jcf, new StringRedisTemplate()));
@@ -508,7 +508,7 @@ public class RedisStoreOutboundChannelAdapterIntegrationTests extends RedisAvail
@Test
@RedisAvailable
public void testPropertiesSimple(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
StringRedisTemplate redisTemplate = new StringRedisTemplate();
RedisProperties redisProperties =
new RedisProperties("foo", this.initTemplate(jcf, redisTemplate));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,6 @@ import java.util.Set;
import org.junit.Test;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ZSetOperations.TypedTuple;
@@ -58,7 +57,7 @@ public class RedisStoreWritingMessageHandlerTests extends RedisAvailableTests{
@Test
@RedisAvailable
public void testListWithListPayloadParsedAndProvidedKey() {
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
String key = "foo";
RedisList<String> redisList =
new DefaultRedisList<String>(key, this.initTemplate(jcf, new StringRedisTemplate()));
@@ -86,7 +85,7 @@ public class RedisStoreWritingMessageHandlerTests extends RedisAvailableTests{
@Test
@RedisAvailable
public void testListWithListPayloadParsedAndProvidedKeyAsHeader() {
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
String key = "foo";
RedisList<String> redisList =
new DefaultRedisList<String>(key, this.initTemplate(jcf, new StringRedisTemplate()));
@@ -114,7 +113,7 @@ public class RedisStoreWritingMessageHandlerTests extends RedisAvailableTests{
@RedisAvailable
@Test(expected=MessageHandlingException.class)
public void testListWithListPayloadParsedAndNoKey() {
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
String key = "foo";
RedisList<String> redisList =
new DefaultRedisList<String>(key, this.initTemplate(jcf, new RedisTemplate<String, String>()));
@@ -136,7 +135,7 @@ public class RedisStoreWritingMessageHandlerTests extends RedisAvailableTests{
@Test
@RedisAvailable
public void testListWithListPayloadAsSingleEntry() {
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
String key = "foo";
RedisList<List<String>> redisList =
new DefaultRedisList<List<String>>(key, this.initTemplate(jcf, new RedisTemplate<String, List<String>>()));
@@ -167,7 +166,7 @@ public class RedisStoreWritingMessageHandlerTests extends RedisAvailableTests{
@Test
@RedisAvailable
public void testZsetWithListPayloadParsedAndProvidedKeyDefault() {
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
String key = "foo";
RedisZSet<String> redisZset =
new DefaultRedisZSet<String>(key, this.initTemplate(jcf, new StringRedisTemplate()));
@@ -205,7 +204,7 @@ public class RedisStoreWritingMessageHandlerTests extends RedisAvailableTests{
@Test
@RedisAvailable
public void testZsetWithListPayloadParsedAndProvidedKeyScoreIncrement() {
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
String key = "foo";
RedisZSet<String> redisZset =
new DefaultRedisZSet<String>(key, this.initTemplate(jcf, new StringRedisTemplate()));
@@ -246,7 +245,7 @@ public class RedisStoreWritingMessageHandlerTests extends RedisAvailableTests{
@Test
@RedisAvailable
public void testZsetWithListPayloadParsedAndProvidedKeyScoreIncrementAsStringHeader() {// see INT-2775
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
String key = "foo";
RedisZSet<String> redisZset =
new DefaultRedisZSet<String>(key, this.initTemplate(jcf, new StringRedisTemplate()));
@@ -287,7 +286,7 @@ public class RedisStoreWritingMessageHandlerTests extends RedisAvailableTests{
@Test
@RedisAvailable
public void testZsetWithListPayloadAsSingleEntryAndHeaderKeyHeaderScore() {
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
String key = "foo";
RedisZSet<List<String>> redisZset =
new DefaultRedisZSet<List<String>>(key, this.initTemplate(jcf, new RedisTemplate<String, List<String>>()));
@@ -320,7 +319,7 @@ public class RedisStoreWritingMessageHandlerTests extends RedisAvailableTests{
@Test
@RedisAvailable
public void testZsetWithMapPayloadParsedHeaderKey() {
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
String key = "presidents";
RedisZSet<String> redisZset =
new DefaultRedisZSet<String>(key, this.initTemplate(jcf, new StringRedisTemplate()));
@@ -362,7 +361,7 @@ public class RedisStoreWritingMessageHandlerTests extends RedisAvailableTests{
@Test
@RedisAvailable
public void testZsetWithMapPayloadPojoParsedHeaderKey() {
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
String key = "presidents";
RedisZSet<President> redisZset =
new DefaultRedisZSet<President>(key, this.initTemplate(jcf, new RedisTemplate<String, President>()));
@@ -405,7 +404,7 @@ public class RedisStoreWritingMessageHandlerTests extends RedisAvailableTests{
@Test
@RedisAvailable
public void testZsetWithMapPayloadPojoAsSingleEntryHeaderKey() {
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
String key = "presidents";
RedisZSet<Map<President, Double>> redisZset =
new DefaultRedisZSet<Map<President, Double>>(key, this.initTemplate(jcf, new RedisTemplate<String, Map<President, Double>>()));
@@ -435,7 +434,7 @@ public class RedisStoreWritingMessageHandlerTests extends RedisAvailableTests{
@Test(expected=IllegalStateException.class)
@RedisAvailable
public void testListWithMapKeyExpression() {
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
String key = "foo";
RedisStoreWritingMessageHandler handler =
new RedisStoreWritingMessageHandler(jcf);
@@ -447,7 +446,7 @@ public class RedisStoreWritingMessageHandlerTests extends RedisAvailableTests{
@Test(expected=IllegalStateException.class)
@RedisAvailable
public void testSetWithMapKeyExpression() {
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
String key = "foo";
RedisStoreWritingMessageHandler handler =
new RedisStoreWritingMessageHandler(jcf);
@@ -460,7 +459,7 @@ public class RedisStoreWritingMessageHandlerTests extends RedisAvailableTests{
@Test(expected=IllegalStateException.class)
@RedisAvailable
public void testZsetWithMapKeyExpression() {
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
String key = "foo";
RedisStoreWritingMessageHandler handler =
new RedisStoreWritingMessageHandler(jcf);
@@ -473,7 +472,7 @@ public class RedisStoreWritingMessageHandlerTests extends RedisAvailableTests{
@Test
@RedisAvailable
public void testMapWithMapKeyExpression() {
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
String key = "foo";
RedisStoreWritingMessageHandler handler =
new RedisStoreWritingMessageHandler(jcf);
@@ -491,7 +490,7 @@ public class RedisStoreWritingMessageHandlerTests extends RedisAvailableTests{
@Test
@RedisAvailable
public void testPropertiesWithMapKeyExpression() {
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
String key = "foo";
RedisStoreWritingMessageHandler handler =
new RedisStoreWritingMessageHandler(jcf);

View File

@@ -61,8 +61,8 @@
map-key-expression="headers['baz']"
collection-type="PROPERTIES"/>
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="port" value="7379"/>
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory">
<property name="port" value="#{T(org.springframework.integration.redis.rules.RedisAvailableRule).REDIS_PORT}"/>
</bean>
</beans>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,49 +15,71 @@
*/
package org.springframework.integration.redis.rules;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Assume;
import org.junit.rules.MethodRule;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.Statement;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
/**
* @author Oleg Zhurakousky
* @author Gunnar Hillert
*
* @author Artem Bilan
*/
public final class RedisAvailableRule implements MethodRule{
public final class RedisAvailableRule implements MethodRule {
private static final Log logger = LogFactory.getLog(RedisAvailableRule.class);
public static final int REDIS_PORT = 6379;
public static final int REDIS_PORT = 7379;
static ThreadLocal<LettuceConnectionFactory> connectionFactoryResource = new ThreadLocal<LettuceConnectionFactory>();
public Statement apply(final Statement base, final FrameworkMethod method, Object target) {
return new Statement(){
RedisAvailable redisAvailable = method.getAnnotation(RedisAvailable.class);
if (redisAvailable != null) {
LettuceConnectionFactory connectionFactory = null;
try {
connectionFactory = new LettuceConnectionFactory();
connectionFactory.setPort(REDIS_PORT);
connectionFactory.afterPropertiesSet();
connectionFactory.getConnection();
connectionFactoryResource.set(connectionFactory);
}
catch (Exception e) {
if (connectionFactory != null) {
connectionFactory.destroy();
}
return new Statement() {
@Override
public void evaluate() throws Throwable {
Assume.assumeTrue("Skipping test due to Redis not being available on port: " + REDIS_PORT, false);
}
};
}
@Override
public void evaluate() throws Throwable {
RedisAvailable redisAvailable = method.getAnnotation(RedisAvailable.class);
if (redisAvailable != null){
return new Statement() {
@Override
public void evaluate() throws Throwable {
try {
JedisConnectionFactory connectionFactory = new JedisConnectionFactory();
connectionFactory.setPort(REDIS_PORT);
connectionFactory.afterPropertiesSet();
connectionFactory.getConnection();
} catch (Exception e) {
if (logger.isWarnEnabled()) {
logger.warn(String.format("Redis is not available on " +
"port '%s'. Skipping the test.", REDIS_PORT));
base.evaluate();
}
finally {
LettuceConnectionFactory connectionFactory = connectionFactoryResource.get();
connectionFactoryResource.remove();
if (connectionFactory != null) {
connectionFactory.destroy();
}
return;
}
}
};
}
return new Statement() {
@Override
public void evaluate() throws Throwable {
base.evaluate();
}
};
}
}

View File

@@ -21,7 +21,8 @@ import org.junit.Rule;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.BoundListOperations;
import org.springframework.data.redis.core.BoundZSetOperations;
import org.springframework.data.redis.core.RedisCallback;
@@ -31,21 +32,20 @@ import org.springframework.data.redis.core.StringRedisTemplate;
/**
* @author Oleg Zhurakousky
* @author Gary Russell
* @author Artem Bilan
*
*/
public class RedisAvailableTests {
@Rule
public RedisAvailableRule redisAvailableRule = new RedisAvailableRule();
@SuppressWarnings({ "rawtypes", "unchecked" })
public JedisConnectionFactory getConnectionFactoryForTest(){
JedisConnectionFactory jcf = new JedisConnectionFactory();
jcf.setPort(7379);
jcf.afterPropertiesSet();
RedisTemplate rt = new RedisTemplate<UUID, Object>();
rt.setConnectionFactory(jcf);
public RedisConnectionFactory getConnectionFactoryForTest(){
LettuceConnectionFactory connectionFactory = RedisAvailableRule.connectionFactoryResource.get();
RedisTemplate<UUID, Object> rt = new RedisTemplate<UUID, Object>();
rt.setConnectionFactory(connectionFactory);
rt.afterPropertiesSet();
rt.execute(new RedisCallback() {
rt.execute(new RedisCallback<Object>() {
public Object doInRedis(RedisConnection connection)
throws DataAccessException {
@@ -53,13 +53,13 @@ public class RedisAvailableTests {
return null;
}
});
return jcf;
return connectionFactory;
}
protected void prepareList(JedisConnectionFactory jcf){
protected void prepareList(RedisConnectionFactory connectionFactory){
StringRedisTemplate redisTemplate = new StringRedisTemplate();
redisTemplate.setConnectionFactory(jcf);
redisTemplate.setConnectionFactory(connectionFactory);
redisTemplate.afterPropertiesSet();
BoundListOperations<String, String> ops = redisTemplate.boundListOps("presidents");
@@ -80,10 +80,10 @@ public class RedisAvailableTests {
ops.rightPush("George Washington");
}
protected void prepareZset(JedisConnectionFactory jcf){
protected void prepareZset(RedisConnectionFactory connectionFactory){
StringRedisTemplate redisTemplate = new StringRedisTemplate();
redisTemplate.setConnectionFactory(jcf);
redisTemplate.setConnectionFactory(connectionFactory);
redisTemplate.afterPropertiesSet();
BoundZSetOperations<String, String> ops = redisTemplate.boundZSetOps("presidents");

View File

@@ -5,12 +5,8 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">
<beans:bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<beans:property name="port" value="7379" />
</beans:bean>
<beans:bean id="messageStore" class="org.springframework.integration.redis.store.RedisMessageStore">
<beans:constructor-arg ref="redisConnectionFactory"/>
<beans:constructor-arg value="#{T(org.springframework.integration.redis.store.DelayerHandlerRescheduleIntegrationTests).connectionFactory}"/>
</beans:bean>
<channel id="output">

View File

@@ -21,17 +21,20 @@ import static org.junit.Assert.fail;
import java.util.concurrent.TimeUnit;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.handler.DelayHandler;
import org.springframework.integration.redis.rules.RedisAvailable;
import org.springframework.integration.redis.rules.RedisAvailableRule;
import org.springframework.integration.redis.rules.RedisAvailableTests;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.store.MessageGroupStore;
@@ -47,9 +50,22 @@ public class DelayerHandlerRescheduleIntegrationTests extends RedisAvailableTest
public static final String DELAYER_ID = "delayerWithRedisMS";
public static LettuceConnectionFactory connectionFactory;
@Rule
public LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
@BeforeClass
public static void setup() {
connectionFactory = new LettuceConnectionFactory();
connectionFactory.setPort(RedisAvailableRule.REDIS_PORT);
connectionFactory.afterPropertiesSet();
}
public static void tearDown() {
connectionFactory.destroy();
}
@Test
@RedisAvailable
public void testDelayerHandlerRescheduleWithRedisMessageStore() throws Exception {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2007-2012 the original author or authors
* Copyright 2007-2013 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,13 +29,11 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import junit.framework.AssertionFailedError;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.channel.DirectChannel;
@@ -48,6 +46,8 @@ import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.store.SimpleMessageGroup;
import org.springframework.integration.support.MessageBuilder;
import junit.framework.AssertionFailedError;
/**
* @author Oleg Zhurakousky
*
@@ -57,7 +57,7 @@ public class RedisMessageGroupStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testNonExistingEmptyMessageGroup() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
MessageGroup messageGroup = store.getMessageGroup(1);
@@ -69,7 +69,7 @@ public class RedisMessageGroupStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testMessageGroupUpdatedDateChangesWithEachAddedMessage() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
MessageGroup messageGroup = store.getMessageGroup(1);
@@ -96,7 +96,7 @@ public class RedisMessageGroupStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testMessageGroupWithAddedMessage() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
MessageGroup messageGroup = store.getMessageGroup(1);
@@ -114,7 +114,7 @@ public class RedisMessageGroupStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testRemoveMessageGroup() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
MessageGroup messageGroup = store.getMessageGroup(1);
@@ -141,7 +141,7 @@ public class RedisMessageGroupStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testCompleteMessageGroup() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
MessageGroup messageGroup = store.getMessageGroup(1);
@@ -155,7 +155,7 @@ public class RedisMessageGroupStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testLastReleasedSequenceNumber() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
MessageGroup messageGroup = store.getMessageGroup(1);
@@ -169,7 +169,7 @@ public class RedisMessageGroupStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testRemoveMessageFromTheGroup() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
MessageGroup messageGroup = store.getMessageGroup(1);
@@ -192,7 +192,7 @@ public class RedisMessageGroupStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testWithMessageHistory() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
store.getMessageGroup(1);
@@ -219,7 +219,7 @@ public class RedisMessageGroupStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testRemoveNonExistingMessageFromTheGroup() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
MessageGroup messageGroup = store.getMessageGroup(1);
@@ -230,7 +230,7 @@ public class RedisMessageGroupStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testRemoveNonExistingMessageFromNonExistingTheGroup() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
store.removeMessageFromGroup(1, new GenericMessage<String>("2"));
}
@@ -240,7 +240,7 @@ public class RedisMessageGroupStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testMultipleInstancesOfGroupStore() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store1 = new RedisMessageStore(jcf);
RedisMessageStore store2 = new RedisMessageStore(jcf);
@@ -261,7 +261,7 @@ public class RedisMessageGroupStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testIteratorOfMessageGroups() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store1 = new RedisMessageStore(jcf);
RedisMessageStore store2 = new RedisMessageStore(jcf);
@@ -303,7 +303,7 @@ public class RedisMessageGroupStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable @Ignore
public void testConcurrentModifications() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
final RedisMessageStore store1 = new RedisMessageStore(jcf);
final RedisMessageStore store2 = new RedisMessageStore(jcf);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2007-2011 the original author or authors
* Copyright 2007-2013 the original author or authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,13 +15,18 @@
*/
package org.springframework.integration.redis.store;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import java.io.Serializable;
import java.util.Properties;
import java.util.UUID;
import org.junit.Test;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.integration.Message;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.history.MessageHistory;
@@ -29,11 +34,6 @@ import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.redis.rules.RedisAvailable;
import org.springframework.integration.redis.rules.RedisAvailableTests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
/**
* @author Oleg Zhurakousky
*
@@ -42,62 +42,62 @@ public class RedisMessageStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testGetNonExistingMessage(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
public void testGetNonExistingMessage(){
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
Message<?> message = store.getMessage(UUID.randomUUID());
assertNull(message);
}
@Test
@RedisAvailable
public void testGetMessageCountWhenEmpty(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
public void testGetMessageCountWhenEmpty(){
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
assertEquals(0, store.getMessageCount());
}
@Test
@RedisAvailable
public void testAddStringMessage(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
public void testAddStringMessage(){
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
Message<String> stringMessage = new GenericMessage<String>("Hello Redis");
Message<String> storedMessage = store.addMessage(stringMessage);
assertNotSame(stringMessage, storedMessage);
assertEquals("Hello Redis", storedMessage.getPayload());
}
@Test
@RedisAvailable
public void testAddSerializableObjectMessage(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
public void testAddSerializableObjectMessage(){
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
Address address = new Address();
address.setAddress("1600 Pennsylvania Av, Washington, DC");
Person person = new Person(address, "Barak Obama");
Message<Person> objectMessage = new GenericMessage<Person>(person);
Message<Person> storedMessage = store.addMessage(objectMessage);
assertNotSame(objectMessage, storedMessage);
assertEquals("Barak Obama", storedMessage.getPayload().getName());
}
@Test(expected=IllegalArgumentException.class)
@RedisAvailable
public void testAddNonSerializableObjectMessage(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
public void testAddNonSerializableObjectMessage(){
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
Message<Foo> objectMessage = new GenericMessage<Foo>(new Foo());
store.addMessage(objectMessage);
}
@SuppressWarnings("unchecked")
@Test
@RedisAvailable
public void testAddAndGetStringMessage(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
public void testAddAndGetStringMessage(){
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
Message<String> stringMessage = new GenericMessage<String>("Hello Redis");
store.addMessage(stringMessage);
@@ -108,8 +108,8 @@ public class RedisMessageStoreTests extends RedisAvailableTests {
@SuppressWarnings("unchecked")
@Test
@RedisAvailable
public void testAddAndRemoveStringMessage(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
public void testAddAndRemoveStringMessage(){
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
Message<String> stringMessage = new GenericMessage<String>("Hello Redis");
store.addMessage(stringMessage);
@@ -118,19 +118,19 @@ public class RedisMessageStoreTests extends RedisAvailableTests {
assertEquals("Hello Redis", retrievedMessage.getPayload());
assertNull(store.getMessage(stringMessage.getHeaders().getId()));
}
@Test
@RedisAvailable
public void testWithMessageHistory() throws Exception{
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
public void testWithMessageHistory() throws Exception{
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMessageStore store = new RedisMessageStore(jcf);
Message<?> message = new GenericMessage<String>("Hello");
DirectChannel fooChannel = new DirectChannel();
fooChannel.setBeanName("fooChannel");
DirectChannel barChannel = new DirectChannel();
barChannel.setBeanName("barChannel");
message = MessageHistory.write(message, fooChannel);
message = MessageHistory.write(message, barChannel);
store.addMessage(message);
@@ -142,7 +142,7 @@ public class RedisMessageStoreTests extends RedisAvailableTests {
assertEquals("fooChannel", fooChannelHistory.get("name"));
assertEquals("channel", fooChannelHistory.get("type"));
}
@SuppressWarnings("serial")
public static class Person implements Serializable{
private Address address;
@@ -176,8 +176,8 @@ public class RedisMessageStoreTests extends RedisAvailableTests {
this.address = address;
}
}
public static class Foo{
}
}

View File

@@ -20,7 +20,8 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
import org.junit.Test;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.integration.redis.rules.RedisAvailable;
@@ -36,7 +37,7 @@ public class RedisMetadataStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testGetNonExistingKeyValue(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);
String retrievedValue = metadataStore.get("does-not-exist");
assertNull(retrievedValue);
@@ -45,7 +46,7 @@ public class RedisMetadataStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testPersistKeyValue(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);
metadataStore.put("RedisMetadataStoreTests-Spring", "Integration");
@@ -59,7 +60,7 @@ public class RedisMetadataStoreTests extends RedisAvailableTests {
@RedisAvailable
public void testGetValueFromMetadataStore(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);
metadataStore.put("RedisMetadataStoreTests-GetValue", "Hello Redis");
@@ -71,7 +72,7 @@ public class RedisMetadataStoreTests extends RedisAvailableTests {
@RedisAvailable
public void testPersistEmptyStringToMetadataStore(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);
metadataStore.put("RedisMetadataStoreTests-PersistEmpty", "");
@@ -83,7 +84,7 @@ public class RedisMetadataStoreTests extends RedisAvailableTests {
@RedisAvailable
public void testPersistNullStringToMetadataStore(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);
try {
@@ -101,7 +102,7 @@ public class RedisMetadataStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testPersistWithEmptyKeyToMetadataStore(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);
metadataStore.put("", "PersistWithEmptyKey");
@@ -112,7 +113,7 @@ public class RedisMetadataStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testPersistWithNullKeyToMetadataStore(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);
try {
@@ -129,7 +130,7 @@ public class RedisMetadataStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testGetValueWithNullKeyFromMetadataStore(){
JedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);
try {

View File

@@ -4,19 +4,19 @@
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">
<int:aggregator input-channel="inputChannel" output-channel="outputChannel" message-store="redisStore"/>
<int:channel id="outputChannel">
<int:queue/>
</int:channel>
<bean id="redisStore" class="org.springframework.integration.redis.store.RedisMessageStore">
<constructor-arg ref="redisConnectionFactory"/>
</bean>
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<property name="port" value="7379" />
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory">
<property name="port" value="#{T(org.springframework.integration.redis.rules.RedisAvailableRule).REDIS_PORT}"/>
</bean>
</beans>

View File

@@ -25,9 +25,10 @@
<constructor-arg name="connectionFactory" ref="redisConnectionFactory"/>
</bean>
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
<bean id="redisConnectionFactory" class="org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory">
<property name="port" value="#{T(org.springframework.integration.redis.rules.RedisAvailableRule).REDIS_PORT}"/>
</bean>
</beans>