Merge remote-tracking branch 'upstream/master' into 4.0.0-WIP

Conflicts:
	spring-integration-core/src/main/java/org/springframework/integration/gateway/MessagingGatewaySupport.java
	spring-integration-core/src/main/java/org/springframework/integration/support/channel/BeanFactoryChannelResolver.java
	spring-integration-core/src/main/java/org/springframework/integration/util/MessagingMethodInvokerHelper.java
	spring-integration-core/src/test/java/org/springframework/integration/config/AggregatorParserTests.java
	spring-integration-core/src/test/java/org/springframework/integration/config/annotation/AggregatorAnnotationTests.java
	spring-integration-core/src/test/java/org/springframework/integration/config/xml/ControlBusTests.java
	spring-integration-file/src/main/java/org/springframework/integration/file/DefaultFileNameGenerator.java
	spring-integration-file/src/main/java/org/springframework/integration/file/remote/handler/FileTransferringMessageHandler.java
	spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java
	spring-integration-ftp/src/test/java/org/springframework/integration/ftp/config/FtpOutboundGatewayParserTests.java
	spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/FtpInboundRemoteFileSystemSynchronizerTests.java
	spring-integration-ftp/src/test/java/org/springframework/integration/ftp/outbound/FtpServerOutboundTests.java
	spring-integration-groovy/src/main/java/org/springframework/integration/groovy/GroovyScriptExecutingMessageProcessor.java
	spring-integration-http/src/test/java/org/springframework/integration/http/outbound/UriVariableExpressionTests.java
	spring-integration-ip/src/test/java/org/springframework/integration/ip/tcp/connection/HelloWorldInterceptor.java
	spring-integration-jpa/src/test/java/org/springframework/integration/jpa/outbound/JpaOutboundGatewayIntegrationTests.java
	spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/MongoDbMessageGroupStoreTests.java
	spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/store/MongoDbMessageStoreTests.java
	spring-integration-redis/src/test/java/org/springframework/integration/redis/config/RedisOutboundChannelAdapterParserTests.java
	spring-integration-sftp/src/test/java/org/springframework/integration/sftp/config/SftpOutboundGatewayParserTests.java
	spring-integration-sftp/src/test/java/org/springframework/integration/sftp/inbound/SftpInboundRemoteFileSystemSynchronizerTests.java
	spring-integration-sftp/src/test/java/org/springframework/integration/sftp/outbound/SftpServerOutboundTests.java

Resolved.
This commit is contained in:
Gary Russell
2013-11-25 17:59:51 -05:00
191 changed files with 8774 additions and 2707 deletions

View File

@@ -14,9 +14,10 @@
package org.springframework.integration.redis.metadata;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.BoundHashOperations;
import org.springframework.data.redis.core.RedisOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.support.collections.RedisProperties;
import org.springframework.integration.metadata.MetadataStore;
import org.springframework.util.Assert;
@@ -25,21 +26,58 @@ import org.springframework.util.Assert;
* to achieve meta-data persistence across application restarts.
*
* @author Gunnar Hillert
* @author Artem Bilan
* @since 3.0
*/
public class RedisMetadataStore implements MetadataStore {
private final StringRedisTemplate redisTemplate;
public static final String KEY = "MetaData";
private final RedisProperties properties;
/**
* Initializes the {@link RedisTemplate}.
* A {@link StringRedisTemplate} is used with default properties.
*
* @param connectionFactory Must not be null
* Specifies the {@link RedisProperties} backend for this {@link MetadataStore}.
*/
public RedisMetadataStore(RedisProperties properties) {
Assert.notNull(properties, "'properties' must not be null.");
this.properties = properties;
}
/**
* Initializes the {@link RedisProperties} by provided {@link RedisConnectionFactory}
* and default hash key - {@link #KEY}.
*/
public RedisMetadataStore(RedisConnectionFactory connectionFactory) {
this(connectionFactory, KEY);
}
/**
* Initializes the {@link RedisProperties} by provided {@link RedisConnectionFactory} and key.
*/
public RedisMetadataStore(RedisConnectionFactory connectionFactory, String key) {
Assert.notNull(connectionFactory, "'connectionFactory' must not be null.");
this.redisTemplate = new StringRedisTemplate(connectionFactory);
Assert.hasText(key, "'key' must not be empty.");
RedisOperations<String, String> redisTemplate = new StringRedisTemplate(connectionFactory);
BoundHashOperations<String, String, String> hashOperations = redisTemplate.boundHashOps(key);
this.properties = new RedisProperties(hashOperations);
}
/**
* Initializes the {@link RedisProperties} by provided {@link RedisConnectionFactory}
* and default hash key - {@link #KEY}.
*/
public RedisMetadataStore(RedisOperations<String, ?> operations) {
this(operations, KEY);
}
/**
* Initializes the {@link RedisProperties} by provided {@link RedisConnectionFactory} and key.
*/
public RedisMetadataStore(RedisOperations<String, ?> operations, String key) {
Assert.notNull(operations, "'operations' must not be null.");
Assert.hasText(key, "'key' must not be empty.");
BoundHashOperations<String, String, String> hashOperations = operations.boundHashOps(key);
this.properties = new RedisProperties(hashOperations);
}
/**
@@ -51,8 +89,7 @@ public class RedisMetadataStore implements MetadataStore {
public void put(String key, String value) {
Assert.notNull(key, "'key' must not be null.");
Assert.notNull(value, "'value' must not be null.");
BoundValueOperations<String, String> ops = this.redisTemplate.boundValueOps(key);
ops.set(value);
this.properties.put(key, value);
}
/**
@@ -62,16 +99,14 @@ public class RedisMetadataStore implements MetadataStore {
*/
public String get(String key) {
Assert.notNull(key, "'key' must not be null.");
BoundValueOperations<String, String> ops = this.redisTemplate.boundValueOps(key);
return ops.get();
return (String) this.properties.get(key);
}
@Override
public String remove(String key) {
Assert.notNull(key, "'key' must not be null.");
String value = this.get(key);
this.redisTemplate.delete(key);
return value;
return (String) this.properties.remove(key);
}
}

