diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/SourceEndpoint.java b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/SourceEndpoint.java deleted file mode 100644 index d6e5a34eb3..0000000000 --- a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/SourceEndpoint.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.integration.endpoint; - -import org.springframework.integration.ConfigurationException; -import org.springframework.integration.channel.MessageChannel; -import org.springframework.integration.message.MessageSource; -import org.springframework.util.Assert; - -/** - * A channel adapter that retrieves messages from a {@link MessageSource} - * and then sends the resulting messages to the provided {@link MessageChannel}. - * - * @author Mark Fisher - */ -public class SourceEndpoint extends AbstractEndpoint { - - public SourceEndpoint(MessageSource source) { - Assert.notNull(source, "source must not be null"); - this.setSource(source); - } - - - @Override - public void initialize() { - if (this.getTarget() == null) { - throw new ConfigurationException( - "no output has been configured for source endpoint '" + this.getName() + "'"); - } - } - -} diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/message/MessageExchangeTemplate.java b/org.springframework.integration/src/main/java/org/springframework/integration/message/MessageExchangeTemplate.java index 80c4a253fd..0938ea8eea 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/message/MessageExchangeTemplate.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/message/MessageExchangeTemplate.java @@ -223,11 +223,11 @@ public class MessageExchangeTemplate implements InitializingBean { } private boolean doReceiveAndForward(PollableSource source, MessageTarget target) { - Message message = this.doReceive(source); - if (message == null) { - return false; - } try { + Message message = this.doReceive(source); + if (message == null) { + return false; + } boolean sent = this.doSend(message, target); if (source instanceof MessageDeliveryAware) { if (sent) { 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 311736ab3d..ce61a3a9df 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 @@ -30,18 +30,18 @@ import org.springframework.beans.factory.BeanCreationException; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.integration.channel.MessageChannel; import org.springframework.integration.channel.PollableChannel; +import org.springframework.integration.channel.PollableChannelAdapter; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.dispatcher.PublishSubscribeChannel; -import org.springframework.integration.endpoint.SourceEndpoint; +import org.springframework.integration.endpoint.HandlerEndpoint; import org.springframework.integration.handler.MessageHandler; import org.springframework.integration.message.ErrorMessage; import org.springframework.integration.message.GenericMessage; import org.springframework.integration.message.Message; import org.springframework.integration.message.MessageBuilder; -import org.springframework.integration.message.MessageSource; +import org.springframework.integration.message.MessagingException; import org.springframework.integration.message.PollableSource; import org.springframework.integration.message.StringMessage; -import org.springframework.integration.scheduling.PollingSchedule; /** * @author Mark Fisher @@ -193,18 +193,26 @@ public class DefaultMessageBusTests { public void testErrorChannelWithFailedDispatch() throws InterruptedException { MessageBus bus = new DefaultMessageBus(); CountDownLatch latch = new CountDownLatch(1); - SourceEndpoint sourceEndpoint = new SourceEndpoint(new FailingSource(latch)); - sourceEndpoint.setTarget(new QueueChannel()); - sourceEndpoint.setSchedule(new PollingSchedule(1000)); - sourceEndpoint.setName("testEndpoint"); - bus.registerEndpoint(sourceEndpoint); + PollableChannelAdapter channelAdapter = new PollableChannelAdapter( + "testChannel", new FailingSource(latch), null); + MessageHandler handler = new MessageHandler() { + public Message handle(Message message) { + return message; + } + }; + HandlerEndpoint endpoint = new HandlerEndpoint(handler); + endpoint.setName("testEndpoint"); + endpoint.setSource(channelAdapter); + bus.registerEndpoint(endpoint); bus.start(); latch.await(2000, TimeUnit.MILLISECONDS); Message message = ((PollableChannel) bus.getErrorChannel()).receive(5000); + bus.stop(); assertNotNull("message should not be null", message); assertTrue(message instanceof ErrorMessage); - assertEquals("intentional test failure", ((ErrorMessage) message).getPayload().getMessage()); - bus.stop(); + Throwable exception = ((ErrorMessage) message).getPayload(); + assertTrue(exception instanceof MessagingException); + assertEquals("intentional test failure", exception.getCause().getMessage()); } @Test(expected = BeanCreationException.class)