diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractExecutorChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractExecutorChannel.java index 6765dc17c8..42d3f60f22 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractExecutorChannel.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/AbstractExecutorChannel.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 the original author or authors. + * Copyright 2015-2017 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. @@ -23,6 +23,7 @@ import java.util.List; import java.util.concurrent.Executor; import org.springframework.integration.dispatcher.AbstractDispatcher; +import org.springframework.integration.support.MessagingExceptionWrapper; import org.springframework.messaging.Message; import org.springframework.messaging.MessageDeliveryException; import org.springframework.messaging.MessageHandler; @@ -43,6 +44,7 @@ import org.springframework.util.CollectionUtils; * is handed to the {@link Executor#execute(Runnable)}. * * @author Artem Bilan + * @author Gary Russell * @see ExecutorChannel * @see PublishSubscribeChannel * @since 4.2 @@ -154,7 +156,7 @@ public abstract class AbstractExecutorChannel extends AbstractSubscribableChanne triggerAfterMessageHandled(message, ex, interceptorStack); } if (ex instanceof MessagingException) { - throw (MessagingException) ex; + throw new MessagingExceptionWrapper(message, (MessagingException) ex); } String description = "Failed to handle " + message + " to " + this + " in " + messageHandler; throw new MessageDeliveryException(message, description, ex); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/MessagePublishingErrorHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/MessagePublishingErrorHandler.java index 9ba55c2cfa..9b9d049af8 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/MessagePublishingErrorHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/MessagePublishingErrorHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,13 +16,10 @@ package org.springframework.integration.channel; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import org.springframework.beans.factory.BeanFactory; -import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.integration.context.IntegrationContextUtils; -import org.springframework.integration.support.channel.BeanFactoryChannelResolver; +import org.springframework.integration.support.ErrorMessagePublisher; +import org.springframework.integration.support.ErrorMessageStrategy; +import org.springframework.integration.support.MessagingExceptionWrapper; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; import org.springframework.messaging.MessagingException; @@ -41,30 +38,32 @@ import org.springframework.util.ErrorHandler; * @author Gary Russell * @author Artem Bilan */ -public class MessagePublishingErrorHandler implements ErrorHandler, BeanFactoryAware { +public class MessagePublishingErrorHandler extends ErrorMessagePublisher implements ErrorHandler { - private final Log logger = LogFactory.getLog(this.getClass()); - - private volatile DestinationResolver channelResolver; - - private volatile MessageChannel defaultErrorChannel; - - private volatile String defaultErrorChannelName; - - private volatile long sendTimeout = 1000; + private static final int DEFAULT_SEND_TIMEOUT = 1000; + private static final ErrorMessageStrategy DEFAULT_ERROR_MESSAGE_STRATEGY = (t, a) -> { + if (t instanceof MessagingExceptionWrapper) { + return new ErrorMessage(t.getCause(), ((MessagingExceptionWrapper) t).getFailedMessage()); + } + else { + return new ErrorMessage(t); + } + }; public MessagePublishingErrorHandler() { + setErrorMessageStrategy(DEFAULT_ERROR_MESSAGE_STRATEGY); + setSendTimeout(DEFAULT_SEND_TIMEOUT); } public MessagePublishingErrorHandler(DestinationResolver channelResolver) { - Assert.notNull(channelResolver, "channelResolver must not be null"); - this.channelResolver = channelResolver; + this(); + setChannelResolver(channelResolver); } public void setDefaultErrorChannel(MessageChannel defaultErrorChannel) { - this.defaultErrorChannel = defaultErrorChannel; + setChannel(defaultErrorChannel); } /** @@ -73,14 +72,7 @@ public class MessagePublishingErrorHandler implements ErrorHandler, BeanFactoryA * @since 4.3 */ public MessageChannel getDefaultErrorChannel() { - String defaultErrorChannelName = this.defaultErrorChannelName; - if (defaultErrorChannelName != null) { - if (this.channelResolver != null) { - this.defaultErrorChannel = this.channelResolver.resolveDestination(defaultErrorChannelName); - this.defaultErrorChannelName = null; - } - } - return this.defaultErrorChannel; + return getChannel(); } /** @@ -89,19 +81,7 @@ public class MessagePublishingErrorHandler implements ErrorHandler, BeanFactoryA * @since 4.3.3 */ public void setDefaultErrorChannelName(String defaultErrorChannelName) { - this.defaultErrorChannelName = defaultErrorChannelName; - } - - public void setSendTimeout(long sendTimeout) { - this.sendTimeout = sendTimeout; - } - - @Override - public void setBeanFactory(BeanFactory beanFactory) { - Assert.notNull(beanFactory, "beanFactory must not be null"); - if (this.channelResolver == null) { - this.channelResolver = new BeanFactoryChannelResolver(beanFactory); - } + setChannelName(defaultErrorChannelName); } @Override @@ -110,12 +90,8 @@ public class MessagePublishingErrorHandler implements ErrorHandler, BeanFactoryA boolean sent = false; if (errorChannel != null) { try { - if (this.sendTimeout >= 0) { - sent = errorChannel.send(new ErrorMessage(t), this.sendTimeout); - } - else { - sent = errorChannel.send(new ErrorMessage(t)); - } + getMessagingTemplate().send(errorChannel, getErrorMessageStrategy().buildErrorMessage(t, null)); + sent = true; } catch (Throwable errorDeliveryError) { //NOSONAR // message will be logged only @@ -140,15 +116,19 @@ public class MessagePublishingErrorHandler implements ErrorHandler, BeanFactoryA } private MessageChannel resolveErrorChannel(Throwable t) { - Message failedMessage = (t instanceof MessagingException) ? - ((MessagingException) t).getFailedMessage() : null; - if (getDefaultErrorChannel() == null && this.channelResolver != null) { - this.defaultErrorChannel = this.channelResolver.resolveDestination( - IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME); + Throwable actualThrowable = t; + if (t instanceof MessagingExceptionWrapper) { + actualThrowable = t.getCause(); + } + Message failedMessage = (actualThrowable instanceof MessagingException) ? + ((MessagingException) actualThrowable).getFailedMessage() : null; + if (getDefaultErrorChannel() == null && getChannelResolver() != null) { + setChannel(getChannelResolver().resolveDestination( + IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME)); } if (failedMessage == null || failedMessage.getHeaders().getErrorChannel() == null) { - return this.defaultErrorChannel; + return getDefaultErrorChannel(); } Object errorChannelHeader = failedMessage.getHeaders().getErrorChannel(); if (errorChannelHeader instanceof MessageChannel) { @@ -157,7 +137,7 @@ public class MessagePublishingErrorHandler implements ErrorHandler, BeanFactoryA Assert.isInstanceOf(String.class, errorChannelHeader, "Unsupported error channel header type. Expected MessageChannel or String, but actual type is [" + errorChannelHeader.getClass() + "]"); - return this.channelResolver.resolveDestination((String) errorChannelHeader); + return getChannelResolver().resolveDestination((String) errorChannelHeader); } } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java index ff4ef1ebe6..64ed69306e 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/endpoint/AbstractPollingEndpoint.java @@ -29,6 +29,7 @@ import org.springframework.aop.framework.ProxyFactory; import org.springframework.beans.factory.BeanClassLoaderAware; import org.springframework.core.task.SyncTaskExecutor; import org.springframework.integration.channel.MessagePublishingErrorHandler; +import org.springframework.integration.support.MessagingExceptionWrapper; import org.springframework.integration.support.channel.BeanFactoryChannelResolver; import org.springframework.integration.transaction.ExpressionEvaluatingTransactionSynchronizationProcessor; import org.springframework.integration.transaction.IntegrationResourceHolder; @@ -266,7 +267,17 @@ public abstract class AbstractPollingEndpoint extends AbstractEndpoint implement if (holder != null) { holder.setMessage(message); } - this.handleMessage(message); + try { + this.handleMessage(message); + } + catch (Exception e) { + if (e instanceof MessagingException) { + throw new MessagingExceptionWrapper(message, (MessagingException) e); + } + else { + throw new MessagingException(message, e); + } + } result = true; } return result; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/ErrorMessagePublisher.java b/spring-integration-core/src/main/java/org/springframework/integration/support/ErrorMessagePublisher.java index 44d1b2c267..cd4b677343 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/ErrorMessagePublisher.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/ErrorMessagePublisher.java @@ -81,11 +81,12 @@ public class ErrorMessagePublisher implements BeanFactoryAware { return this.channel; } - public void setSendTimeout(long sendTimeout) { + public final void setSendTimeout(long sendTimeout) { this.messagingTemplate.setSendTimeout(sendTimeout); } - public void setChannelResolver(DestinationResolver channelResolver) { + public final void setChannelResolver(DestinationResolver channelResolver) { + Assert.notNull(channelResolver, "channelResolver must not be null"); this.channelResolver = channelResolver; } @@ -97,6 +98,14 @@ public class ErrorMessagePublisher implements BeanFactoryAware { } } + protected MessagingTemplate getMessagingTemplate() { + return this.messagingTemplate; + } + + protected DestinationResolver getChannelResolver() { + return this.channelResolver; + } + /** * Publish an error message for the supplied exception. * @param exception the exception. diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/MessagingExceptionWrapper.java b/spring-integration-core/src/main/java/org/springframework/integration/support/MessagingExceptionWrapper.java new file mode 100644 index 0000000000..93cacff7ca --- /dev/null +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/MessagingExceptionWrapper.java @@ -0,0 +1,43 @@ +/* + * Copyright 2017 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.support; + +import org.springframework.messaging.Message; +import org.springframework.messaging.MessagingException; + +/** + * A wrapper exception for a {@link MessagingException} used to convey the cause and + * original message to a + * {@link org.springframework.integration.channel.MessagePublishingErrorHandler}. + * The original message is in this exception's {@link #getFailedMessage() failedMessage} + * property. + *

Intended for internal framework use only. Error handlers will typically unwrap + * the cause while creating an error message. + * + * @author Gary Russell + * @since 5.0 + * + */ +public class MessagingExceptionWrapper extends MessagingException { + + private static final long serialVersionUID = 1L; + + public MessagingExceptionWrapper(Message originalMessage, MessagingException cause) { + super(originalMessage, cause); + } + +} diff --git a/spring-integration-core/src/test/java/org/springframework/integration/channel/registry/HeaderChannelRegistryTests.java b/spring-integration-core/src/test/java/org/springframework/integration/channel/registry/HeaderChannelRegistryTests.java index 005cf3cce4..1d9126d097 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/channel/registry/HeaderChannelRegistryTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/channel/registry/HeaderChannelRegistryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2016 the original author or authors. + * Copyright 2013-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package org.springframework.integration.channel.registry; +import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.instanceOf; @@ -48,6 +49,7 @@ import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.core.MessagingTemplate; import org.springframework.integration.handler.AbstractReplyProducingMessageHandler; import org.springframework.integration.support.MessageBuilder; +import org.springframework.integration.support.MessagingExceptionWrapper; import org.springframework.integration.support.channel.BeanFactoryChannelResolver; import org.springframework.integration.support.channel.HeaderChannelRegistry; import org.springframework.integration.test.util.TestUtils; @@ -177,6 +179,8 @@ public class HeaderChannelRegistryTests { Message reply = template.sendAndReceive(new GenericMessage("bar")); assertNotNull(reply); assertTrue(reply instanceof ErrorMessage); + assertNotNull(((ErrorMessage) reply).getOriginalMessage()); + assertThat(reply.getPayload(), not(instanceOf(MessagingExceptionWrapper.class))); } @Test diff --git a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DefaultConfiguringBeanFactoryPostProcessorTests.java b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DefaultConfiguringBeanFactoryPostProcessorTests.java index 9b6770b513..baaae6e915 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DefaultConfiguringBeanFactoryPostProcessorTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/config/xml/DefaultConfiguringBeanFactoryPostProcessorTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -71,10 +71,12 @@ public class DefaultConfiguringBeanFactoryPostProcessorTests { assertEquals(ThreadPoolTaskScheduler.class, taskScheduler.getClass()); ErrorHandler errorHandler = TestUtils.getPropertyValue(taskScheduler, "errorHandler", ErrorHandler.class); assertEquals(MessagePublishingErrorHandler.class, errorHandler.getClass()); - MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, + "messagingTemplate.defaultDestination", MessageChannel.class); assertNull(defaultErrorChannel); errorHandler.handleError(new Throwable()); - defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "messagingTemplate.defaultDestination", + MessageChannel.class); assertNotNull(defaultErrorChannel); assertEquals(context.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME), defaultErrorChannel); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollingConsumerEndpointTests.java b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollingConsumerEndpointTests.java index 73019d3932..4c1bde8314 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollingConsumerEndpointTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/endpoint/PollingConsumerEndpointTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 the original author or authors. + * Copyright 2002-2017 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. @@ -32,6 +32,7 @@ import org.mockito.Mockito; import org.springframework.beans.factory.BeanFactory; import org.springframework.integration.MessageRejectedException; +import org.springframework.integration.support.MessagingExceptionWrapper; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandler; import org.springframework.messaging.PollableChannel; @@ -243,6 +244,9 @@ public class PollingConsumerEndpointTests { } public void throwLastErrorIfAvailable() throws Throwable { + if (this.lastError instanceof MessagingExceptionWrapper) { + this.lastError = this.lastError.getCause(); + } Throwable t = this.lastError; this.lastError = null; throw t; diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/config/DefaultConfigurationTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/config/DefaultConfigurationTests.java index 21c4734522..3372bcd044 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/config/DefaultConfigurationTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/config/DefaultConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2017 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. @@ -39,6 +39,7 @@ import org.springframework.util.ErrorHandler; /** * @author Mark Fisher * @author Artem Bilan + * @author Gary Russell * @since 1.0.3 */ @RunWith(SpringJUnit4ClassRunner.class) @@ -69,10 +70,12 @@ public class DefaultConfigurationTests { assertEquals(ThreadPoolTaskScheduler.class, taskScheduler.getClass()); ErrorHandler errorHandler = TestUtils.getPropertyValue(taskScheduler, "errorHandler", ErrorHandler.class); assertEquals(MessagePublishingErrorHandler.class, errorHandler.getClass()); - MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, + "messagingTemplate.defaultDestination", MessageChannel.class); assertNull(defaultErrorChannel); errorHandler.handleError(new Throwable()); - defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "messagingTemplate.defaultDestination", + MessageChannel.class); assertNotNull(defaultErrorChannel); assertEquals(context.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME), defaultErrorChannel); } diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/config/DefaultConfigurationTests.java b/spring-integration-http/src/test/java/org/springframework/integration/http/config/DefaultConfigurationTests.java index bf2284963b..de31eafe8d 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/config/DefaultConfigurationTests.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/config/DefaultConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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. @@ -39,6 +39,7 @@ import org.springframework.util.ErrorHandler; /** * @author Mark Fisher * @author Artem Bilan + * @author Gary Russell * @since 1.0.3 */ @RunWith(SpringJUnit4ClassRunner.class) @@ -69,10 +70,12 @@ public class DefaultConfigurationTests { assertEquals(ThreadPoolTaskScheduler.class, taskScheduler.getClass()); ErrorHandler errorHandler = TestUtils.getPropertyValue(taskScheduler, "errorHandler", ErrorHandler.class); assertEquals(MessagePublishingErrorHandler.class, errorHandler.getClass()); - MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, + "messagingTemplate.defaultDestination", MessageChannel.class); assertNull(defaultErrorChannel); errorHandler.handleError(new Throwable()); - defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "messagingTemplate.defaultDestination", + MessageChannel.class); assertNotNull(defaultErrorChannel); assertEquals(context.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME), defaultErrorChannel); } diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/config/DefaultConfigurationTests.java b/spring-integration-jms/src/test/java/org/springframework/integration/jms/config/DefaultConfigurationTests.java index ee537a09df..6eff4b665a 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/config/DefaultConfigurationTests.java +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/config/DefaultConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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. @@ -71,10 +71,12 @@ public class DefaultConfigurationTests { assertEquals(ThreadPoolTaskScheduler.class, taskScheduler.getClass()); ErrorHandler errorHandler = TestUtils.getPropertyValue(taskScheduler, "errorHandler", ErrorHandler.class); assertEquals(MessagePublishingErrorHandler.class, errorHandler.getClass()); - MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, + "messagingTemplate.defaultDestination", MessageChannel.class); assertNull(defaultErrorChannel); errorHandler.handleError(new Throwable()); - defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "messagingTemplate.defaultDestination", + MessageChannel.class); assertNotNull(defaultErrorChannel); assertEquals(context.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME), defaultErrorChannel); } diff --git a/spring-integration-mail/src/test/java/org/springframework/integration/mail/config/DefaultConfigurationTests.java b/spring-integration-mail/src/test/java/org/springframework/integration/mail/config/DefaultConfigurationTests.java index e2d24a8d41..25b8a3b789 100644 --- a/spring-integration-mail/src/test/java/org/springframework/integration/mail/config/DefaultConfigurationTests.java +++ b/spring-integration-mail/src/test/java/org/springframework/integration/mail/config/DefaultConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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. @@ -39,6 +39,7 @@ import org.springframework.util.ErrorHandler; /** * @author Mark Fisher * @author Artem Bilan + * @author Gary Russell * @since 1.0.3 */ @RunWith(SpringJUnit4ClassRunner.class) @@ -69,10 +70,12 @@ public class DefaultConfigurationTests { assertEquals(ThreadPoolTaskScheduler.class, taskScheduler.getClass()); ErrorHandler errorHandler = TestUtils.getPropertyValue(taskScheduler, "errorHandler", ErrorHandler.class); assertEquals(MessagePublishingErrorHandler.class, errorHandler.getClass()); - MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, + "messagingTemplate.defaultDestination", MessageChannel.class); assertNull(defaultErrorChannel); errorHandler.handleError(new Throwable()); - defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "messagingTemplate.defaultDestination", + MessageChannel.class); assertNotNull(defaultErrorChannel); assertEquals(context.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME), defaultErrorChannel); } diff --git a/spring-integration-rmi/src/test/java/org/springframework/integration/rmi/config/DefaultConfigurationTests.java b/spring-integration-rmi/src/test/java/org/springframework/integration/rmi/config/DefaultConfigurationTests.java index ff22b8af97..70ea37a6d4 100644 --- a/spring-integration-rmi/src/test/java/org/springframework/integration/rmi/config/DefaultConfigurationTests.java +++ b/spring-integration-rmi/src/test/java/org/springframework/integration/rmi/config/DefaultConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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. @@ -39,6 +39,7 @@ import org.springframework.util.ErrorHandler; /** * @author Mark Fisher * @author Artem Bilan + * @author Gary Russell * @since 1.0.3 */ @RunWith(SpringJUnit4ClassRunner.class) @@ -69,10 +70,12 @@ public class DefaultConfigurationTests { assertEquals(ThreadPoolTaskScheduler.class, taskScheduler.getClass()); ErrorHandler errorHandler = TestUtils.getPropertyValue(taskScheduler, "errorHandler", ErrorHandler.class); assertEquals(MessagePublishingErrorHandler.class, errorHandler.getClass()); - MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, + "messagingTemplate.defaultDestination", MessageChannel.class); assertNull(defaultErrorChannel); errorHandler.handleError(new Throwable()); - defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "messagingTemplate.defaultDestination", + MessageChannel.class); assertNotNull(defaultErrorChannel); assertEquals(context.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME), defaultErrorChannel); } diff --git a/spring-integration-security/src/test/java/org/springframework/integration/security/config/DefaultConfigurationTests.java b/spring-integration-security/src/test/java/org/springframework/integration/security/config/DefaultConfigurationTests.java index 91dfc02e23..983e0f51a8 100644 --- a/spring-integration-security/src/test/java/org/springframework/integration/security/config/DefaultConfigurationTests.java +++ b/spring-integration-security/src/test/java/org/springframework/integration/security/config/DefaultConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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. @@ -39,6 +39,7 @@ import org.springframework.util.ErrorHandler; /** * @author Mark Fisher * @author Artem Bilan + * @author Gary Russell * @since 1.0.3 */ @RunWith(SpringJUnit4ClassRunner.class) @@ -69,10 +70,12 @@ public class DefaultConfigurationTests { assertEquals(ThreadPoolTaskScheduler.class, taskScheduler.getClass()); ErrorHandler errorHandler = TestUtils.getPropertyValue(taskScheduler, "errorHandler", ErrorHandler.class); assertEquals(MessagePublishingErrorHandler.class, errorHandler.getClass()); - MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, + "messagingTemplate.defaultDestination", MessageChannel.class); assertNull(defaultErrorChannel); errorHandler.handleError(new Throwable()); - defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "messagingTemplate.defaultDestination", + MessageChannel.class); assertNotNull(defaultErrorChannel); assertEquals(context.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME), defaultErrorChannel); } diff --git a/spring-integration-stream/src/test/java/org/springframework/integration/stream/config/DefaultConfigurationTests.java b/spring-integration-stream/src/test/java/org/springframework/integration/stream/config/DefaultConfigurationTests.java index 47c54b3bbb..8353024cee 100644 --- a/spring-integration-stream/src/test/java/org/springframework/integration/stream/config/DefaultConfigurationTests.java +++ b/spring-integration-stream/src/test/java/org/springframework/integration/stream/config/DefaultConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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. @@ -39,6 +39,7 @@ import org.springframework.util.ErrorHandler; /** * @author Mark Fisher * @author Artem Bilan + * @author Gary Russell * @since 1.0.3 */ @RunWith(SpringJUnit4ClassRunner.class) @@ -69,10 +70,12 @@ public class DefaultConfigurationTests { assertEquals(ThreadPoolTaskScheduler.class, taskScheduler.getClass()); ErrorHandler errorHandler = TestUtils.getPropertyValue(taskScheduler, "errorHandler", ErrorHandler.class); assertEquals(MessagePublishingErrorHandler.class, errorHandler.getClass()); - MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, + "messagingTemplate.defaultDestination", MessageChannel.class); assertNull(defaultErrorChannel); errorHandler.handleError(new Throwable()); - defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "messagingTemplate.defaultDestination", + MessageChannel.class); assertNotNull(defaultErrorChannel); assertEquals(context.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME), defaultErrorChannel); } diff --git a/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/DefaultConfigurationTests.java b/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/DefaultConfigurationTests.java index 4b88b565bd..b97b841bf2 100644 --- a/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/DefaultConfigurationTests.java +++ b/spring-integration-ws/src/test/java/org/springframework/integration/ws/config/DefaultConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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. @@ -39,6 +39,7 @@ import org.springframework.util.ErrorHandler; /** * @author Mark Fisher * @author Artem Bilan + * @author Gary Russell * @since 1.0.3 */ @RunWith(SpringJUnit4ClassRunner.class) @@ -69,10 +70,12 @@ public class DefaultConfigurationTests { assertEquals(ThreadPoolTaskScheduler.class, taskScheduler.getClass()); ErrorHandler errorHandler = TestUtils.getPropertyValue(taskScheduler, "errorHandler", ErrorHandler.class); assertEquals(MessagePublishingErrorHandler.class, errorHandler.getClass()); - MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, + "messagingTemplate.defaultDestination", MessageChannel.class); assertNull(defaultErrorChannel); errorHandler.handleError(new Throwable()); - defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "messagingTemplate.defaultDestination", + MessageChannel.class); assertNotNull(defaultErrorChannel); assertEquals(context.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME), defaultErrorChannel); } diff --git a/spring-integration-xml/src/test/java/org/springframework/integration/xml/config/DefaultConfigurationTests.java b/spring-integration-xml/src/test/java/org/springframework/integration/xml/config/DefaultConfigurationTests.java index 1f9434e5f6..2dab9a0257 100644 --- a/spring-integration-xml/src/test/java/org/springframework/integration/xml/config/DefaultConfigurationTests.java +++ b/spring-integration-xml/src/test/java/org/springframework/integration/xml/config/DefaultConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2017 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. @@ -39,6 +39,7 @@ import org.springframework.util.ErrorHandler; /** * @author Mark Fisher * @author Artem Bilan + * @author Gary Russell * @since 1.0.3 */ @RunWith(SpringJUnit4ClassRunner.class) @@ -69,10 +70,12 @@ public class DefaultConfigurationTests { assertEquals(ThreadPoolTaskScheduler.class, taskScheduler.getClass()); ErrorHandler errorHandler = TestUtils.getPropertyValue(taskScheduler, "errorHandler", ErrorHandler.class); assertEquals(MessagePublishingErrorHandler.class, errorHandler.getClass()); - MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + MessageChannel defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, + "messagingTemplate.defaultDestination", MessageChannel.class); assertNull(defaultErrorChannel); errorHandler.handleError(new Throwable()); - defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "defaultErrorChannel", MessageChannel.class); + defaultErrorChannel = TestUtils.getPropertyValue(errorHandler, "messagingTemplate.defaultDestination", + MessageChannel.class); assertNotNull(defaultErrorChannel); assertEquals(context.getBean(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME), defaultErrorChannel); }