Removed the name parameter from channelRegistry.registerChannel() since the MessageChannel interface already defines getName(). Removed the setName() method from the MessageChannel interface. Removed the 'error-channel' attribute from the <message-bus/> element and the setErrorChannel() method from MessageBus. The "errorChannel" name is now sufficient for configuration.
This commit is contained in:
@@ -37,8 +37,9 @@ public class PublisherAnnotationAdvisorTests {
|
||||
@Test
|
||||
public void testPublisherAnnotation() {
|
||||
final QueueChannel channel = new QueueChannel();
|
||||
channel.setBeanName("testChannel");
|
||||
ChannelRegistry channelRegistry = new DefaultChannelRegistry();
|
||||
channelRegistry.registerChannel("testChannel", channel);
|
||||
channelRegistry.registerChannel(channel);
|
||||
PublisherAnnotationAdvisor advisor = new PublisherAnnotationAdvisor(channelRegistry);
|
||||
TestService proxy = (TestService) this.createProxy(new TestServiceImpl("hello world"), advisor);
|
||||
proxy.publisherTest();
|
||||
@@ -50,8 +51,9 @@ public class PublisherAnnotationAdvisorTests {
|
||||
@Test
|
||||
public void testNoPublisherAnnotation() {
|
||||
final QueueChannel channel = new QueueChannel();
|
||||
channel.setBeanName("testChannel");
|
||||
ChannelRegistry channelRegistry = new DefaultChannelRegistry();
|
||||
channelRegistry.registerChannel("testChannel", channel);
|
||||
channelRegistry.registerChannel(channel);
|
||||
PublisherAnnotationAdvisor advisor = new PublisherAnnotationAdvisor(channelRegistry);
|
||||
TestService proxy = (TestService) this.createProxy(new TestServiceImpl("hello world"), advisor);
|
||||
proxy.noPublisherTest();
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.channel.ChannelRegistry;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.channel.PollableChannelAdapter;
|
||||
import org.springframework.integration.channel.PublishSubscribeChannel;
|
||||
@@ -53,11 +53,13 @@ public class DefaultMessageBusTests {
|
||||
DefaultMessageBus bus = new DefaultMessageBus();
|
||||
QueueChannel sourceChannel = new QueueChannel();
|
||||
QueueChannel targetChannel = new QueueChannel();
|
||||
bus.registerChannel("sourceChannel", sourceChannel);
|
||||
sourceChannel.setBeanName("sourceChannel");
|
||||
targetChannel.setBeanName("targetChannel");
|
||||
bus.registerChannel(sourceChannel);
|
||||
Message<String> message = MessageBuilder.fromPayload("test")
|
||||
.setReturnAddress("targetChannel").build();
|
||||
sourceChannel.send(message);
|
||||
bus.registerChannel("targetChannel", targetChannel);
|
||||
bus.registerChannel(targetChannel);
|
||||
MessageHandler handler = new MessageHandler() {
|
||||
public Message<?> handle(Message<?> message) {
|
||||
return message;
|
||||
@@ -78,11 +80,13 @@ public class DefaultMessageBusTests {
|
||||
MessageBus bus = new DefaultMessageBus();
|
||||
QueueChannel sourceChannel = new QueueChannel();
|
||||
QueueChannel targetChannel = new QueueChannel();
|
||||
bus.registerChannel("sourceChannel", sourceChannel);
|
||||
sourceChannel.setBeanName("sourceChannel");
|
||||
targetChannel.setBeanName("targetChannel");
|
||||
bus.registerChannel(sourceChannel);
|
||||
Message<String> message = MessageBuilder.fromPayload("test")
|
||||
.setReturnAddress("targetChannel").build();
|
||||
sourceChannel.send(message);
|
||||
bus.registerChannel("targetChannel", targetChannel);
|
||||
bus.registerChannel(targetChannel);
|
||||
MessageHandler handler = new MessageHandler() {
|
||||
public Message<?> handle(Message<?> message) {
|
||||
return message;
|
||||
@@ -102,10 +106,12 @@ public class DefaultMessageBusTests {
|
||||
public void testChannelsWithoutHandlers() {
|
||||
MessageBus bus = new DefaultMessageBus();
|
||||
QueueChannel sourceChannel = new QueueChannel();
|
||||
sourceChannel.setBeanName("sourceChannel");
|
||||
sourceChannel.send(new StringMessage("test"));
|
||||
QueueChannel targetChannel = new QueueChannel();
|
||||
bus.registerChannel("sourceChannel", sourceChannel);
|
||||
bus.registerChannel("targetChannel", targetChannel);
|
||||
targetChannel.setBeanName("targetChannel");
|
||||
bus.registerChannel(sourceChannel);
|
||||
bus.registerChannel(targetChannel);
|
||||
bus.start();
|
||||
Message<?> result = targetChannel.receive(100);
|
||||
assertNull(result);
|
||||
@@ -143,9 +149,12 @@ public class DefaultMessageBusTests {
|
||||
}
|
||||
};
|
||||
MessageBus bus = new DefaultMessageBus();
|
||||
bus.registerChannel("input", inputChannel);
|
||||
bus.registerChannel("output1", outputChannel1);
|
||||
bus.registerChannel("output2", outputChannel2);
|
||||
inputChannel.setBeanName("input");
|
||||
outputChannel1.setBeanName("output1");
|
||||
outputChannel2.setBeanName("output2");
|
||||
bus.registerChannel(inputChannel);
|
||||
bus.registerChannel(outputChannel1);
|
||||
bus.registerChannel(outputChannel2);
|
||||
DefaultEndpoint<MessageHandler> endpoint1 = new DefaultEndpoint<MessageHandler>(handler1);
|
||||
endpoint1.setBeanName("testEndpoint1");
|
||||
endpoint1.setSource(inputChannel);
|
||||
@@ -185,9 +194,12 @@ public class DefaultMessageBusTests {
|
||||
}
|
||||
};
|
||||
MessageBus bus = new DefaultMessageBus();
|
||||
bus.registerChannel("input", inputChannel);
|
||||
bus.registerChannel("output1", outputChannel1);
|
||||
bus.registerChannel("output2", outputChannel2);
|
||||
inputChannel.setBeanName("input");
|
||||
outputChannel1.setBeanName("output1");
|
||||
outputChannel2.setBeanName("output2");
|
||||
bus.registerChannel(inputChannel);
|
||||
bus.registerChannel(outputChannel1);
|
||||
bus.registerChannel(outputChannel2);
|
||||
DefaultEndpoint<MessageHandler> endpoint1 = new DefaultEndpoint<MessageHandler>(handler1);
|
||||
endpoint1.setBeanName("testEndpoint1");
|
||||
endpoint1.setSource(inputChannel);
|
||||
@@ -240,17 +252,19 @@ public class DefaultMessageBusTests {
|
||||
|
||||
@Test
|
||||
public void testErrorChannelRegistration() {
|
||||
MessageChannel errorChannel = new QueueChannel();
|
||||
DefaultMessageBus bus = new DefaultMessageBus();
|
||||
bus.setErrorChannel(errorChannel);
|
||||
QueueChannel errorChannel = new QueueChannel();
|
||||
errorChannel.setBeanName(ChannelRegistry.ERROR_CHANNEL_NAME);
|
||||
bus.registerChannel(errorChannel);
|
||||
assertEquals(errorChannel, bus.getErrorChannel());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandlerSubscribedToErrorChannel() throws InterruptedException {
|
||||
MessageChannel errorChannel = new QueueChannel();
|
||||
DefaultMessageBus bus = new DefaultMessageBus();
|
||||
bus.setErrorChannel(errorChannel);
|
||||
QueueChannel errorChannel = new QueueChannel();
|
||||
errorChannel.setBeanName(ChannelRegistry.ERROR_CHANNEL_NAME);
|
||||
bus.registerChannel(errorChannel);
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
MessageHandler handler = new MessageHandler() {
|
||||
public Message<?> handle(Message<?> message) {
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.annotation.Handler;
|
||||
import org.springframework.integration.annotation.MessageEndpoint;
|
||||
import org.springframework.integration.channel.ChannelRegistry;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.MessageChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.channel.ThreadLocalChannel;
|
||||
import org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor;
|
||||
@@ -41,15 +41,17 @@ public class DirectChannelSubscriptionTests {
|
||||
|
||||
private DefaultMessageBus bus = new DefaultMessageBus();
|
||||
|
||||
private MessageChannel sourceChannel = new DirectChannel();
|
||||
private DirectChannel sourceChannel = new DirectChannel();
|
||||
|
||||
private ThreadLocalChannel targetChannel = new ThreadLocalChannel();
|
||||
|
||||
|
||||
@Before
|
||||
public void setupChannels() {
|
||||
bus.registerChannel("sourceChannel", sourceChannel);
|
||||
bus.registerChannel("targetChannel", targetChannel);
|
||||
sourceChannel.setBeanName("sourceChannel");
|
||||
targetChannel.setBeanName("targetChannel");
|
||||
bus.registerChannel(sourceChannel);
|
||||
bus.registerChannel(targetChannel);
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +85,8 @@ public class DirectChannelSubscriptionTests {
|
||||
@Test(expected=RuntimeException.class)
|
||||
public void testExceptionThrownFromRegisteredEndpoint() {
|
||||
QueueChannel errorChannel = new QueueChannel();
|
||||
bus.setErrorChannel(errorChannel);
|
||||
errorChannel.setBeanName(ChannelRegistry.ERROR_CHANNEL_NAME);
|
||||
bus.registerChannel(errorChannel);
|
||||
DefaultEndpoint<MessageHandler> endpoint = new DefaultEndpoint<MessageHandler>(new MessageHandler() {
|
||||
public Message<?> handle(Message<?> message) {
|
||||
throw new RuntimeException("intentional test failure");
|
||||
@@ -100,7 +103,8 @@ public class DirectChannelSubscriptionTests {
|
||||
@Test(expected=MessagingException.class)
|
||||
public void testExceptionThrownFromAnnotatedEndpoint() {
|
||||
QueueChannel errorChannel = new QueueChannel();
|
||||
bus.setErrorChannel(errorChannel);
|
||||
errorChannel.setBeanName(ChannelRegistry.ERROR_CHANNEL_NAME);
|
||||
bus.registerChannel(errorChannel);
|
||||
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor(bus);
|
||||
postProcessor.afterPropertiesSet();
|
||||
FailingTestEndpoint endpoint = new FailingTestEndpoint();
|
||||
|
||||
@@ -30,8 +30,9 @@ public class DefaultChannelRegistryTests {
|
||||
@Test
|
||||
public void testLookupRegisteredChannel() {
|
||||
QueueChannel testChannel = new QueueChannel();
|
||||
testChannel.setBeanName("testChannel");
|
||||
DefaultChannelRegistry registry = new DefaultChannelRegistry();
|
||||
registry.registerChannel("testChannel", testChannel);
|
||||
registry.registerChannel(testChannel);
|
||||
MessageChannel lookedUpChannel = registry.lookupChannel("testChannel");
|
||||
assertNotNull(testChannel);
|
||||
assertSame(testChannel, lookedUpChannel);
|
||||
@@ -47,8 +48,9 @@ public class DefaultChannelRegistryTests {
|
||||
@Test
|
||||
public void testLookupUnregisteredChannel() {
|
||||
QueueChannel testChannel = new QueueChannel();
|
||||
testChannel.setBeanName("testChannel");
|
||||
DefaultChannelRegistry registry = new DefaultChannelRegistry();
|
||||
registry.registerChannel("testChannel", testChannel);
|
||||
registry.registerChannel(testChannel);
|
||||
MessageChannel lookedUpChannel1 = registry.lookupChannel("testChannel");
|
||||
assertNotNull(lookedUpChannel1);
|
||||
assertSame(testChannel, lookedUpChannel1);
|
||||
|
||||
@@ -55,10 +55,10 @@ public class MessageBusParserTests {
|
||||
@Test
|
||||
public void testErrorChannelReference() {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"messageBusWithErrorChannelReference.xml", this.getClass());
|
||||
"messageBusWithErrorChannel.xml", this.getClass());
|
||||
DefaultMessageBus bus = (DefaultMessageBus) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME);
|
||||
bus.initialize();
|
||||
assertEquals(context.getBean("testErrorChannel"), bus.getErrorChannel());
|
||||
assertEquals(context.getBean("errorChannel"), bus.getErrorChannel());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -268,10 +268,12 @@ public class MessagingAnnotationPostProcessorTests {
|
||||
@Test
|
||||
public void testMessageEndpointAnnotationInheritedFromInterface() {
|
||||
MessageBus messageBus = new DefaultMessageBus();
|
||||
MessageChannel inputChannel = new QueueChannel();
|
||||
QueueChannel inputChannel = new QueueChannel();
|
||||
QueueChannel outputChannel = new QueueChannel();
|
||||
messageBus.registerChannel("inputChannel", inputChannel);
|
||||
messageBus.registerChannel("outputChannel", outputChannel);
|
||||
inputChannel.setBeanName("inputChannel");
|
||||
outputChannel.setBeanName("outputChannel");
|
||||
messageBus.registerChannel(inputChannel);
|
||||
messageBus.registerChannel(outputChannel);
|
||||
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor(messageBus);
|
||||
postProcessor.afterPropertiesSet();
|
||||
postProcessor.postProcessAfterInitialization(new SimpleAnnotatedEndpointImplementation(), "impl");
|
||||
@@ -299,10 +301,12 @@ public class MessagingAnnotationPostProcessorTests {
|
||||
@Test
|
||||
public void testMessageEndpointAnnotationInheritedFromInterfaceWithProxy() {
|
||||
MessageBus messageBus = new DefaultMessageBus();
|
||||
MessageChannel inputChannel = new QueueChannel();
|
||||
QueueChannel inputChannel = new QueueChannel();
|
||||
QueueChannel outputChannel = new QueueChannel();
|
||||
messageBus.registerChannel("inputChannel", inputChannel);
|
||||
messageBus.registerChannel("outputChannel", outputChannel);
|
||||
inputChannel.setBeanName("inputChannel");
|
||||
outputChannel.setBeanName("outputChannel");
|
||||
messageBus.registerChannel(inputChannel);
|
||||
messageBus.registerChannel(outputChannel);
|
||||
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor(messageBus);
|
||||
postProcessor.afterPropertiesSet();
|
||||
ProxyFactory proxyFactory = new ProxyFactory(new SimpleAnnotatedEndpointImplementation());
|
||||
@@ -319,8 +323,10 @@ public class MessagingAnnotationPostProcessorTests {
|
||||
MessageBus messageBus = new DefaultMessageBus();
|
||||
QueueChannel input = new QueueChannel();
|
||||
QueueChannel output = new QueueChannel();
|
||||
messageBus.registerChannel("input", input);
|
||||
messageBus.registerChannel("output", output);
|
||||
input.setBeanName("input");
|
||||
output.setBeanName("output");
|
||||
messageBus.registerChannel(input);
|
||||
messageBus.registerChannel(output);
|
||||
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor(messageBus);
|
||||
postProcessor.afterPropertiesSet();
|
||||
SplitterAnnotationTestEndpoint endpoint = new SplitterAnnotationTestEndpoint();
|
||||
@@ -346,7 +352,8 @@ public class MessagingAnnotationPostProcessorTests {
|
||||
public void testEndpointWithNoHandlerMethod() {
|
||||
MessageBus messageBus = new DefaultMessageBus();
|
||||
QueueChannel testChannel = new QueueChannel();
|
||||
messageBus.registerChannel("testChannel", testChannel);
|
||||
testChannel.setBeanName("testChannel");
|
||||
messageBus.registerChannel(testChannel);
|
||||
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor(messageBus);
|
||||
postProcessor.afterPropertiesSet();
|
||||
AnnotatedEndpointWithNoHandlerMethod endpoint = new AnnotatedEndpointWithNoHandlerMethod();
|
||||
@@ -357,7 +364,8 @@ public class MessagingAnnotationPostProcessorTests {
|
||||
public void testEndpointWithPollerAnnotation() {
|
||||
MessageBus messageBus = new DefaultMessageBus();
|
||||
QueueChannel testChannel = new QueueChannel();
|
||||
messageBus.registerChannel("testChannel", testChannel);
|
||||
testChannel.setBeanName("testChannel");
|
||||
messageBus.registerChannel(testChannel);
|
||||
MessagingAnnotationPostProcessor postProcessor = new MessagingAnnotationPostProcessor(messageBus);
|
||||
postProcessor.afterPropertiesSet();
|
||||
AnnotatedEndpointWithPolledAnnotation endpoint = new AnnotatedEndpointWithPolledAnnotation();
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration-core-1.0.xsd">
|
||||
|
||||
<channel id="testErrorChannel"/>
|
||||
<channel id="errorChannel"/>
|
||||
|
||||
<message-bus error-channel="testErrorChannel"/>
|
||||
<message-bus/>
|
||||
|
||||
</beans:beans>
|
||||
@@ -95,8 +95,9 @@ public class DefaultEndpointTests {
|
||||
@Test
|
||||
public void returnAddressHeaderWithChannelName() {
|
||||
QueueChannel channel = new QueueChannel(1);
|
||||
channel.setBeanName("testChannel");
|
||||
ChannelRegistry channelRegistry = new DefaultMessageBus();
|
||||
channelRegistry.registerChannel("testChannel", channel);
|
||||
channelRegistry.registerChannel(channel);
|
||||
MessageHandler handler = new TestHandler();
|
||||
DefaultEndpoint<MessageHandler> endpoint = new DefaultEndpoint<MessageHandler>(handler);
|
||||
endpoint.setChannelRegistry(channelRegistry);
|
||||
@@ -112,8 +113,9 @@ public class DefaultEndpointTests {
|
||||
QueueChannel channel1 = new QueueChannel(1);
|
||||
QueueChannel channel2 = new QueueChannel(1);
|
||||
QueueChannel channel3 = new QueueChannel(1);
|
||||
channel1.setBeanName("testChannel");
|
||||
ChannelRegistry channelRegistry = new DefaultMessageBus();
|
||||
channelRegistry.registerChannel("testChannel", channel1);
|
||||
channelRegistry.registerChannel(channel1);
|
||||
MessageHandler handler = new TestNextTargetSettingHandler("testChannel");
|
||||
DefaultEndpoint<MessageHandler> endpoint = new DefaultEndpoint<MessageHandler>(handler);
|
||||
endpoint.setChannelRegistry(channelRegistry);
|
||||
@@ -133,8 +135,9 @@ public class DefaultEndpointTests {
|
||||
public void dynamicReplyChannel() throws Exception {
|
||||
final QueueChannel replyChannel1 = new QueueChannel();
|
||||
final QueueChannel replyChannel2 = new QueueChannel();
|
||||
replyChannel2.setBeanName("replyChannel2");
|
||||
ChannelRegistry channelRegistry = new DefaultChannelRegistry();
|
||||
channelRegistry.registerChannel("replyChannel2", replyChannel2);
|
||||
channelRegistry.registerChannel(replyChannel2);
|
||||
MessageHandler handler = new MessageHandler() {
|
||||
public Message<?> handle(Message<?> message) {
|
||||
return new StringMessage("foo" + message.getPayload());
|
||||
|
||||
@@ -85,7 +85,7 @@ public class ReturnAddressTests {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"returnAddressTests.xml", this.getClass());
|
||||
MessageChannel channel3 = (MessageChannel) context.getBean("channel3");
|
||||
PollableChannel errorChannel = (PollableChannel) context.getBean("customErrorChannel");
|
||||
PollableChannel errorChannel = (PollableChannel) context.getBean("errorChannel");
|
||||
context.start();
|
||||
StringMessage message = new StringMessage("*");
|
||||
channel3.send(message);
|
||||
@@ -98,7 +98,7 @@ public class ReturnAddressTests {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"returnAddressTests.xml", this.getClass());
|
||||
MessageChannel channel3 = (MessageChannel) context.getBean("channel3WithOverride");
|
||||
PollableChannel errorChannel = (PollableChannel) context.getBean("customErrorChannel");
|
||||
PollableChannel errorChannel = (PollableChannel) context.getBean("errorChannel");
|
||||
context.start();
|
||||
StringMessage message = new StringMessage("*");
|
||||
channel3.send(message);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
http://www.springframework.org/schema/integration
|
||||
http://www.springframework.org/schema/integration/spring-integration-core-1.0.xsd">
|
||||
|
||||
<si:message-bus error-channel="customErrorChannel"/>
|
||||
<si:message-bus/>
|
||||
|
||||
<si:channel id="channel1"/>
|
||||
<si:channel id="channel2"/>
|
||||
@@ -16,7 +16,7 @@
|
||||
<si:channel id="channel1WithOverride"/>
|
||||
<si:channel id="channel3WithOverride"/>
|
||||
<si:channel id="replyChannel"/>
|
||||
<si:channel id="customErrorChannel"/>
|
||||
<si:channel id="errorChannel"/>
|
||||
|
||||
<si:service-activator input-channel="channel1WithOverride" ref="testBean" method="duplicate"
|
||||
output-channel="channel2" return-address-overrides="true"/>
|
||||
|
||||
@@ -94,11 +94,12 @@ public class MethodInvokingTargetTests {
|
||||
target.setMethodName("foo");
|
||||
target.afterPropertiesSet();
|
||||
QueueChannel channel = new QueueChannel();
|
||||
channel.setBeanName("channel");
|
||||
Message<String> message = new GenericMessage<String>("testing");
|
||||
channel.send(message);
|
||||
assertNull(queue.poll());
|
||||
MessageBus bus = new DefaultMessageBus();
|
||||
bus.registerChannel("channel", channel);
|
||||
bus.registerChannel(channel);
|
||||
MessageEndpoint endpoint = new DefaultEndpoint<MethodInvokingTarget>(target);
|
||||
endpoint.setBeanName("testEndpoint");
|
||||
endpoint.setSource(channel);
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.bus.DefaultMessageBus;
|
||||
@@ -31,28 +32,26 @@ import org.springframework.integration.bus.MessageBus;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.endpoint.DefaultEndpoint;
|
||||
import org.springframework.integration.handler.MessageHandler;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.message.MessageExchangeTemplate;
|
||||
import org.springframework.integration.message.MessageTarget;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class MessageExchangeTemplateTests {
|
||||
|
||||
private final QueueChannel requestChannel = new QueueChannel();
|
||||
private QueueChannel requestChannel;
|
||||
|
||||
|
||||
public MessageExchangeTemplateTests() {
|
||||
@Before
|
||||
public void setUp() {
|
||||
this.requestChannel = new QueueChannel();
|
||||
this.requestChannel.setBeanName("requestChannel");
|
||||
MessageHandler testHandler = new MessageHandler() {
|
||||
public Message<?> handle(Message<?> message) {
|
||||
return new StringMessage(message.getPayload().toString().toUpperCase());
|
||||
}
|
||||
};
|
||||
MessageBus bus = new DefaultMessageBus();
|
||||
bus.registerChannel("requestChannel", requestChannel);
|
||||
bus.registerChannel(requestChannel);
|
||||
DefaultEndpoint<MessageHandler> endpoint = new DefaultEndpoint<MessageHandler>(testHandler);
|
||||
endpoint.setBeanName("testEndpoint");
|
||||
endpoint.setSource(requestChannel);
|
||||
|
||||
@@ -72,9 +72,11 @@ public class MultiChannelRouterTests {
|
||||
};
|
||||
QueueChannel channel1 = new QueueChannel();
|
||||
QueueChannel channel2 = new QueueChannel();
|
||||
channel1.setBeanName("channel1");
|
||||
channel2.setBeanName("channel2");
|
||||
ChannelRegistry channelRegistry = new DefaultChannelRegistry();
|
||||
channelRegistry.registerChannel("channel1", channel1);
|
||||
channelRegistry.registerChannel("channel2", channel2);
|
||||
channelRegistry.registerChannel(channel1);
|
||||
channelRegistry.registerChannel(channel2);
|
||||
MultiChannelRouter router = new MultiChannelRouter();
|
||||
router.setChannelNameResolver(channelNameResolver);
|
||||
router.setChannelRegistry(channelRegistry);
|
||||
|
||||
@@ -62,9 +62,11 @@ public class RecipientListRouterTests {
|
||||
public void testRoutingWithChannelNames() {
|
||||
QueueChannel channel1 = new QueueChannel();
|
||||
QueueChannel channel2 = new QueueChannel();
|
||||
channel1.setBeanName("channel1");
|
||||
channel2.setBeanName("channel2");
|
||||
ChannelRegistry channelRegistry = new DefaultChannelRegistry();
|
||||
channelRegistry.registerChannel("channel1", channel1);
|
||||
channelRegistry.registerChannel("channel2", channel2);
|
||||
channelRegistry.registerChannel(channel1);
|
||||
channelRegistry.registerChannel(channel2);
|
||||
RecipientListRouter router = new RecipientListRouter();
|
||||
router.setChannelNames(new String[] {"channel1", "channel2"});
|
||||
router.setChannelRegistry(channelRegistry);
|
||||
@@ -83,9 +85,11 @@ public class RecipientListRouterTests {
|
||||
public void testRoutingToSingleChannelByName() {
|
||||
QueueChannel channel1 = new QueueChannel();
|
||||
QueueChannel channel2 = new QueueChannel();
|
||||
channel1.setBeanName("channel1");
|
||||
channel2.setBeanName("channel2");
|
||||
ChannelRegistry channelRegistry = new DefaultChannelRegistry();
|
||||
channelRegistry.registerChannel("channel1", channel1);
|
||||
channelRegistry.registerChannel("channel2", channel2);
|
||||
channelRegistry.registerChannel(channel1);
|
||||
channelRegistry.registerChannel(channel2);
|
||||
RecipientListRouter router = new RecipientListRouter();
|
||||
router.setChannelNames(new String[] {"channel1"});
|
||||
router.setChannelRegistry(channelRegistry);
|
||||
@@ -103,12 +107,14 @@ public class RecipientListRouterTests {
|
||||
public void testConfigurationExceptionWhenBothChannelsAndNamesAreProvided() {
|
||||
QueueChannel channel1 = new QueueChannel();
|
||||
QueueChannel channel2 = new QueueChannel();
|
||||
channel1.setBeanName("channel1");
|
||||
channel2.setBeanName("channel2");
|
||||
List<MessageChannel> channels = new ArrayList<MessageChannel>();
|
||||
channels.add(channel1);
|
||||
channels.add(channel2);
|
||||
ChannelRegistry channelRegistry = new DefaultChannelRegistry();
|
||||
channelRegistry.registerChannel("channel1", channel1);
|
||||
channelRegistry.registerChannel("channel2", channel2);
|
||||
channelRegistry.registerChannel(channel1);
|
||||
channelRegistry.registerChannel(channel2);
|
||||
RecipientListRouter router = new RecipientListRouter();
|
||||
router.setChannels(channels);
|
||||
router.setChannelNames(new String[] {"channel1"});
|
||||
|
||||
@@ -150,10 +150,12 @@ public class RouterMessageHandlerTests {
|
||||
Message<String> fooMessage = new StringMessage("foo");
|
||||
Message<String> barMessage = new StringMessage("bar");
|
||||
Message<String> badMessage = new StringMessage("bad");
|
||||
MessageChannel fooChannel = new QueueChannel();
|
||||
MessageChannel barChannel = new QueueChannel();
|
||||
channelRegistry.registerChannel("foo-channel", fooChannel);
|
||||
channelRegistry.registerChannel("bar-channel", barChannel);
|
||||
QueueChannel fooChannel = new QueueChannel();
|
||||
QueueChannel barChannel = new QueueChannel();
|
||||
fooChannel.setBeanName("foo-channel");
|
||||
barChannel.setBeanName("bar-channel");
|
||||
channelRegistry.registerChannel(fooChannel);
|
||||
channelRegistry.registerChannel(barChannel);
|
||||
Message<?> result1 = ((CompositeMessage) handler.handle(fooMessage)).getPayload().get(0);
|
||||
assertNotNull(result1);
|
||||
assertEquals("foo", result1.getPayload());
|
||||
@@ -185,8 +187,10 @@ public class RouterMessageHandlerTests {
|
||||
private void doTestChannelInstanceResolutionByMessage(RouterMessageHandler handler, ChannelRegistry channelRegistry) {
|
||||
QueueChannel fooChannel = new QueueChannel();
|
||||
QueueChannel barChannel = new QueueChannel();
|
||||
channelRegistry.registerChannel("foo-channel", fooChannel);
|
||||
channelRegistry.registerChannel("bar-channel", barChannel);
|
||||
fooChannel.setBeanName("foo-channel");
|
||||
barChannel.setBeanName("bar-channel");
|
||||
channelRegistry.registerChannel(fooChannel);
|
||||
channelRegistry.registerChannel(barChannel);
|
||||
Message<String> fooMessage = new StringMessage("foo");
|
||||
Message<String> barMessage = new StringMessage("bar");
|
||||
Message<String> badMessage = new StringMessage("bad");
|
||||
@@ -221,8 +225,10 @@ public class RouterMessageHandlerTests {
|
||||
private void doTestMultiChannelNameResolutionByPayload(RouterMessageHandler handler, ChannelRegistry channelRegistry) {
|
||||
QueueChannel fooChannel = new QueueChannel();
|
||||
QueueChannel barChannel = new QueueChannel();
|
||||
channelRegistry.registerChannel("foo-channel", fooChannel);
|
||||
channelRegistry.registerChannel("bar-channel", barChannel);
|
||||
fooChannel.setBeanName("foo-channel");
|
||||
barChannel.setBeanName("bar-channel");
|
||||
channelRegistry.registerChannel(fooChannel);
|
||||
channelRegistry.registerChannel(barChannel);
|
||||
Message<String> fooMessage = new StringMessage("foo");
|
||||
Message<String> barMessage = new StringMessage("bar");
|
||||
Message<String> badMessage = new StringMessage("bad");
|
||||
@@ -267,8 +273,10 @@ public class RouterMessageHandlerTests {
|
||||
private void doTestMultiChannelNameResolutionByMessage(RouterMessageHandler handler, ChannelRegistry channelRegistry) {
|
||||
QueueChannel fooChannel = new QueueChannel();
|
||||
QueueChannel barChannel = new QueueChannel();
|
||||
channelRegistry.registerChannel("foo-channel", fooChannel);
|
||||
channelRegistry.registerChannel("bar-channel", barChannel);
|
||||
fooChannel.setBeanName("foo-channel");
|
||||
barChannel.setBeanName("bar-channel");
|
||||
channelRegistry.registerChannel(fooChannel);
|
||||
channelRegistry.registerChannel(barChannel);
|
||||
Message<String> fooMessage = new StringMessage("foo");
|
||||
Message<String> barMessage = new StringMessage("bar");
|
||||
Message<String> badMessage = new StringMessage("bad");
|
||||
@@ -313,8 +321,10 @@ public class RouterMessageHandlerTests {
|
||||
private void doTestMultiChannelNameArrayResolutionByMessage(RouterMessageHandler handler, ChannelRegistry channelRegistry) {
|
||||
QueueChannel fooChannel = new QueueChannel();
|
||||
QueueChannel barChannel = new QueueChannel();
|
||||
channelRegistry.registerChannel("foo-channel", fooChannel);
|
||||
channelRegistry.registerChannel("bar-channel", barChannel);
|
||||
fooChannel.setBeanName("foo-channel");
|
||||
barChannel.setBeanName("bar-channel");
|
||||
channelRegistry.registerChannel(fooChannel);
|
||||
channelRegistry.registerChannel(barChannel);
|
||||
Message<String> fooMessage = new StringMessage("foo");
|
||||
Message<String> barMessage = new StringMessage("bar");
|
||||
Message<String> badMessage = new StringMessage("bad");
|
||||
@@ -359,8 +369,10 @@ public class RouterMessageHandlerTests {
|
||||
private void doTestMultiChannelListResolutionByPayload(RouterMessageHandler handler, ChannelRegistry channelRegistry) {
|
||||
QueueChannel fooChannel = new QueueChannel();
|
||||
QueueChannel barChannel = new QueueChannel();
|
||||
channelRegistry.registerChannel("foo-channel", fooChannel);
|
||||
channelRegistry.registerChannel("bar-channel", barChannel);
|
||||
fooChannel.setBeanName("foo-channel");
|
||||
barChannel.setBeanName("bar-channel");
|
||||
channelRegistry.registerChannel(fooChannel);
|
||||
channelRegistry.registerChannel(barChannel);
|
||||
Message<String> fooMessage = new StringMessage("foo");
|
||||
Message<String> barMessage = new StringMessage("bar");
|
||||
Message<String> badMessage = new StringMessage("bad");
|
||||
@@ -405,8 +417,10 @@ public class RouterMessageHandlerTests {
|
||||
private void doTestMultiChannelListResolutionByMessage(RouterMessageHandler handler, ChannelRegistry channelRegistry) {
|
||||
QueueChannel fooChannel = new QueueChannel();
|
||||
QueueChannel barChannel = new QueueChannel();
|
||||
channelRegistry.registerChannel("foo-channel", fooChannel);
|
||||
channelRegistry.registerChannel("bar-channel", barChannel);
|
||||
fooChannel.setBeanName("foo-channel");
|
||||
barChannel.setBeanName("bar-channel");
|
||||
channelRegistry.registerChannel(fooChannel);
|
||||
channelRegistry.registerChannel(barChannel);
|
||||
Message<String> fooMessage = new StringMessage("foo");
|
||||
Message<String> barMessage = new StringMessage("bar");
|
||||
Message<String> badMessage = new StringMessage("bad");
|
||||
@@ -451,8 +465,10 @@ public class RouterMessageHandlerTests {
|
||||
private void doTestMultiChannelArrayResolutionByMessage(RouterMessageHandler handler, ChannelRegistry channelRegistry) {
|
||||
QueueChannel fooChannel = new QueueChannel();
|
||||
QueueChannel barChannel = new QueueChannel();
|
||||
channelRegistry.registerChannel("foo-channel", fooChannel);
|
||||
channelRegistry.registerChannel("bar-channel", barChannel);
|
||||
fooChannel.setBeanName("foo-channel");
|
||||
barChannel.setBeanName("bar-channel");
|
||||
channelRegistry.registerChannel(fooChannel);
|
||||
channelRegistry.registerChannel(barChannel);
|
||||
Message<String> fooMessage = new StringMessage("foo");
|
||||
Message<String> barMessage = new StringMessage("bar");
|
||||
Message<String> badMessage = new StringMessage("bad");
|
||||
|
||||
@@ -61,8 +61,9 @@ public class SingleChannelRouterTests {
|
||||
}
|
||||
};
|
||||
QueueChannel channel = new QueueChannel();
|
||||
channel.setBeanName("testChannel");
|
||||
ChannelRegistry channelRegistry = new DefaultChannelRegistry();
|
||||
channelRegistry.registerChannel("testChannel", channel);
|
||||
channelRegistry.registerChannel(channel);
|
||||
SingleChannelRouter router = new SingleChannelRouter();
|
||||
router.setChannelNameResolver(channelNameResolver);
|
||||
router.setChannelRegistry(channelRegistry);
|
||||
|
||||
Reference in New Issue
Block a user