Merge remote branch 'upstream/2.1.x' into 2.1.x

This commit is contained in:
Oleg Zhurakousky
2012-07-06 14:14:01 -04:00
12 changed files with 235 additions and 38 deletions

View File

@@ -152,7 +152,7 @@ project('spring-integration-amqp') {
importTemplate += [
'org.apache.commons.logging;version="[1.1.1, 2.0.0)"',
'org.apache.commons.lang.*;version="[2.5.0, 3.0.0)"',
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.context;version="[3.0.5, 4.0.0)"',
'org.springframework.core.*;version="[3.0.5, 4.0.0)"',
@@ -200,7 +200,7 @@ project('spring-integration-event') {
bundlor {
bundleSymbolicName = 'org.springframework.integration.event'
importTemplate += [
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.context.*;version="[3.0.5, 4.0.0)"',
'org.springframework.expression.*;version="[3.0.5, 4.0.0)"',
@@ -227,7 +227,7 @@ project('spring-integration-feed') {
importTemplate += [
'org.apache.commons.logging;version="[1.1.1, 2.0.0)"',
'org.apache.commons.lang.*;version="[2.5.0, 3.0.0)"',
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.scheduling.*;version="[3.0.5, 4.0.0)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.context;version="[3.0.5, 4.0.0)"',
@@ -251,7 +251,7 @@ project('spring-integration-file') {
bundleSymbolicName = 'org.springframework.integration.file'
importTemplate += [
'org.apache.commons.logging;version="[1.1.1, 2.0.0)"',
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.expression.*;version="[3.0.5, 4.0.0)"',
'org.springframework.context;version="[3.0.5, 4.0.0)"',
@@ -279,7 +279,7 @@ project('spring-integration-ftp') {
importTemplate += [
'org.apache.commons.logging;version="[1.1.1, 2.0.0)"',
'org.apache.commons.net.*;version="[2.0.0, 3.1.0)"',
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.context;version="[3.0.5, 4.0.0)"',
'org.springframework.core.*;version="[3.0.5, 4.0.0)"',
@@ -312,7 +312,7 @@ project('spring-integration-gemfire') {
bundleSymbolicName = 'org.springframework.integration.gemfire'
importTemplate += [
'org.apache.commons.logging;version="[1.1.1, 2.0.0)"',
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.context;version="[3.0.5, 4.0.0)"',
'org.springframework.core.*;version="[3.0.5, 4.0.0)"',
@@ -339,7 +339,7 @@ project('spring-integration-groovy') {
bundleSymbolicName = 'org.springframework.integration.groovy'
importTemplate += [
'org.apache.commons.logging;version="[1.1.1, 2.0.0)"',
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.*;version="[3.0.5, 4.0.0)"',
'groovy.*;version="[1.7.3, 2.0.0)"',
'org.w3c.dom.*;version="0"'
@@ -367,7 +367,7 @@ project('spring-integration-http') {
bundlor {
bundleSymbolicName = 'org.springframework.integration.http'
importTemplate += [
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.context.*;version="[3.0.5, 4.0.0)"',
'org.springframework.core.*;version="[3.0.5, 4.0.0)"',
@@ -397,7 +397,7 @@ project('spring-integration-ip') {
bundleSymbolicName = 'org.springframework.integration.ip'
importTemplate += [
'org.apache.commons.logging;version="[1.1.1, 2.0.0)"',
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.context;version="[3.0.5, 4.0.0)"',
'org.springframework.core.*;version="[3.0.5, 4.0.0)"',
@@ -427,7 +427,7 @@ project('spring-integration-jdbc') {
bundlor {
bundleSymbolicName = 'org.springframework.integration.jdbc'
importTemplate += [
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.*;version="[3.0.5, 4.0.0)"',
'org.apache.commons.logging;version="[1.1.1, 2.0.0)"',
'org.aopalliance.*;version="[1.0.0, 2.0.0)"',
@@ -457,7 +457,7 @@ project('spring-integration-jms') {
bundlor {
bundleSymbolicName = 'org.springframework.integration.jms'
importTemplate += [
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.expression.*;version="[3.0.5, 4.0.0)"',
'org.springframework.context;version="[3.0.5, 4.0.0)"',
@@ -484,7 +484,7 @@ project('spring-integration-jmx') {
bundlor {
bundleSymbolicName = 'org.springframework.integration.jmx'
importTemplate += [
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.*;version="[3.0.5, 4.0.0)"',
'org.apache.commons.logging;version="[1.1.1, 2.0.0)"',
'org.aopalliance.*;version="[1.0.0, 2.0.0)"',
@@ -506,7 +506,7 @@ project('spring-integration-mail') {
bundlor {
bundleSymbolicName = 'org.springframework.integration.mail'
importTemplate += [
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.expression.*;version="[3.0.5, 4.0.0)"',
'org.springframework.scheduling.*;version="[3.0.5, 4.0.0)"',
@@ -545,7 +545,7 @@ project('spring-integration-mongodb') {
bundleSymbolicName = 'org.springframework.integration.mongodb'
importTemplate += [
'org.apache.commons.logging;version="[1.1.1, 2.0.0)"',
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.context;version="[3.0.5, 4.0.0)"',
'org.springframework.core.*;version="[3.0.5, 4.0.0)"',
@@ -581,7 +581,7 @@ project('spring-integration-redis') {
bundleSymbolicName = 'org.springframework.integration.redis'
importTemplate += [
'org.apache.commons.logging;version="[1.1.1, 2.0.0)"',
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.context;version="[3.0.5, 4.0.0)"',
'org.springframework.core.*;version="[3.0.5, 4.0.0)"',
@@ -605,7 +605,7 @@ project('spring-integration-rmi') {
bundlor {
bundleSymbolicName = 'org.springframework.integration.rmi'
importTemplate += [
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.context;version="[3.0.5, 4.0.0)"',
'org.springframework.core.*;version="[3.0.5, 4.0.0)"',
@@ -633,7 +633,7 @@ project('spring-integration-scripting') {
bundleSymbolicName = 'org.springframework.integration.scripting'
importTemplate += [
'org.apache.commons.logging;version="[1.1.1, 2.0.0)"',
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.*;version="[3.0.5, 4.0.0)"',
'org.w3c.dom.*;version="0"',
'javax.script.*;version="0"'
@@ -663,7 +663,7 @@ project('spring-integration-security') {
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.core;version="[3.0.5, 4.0.0)"',
'org.springframework.util.*;version="[3.0.5, 4.0.0)"',
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.security.*;version="[3.0.3, 4.0.0)"',
'org.w3c.dom.*;version="0"'
]
@@ -685,7 +685,7 @@ project('spring-integration-sftp') {
bundleSymbolicName = 'org.springframework.integration.sftp'
importTemplate += [
'org.apache.commons.logging;version="[1.1.1, 2.0.0)"',
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.context;version="[3.0.5, 4.0.0)"',
'org.springframework.core.*;version="[3.0.5, 4.0.0)"',
@@ -710,7 +710,7 @@ project('spring-integration-stream') {
'org.apache.commons.logging;version="[1.1.1, 2.0.0)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.util;version="[3.0.5, 4.0.0)"',
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.w3c.dom.*;version="0"'
]
}
@@ -730,7 +730,7 @@ project('spring-integration-test') {
importTemplate += [
'org.apache.tools.ant.*;version="[1.7.0, 2.0.0)"',
'org.springframework.*;version="[3.0.5, 4.0.0)"',
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'junit.framework.*;version="[4.6.0, 4.7.0)"',
'org.junit.*;version="[4.6.0, 4.7.0)"',
'org.mockito.*;version="[1.6.0, 2.0.0)"',
@@ -762,7 +762,7 @@ project('spring-integration-twitter') {
importTemplate += [
'org.aopalliance.*;version="[1.0.0, 2.0.0)"',
'org.apache.commons.logging;version="[1.1.1, 2.0.0)"',
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.scheduling.*;version="[3.0.5, 4.0.0)"',
'org.springframework.aop.*;version="[3.0.5, 4.0.0)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
@@ -803,7 +803,7 @@ project('spring-integration-ws') {
bundlor {
bundleSymbolicName = 'org.springframework.integration.ws'
importTemplate += [
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.core.convert;version="[3.0.5, 4.0.0)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.context.*;version="[3.0.5, 4.0.0)"',
@@ -841,7 +841,7 @@ project('spring-integration-xml') {
bundlor {
bundleSymbolicName = 'org.springframework.integration.xml'
importTemplate += [
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.core.*;version="[3.0.5, 4.0.0)"',
'org.springframework.context.expression.*;version="[3.0.5, 4.0.0)"',
@@ -872,7 +872,7 @@ project('spring-integration-xmpp') {
bundleSymbolicName = 'org.springframework.integration.xmpp'
importTemplate += [
'org.apache.commons.logging;version="[1.1.1, 2.0.0)"',
'org.springframework.integration.*;version="[2.1.2, 2.1.3)"',
'org.springframework.integration.*;version="[2.1.3, 2.1.4)"',
'org.springframework.beans.*;version="[3.0.5, 4.0.0)"',
'org.springframework.context;version="[3.0.5, 4.0.0)"',
'org.springframework.core.*;version="[3.0.5, 4.0.0)"',

View File

@@ -1 +1 @@
version=2.1.3.BUILD-SNAPSHOT
version=2.1.4.BUILD-SNAPSHOT

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2012 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,6 +16,10 @@
package org.springframework.integration.aggregator;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.SpelParserConfiguration;
@@ -28,11 +32,13 @@ import org.springframework.util.Assert;
* {@link CorrelationStrategy} implementation that evaluates an expression.
*
* @author Dave Syer
* @author Oleg Zhurakousky
*/
public class ExpressionEvaluatingCorrelationStrategy implements CorrelationStrategy {
public class ExpressionEvaluatingCorrelationStrategy implements CorrelationStrategy, BeanFactoryAware, InitializingBean{
private static final ExpressionParser expressionParser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
private volatile BeanFactory beanFactory;
private final ExpressionEvaluatingMessageProcessor<Object> processor;
@@ -47,9 +53,18 @@ public class ExpressionEvaluatingCorrelationStrategy implements CorrelationStrat
this.processor = new ExpressionEvaluatingMessageProcessor<Object>(expression, Object.class);
}
public Object getCorrelationKey(Message<?> message) {
return processor.processMessage(message);
}
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
}
public void afterPropertiesSet() throws Exception {
if (this.beanFactory != null){
this.processor.setBeanFactory(this.beanFactory);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2012 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,10 +27,13 @@ import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.support.ConversionServiceFactory;
import org.springframework.expression.TypeConverter;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.history.MessageHistory;
/**
* @author Dave Syer
* @author Oleg Zhurakousky
* @author Gary Russell
*/
public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware {
@@ -98,6 +101,18 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware
if ((targetType.getType() == Void.class || targetType.getType() == Void.TYPE) && value == null) {
return null;
}
/*
* INT-2630 Spring 3.1 now converts ALL arguments; we know we don't need to convert MessageHeaders
* or MessageHistory; the MapToMap converter requires a no-arg constructor.
*/
if (sourceType != null && sourceType.getType() == MessageHeaders.class
&& targetType.getType() == MessageHeaders.class) {
return value;
}
if (sourceType != null && sourceType.getType() == MessageHistory.class
&& targetType.getType() == MessageHistory.class) {
return value;
}
if (conversionService.canConvert(sourceType, targetType)) {
return conversionService.convert(value, sourceType, targetType);
}
@@ -109,7 +124,7 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware
if (editor != null) { // INT-1441
editor.setValue(value);
String text = editor.getAsText();
if (String.class.isAssignableFrom(targetType.getClass())) {
if (String.class.isAssignableFrom(targetType.getClass())) {
return text;
}
return convertValue(text, TypeDescriptor.valueOf(String.class), targetType);

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2002-2010 the original author or authors.
*
* Copyright 2002-2012 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. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
@@ -14,17 +14,25 @@
package org.springframework.integration.aggregator;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.SpelParserConfiguration;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.support.MessageBuilder;
/**
* @author Alex Peters
* @author Oleg Zhurakousky
*/
public class ExpressionEvaluatingCorrelationStrategyTests {
@@ -51,4 +59,22 @@ public class ExpressionEvaluatingCorrelationStrategyTests {
assertThat(correlationKey, is(String.class));
assertThat((String) correlationKey, is("b"));
}
@Test
public void testCorrelationStrategyWithAtBeanExpression() throws Exception {
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("expression-evaluating-correlation-with-bf.xml", this.getClass());
MessageChannel inputChannel = context.getBean("inputChannel", MessageChannel.class);
QueueChannel outputChannel = context.getBean("outputChannel", QueueChannel.class);
Message<?> message = MessageBuilder.withPayload("foo").setSequenceNumber(1).setSequenceSize(1).build();
inputChannel.send(message);
Message<?> reply = outputChannel.receive(0);
assertNotNull(reply);
}
public static class CustomCorrelator {
public Object correlate(Object o){
return o;
}
}
}

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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"
correlation-strategy-expression="@correlator.correlate(payload)"/>
<int:channel id="outputChannel">
<int:queue/>
</int:channel>
<bean id="correlator"
class="org.springframework.integration.aggregator.ExpressionEvaluatingCorrelationStrategyTests.CustomCorrelator"/>
</beans>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<int:message-history />
<int:channel id="input" />
<int:transformer input-channel="input" output-channel="output">
<bean class="org.springframework.integration.transformer.MessageHistoryParameterTests$MessageHistoryAwareTransformer"/>
</int:transformer>
<int:channel id="output">
<int:queue />
</int:channel>
</beans>

View File

@@ -0,0 +1,66 @@
/*
* Copyright 2002-2012 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.transformer;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Headers;
import org.springframework.integration.annotation.Payload;
import org.springframework.integration.annotation.Transformer;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.message.GenericMessage;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Gary Russell
* @since 2.2
*
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class MessageHistoryParameterTests {
@Autowired
private MessageChannel input;
@Autowired
private PollableChannel output;
@Test
public void test() {
input.send(new GenericMessage<String>("foo"));
assertNotNull(output.receive(10000));
}
public static class MessageHistoryAwareTransformer {
@Transformer
public Object transform(@Headers MessageHeaders headers,
@Header("history") MessageHistory history, @Payload Object payload) {
return payload;
}
}
}

View File

@@ -1,9 +1,10 @@
/**
*
*
*/
package org.springframework.integration.util;
import static junit.framework.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import java.util.ArrayList;
import java.util.Arrays;
@@ -13,6 +14,11 @@ import java.util.List;
import org.junit.Test;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.message.GenericMessage;
/**
* @author Oleg Zhurakousky
@@ -25,7 +31,7 @@ public class BeanFactoryTypeConverterTests {
public void testEmptyCollectionConversion(){
BeanFactoryTypeConverter typeConverter = new BeanFactoryTypeConverter();
List<String> sourceObject = new ArrayList<String>();
ArrayList<BeanFactoryTypeConverterTests> convertedCollection =
ArrayList<BeanFactoryTypeConverterTests> convertedCollection =
(ArrayList<BeanFactoryTypeConverterTests>) typeConverter.convertValue(sourceObject, TypeDescriptor.forObject(sourceObject), TypeDescriptor.forObject(new ArrayList<BeanFactoryTypeConverterTests>()));
assertEquals(sourceObject, convertedCollection);
}
@@ -47,4 +53,29 @@ public class BeanFactoryTypeConverterTests {
assertEquals(Arrays.asList(1234), converted);
}
@Test
public void testMessageHeadersNotConverted() {
BeanFactoryTypeConverter typeConverter = new BeanFactoryTypeConverter();
typeConverter.setBeanFactory(new DefaultListableBeanFactory());
MessageHeaders headers = new GenericMessage<String>("foo").getHeaders();
assertSame(headers, typeConverter.convertValue(headers, TypeDescriptor.valueOf(MessageHeaders.class), TypeDescriptor.valueOf(MessageHeaders.class)));
}
@Test
public void testMessageHistoryNotConverted() {
BeanFactoryTypeConverter typeConverter = new BeanFactoryTypeConverter();
typeConverter.setBeanFactory(new DefaultListableBeanFactory());
Message<String> message = new GenericMessage<String>("foo");
message = MessageHistory.write(message, new NamedComponent(){
public String getComponentName() {
return "bar";
}
public String getComponentType() {
return "baz";
}
});
MessageHistory history = MessageHistory.read(message);
assertSame(history, typeConverter.convertValue(history, TypeDescriptor.valueOf(MessageHeaders.class), TypeDescriptor.valueOf(MessageHeaders.class)));
}
}

View File

@@ -0,0 +1 @@
Initial File Content:String content:byte[] content:File content

File diff suppressed because one or more lines are too long

View File

@@ -74,7 +74,11 @@ public class TcpNioConnection extends AbstractTcpConnection {
public TcpNioConnection(SocketChannel socketChannel, boolean server, boolean lookupHost) throws Exception {
super(socketChannel.socket(), server, lookupHost);
this.socketChannel = socketChannel;
this.pipedInputStream = new PipedInputStream();
int receiveBufferSize = socketChannel.socket().getReceiveBufferSize();
if (receiveBufferSize <= 0) {
receiveBufferSize = this.maxMessageSize;
}
this.pipedInputStream = new PipedInputStream(receiveBufferSize);
this.pipedOutputStream = new PipedOutputStream(this.pipedInputStream);
this.channelOutputStream = new ChannelOutputStream();
}