added support for pollers to schema

This commit is contained in:
Jonas Partner
2008-10-18 18:52:10 +00:00
parent d36f80937d
commit 8a59e6ab41
4 changed files with 39 additions and 5 deletions

View File

@@ -68,7 +68,7 @@ public class XPathRouterParserTests {
public void testSimpleStringExpression() throws Exception {
Document doc = XmlTestUtil.getDocumentForString("<name>outputOne</name>");
GenericMessage<Document> docMessage = new GenericMessage<Document>(doc);
SubscribingConsumerEndpoint sce = buildContext("<si-xml:xpath-router id='router' input-channel='test-input'><si-xml:xpath-expression expression='/name'/></si-xml:xpath-router>");
buildContext("<si-xml:xpath-router id='router' input-channel='test-input'><si-xml:xpath-expression expression='/name'/></si-xml:xpath-router>");
inputChannel.send(docMessage);
assertEquals("Wrong number of messages", 1, outputChannel.getMesssageCount());
@@ -78,7 +78,7 @@ public class XPathRouterParserTests {
public void testNamespacedStringExpression() throws Exception {
Document doc = XmlTestUtil.getDocumentForString("<ns1:name xmlns:ns1='www.example.org'>outputOne</ns1:name>");
GenericMessage<Document> docMessage = new GenericMessage<Document>(doc);
SubscribingConsumerEndpoint sce = buildContext("<si-xml:xpath-router id='router' input-channel='test-input'><si-xml:xpath-expression expression='/ns2:name' ns-prefix='ns2' ns-uri='www.example.org' /></si-xml:xpath-router>");
buildContext("<si-xml:xpath-router id='router' input-channel='test-input'><si-xml:xpath-expression expression='/ns2:name' ns-prefix='ns2' ns-uri='www.example.org' /></si-xml:xpath-router>");
inputChannel.send(docMessage);
assertEquals("Wrong number of messages", 1, outputChannel.getMesssageCount());
@@ -93,7 +93,7 @@ public class XPathRouterParserTests {
"<si-xml:xpath-router id='router' input-channel='test-input'><si-xml:xpath-expression expression='/ns1:name/ns2:type'> ");
buffer.append("<map><entry key='ns1' value='www.example.org' /> <entry key='ns2' value='www.example.org2'/></map>");
buffer.append("</si-xml:xpath-expression></si-xml:xpath-router>");
SubscribingConsumerEndpoint sce = buildContext(buffer.toString());
buildContext(buffer.toString());
inputChannel.send(docMessage);
assertEquals("Wrong number of messages", 1, outputChannel.getMesssageCount());
@@ -109,7 +109,7 @@ public class XPathRouterParserTests {
buffer.append("</si-xml:xpath-router>");
buffer.append("<util:map id='nsMap'><entry key='ns1' value='www.example.org' /><entry key='ns2' value='www.example.org2' /></util:map>");
SubscribingConsumerEndpoint sce = buildContext(buffer.toString());
buildContext(buffer.toString());
inputChannel.send(docMessage);
assertEquals("Wrong number of messages", 1, outputChannel.getMesssageCount());
}

View File

@@ -12,7 +12,12 @@
<si:message-bus/>
<si:channel id="input"/>
<si:channel id="input" />
<si:channel id="pollableInput" >
<si:queue capacity="1"/>
</si:channel>
<si:channel id="output">
<si:queue capacity="1"/>
@@ -22,6 +27,16 @@
input-channel="input"
output-channel="output"
unmarshaller="unmarshaller"/>
<si-xml:unmarshalling-transformer id="unmrshallerWithPoller"
input-channel="pollableInput"
output-channel="output"
unmarshaller="unmarshaller">
<si:poller>
<si:interval-trigger interval="500" />
</si:poller>
</si-xml:unmarshalling-transformer>
<bean id="unmarshaller" class="org.springframework.integration.xml.config.StubUnmarshaller"/>

View File

@@ -88,6 +88,21 @@ public class XmlUnmarshallingTransformerParserTests {
assertEquals("Wrong payload after unmarshalling", "unmarshalled", result.getPayload());
assertTrue("Wrong source passed to unmarshaller", unmarshaller.sourcesPassed.poll() instanceof DOMSource);
}
@Test
public void testPollingUnmarshall() throws Exception {
MessageChannel input = (MessageChannel) appContext.getBean("pollableInput");
PollableChannel output = (PollableChannel) appContext.getBean("output");
GenericMessage<Object> message = new GenericMessage<Object>(new StringSource(
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><order><orderItem>test</orderItem></order>"));
input.send(message);
Message<?> result = output.receive(5000);
assertEquals("Wrong payload after unmarshalling", "unmarshalled", result.getPayload());
assertTrue("Wrong source passed to unmarshaller", unmarshaller.sourcesPassed.poll() instanceof StringSource);
}
@Test(expected = MessagingException.class)
public void testUnmarshallUnsupported() throws Exception {