INT-461: changed the order in which the constructor arguments for the *XPathMessageSelector are provided (to match the actual constructor), the current constructor resolution on bean creation is ambiguous.
This commit is contained in:
@@ -16,18 +16,18 @@
|
||||
|
||||
package org.springframework.integration.xml.config;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.integration.xml.selector.BooleanTestXPathMessageSelector;
|
||||
import org.springframework.integration.xml.selector.StringValueTestXPathMessageSelector;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
/**
|
||||
* @author Jonas Partner
|
||||
*/
|
||||
@@ -57,6 +57,13 @@ public class XPathSelectorParser extends AbstractSingleBeanDefinitionParser {
|
||||
boolean xPathReferencePresent = StringUtils.hasText(xPathExpressionRef);
|
||||
Assert.isTrue(xPathExpressionChildPresent ^ xPathReferencePresent,
|
||||
"Exactly one of 'xpath-expression' or 'xpath-expression-ref' is required.");
|
||||
if (xPathExpressionChildPresent) {
|
||||
BeanDefinition beanDefinition = xpathParser.parse((Element) xPathExpressionNodes.item(0), parserContext);
|
||||
builder.addConstructorArgValue(beanDefinition);
|
||||
}
|
||||
else {
|
||||
builder.addConstructorArgReference(xPathExpressionRef);
|
||||
}
|
||||
if (evaluationType.equals("boolean")) {
|
||||
builder.getBeanDefinition().setBeanClass(BooleanTestXPathMessageSelector.class);
|
||||
Assert.state(!StringUtils.hasText(stringTestValue),
|
||||
@@ -72,13 +79,6 @@ public class XPathSelectorParser extends AbstractSingleBeanDefinitionParser {
|
||||
throw new IllegalArgumentException("Unsupported value [" + evaluationType
|
||||
+ "] for 'evaluation-result-type', expected boolean or string.");
|
||||
}
|
||||
if (xPathExpressionChildPresent) {
|
||||
BeanDefinition beanDefinition = xpathParser.parse((Element) xPathExpressionNodes.item(0), parserContext);
|
||||
builder.addConstructorArgValue(beanDefinition);
|
||||
}
|
||||
else {
|
||||
builder.addConstructorArgReference(xPathExpressionRef);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,7 +44,15 @@ public class XPathSelectorParserTests {
|
||||
public void testStringExpressionWithNamespaceBoolean() throws Exception {
|
||||
String contextXml = "<si-xml:xpath-selector id='selector' evaluation-result-type='boolean'><si-xml:xpath-expression expression='/ns:name' ns-prefix='ns' ns-uri='www.example.org'/> </si-xml:xpath-selector>";
|
||||
MessageSelector selector = getSelector(contextXml);
|
||||
|
||||
assertTrue(selector.accept(new GenericMessage<Document>(XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>"))));
|
||||
assertFalse(selector.accept(new GenericMessage<Document>(XmlTestUtil.getDocumentForString("<name>outputOne</name>"))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringExpressionWithNamespaceString() throws Exception {
|
||||
String contextXml = "<si-xml:xpath-selector id='selector' evaluation-result-type='string' string-test-value='outputOne'><si-xml:xpath-expression expression='/ns:name' ns-prefix='ns' ns-uri='www.example.org'/> </si-xml:xpath-selector>";
|
||||
MessageSelector selector = getSelector(contextXml);
|
||||
|
||||
assertTrue(selector.accept(new GenericMessage<Document>(XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>"))));
|
||||
assertFalse(selector.accept(new GenericMessage<Document>(XmlTestUtil.getDocumentForString("<name>outputOne</name>"))));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user