View File

@@ -26,6 +26,7 @@ import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
@@ -68,6 +69,9 @@ public class RedisChannelParserTests extends RedisAvailableTests{
public void testPubSubChannelUsage() throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("RedisChannelParserTests-context.xml", this.getClass());
SubscribableChannel redisChannel = context.getBean("redisChannel", SubscribableChannel.class);
this.awaitContainerSubscribed(TestUtils.getPropertyValue(redisChannel, "container", RedisMessageListenerContainer.class));
final Message<?> m = new GenericMessage<String>("Hello Redis");
final CountDownLatch latch = new CountDownLatch(1);
@@ -79,7 +83,7 @@ public class RedisChannelParserTests extends RedisAvailableTests{
});
redisChannel.send(m);
assertTrue(latch.await(2, TimeUnit.SECONDS));
assertTrue(latch.await(5, TimeUnit.SECONDS));
context.stop();
}

View File

@@ -15,7 +15,7 @@
message-converter="testConverter"
serializer="serializer"/>
<int-redis:inbound-channel-adapter channel="receiveChannel" topics="foo"/>
<int-redis:inbound-channel-adapter id="fooInbound" channel="receiveChannel" topics="foo"/>
<int:channel id="receiveChannel">
<int:queue/>

View File

@@ -25,14 +25,17 @@ import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.expression.Expression;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.redis.inbound.RedisInboundChannelAdapter;
import org.springframework.integration.redis.outbound.RedisPublishingMessageHandler;
import org.springframework.integration.redis.rules.RedisAvailable;
import org.springframework.integration.redis.rules.RedisAvailableTests;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.support.converter.SimpleMessageConverter;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.GenericMessage;
@@ -48,11 +51,14 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class RedisOutboundChannelAdapterParserTests extends RedisAvailableTests{
public class RedisOutboundChannelAdapterParserTests extends RedisAvailableTests {
@Autowired
private ApplicationContext context;
@Autowired
private RedisInboundChannelAdapter fooInbound;
@Test
@RedisAvailable
public void validateConfiguration() {
@@ -73,6 +79,7 @@ public class RedisOutboundChannelAdapterParserTests extends RedisAvailableTests{
@RedisAvailable
public void testOutboundChannelAdapterMessaging() throws Exception{
MessageChannel sendChannel = context.getBean("sendChannel", MessageChannel.class);
this.awaitContainerSubscribed(TestUtils.getPropertyValue(fooInbound, "container", RedisMessageListenerContainer.class));
sendChannel.send(new GenericMessage<String>("Hello Redis"));
QueueChannel receiveChannel = context.getBean("receiveChannel", QueueChannel.class);
Message<?> message = receiveChannel.receive(5000);
@@ -91,6 +98,7 @@ public class RedisOutboundChannelAdapterParserTests extends RedisAvailableTests{
@RedisAvailable
public void testOutboundChannelAdapterWithinChain() throws Exception{
MessageChannel sendChannel = context.getBean("redisOutboudChain", MessageChannel.class);
this.awaitContainerSubscribed(TestUtils.getPropertyValue(fooInbound, "container", RedisMessageListenerContainer.class));
sendChannel.send(new GenericMessage<String>("Hello Redis from chain"));
QueueChannel receiveChannel = context.getBean("receiveChannel", QueueChannel.class);
Message<?> message = receiveChannel.receive(5000);

View File

@@ -38,7 +38,7 @@ import org.springframework.integration.redis.rules.RedisAvailableTests;
* @author Artem Bilan
* @since 2.2
*/
public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvailableTests{
public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvailableTests {
@Test
@RedisAvailable
@@ -111,113 +111,86 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
@Test
@RedisAvailable
@SuppressWarnings("unchecked")
public void testZsetInboundConfiguration(){
public void testZsetInboundAdapter() throws InterruptedException {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
this.prepareZset(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("zset-inbound-adapter.xml", this.getClass());
//No Score test
SourcePollingChannelAdapter zsetAdapterNoScore =
context.getBean("zsetAdapterNoScore", SourcePollingChannelAdapter.class);
zsetAdapterNoScore.start();
QueueChannel redisChannel = context.getBean("redisChannel", QueueChannel.class);
Message<RedisZSet<Object>> message = (Message<RedisZSet<Object>>) redisChannel.receive(1000);
Message<RedisZSet<Object>> message = (Message<RedisZSet<Object>>) redisChannel.receive(2000);
assertNotNull(message);
assertEquals(13, message.getPayload().size());
//poll again, should get the same stuff
message = (Message<RedisZSet<Object>>) redisChannel.receive(1000);
message = (Message<RedisZSet<Object>>) redisChannel.receive(2000);
assertNotNull(message);
assertEquals(13, message.getPayload().size());
zsetAdapterNoScore.stop();
context.close();
}
@Test
@RedisAvailable
@SuppressWarnings("unchecked")
public void testZsetInboundConfigurationWithScoreRange(){
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
this.prepareZset(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("zset-inbound-adapter.xml", this.getClass());
//ScoreRange test
SourcePollingChannelAdapter zsetAdapterWithScoreRange =
context.getBean("zsetAdapterWithScoreRange", SourcePollingChannelAdapter.class);
zsetAdapterWithScoreRange.start();
QueueChannel redisChannel = context.getBean("redisChannel", QueueChannel.class);
Message<RedisZSet<Object>> message = (Message<RedisZSet<Object>>) redisChannel.receive(1000);
message = (Message<RedisZSet<Object>>) redisChannel.receive(2000);
assertNotNull(message);
assertEquals(11, message.getPayload().rangeByScore(18, 20).size());
//poll again, should get the same stuff
message = (Message<RedisZSet<Object>>) redisChannel.receive(1000);
message = (Message<RedisZSet<Object>>) redisChannel.receive(2000);
assertNotNull(message);
assertEquals(11, message.getPayload().rangeByScore(18, 20).size());
zsetAdapterWithScoreRange.stop();
context.close();
}
@Test
@RedisAvailable
@SuppressWarnings("unchecked")
public void testZsetInboundConfigurationWithSingleScore(){
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
this.prepareZset(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("zset-inbound-adapter.xml", this.getClass());
//SingleScore test
SourcePollingChannelAdapter zsetAdapterWithSingleScore =
context.getBean("zsetAdapterWithSingleScore", SourcePollingChannelAdapter.class);
zsetAdapterWithSingleScore.start();
QueueChannel redisChannel = context.getBean("redisChannel", QueueChannel.class);
Message<RedisZSet<Object>> message = (Message<RedisZSet<Object>>) redisChannel.receive(1000);
message = (Message<RedisZSet<Object>>) redisChannel.receive(2000);
assertNotNull(message);
assertEquals(2, message.getPayload().rangeByScore(18, 18).size());
//poll again, should get the same stuff
message = (Message<RedisZSet<Object>>) redisChannel.receive(1000);
message = (Message<RedisZSet<Object>>) redisChannel.receive(2000);
assertNotNull(message);
assertEquals(2, message.getPayload().rangeByScore(18, 18).size());
zsetAdapterWithSingleScore.stop();
context.close();
}
@Test
@RedisAvailable
@SuppressWarnings("unchecked")
public void testZsetInboundConfigurationWithSingleScoreAndSynchronization() throws Exception{
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
this.prepareZset(jcf);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("zset-inbound-adapter.xml", this.getClass());
//SingleScoreAndSynchronization test
SourcePollingChannelAdapter zsetAdapterWithSingleScoreAndSynchronization =
context.getBean("zsetAdapterWithSingleScoreAndSynchronization", SourcePollingChannelAdapter.class);
SourcePollingChannelAdapter zsetAdapterNoScore =
context.getBean("zsetAdapterNoScore", SourcePollingChannelAdapter.class);
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);
message = (Message<RedisZSet<Object>>) redisChannel.receive(2000);
assertNotNull(message);
assertEquals(13, message.getPayload().size());
zsetAdapterNoScore.stop();
// get only presidents for 18th century
zsetAdapterWithSingleScoreAndSynchronization.start();
message = (Message<RedisZSet<Object>>) otherRedisChannel.receive(1000);
message = (Message<RedisZSet<Object>>) otherRedisChannel.receive(2000);
assertNotNull(message);
assertEquals(2, message.getPayload().rangeByScore(18, 18).size());
// ... however other elements are still available 13-2=11
zsetAdapterNoScore.start();
message = (Message<RedisZSet<Object>>) redisChannel.receive(1000);
message = (Message<RedisZSet<Object>>) redisChannel.receive(2000);
assertNotNull(message);
int n = 0;
@@ -227,6 +200,7 @@ public class RedisStoreInboundChannelAdapterIntegrationTests extends RedisAvaila
assertTrue(n < 100);
zsetAdapterNoScore.stop();
zsetAdapterWithSingleScoreAndSynchronization.stop();
context.close();
}

View File

@@ -22,7 +22,7 @@ import static org.junit.Assert.fail;
import org.junit.Test;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.BoundHashOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.integration.redis.rules.RedisAvailable;
import org.springframework.integration.redis.rules.RedisAvailableTests;
@@ -37,7 +37,7 @@ public class RedisMetadataStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testGetNonExistingKeyValue(){
public void testGetNonExistingKeyValue() {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);
String retrievedValue = metadataStore.get("does-not-exist");
@@ -46,20 +46,20 @@ public class RedisMetadataStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testPersistKeyValue(){
public void testPersistKeyValue() {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf, "foo");
metadataStore.put("RedisMetadataStoreTests-Spring", "Integration");
StringRedisTemplate redisTemplate = new StringRedisTemplate(jcf);
BoundValueOperations<String, String> ops = redisTemplate.boundValueOps("RedisMetadataStoreTests-Spring");
BoundHashOperations<String,Object,Object> ops = redisTemplate.boundHashOps("foo");
assertEquals("Integration", ops.get());
assertEquals("Integration", ops.get("RedisMetadataStoreTests-Spring"));
}
@Test
@RedisAvailable
public void testGetValueFromMetadataStore(){
public void testGetValueFromMetadataStore() {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);
@@ -71,7 +71,7 @@ public class RedisMetadataStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testPersistEmptyStringToMetadataStore(){
public void testPersistEmptyStringToMetadataStore() {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);
@@ -83,7 +83,7 @@ public class RedisMetadataStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testPersistNullStringToMetadataStore(){
public void testPersistNullStringToMetadataStore() {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);
@@ -102,7 +102,7 @@ public class RedisMetadataStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testPersistWithEmptyKeyToMetadataStore(){
public void testPersistWithEmptyKeyToMetadataStore() {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);
metadataStore.put("", "PersistWithEmptyKey");
@@ -113,7 +113,7 @@ public class RedisMetadataStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testPersistWithNullKeyToMetadataStore(){
public void testPersistWithNullKeyToMetadataStore() {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);
@@ -130,7 +130,7 @@ public class RedisMetadataStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testGetValueWithNullKeyFromMetadataStore(){
public void testGetValueWithNullKeyFromMetadataStore() {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);
@@ -147,7 +147,7 @@ public class RedisMetadataStoreTests extends RedisAvailableTests {
@Test
@RedisAvailable
public void testRemoveFromMetadataStore(){
public void testRemoveFromMetadataStore() {
RedisConnectionFactory jcf = this.getConnectionFactoryForTest();
RedisMetadataStore metadataStore = new RedisMetadataStore(jcf);