INT-3131: Compatibility with SPR 4.0
Polishing tests to follow with new changes in the SPR 4.0 Polishing build.gradle to be compatible with SPR 4.0 Build passes with SPR 3.2.4 too JIRA: https://jira.springsource.org/browse/INT-3131
This commit is contained in:
committed by
Gary Russell
parent
693a1e17a0
commit
35e8929f1c
@@ -270,11 +270,7 @@ project('spring-integration-http') {
|
||||
compile project(":spring-integration-core")
|
||||
compile "org.springframework:spring-webmvc:$springVersion"
|
||||
|
||||
if (springVersionDefault.equalsIgnoreCase(springVersion)) {
|
||||
compile("javax.servlet:javax.servlet-api:3.0.1", provided)
|
||||
} else {
|
||||
compile("javax.servlet:servlet-api:2.5", provided)
|
||||
}
|
||||
compile("javax.servlet:javax.servlet-api:3.0.1", provided)
|
||||
|
||||
compile("commons-httpclient:commons-httpclient:3.1") { dep ->
|
||||
optional dep
|
||||
@@ -552,7 +548,7 @@ project('spring-integration-ws') {
|
||||
compile("javax.activation:activation:$javaxActivationVersion", optional)
|
||||
testCompile project(":spring-integration-test")
|
||||
testCompile "stax:stax-api:1.0.1"
|
||||
testCompile "xstream:xstream:1.2.2"
|
||||
testCompile 'com.thoughtworks.xstream:xstream:1.4.4'
|
||||
testCompile ("org.springframework.ws:spring-ws-support:$springWsVersion") {
|
||||
exclude group: 'org.springframework'
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -37,6 +37,7 @@ public class BeanFactoryChannelResolverTests {
|
||||
QueueChannel testChannel = new QueueChannel();
|
||||
testChannel.setBeanName("testChannel");
|
||||
context.getBeanFactory().registerSingleton("testChannel", testChannel);
|
||||
context.refresh();
|
||||
BeanFactoryChannelResolver resolver = new BeanFactoryChannelResolver(context);
|
||||
MessageChannel lookedUpChannel = resolver.resolveChannelName("testChannel");
|
||||
assertNotNull(testChannel);
|
||||
@@ -46,6 +47,7 @@ public class BeanFactoryChannelResolverTests {
|
||||
@Test(expected = ChannelResolutionException.class)
|
||||
public void lookupNonRegisteredChannel() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.refresh();
|
||||
BeanFactoryChannelResolver resolver = new BeanFactoryChannelResolver(context);
|
||||
resolver.resolveChannelName("noSuchChannel");
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.context.support.ConversionServiceFactoryBean;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
@@ -41,6 +42,7 @@ import org.springframework.integration.message.GenericMessage;
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Gunnar Hillert
|
||||
* @author Artem Bilan
|
||||
* @since 2.0
|
||||
*/
|
||||
public class DatatypeChannelTests {
|
||||
@@ -84,7 +86,7 @@ public class DatatypeChannelTests {
|
||||
});
|
||||
channel.setConversionService(conversionService);
|
||||
assertTrue(channel.send(new GenericMessage<Boolean>(Boolean.TRUE)));
|
||||
assertEquals(new Integer(1), channel.receive().getPayload());
|
||||
assertEquals(1, channel.receive().getPayload());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -103,9 +105,11 @@ public class DatatypeChannelTests {
|
||||
BeanDefinitionBuilder channelBuilder = BeanDefinitionBuilder.genericBeanDefinition(QueueChannel.class);
|
||||
channelBuilder.addPropertyValue("datatypes", "java.lang.Integer, java.util.Date");
|
||||
context.registerBeanDefinition("testChannel", channelBuilder.getBeanDefinition());
|
||||
context.refresh();
|
||||
|
||||
QueueChannel channel = context.getBean("testChannel", QueueChannel.class);
|
||||
assertTrue(channel.send(new GenericMessage<Boolean>(Boolean.TRUE)));
|
||||
assertEquals(new Integer(1), channel.receive().getPayload());
|
||||
assertEquals(1, channel.receive().getPayload());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -130,9 +134,11 @@ public class DatatypeChannelTests {
|
||||
channelBuilder.addPropertyValue("datatypes", "java.lang.Integer, java.util.Date");
|
||||
channelBuilder.addPropertyValue("conversionService", customConversionService);
|
||||
context.registerBeanDefinition("testChannel", channelBuilder.getBeanDefinition());
|
||||
context.refresh();
|
||||
|
||||
QueueChannel channel = context.getBean("testChannel", QueueChannel.class);
|
||||
assertTrue(channel.send(new GenericMessage<Boolean>(Boolean.TRUE)));
|
||||
assertEquals(new Integer(99), channel.receive().getPayload());
|
||||
assertEquals(99, channel.receive().getPayload());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
@@ -40,10 +41,11 @@ public class LocalChannelRegistryTests {
|
||||
|
||||
private LocalChannelRegistry registry = new LocalChannelRegistry();
|
||||
|
||||
private ApplicationContext context = new GenericApplicationContext();
|
||||
private AbstractApplicationContext context = new GenericApplicationContext();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
context.refresh();
|
||||
registry.setApplicationContext(context);
|
||||
}
|
||||
|
||||
|
||||
@@ -56,6 +56,8 @@ public class MessagingAnnotationPostProcessorTests {
|
||||
TestApplicationContext context = TestUtils.createTestApplicationContext();
|
||||
DirectChannel inputChannel = new DirectChannel();
|
||||
context.registerChannel("inputChannel", inputChannel);
|
||||
context.refresh();
|
||||
|
||||
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor();
|
||||
postProcessor.setBeanFactory(context.getBeanFactory());
|
||||
postProcessor.afterPropertiesSet();
|
||||
|
||||
@@ -40,11 +40,11 @@ import org.springframework.util.Assert;
|
||||
public class ConverterParserWithExistingConversionServiceTests {
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
|
||||
@Autowired
|
||||
@Qualifier(IntegrationContextUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME)
|
||||
private ConversionService conversionService;
|
||||
|
||||
|
||||
@Test
|
||||
public void testConversionServiceAvailability(){
|
||||
Assert.isTrue(applicationContext.getBean(IntegrationContextUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME).equals(conversionService));
|
||||
@@ -53,11 +53,12 @@ public class ConverterParserWithExistingConversionServiceTests {
|
||||
}
|
||||
@Test
|
||||
public void testParentConversionServiceAvailability(){
|
||||
ApplicationContext parentContext =
|
||||
ApplicationContext parentContext =
|
||||
new ClassPathXmlApplicationContext("ConverterParserWithExistingConversionServiceTests-parent.xml", ConverterParserWithExistingConversionServiceTests.class);
|
||||
GenericApplicationContext childContext = new GenericApplicationContext();
|
||||
childContext.setParent(parentContext);
|
||||
|
||||
childContext.refresh();
|
||||
|
||||
GenericConversionService conversionServiceParent = parentContext.getBean(IntegrationContextUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME,GenericConversionService.class);
|
||||
GenericConversionService conversionServiceChild = childContext.getBean(IntegrationContextUtils.INTEGRATION_CONVERSION_SERVICE_BEAN_NAME,GenericConversionService.class);
|
||||
Assert.isTrue(conversionServiceParent == conversionServiceChild); // validating that they are pointing to the same object
|
||||
@@ -67,7 +68,7 @@ public class ConverterParserWithExistingConversionServiceTests {
|
||||
Assert.isTrue(conversionServiceChild.canConvert(TestBean1.class, TestBean3.class));
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static class TestBean1 {
|
||||
|
||||
private String text;
|
||||
@@ -105,7 +106,7 @@ public class ConverterParserWithExistingConversionServiceTests {
|
||||
return this.text.replace("-TEST", "_TARGET_CHANNEL");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class TestConverter implements Converter<TestBean1, TestBean2> {
|
||||
|
||||
public TestBean2 convert(TestBean1 source) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<header-enricher>
|
||||
<header name="testHeader">
|
||||
<beans:ref local="testBean"/>
|
||||
<beans:ref bean="testBean"/>
|
||||
</header>
|
||||
</header-enricher>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -34,6 +34,7 @@ import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.MessageDeliveryException;
|
||||
@@ -49,6 +50,7 @@ import org.springframework.integration.test.util.TestUtils;
|
||||
/**
|
||||
* @author Iwein Fuld
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class MessagingGatewayTests {
|
||||
@@ -70,7 +72,10 @@ public class MessagingGatewayTests {
|
||||
this.messagingGateway = new MessagingGatewaySupport() {};
|
||||
this.messagingGateway.setRequestChannel(requestChannel);
|
||||
this.messagingGateway.setReplyChannel(replyChannel);
|
||||
this.messagingGateway.setBeanFactory(TestUtils.createTestApplicationContext());
|
||||
AbstractApplicationContext context = TestUtils.createTestApplicationContext();
|
||||
context.refresh();
|
||||
|
||||
this.messagingGateway.setBeanFactory(context);
|
||||
this.messagingGateway.afterPropertiesSet();
|
||||
this.messagingGateway.start();
|
||||
reset(allmocks);
|
||||
@@ -169,7 +174,7 @@ public class MessagingGatewayTests {
|
||||
@Ignore
|
||||
public void sendMessageAndReceiveObject() {
|
||||
// setup local mocks
|
||||
MessageHeaders messageHeadersMock = createMock(MessageHeaders.class);
|
||||
MessageHeaders messageHeadersMock = createMock(MessageHeaders.class);
|
||||
//set expectations
|
||||
expect(replyChannel.receive(0)).andReturn(messageMock);
|
||||
expect(messageMock.getHeaders()).andReturn(messageHeadersMock);
|
||||
@@ -211,7 +216,7 @@ public class MessagingGatewayTests {
|
||||
@Ignore
|
||||
public void sendMessageAndReceiveMessage() {
|
||||
// setup local mocks
|
||||
MessageHeaders messageHeadersMock = createMock(MessageHeaders.class);
|
||||
MessageHeaders messageHeadersMock = createMock(MessageHeaders.class);
|
||||
//set expectations
|
||||
expect(replyChannel.receive(0)).andReturn(messageMock);
|
||||
expect(messageMock.getHeaders()).andReturn(messageHeadersMock);
|
||||
@@ -234,12 +239,12 @@ public class MessagingGatewayTests {
|
||||
verify(allmocks);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// should fail but it doesn't now
|
||||
@Test(expected=MessagingException.class)
|
||||
public void validateErroMessageCanNotBeReplyMessage() {
|
||||
DirectChannel reqChannel = new DirectChannel();
|
||||
reqChannel.subscribe(new MessageHandler() {
|
||||
reqChannel.subscribe(new MessageHandler() {
|
||||
public void handleMessage(Message<?> message) throws MessagingException {
|
||||
throw new RuntimeException("ooops");
|
||||
}
|
||||
@@ -248,22 +253,21 @@ public class MessagingGatewayTests {
|
||||
ServiceActivatingHandler handler = new ServiceActivatingHandler(new MyErrorService());
|
||||
handler.afterPropertiesSet();
|
||||
errorChannel.subscribe(handler);
|
||||
this.messagingGateway = new MessagingGatewaySupport() {};
|
||||
|
||||
|
||||
this.messagingGateway.setRequestChannel(reqChannel);
|
||||
this.messagingGateway.setErrorChannel(errorChannel);
|
||||
this.messagingGateway.setBeanFactory(TestUtils.createTestApplicationContext());
|
||||
this.messagingGateway.setReplyChannel(null);
|
||||
this.messagingGateway.afterPropertiesSet();
|
||||
this.messagingGateway.start();
|
||||
|
||||
|
||||
this.messagingGateway.sendAndReceiveMessage("hello");
|
||||
}
|
||||
|
||||
|
||||
// should not fail but it does now
|
||||
@Test
|
||||
public void validateErrorChannelWithSuccessfulReply() {
|
||||
DirectChannel reqChannel = new DirectChannel();
|
||||
reqChannel.subscribe(new MessageHandler() {
|
||||
reqChannel.subscribe(new MessageHandler() {
|
||||
public void handleMessage(Message<?> message) throws MessagingException {
|
||||
throw new RuntimeException("ooops");
|
||||
}
|
||||
@@ -272,23 +276,22 @@ public class MessagingGatewayTests {
|
||||
ServiceActivatingHandler handler = new ServiceActivatingHandler(new MyOneWayErrorService());
|
||||
handler.afterPropertiesSet();
|
||||
errorChannel.subscribe(handler);
|
||||
this.messagingGateway = new MessagingGatewaySupport() {};
|
||||
|
||||
|
||||
this.messagingGateway.setRequestChannel(reqChannel);
|
||||
this.messagingGateway.setErrorChannel(errorChannel);
|
||||
this.messagingGateway.setBeanFactory(TestUtils.createTestApplicationContext());
|
||||
this.messagingGateway.setReplyChannel(null);
|
||||
this.messagingGateway.afterPropertiesSet();
|
||||
this.messagingGateway.start();
|
||||
|
||||
this.messagingGateway.send("hello");
|
||||
|
||||
this.messagingGateway.send("hello");
|
||||
}
|
||||
|
||||
|
||||
public static class MyErrorService {
|
||||
public Message<?> handleErrorMessage(Message<?> errorMessage){
|
||||
return errorMessage;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class MyOneWayErrorService {
|
||||
public void handleErrorMessage(Message<?> errorMessage){
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2011 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.
|
||||
@@ -24,6 +24,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
@@ -39,6 +40,7 @@ import org.springframework.util.CollectionUtils;
|
||||
* @author Mark Fisher
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gunnar Hillert
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class RouterTests {
|
||||
|
||||
@@ -48,7 +50,7 @@ public class RouterTests {
|
||||
@Override
|
||||
protected List<Object> getChannelKeys(Message<?> message) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
};
|
||||
Message<String> message = new GenericMessage<String>("test");
|
||||
router.handleMessage(message);
|
||||
@@ -118,6 +120,8 @@ public class RouterTests {
|
||||
QueueChannel testChannel = new QueueChannel();
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.getBeanFactory().registerSingleton("testChannel", testChannel);
|
||||
context.refresh();
|
||||
|
||||
router.setBeanFactory(context);
|
||||
router.handleMessage(new GenericMessage<String>("test"));
|
||||
Message<?> reply = testChannel.receive(0);
|
||||
@@ -132,38 +136,41 @@ public class RouterTests {
|
||||
return CollectionUtils.arrayToList(new String[] { "testChannel1,testChannel2" });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
QueueChannel testChannel1 = new QueueChannel();
|
||||
QueueChannel testChannel2 = new QueueChannel();
|
||||
|
||||
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
|
||||
context.getBeanFactory().registerSingleton("testChannel1", testChannel1);
|
||||
context.getBeanFactory().registerSingleton("testChannel2", testChannel2);
|
||||
|
||||
context.refresh();
|
||||
|
||||
router.setBeanFactory(context);
|
||||
router.handleMessage(new GenericMessage<String>("test"));
|
||||
|
||||
|
||||
Message<?> reply1 = testChannel1.receive(0);
|
||||
assertEquals("test", reply1.getPayload());
|
||||
|
||||
|
||||
Message<?> reply2 = testChannel2.receive(0);
|
||||
assertEquals("test", reply2.getPayload());
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = MessagingException.class)
|
||||
public void channelResolutionIsRequiredByDefault() {
|
||||
|
||||
|
||||
AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() {
|
||||
@SuppressWarnings("unchecked")
|
||||
protected List<Object> getChannelKeys(Message<?> message) {
|
||||
return CollectionUtils.arrayToList(new String[] { "testChannelDoesNotExist", "testChannel" });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
QueueChannel testChannel = new QueueChannel();
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.getBeanFactory().registerSingleton("testChannel", testChannel);
|
||||
context.refresh();
|
||||
|
||||
router.setBeanFactory(context);
|
||||
router.handleMessage(new GenericMessage<String>("test"));
|
||||
|
||||
@@ -171,26 +178,28 @@ public class RouterTests {
|
||||
|
||||
@Test
|
||||
public void unresolvableChannelIdentifierInListAreIgnoredWhenResolutionRequiredIsFalse() {
|
||||
|
||||
|
||||
AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() {
|
||||
@SuppressWarnings("unchecked")
|
||||
protected List<Object> getChannelKeys(Message<?> message) {
|
||||
return CollectionUtils.arrayToList(new String[] { "testChannelDoesNotExist", "testChannel" });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
router.setResolutionRequired(false);
|
||||
|
||||
|
||||
QueueChannel testChannel = new QueueChannel();
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.getBeanFactory().registerSingleton("testChannel", testChannel);
|
||||
context.refresh();
|
||||
|
||||
router.setBeanFactory(context);
|
||||
router.handleMessage(new GenericMessage<String>("test"));
|
||||
Message<?> reply = testChannel.receive(0);
|
||||
assertEquals("test", reply.getPayload());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void beanFactoryWithRouterAndChannelPrefix() {
|
||||
AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() {
|
||||
@@ -199,12 +208,14 @@ public class RouterTests {
|
||||
return CollectionUtils.arrayToList(new String[] { "MyChannel" });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
router.setPrefix("testing_");
|
||||
|
||||
|
||||
QueueChannel testChannel = new QueueChannel();
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.getBeanFactory().registerSingleton("testing_MyChannel", testChannel);
|
||||
context.refresh();
|
||||
|
||||
router.setBeanFactory(context);
|
||||
router.handleMessage(new GenericMessage<String>("test"));
|
||||
Message<?> reply = testChannel.receive(0);
|
||||
@@ -220,17 +231,19 @@ public class RouterTests {
|
||||
return CollectionUtils.arrayToList(new String[] { "testing_MyChannel" });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
router.setPrefix("testing_");
|
||||
|
||||
|
||||
QueueChannel testChannel = new QueueChannel();
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.getBeanFactory().registerSingleton("testing_MyChannel", testChannel);
|
||||
context.refresh();
|
||||
|
||||
router.setBeanFactory(context);
|
||||
router.handleMessage(new GenericMessage<String>("test"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void beanFactoryWithRouterAndChannelSuffix() {
|
||||
AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() {
|
||||
@@ -239,12 +252,14 @@ public class RouterTests {
|
||||
return CollectionUtils.arrayToList(new String[] { "MyChannel" });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
router.setSuffix("_withSuffix");
|
||||
|
||||
|
||||
QueueChannel testChannel = new QueueChannel();
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.getBeanFactory().registerSingleton("MyChannel_withSuffix", testChannel);
|
||||
context.refresh();
|
||||
|
||||
router.setBeanFactory(context);
|
||||
router.handleMessage(new GenericMessage<String>("test"));
|
||||
Message<?> reply = testChannel.receive(0);
|
||||
@@ -259,132 +274,137 @@ public class RouterTests {
|
||||
return CollectionUtils.arrayToList(new String[] { "MyChannel_withSuffix" });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
router.setSuffix("_withSuffix");
|
||||
|
||||
|
||||
QueueChannel testChannel = new QueueChannel();
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.getBeanFactory().registerSingleton("MyChannel_withSuffix", testChannel);
|
||||
context.refresh();
|
||||
|
||||
router.setBeanFactory(context);
|
||||
router.handleMessage(new GenericMessage<String>("test"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void beanFactoryWithRouterAndChannelIdentifiersInListWithinAList() {
|
||||
AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() {
|
||||
@SuppressWarnings("unchecked")
|
||||
protected List<Object> getChannelKeys(Message<?> message) {
|
||||
|
||||
|
||||
List<String> channelNames1 = CollectionUtils.arrayToList(new String[] { "channel1" });
|
||||
List<String> channelNames2 = CollectionUtils.arrayToList(new String[] { "channel2" });
|
||||
|
||||
|
||||
List<Object> listWithListOfChannelNames = new ArrayList<Object>();
|
||||
|
||||
|
||||
listWithListOfChannelNames.add(channelNames1);
|
||||
listWithListOfChannelNames.add(channelNames2);
|
||||
|
||||
|
||||
return listWithListOfChannelNames;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
QueueChannel testChannel1 = new QueueChannel();
|
||||
QueueChannel testChannel2 = new QueueChannel();
|
||||
|
||||
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
|
||||
context.getBeanFactory().registerSingleton("channel1", testChannel1);
|
||||
context.getBeanFactory().registerSingleton("channel2", testChannel2);
|
||||
context.refresh();
|
||||
|
||||
router.setBeanFactory(context);
|
||||
router.handleMessage(new GenericMessage<String>("test"));
|
||||
|
||||
|
||||
Message<?> reply1 = testChannel1.receive(0);
|
||||
assertEquals("test", reply1.getPayload());
|
||||
|
||||
|
||||
Message<?> reply2 = testChannel2.receive(0);
|
||||
assertEquals("test", reply2.getPayload());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void beanFactoryWithRouterAndChannelIdentifiersInMessageChannelArrayWithinAList() {
|
||||
|
||||
|
||||
final QueueChannel testChannel1 = new QueueChannel();
|
||||
final QueueChannel testChannel2 = new QueueChannel();
|
||||
|
||||
|
||||
AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() {
|
||||
|
||||
protected List<Object> getChannelKeys(Message<?> message) {
|
||||
|
||||
|
||||
MessageChannel[] channelNames1 = new MessageChannel[] { testChannel1 };
|
||||
MessageChannel[] channelNames2 = new MessageChannel[] { testChannel2 };
|
||||
|
||||
|
||||
List<Object> listWithListOfChannelNames = new ArrayList<Object>();
|
||||
|
||||
|
||||
listWithListOfChannelNames.add(channelNames1);
|
||||
listWithListOfChannelNames.add(channelNames2);
|
||||
|
||||
|
||||
return listWithListOfChannelNames;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
|
||||
context.getBeanFactory().registerSingleton("channel1", testChannel1);
|
||||
context.getBeanFactory().registerSingleton("channel2", testChannel2);
|
||||
context.refresh();
|
||||
|
||||
router.setBeanFactory(context);
|
||||
router.handleMessage(new GenericMessage<String>("test"));
|
||||
|
||||
|
||||
Message<?> reply1 = testChannel1.receive(0);
|
||||
assertEquals("test", reply1.getPayload());
|
||||
|
||||
|
||||
Message<?> reply2 = testChannel2.receive(0);
|
||||
assertEquals("test", reply2.getPayload());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void beanFactoryWithRouterAndRetrieveChannelIdentifiersUsingDefaultConversionService() {
|
||||
|
||||
|
||||
final QueueChannel testChannel1 = new QueueChannel();
|
||||
final QueueChannel testChannel2 = new QueueChannel();
|
||||
|
||||
|
||||
AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() {
|
||||
@SuppressWarnings("unchecked")
|
||||
protected List<Object> getChannelKeys(Message<?> message) {
|
||||
return CollectionUtils.arrayToList(new Integer[] { 100, 200 });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
|
||||
context.getBeanFactory().registerSingleton("100", testChannel1);
|
||||
context.getBeanFactory().registerSingleton("200", testChannel2);
|
||||
context.refresh();
|
||||
|
||||
router.setBeanFactory(context);
|
||||
router.handleMessage(new GenericMessage<String>("test"));
|
||||
|
||||
|
||||
Message<?> reply1 = testChannel1.receive(0);
|
||||
assertEquals("test", reply1.getPayload());
|
||||
|
||||
|
||||
Message<?> reply2 = testChannel2.receive(0);
|
||||
assertEquals("test", reply2.getPayload());
|
||||
}
|
||||
|
||||
|
||||
private class CustomObjectWithChannelName {
|
||||
|
||||
|
||||
String channel = "channel1";
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String getChannel() {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = MessagingException.class)
|
||||
public void beanFactoryWithRouterAndRetrieveChannelIdentifierUsingDefaultConversionServiceFailing() {
|
||||
|
||||
|
||||
final QueueChannel testChannel1 = new QueueChannel();
|
||||
|
||||
AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() {
|
||||
@@ -393,14 +413,15 @@ public class RouterTests {
|
||||
return CollectionUtils.arrayToList(new CustomObjectWithChannelName[] { new CustomObjectWithChannelName() });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
|
||||
context.getBeanFactory().registerSingleton("channel1", testChannel1);
|
||||
context.refresh();
|
||||
|
||||
router.setBeanFactory(context);
|
||||
router.handleMessage(new GenericMessage<String>("test"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ public class SOLingerTests {
|
||||
TestingUtilities.waitListening(inCF, null);
|
||||
try {
|
||||
Socket socket = SocketFactory.getDefault().createSocket("localhost", port);
|
||||
socket.setSoTimeout(10000);
|
||||
String test = "Test\r\n";
|
||||
socket.getOutputStream().write(test.getBytes());
|
||||
byte[] buff = new byte[test.length() + 5];
|
||||
|
||||
Reference in New Issue
Block a user