INT-3415 Add apply-sequence to xpath-splitter

JIRA: https://jira.spring.io/browse/INT-3415

* Add `XPathSplitterParserTests`

XSD Doc Polishing
This commit is contained in:
Artem Bilan
2014-07-01 15:40:30 +03:00
committed by Gary Russell
parent 58932dc31f
commit 1ca631e2c8
5 changed files with 104 additions and 3 deletions

View File

@@ -3322,7 +3322,9 @@
<xsd:documentation>
Set this flag to false to prevent adding sequence related headers in this splitter.
This can be convenient in cases where the set sequence numbers conflict with downstream
custom aggregations.
custom aggregations. When true, existing correlation and sequence related headers
are pushed onto a stack; downstream components, such as aggregators may pop
the stack to revert the existing headers after aggregation. Default is 'true'.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import org.springframework.util.StringUtils;
/**
* @author Jonas Partner
* @author Artem Bilan
*/
public class XPathMessageSplitterParser extends AbstractConsumerEndpointParser {
@@ -53,6 +54,7 @@ public class XPathMessageSplitterParser extends AbstractConsumerEndpointParser {
}
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "doc-builder-factory", "documentBuilder");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "create-documents");
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "apply-sequence");
return builder;
}

View File

@@ -742,7 +742,31 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="create-documents" type="xsd:string" use="optional"/>
<xsd:attribute name="create-documents" use="optional" default="false">
<xsd:annotation>
<xsd:documentation>
Set this flag to 'true' to convert each resuling Node to a Document
before sending replies from this splitter. Default is 'false'
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="xsd:boolean xsd:string" />
</xsd:simpleType>
</xsd:attribute>
<xsd:attribute name="apply-sequence" use="optional" default="true">
<xsd:annotation>
<xsd:documentation>
Set this flag to false to prevent adding sequence related headers in this splitter.
This can be convenient in cases where the set sequence numbers conflict with downstream
custom aggregations. When true, existing correlation and sequence related headers
are pushed onto a stack; downstream components, such as aggregators may pop
the stack to revert the existing headers after aggregation. Default is 'true'.
</xsd:documentation>
</xsd:annotation>
<xsd:simpleType>
<xsd:union memberTypes="xsd:boolean xsd:string" />
</xsd:simpleType>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/integration/xml"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:si="http://www.springframework.org/schema/integration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/xml
http://www.springframework.org/schema/integration/xml/spring-integration-xml.xsd">
<si:channel id="output">
<si:queue/>
</si:channel>
<xpath-splitter id="xpathSplitter" input-channel="input" apply-sequence="false" create-documents="true">
<xpath-expression expression="/orders/order"/>
</xpath-splitter>
</beans:beans>

View File

@@ -0,0 +1,52 @@
/*
* Copyright 2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.xml.config;
import static org.junit.Assert.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.MessageHandler;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @author Artem Bilan
*/
@ContextConfiguration
@RunWith(SpringJUnit4ClassRunner.class)
public class XPathSplitterParserTests {
@Autowired @Qualifier("xpathSplitter.handler")
private MessageHandler xpathSplitter;
@Test
public void testXpathSplitterConfig() {
assertTrue(TestUtils.getPropertyValue(this.xpathSplitter, "createDocuments", Boolean.class));
assertFalse(TestUtils.getPropertyValue(this.xpathSplitter, "applySequence", Boolean.class));
assertEquals("/orders/order",
TestUtils.getPropertyValue(this.xpathSplitter,
"xpathExpression.xpathExpression.xpath.m_patternString",
String.class));
}
}