From df492e18fae0744b3fab57886ed3880c87755898 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Fri, 20 Dec 2013 14:07:56 -0500 Subject: [PATCH] INT-3248 Suppress HeaderChannelRegistry Warning Remove warning from BFCR if there is no HeaderChannelRegistry in the bean factory. Change the log to DEBUG and remove the stack trace. Instead, update the Exception message when a channel name can't be resolved to a channel to indicate that there is no registry. JIRA: https://jira.springsource.org/browse/INT-3248 --- .../channel/BeanFactoryChannelResolver.java | 5 +- .../registry/HeaderChannelRegistryTests.java | 60 ++++++++++++++++++- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/support/channel/BeanFactoryChannelResolver.java b/spring-integration-core/src/main/java/org/springframework/integration/support/channel/BeanFactoryChannelResolver.java index 4ebce0b8d7..91935bd058 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/support/channel/BeanFactoryChannelResolver.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/support/channel/BeanFactoryChannelResolver.java @@ -88,7 +88,7 @@ public class BeanFactoryChannelResolver implements DestinationResolver(){ + + @Override + public Object answer(InvocationOnMock invocation) throws Throwable { + throw new NoSuchBeanDefinitionException("bar"); + } + }).when(beanFactory).getBean("foo", MessageChannel.class); + resolver.setBeanFactory(beanFactory); + try { + resolver.resolveDestination("foo"); + fail("Expected exception"); + } + catch (DestinationResolutionException e){ + assertThat(e.getMessage(), + Matchers.equalTo("failed to look up MessageChannel with name 'foo' in the BeanFactory.")); + } + } + + @Test + public void testBFCRNoRegistry() { + BeanFactoryChannelResolver resolver = new BeanFactoryChannelResolver(); + BeanFactory beanFactory = mock(BeanFactory.class); + doAnswer(new Answer(){ + + @Override + public Object answer(InvocationOnMock invocation) throws Throwable { + throw new NoSuchBeanDefinitionException("bar"); + } + }).when(beanFactory).getBean("foo", MessageChannel.class); + resolver.setBeanFactory(beanFactory); + try { + resolver.resolveDestination("foo"); + fail("Expected exception"); + } + catch (DestinationResolutionException e){ + assertThat(e.getMessage(), + Matchers.equalTo("failed to look up MessageChannel with name 'foo' in the BeanFactory (and there is no HeaderChannelRegistry present).")); + } + } + public static class Foo extends AbstractReplyProducingMessageHandler { @Override