use of org.springframework.integration.router.AbstractMappingMessageRouter in project spring-integration by spring-projects.
the class XPathRouterParserTests method testWithDynamicChanges.
@Test
public void testWithDynamicChanges() throws Exception {
ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("XPathRouterTests-context.xml", this.getClass());
MessageChannel inputChannel = ac.getBean("xpathRouterEmptyChannel", MessageChannel.class);
PollableChannel channelA = ac.getBean("channelA", PollableChannel.class);
PollableChannel channelB = ac.getBean("channelB", PollableChannel.class);
Document doc = XmlTestUtil.getDocumentForString("<name>channelA</name>");
GenericMessage<Document> docMessage = new GenericMessage<Document>(doc);
inputChannel.send(docMessage);
assertNotNull(channelA.receive(10));
assertNull(channelB.receive(10));
EventDrivenConsumer routerEndpoint = ac.getBean("xpathRouterEmpty", EventDrivenConsumer.class);
AbstractMappingMessageRouter xpathRouter = (AbstractMappingMessageRouter) TestUtils.getPropertyValue(routerEndpoint, "handler");
xpathRouter.setChannelMapping("channelA", "channelB");
inputChannel.send(docMessage);
assertNotNull(channelB.receive(10));
assertNull(channelA.receive(10));
ac.close();
}
use of org.springframework.integration.router.AbstractMappingMessageRouter in project spring-integration by spring-projects.
the class XPathRouterParserTests method testWithDynamicChangesWithExistingMappingsAndMultiChannel.
@Test
public void testWithDynamicChangesWithExistingMappingsAndMultiChannel() throws Exception {
ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("XPathRouterTests-context.xml", this.getClass());
MessageChannel inputChannel = ac.getBean("multiChannelRouterChannel", MessageChannel.class);
PollableChannel channelA = ac.getBean("channelA", PollableChannel.class);
PollableChannel channelB = ac.getBean("channelB", PollableChannel.class);
Document doc = XmlTestUtil.getDocumentForString("<root><name>channelA</name><name>channelB</name></root>");
GenericMessage<Document> docMessage = new GenericMessage<Document>(doc);
inputChannel.send(docMessage);
assertNotNull(channelA.receive(10));
assertNotNull(channelA.receive(10));
assertNull(channelB.receive(10));
EventDrivenConsumer routerEndpoint = ac.getBean("xpathRouterWithMappingMultiChannel", EventDrivenConsumer.class);
AbstractMappingMessageRouter xpathRouter = (AbstractMappingMessageRouter) TestUtils.getPropertyValue(routerEndpoint, "handler");
xpathRouter.removeChannelMapping("channelA");
xpathRouter.removeChannelMapping("channelB");
inputChannel.send(docMessage);
assertNotNull(channelA.receive(10));
assertNotNull(channelB.receive(10));
ac.close();
}
use of org.springframework.integration.router.AbstractMappingMessageRouter in project spring-integration by spring-projects.
the class XPathRouterParserTests method testWithDynamicChangesWithExistingMappings.
@Test
public void testWithDynamicChangesWithExistingMappings() throws Exception {
ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("XPathRouterTests-context.xml", this.getClass());
MessageChannel inputChannel = ac.getBean("xpathRouterWithMappingChannel", MessageChannel.class);
PollableChannel channelA = ac.getBean("channelA", PollableChannel.class);
PollableChannel channelB = ac.getBean("channelB", PollableChannel.class);
Document doc = XmlTestUtil.getDocumentForString("<name>channelA</name>");
GenericMessage<Document> docMessage = new GenericMessage<Document>(doc);
inputChannel.send(docMessage);
assertNull(channelA.receive(10));
assertNotNull(channelB.receive(10));
EventDrivenConsumer routerEndpoint = ac.getBean("xpathRouterWithMapping", EventDrivenConsumer.class);
AbstractMappingMessageRouter xpathRouter = (AbstractMappingMessageRouter) TestUtils.getPropertyValue(routerEndpoint, "handler");
xpathRouter.removeChannelMapping("channelA");
inputChannel.send(docMessage);
assertNotNull(channelA.receive(10));
assertNull(channelB.receive(10));
ac.close();
}
Aggregations