RouterEndpoint now delegates directly to a single ChannelResolver strategy. This removes the extra level of indirection that was provided by the Router interface. Also, instead of providing multiple ChannelResolver strategy interfaces, the name-resolving and single-channel implementations are now available as abstract base classes.

This commit is contained in:
Mark Fisher
2008-09-04 01:55:32 +00:00
parent b3a155de94
commit 40fc9c207d
30 changed files with 617 additions and 794 deletions

View File

@@ -34,24 +34,24 @@ import org.springframework.xml.xpath.XPathExpressionFactory;
*/
public class XPathMultiChannelNameResolverTests {
@SuppressWarnings("unchecked")
@Test
@SuppressWarnings("unchecked")
public void testSimpleSingleeAttribute() throws Exception {
Document doc = XmlTestUtil.getDocumentForString("<doc type=\"one\" />");
XPathExpression expression = XPathExpressionFactory.createXPathExpression("/doc/@type");
XPathMultiChannelNameResolver resolver = new XPathMultiChannelNameResolver(expression);
String[] channelNames = resolver.resolve(new GenericMessage(doc));
String[] channelNames = resolver.resolveChannelNames(new GenericMessage(doc));
assertEquals("Wrong number of channels returend", 1, channelNames.length);
assertEquals("Wrong channel name", "one", channelNames[0]);
}
@SuppressWarnings("unchecked")
@Test
@SuppressWarnings("unchecked")
public void testMultipleNodeValues() throws Exception {
Document doc = XmlTestUtil.getDocumentForString("<doc type=\"one\"><book>bOne</book><book>bTwo</book></doc>");
XPathExpression expression = XPathExpressionFactory.createXPathExpression("/doc/book");
XPathMultiChannelNameResolver resolver = new XPathMultiChannelNameResolver(expression);
String[] channelNames = resolver.resolve(new GenericMessage(doc));
String[] channelNames = resolver.resolveChannelNames(new GenericMessage(doc));
assertEquals("Wrong number of channels returend", 2, channelNames.length);
assertEquals("Wrong channel name", "bOne", channelNames[0]);
assertEquals("Wrong channel name", "bTwo", channelNames[1]);
@@ -61,7 +61,7 @@ public class XPathMultiChannelNameResolverTests {
public void testNonNodePayload() throws Exception {
XPathExpression expression = XPathExpressionFactory.createXPathExpression("/doc/@type");
XPathMultiChannelNameResolver resolver = new XPathMultiChannelNameResolver(expression);
resolver.resolve(new StringMessage("test"));
resolver.resolveChannelNames(new StringMessage("test"));
}
}

View File

@@ -24,7 +24,6 @@ import org.w3c.dom.Document;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.MessagingException;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.xml.router.XPathSingleChannelNameResolver;
import org.springframework.integration.xml.util.XmlTestUtil;
import org.springframework.xml.xpath.XPathExpression;
import org.springframework.xml.xpath.XPathExpressionFactory;
@@ -34,13 +33,13 @@ import org.springframework.xml.xpath.XPathExpressionFactory;
*/
public class XPathSingleChannelNameResolverTests {
@SuppressWarnings("unchecked")
@Test
@SuppressWarnings("unchecked")
public void testSimpleDocType() throws Exception {
Document doc = XmlTestUtil.getDocumentForString("<doc type=\"one\" />");
XPathExpression expression = XPathExpressionFactory.createXPathExpression("/doc/@type");
XPathSingleChannelNameResolver resolver = new XPathSingleChannelNameResolver(expression);
String channelName = resolver.resolve(new GenericMessage(doc));
String channelName = resolver.resolveChannelName(new GenericMessage(doc));
assertEquals("Wrong channel name", "one", channelName);
}
@@ -48,7 +47,7 @@ public class XPathSingleChannelNameResolverTests {
public void testNonNodePayload() throws Exception {
XPathExpression expression = XPathExpressionFactory.createXPathExpression("/doc/@type");
XPathSingleChannelNameResolver resolver = new XPathSingleChannelNameResolver(expression);
resolver.resolve(new StringMessage("test"));
resolver.resolveChannelName(new StringMessage("test"));
}
}