use of org.springframework.integration.support.channel.BeanFactoryChannelResolver in project spring-integration by spring-projects.
the class ChannelAdapterParserTests method expressionConsumer.
@Test
public /**
* @since 2.1
*/
void expressionConsumer() {
String beanName = "expressionConsumer";
Object channel = this.applicationContext.getBean(beanName);
assertTrue(channel instanceof DirectChannel);
BeanFactoryChannelResolver channelResolver = new BeanFactoryChannelResolver(this.applicationContext);
assertNotNull(channelResolver.resolveDestination(beanName));
Object adapter = this.applicationContext.getBean(beanName + ".adapter");
assertNotNull(adapter);
assertTrue(adapter instanceof EventDrivenConsumer);
TestBean testBean = (TestBean) this.applicationContext.getBean("testBean");
assertNull(testBean.getMessage());
Message<?> message = new GenericMessage<String>("consumer test expression");
assertTrue(((MessageChannel) channel).send(message));
assertNotNull(testBean.getMessage());
assertEquals("consumer test expression", testBean.getMessage());
}
use of org.springframework.integration.support.channel.BeanFactoryChannelResolver in project spring-integration by spring-projects.
the class ChannelAdapterParserTests method methodInvokingSourceAdapterIsNotChannel.
@Test(expected = DestinationResolutionException.class)
public void methodInvokingSourceAdapterIsNotChannel() {
BeanFactoryChannelResolver channelResolver = new BeanFactoryChannelResolver(this.applicationContext);
channelResolver.resolveDestination("methodInvokingSource");
}
use of org.springframework.integration.support.channel.BeanFactoryChannelResolver in project spring-integration by spring-projects.
the class HeaderChannelRegistryTests method testBFCRNoRegistry.
@Test
public void testBFCRNoRegistry() {
BeanFactoryChannelResolver resolver = new BeanFactoryChannelResolver();
BeanFactory beanFactory = mock(BeanFactory.class);
doAnswer(invocation -> {
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.containsString("failed to look up MessageChannel with name 'foo' in the BeanFactory " + "(and there is no HeaderChannelRegistry present)."));
}
}
use of org.springframework.integration.support.channel.BeanFactoryChannelResolver in project spring-integration by spring-projects.
the class HeaderChannelRegistryTests method testBFCRWithRegistry.
@Test
public void testBFCRWithRegistry() {
BeanFactoryChannelResolver resolver = new BeanFactoryChannelResolver();
BeanFactory beanFactory = mock(BeanFactory.class);
when(beanFactory.getBean(IntegrationContextUtils.INTEGRATION_HEADER_CHANNEL_REGISTRY_BEAN_NAME, HeaderChannelRegistry.class)).thenReturn(mock(HeaderChannelRegistry.class));
doAnswer(invocation -> {
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.containsString("failed to look up MessageChannel with name 'foo' in the BeanFactory."));
}
}
use of org.springframework.integration.support.channel.BeanFactoryChannelResolver in project spring-integration by spring-projects.
the class MessageBusParserTests method testDefaultErrorChannel.
@Test
public void testDefaultErrorChannel() {
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("messageBusWithDefaults.xml", this.getClass());
BeanFactoryChannelResolver resolver = new BeanFactoryChannelResolver(context);
assertEquals(context.getBean("errorChannel"), resolver.resolveDestination("errorChannel"));
context.close();
}
Aggregations