diff --git a/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XPathRouterParserTests-context.xml b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XPathRouterParserTests-context.xml index 16ccdff0ac..1165fe9c43 100644 --- a/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XPathRouterParserTests-context.xml +++ b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XPathRouterParserTests-context.xml @@ -11,7 +11,7 @@ - + @@ -19,7 +19,7 @@ - + diff --git a/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XPathRouterParserTests.java b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XPathRouterParserTests.java index f12678b042..713f5a8e56 100644 --- a/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XPathRouterParserTests.java +++ b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XPathRouterParserTests.java @@ -48,8 +48,8 @@ public class XPathRouterParserTests extends AbstractJUnit4SpringContextTests{ @Autowired @Qualifier("outputTwo") PollableChannel outputTwo; - @Autowired @Qualifier("errors") - PollableChannel errors; + @Autowired @Qualifier("errorChannel") + PollableChannel errorChannel; @SuppressWarnings("unchecked") @@ -78,7 +78,7 @@ public class XPathRouterParserTests extends AbstractJUnit4SpringContextTests{ Document doc = XmlTestUtil.getDocumentForString("outputThree"); GenericMessage docMessage = new GenericMessage(doc); inputOne.send(docMessage); - GenericMessage received = (GenericMessage) errors.receive(1000); + GenericMessage received = (GenericMessage) errorChannel.receive(1000); assertNotNull("Did not recevie message on errors", received); } @@ -109,7 +109,7 @@ public class XPathRouterParserTests extends AbstractJUnit4SpringContextTests{ Document doc = XmlTestUtil.getDocumentForString("outputThree"); GenericMessage docMessage = new GenericMessage(doc); inputTwo.send(docMessage); - GenericMessage received = (GenericMessage) errors.receive(1000); + GenericMessage received = (GenericMessage) errorChannel.receive(1000); assertNotNull("Did not recevie message on errors", received); } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/bus/DefaultErrorChannel.java b/org.springframework.integration/src/main/java/org/springframework/integration/bus/DefaultErrorChannel.java index 7c64081764..36ff9c7fd4 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/bus/DefaultErrorChannel.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/bus/DefaultErrorChannel.java @@ -19,6 +19,7 @@ package org.springframework.integration.bus; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.springframework.integration.channel.ChannelRegistry; import org.springframework.integration.channel.MessageChannel; import org.springframework.integration.channel.RendezvousChannel; import org.springframework.integration.channel.interceptor.ChannelInterceptorAdapter; @@ -36,6 +37,7 @@ public class DefaultErrorChannel extends RendezvousChannel { public DefaultErrorChannel() { this.addInterceptor(new ErrorLoggingInterceptor()); + this.setBeanName(ChannelRegistry.ERROR_CHANNEL_NAME); } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/bus/DefaultMessageBus.java b/org.springframework.integration/src/main/java/org/springframework/integration/bus/DefaultMessageBus.java index 6f819da3aa..bfcf6fad27 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/bus/DefaultMessageBus.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/bus/DefaultMessageBus.java @@ -173,7 +173,7 @@ public class DefaultMessageBus implements MessageBus, ApplicationContextAware, A String channelName = entry.getKey(); MessageChannel previousChannel = this.lookupChannel(channelName); if (previousChannel == null) { - this.registerChannel(channelName, entry.getValue()); + this.registerChannel(entry.getValue()); } else if (!previousChannel.equals(entry.getValue())) { throw new ConfigurationException("A different channel instance has already " @@ -213,7 +213,7 @@ public class DefaultMessageBus implements MessageBus, ApplicationContextAware, A this.taskScheduler = new ProviderTaskScheduler(new SimpleScheduleServiceProvider(executor)); } if (this.getErrorChannel() == null) { - this.setErrorChannel(new DefaultErrorChannel()); + this.registerChannel(new DefaultErrorChannel()); } this.initialized = true; this.initializing = false; @@ -224,30 +224,22 @@ public class DefaultMessageBus implements MessageBus, ApplicationContextAware, A return this.lookupChannel(ERROR_CHANNEL_NAME); } - public void setErrorChannel(MessageChannel errorChannel) { - this.registerChannel(ERROR_CHANNEL_NAME, errorChannel); - } - public MessageChannel lookupChannel(String channelName) { MessageChannel channel = this.channelRegistry.lookupChannel(channelName); if (channel == null && this.applicationContext != null && this.applicationContext.containsBean(channelName)) { Object bean = this.applicationContext.getBean(channelName); if (bean instanceof MessageChannel) { channel = (MessageChannel) bean; - this.registerChannel(channelName, channel); + this.registerChannel(channel); } } return channel; } - public void registerChannel(String name, MessageChannel channel) { - if (!this.initialized) { - this.initialize(); - } - channel.setName(name); - this.channelRegistry.registerChannel(name, channel); + public void registerChannel(MessageChannel channel) { + this.channelRegistry.registerChannel(channel); if (logger.isInfoEnabled()) { - logger.info("registered channel '" + name + "'"); + logger.info("registered channel '" + channel.getName() + "'"); } } @@ -354,7 +346,7 @@ public class DefaultMessageBus implements MessageBus, ApplicationContextAware, A logger.info("auto-creating channel '" + channelName + "'"); } channel = channelFactory.getChannel(channelName, null); - this.registerChannel(channelName, channel); + this.registerChannel(channel); } return channel; } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/channel/AbstractChannelAdapter.java b/org.springframework.integration/src/main/java/org/springframework/integration/channel/AbstractChannelAdapter.java index d9523a7fa0..fe561e0b12 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/channel/AbstractChannelAdapter.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/channel/AbstractChannelAdapter.java @@ -33,7 +33,7 @@ public class AbstractChannelAdapter extends AbstractMessageChannel { public AbstractChannelAdapter(String name, MessageTarget target) { Assert.notNull(name, "name must not be null"); - this.setName(name); + this.setBeanName(name); this.target = target; } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java b/org.springframework.integration/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java index 49dd54ae33..2ff947fab5 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/channel/AbstractMessageChannel.java @@ -44,9 +44,10 @@ public abstract class AbstractMessageChannel implements MessageChannel, BeanName /** - * Set the name of this channel. + * Set the name of this channel. This will be invoked automatically whenever + * the channel is configured explicitly with a bean definition. */ - public void setName(String name) { + public void setBeanName(String name) { this.name = name; } @@ -57,15 +58,6 @@ public abstract class AbstractMessageChannel implements MessageChannel, BeanName return this.name; } - /** - * Set the name of this channel to its bean name. This will be invoked - * automatically whenever the channel is configured explicitly with a bean - * definition. - */ - public void setBeanName(String beanName) { - this.setName(beanName); - } - /** * Set the list of channel interceptors. This will clear any existing * interceptors. diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/channel/ChannelRegistry.java b/org.springframework.integration/src/main/java/org/springframework/integration/channel/ChannelRegistry.java index 914d1166e7..48a9ffaf47 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/channel/ChannelRegistry.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/channel/ChannelRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2008 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. @@ -26,7 +26,7 @@ public interface ChannelRegistry { static final String ERROR_CHANNEL_NAME = "errorChannel"; - void registerChannel(String name, MessageChannel channel); + void registerChannel(MessageChannel channel); MessageChannel unregisterChannel(String name); diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/channel/DefaultChannelRegistry.java b/org.springframework.integration/src/main/java/org/springframework/integration/channel/DefaultChannelRegistry.java index c9d6605329..4d1993e41e 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/channel/DefaultChannelRegistry.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/channel/DefaultChannelRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 the original author or authors. + * Copyright 2002-2008 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. @@ -35,10 +35,10 @@ public class DefaultChannelRegistry implements ChannelRegistry { return this.channels.get(channelName); } - public void registerChannel(String name, MessageChannel channel) { - Assert.notNull(name, "'name' must not be null"); + public void registerChannel(MessageChannel channel) { Assert.notNull(channel, "'channel' must not be null"); - this.channels.put(name, channel); + Assert.notNull(channel.getName(), "channel name must not be null"); + this.channels.put(channel.getName(), channel); } public MessageChannel unregisterChannel(String name) { diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/channel/MessageChannel.java b/org.springframework.integration/src/main/java/org/springframework/integration/channel/MessageChannel.java index bc8ab8ec34..cb51a3210c 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/channel/MessageChannel.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/channel/MessageChannel.java @@ -31,9 +31,4 @@ public interface MessageChannel extends MessageSource, BlockingTarget { */ String getName(); - /** - * Set the name of this channel. - */ - void setName(String name); - } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/channel/factory/AbstractChannelFactory.java b/org.springframework.integration/src/main/java/org/springframework/integration/channel/factory/AbstractChannelFactory.java index 306c7c3283..b14a2d12ca 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/channel/factory/AbstractChannelFactory.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/channel/factory/AbstractChannelFactory.java @@ -40,7 +40,7 @@ public abstract class AbstractChannelFactory implements ChannelFactory { channel.setInterceptors(interceptors); } if (name != null && channel.getName() == null) { - channel.setName(name); + channel.setBeanName(name); } return channel; } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/MessageBusParser.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/MessageBusParser.java index 22f01014c6..8c3a26d419 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/config/MessageBusParser.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/MessageBusParser.java @@ -28,15 +28,13 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder; import org.springframework.beans.factory.support.ManagedList; import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser; import org.springframework.beans.factory.xml.ParserContext; -import org.springframework.core.Conventions; import org.springframework.integration.ConfigurationException; import org.springframework.integration.bus.DefaultMessageBus; import org.springframework.integration.bus.MessageBus; import org.springframework.integration.bus.MessageBusAwareBeanPostProcessor; -import org.springframework.util.StringUtils; /** - * Parser for the message-bus element of the integration namespace. + * Parser for the <message-bus> element of the integration namespace. * * @author Mark Fisher * @author Marius Bogoevici @@ -47,8 +45,6 @@ public class MessageBusParser extends AbstractSimpleBeanDefinitionParser { public static final String MESSAGE_BUS_AWARE_POST_PROCESSOR_BEAN_NAME = "internal.MessageBusAwareBeanPostProcessor"; - private static final String ERROR_CHANNEL_ATTRIBUTE = "error-channel"; - private static final String CHANNEL_FACTORY_ATTRIBUTE = "channel-factory"; private static final String INTERCEPTOR_ELEMENT = "interceptor"; @@ -75,28 +71,18 @@ public class MessageBusParser extends AbstractSimpleBeanDefinitionParser { @Override protected boolean isEligibleAttribute(String attributeName) { - return !ERROR_CHANNEL_ATTRIBUTE.equals(attributeName) && - !CHANNEL_FACTORY_ATTRIBUTE.equals(attributeName) && + return !CHANNEL_FACTORY_ATTRIBUTE.equals(attributeName) && super.isEligibleAttribute(attributeName); } @Override - protected void postProcess(BeanDefinitionBuilder beanDefinition, Element element) { - String errorChannelRef = element.getAttribute(ERROR_CHANNEL_ATTRIBUTE); - if (StringUtils.hasText(errorChannelRef)) { - beanDefinition.addPropertyReference(Conventions.attributeNameToPropertyName( - ERROR_CHANNEL_ATTRIBUTE), errorChannelRef); - } - String channelFactoryRef = element.getAttribute(CHANNEL_FACTORY_ATTRIBUTE); - if (StringUtils.hasText(channelFactoryRef)) { - beanDefinition.addPropertyReference(Conventions.attributeNameToPropertyName( - CHANNEL_FACTORY_ATTRIBUTE), channelFactoryRef); - } - this.processChildElements(beanDefinition, element); + protected void postProcess(BeanDefinitionBuilder builder, Element element) { + IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, CHANNEL_FACTORY_ATTRIBUTE); + this.processChildElements(builder, element); } @SuppressWarnings("unchecked") - private void processChildElements(BeanDefinitionBuilder beanDefinition, Element element) { + private void processChildElements(BeanDefinitionBuilder builder, Element element) { NodeList childNodes = element.getChildNodes(); ManagedList interceptors = new ManagedList(); for (int i = 0; i < childNodes.getLength(); i++) { @@ -109,7 +95,7 @@ public class MessageBusParser extends AbstractSimpleBeanDefinitionParser { } } if (interceptors.size() > 0) { - beanDefinition.addPropertyValue(INTERCEPTORS_PROPERTY, interceptors); + builder.addPropertyValue(INTERCEPTORS_PROPERTY, interceptors); } } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/PollableAnnotationPostProcessor.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/PollableAnnotationPostProcessor.java index 131bb21fda..aba8e9f3ca 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/PollableAnnotationPostProcessor.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/PollableAnnotationPostProcessor.java @@ -50,7 +50,7 @@ public class PollableAnnotationPostProcessor extends AbstractAnnotationMethodPos if (channelAdapterAnnotation != null) { String channelName = channelAdapterAnnotation.value(); PollableChannelAdapter adapter = new PollableChannelAdapter(channelName, source, null); - this.getMessageBus().registerChannel(channelName, adapter); + this.getMessageBus().registerChannel(adapter); } return source; } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/TargetAnnotationPostProcessor.java b/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/TargetAnnotationPostProcessor.java index 6bf0ae24bf..280f1b31b4 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/TargetAnnotationPostProcessor.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/annotation/TargetAnnotationPostProcessor.java @@ -49,7 +49,7 @@ public class TargetAnnotationPostProcessor extends AbstractAnnotationMethodPostP if (channelAdapterAnnotation != null) { String channelName = channelAdapterAnnotation.value(); PollableChannelAdapter adapter = new PollableChannelAdapter(channelName, null, target); - this.getMessageBus().registerChannel(channelName, adapter); + this.getMessageBus().registerChannel(adapter); } return target; } diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/config/spring-integration-core-1.0.xsd b/org.springframework.integration/src/main/java/org/springframework/integration/config/spring-integration-core-1.0.xsd index 6f5deb8295..65f20b374f 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/config/spring-integration-core-1.0.xsd +++ b/org.springframework.integration/src/main/java/org/springframework/integration/config/spring-integration-core-1.0.xsd @@ -34,7 +34,6 @@ - diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/aop/PublisherAnnotationAdvisorTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/aop/PublisherAnnotationAdvisorTests.java index ece0aed1cf..e384639eb9 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/aop/PublisherAnnotationAdvisorTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/aop/PublisherAnnotationAdvisorTests.java @@ -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(); diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/bus/DefaultMessageBusTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/bus/DefaultMessageBusTests.java index 1b106d4503..9ac9bd569b 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/bus/DefaultMessageBusTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/bus/DefaultMessageBusTests.java @@ -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 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 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 endpoint1 = new DefaultEndpoint(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 endpoint1 = new DefaultEndpoint(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) { diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/bus/DirectChannelSubscriptionTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/bus/DirectChannelSubscriptionTests.java index 65f925bbc6..1cec43d7c7 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/bus/DirectChannelSubscriptionTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/bus/DirectChannelSubscriptionTests.java @@ -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 endpoint = new DefaultEndpoint(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(); diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/channel/DefaultChannelRegistryTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/channel/DefaultChannelRegistryTests.java index db6f940391..4ecb5703fa 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/channel/DefaultChannelRegistryTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/channel/DefaultChannelRegistryTests.java @@ -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); diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/MessageBusParserTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/MessageBusParserTests.java index 08223740a4..5b24768a47 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/MessageBusParserTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/config/MessageBusParserTests.java @@ -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 diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessorTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessorTests.java index ea66feb16a..fb0f001b76 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessorTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/config/annotation/MessagingAnnotationPostProcessorTests.java @@ -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(); diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/messageBusWithErrorChannelReference.xml b/org.springframework.integration/src/test/java/org/springframework/integration/config/messageBusWithErrorChannel.xml similarity index 85% rename from org.springframework.integration/src/test/java/org/springframework/integration/config/messageBusWithErrorChannelReference.xml rename to org.springframework.integration/src/test/java/org/springframework/integration/config/messageBusWithErrorChannel.xml index ef47c73da3..16687fb51a 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/messageBusWithErrorChannelReference.xml +++ b/org.springframework.integration/src/test/java/org/springframework/integration/config/messageBusWithErrorChannel.xml @@ -7,8 +7,8 @@ http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-core-1.0.xsd"> - + - + diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/endpoint/DefaultEndpointTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/endpoint/DefaultEndpointTests.java index 14e2fa2d7f..c9afcd0845 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/endpoint/DefaultEndpointTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/endpoint/DefaultEndpointTests.java @@ -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 endpoint = new DefaultEndpoint(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 endpoint = new DefaultEndpoint(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()); diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/endpoint/ReturnAddressTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/endpoint/ReturnAddressTests.java index 75daa0566b..fe5fe48bc0 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/endpoint/ReturnAddressTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/endpoint/ReturnAddressTests.java @@ -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); diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/endpoint/returnAddressTests.xml b/org.springframework.integration/src/test/java/org/springframework/integration/endpoint/returnAddressTests.xml index 6f68d5db6d..8d8efbea62 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/endpoint/returnAddressTests.xml +++ b/org.springframework.integration/src/test/java/org/springframework/integration/endpoint/returnAddressTests.xml @@ -7,7 +7,7 @@ http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-core-1.0.xsd"> - + @@ -16,7 +16,7 @@ - + diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/handler/MethodInvokingTargetTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/handler/MethodInvokingTargetTests.java index 6e39a9bea8..cd03132a4a 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/handler/MethodInvokingTargetTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/handler/MethodInvokingTargetTests.java @@ -94,11 +94,12 @@ public class MethodInvokingTargetTests { target.setMethodName("foo"); target.afterPropertiesSet(); QueueChannel channel = new QueueChannel(); + channel.setBeanName("channel"); Message message = new GenericMessage("testing"); channel.send(message); assertNull(queue.poll()); MessageBus bus = new DefaultMessageBus(); - bus.registerChannel("channel", channel); + bus.registerChannel(channel); MessageEndpoint endpoint = new DefaultEndpoint(target); endpoint.setBeanName("testEndpoint"); endpoint.setSource(channel); diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/message/MessageExchangeTemplateTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/message/MessageExchangeTemplateTests.java index 45cd892c7e..5e3bba11ec 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/message/MessageExchangeTemplateTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/message/MessageExchangeTemplateTests.java @@ -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 endpoint = new DefaultEndpoint(testHandler); endpoint.setBeanName("testEndpoint"); endpoint.setSource(requestChannel); diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/router/MultiChannelRouterTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/router/MultiChannelRouterTests.java index 8d659b0f48..82898061c2 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/router/MultiChannelRouterTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/router/MultiChannelRouterTests.java @@ -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); diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/router/RecipientListRouterTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/router/RecipientListRouterTests.java index 70fef54619..d844ed495c 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/router/RecipientListRouterTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/router/RecipientListRouterTests.java @@ -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 channels = new ArrayList(); 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"}); diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/router/RouterMessageHandlerTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/router/RouterMessageHandlerTests.java index cf0130c574..003f20f457 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/router/RouterMessageHandlerTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/router/RouterMessageHandlerTests.java @@ -150,10 +150,12 @@ public class RouterMessageHandlerTests { Message fooMessage = new StringMessage("foo"); Message barMessage = new StringMessage("bar"); Message 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 fooMessage = new StringMessage("foo"); Message barMessage = new StringMessage("bar"); Message 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 fooMessage = new StringMessage("foo"); Message barMessage = new StringMessage("bar"); Message 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 fooMessage = new StringMessage("foo"); Message barMessage = new StringMessage("bar"); Message 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 fooMessage = new StringMessage("foo"); Message barMessage = new StringMessage("bar"); Message 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 fooMessage = new StringMessage("foo"); Message barMessage = new StringMessage("bar"); Message 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 fooMessage = new StringMessage("foo"); Message barMessage = new StringMessage("bar"); Message 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 fooMessage = new StringMessage("foo"); Message barMessage = new StringMessage("bar"); Message badMessage = new StringMessage("bad"); diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/router/SingleChannelRouterTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/router/SingleChannelRouterTests.java index 38ce17d08c..04e36f8c66 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/router/SingleChannelRouterTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/router/SingleChannelRouterTests.java @@ -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);