INT-909 Added support for the 'extract-payload' attribute on the 'marshalling-transformer' element. The default value is "true".

This commit is contained in:
Mark Fisher
2009-12-14 00:44:50 +00:00
parent 8124446f9d
commit 9494dd9371
4 changed files with 36 additions and 6 deletions

View File

@@ -46,8 +46,14 @@
input-channel="marshallingTransformerWithResultTransformer"
output-channel="output"
marshaller="marshaller"
result-transformer="resultTransformer">
</si-xml:marshalling-transformer>
result-transformer="resultTransformer" />
<si:channel id="marshallingTransformerWithFullMessage"/>
<si-xml:marshalling-transformer
input-channel="marshallingTransformerWithFullMessage"
output-channel="output"
extract-payload="false"
marshaller="marshaller" />
<bean id="marshaller" class="org.springframework.integration.xml.config.StubMarshaller" />

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2009 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.
@@ -60,7 +60,7 @@ public class XmlMarshallingTransformerParserTests {
Message<?> result = output.receive(0);
assertTrue("Wrong payload type", result.getPayload() instanceof DOMResult);
Document doc = (Document) ((DOMResult) result.getPayload()).getNode();
assertEquals("Wrong palyoad", "hello", doc.getDocumentElement().getTextContent());
assertEquals("Wrong payload", "hello", doc.getDocumentElement().getTextContent());
}
@Test
@@ -71,7 +71,7 @@ public class XmlMarshallingTransformerParserTests {
Message<?> result = output.receive(0);
assertTrue("Wrong payload type", result.getPayload() instanceof String);
String resultPayload = (String)result.getPayload();
assertEquals("Wrong palyoad", "testReturn", resultPayload);
assertEquals("Wrong payload", "testReturn", resultPayload);
}
@Test
@@ -82,7 +82,7 @@ public class XmlMarshallingTransformerParserTests {
Message<?> result = output.receive(0);
assertTrue("Wrong payload type ", result.getPayload() instanceof DOMResult);
Document doc = (Document) ((DOMResult) result.getPayload()).getNode();
assertEquals("Wrong palyoad", "hello", doc.getDocumentElement().getTextContent());
assertEquals("Wrong payload", "hello", doc.getDocumentElement().getTextContent());
}
@Test
@@ -103,4 +103,16 @@ public class XmlMarshallingTransformerParserTests {
assertTrue("Wrong payload type", result.getPayload() instanceof StubStringResult);
}
@Test
public void testFullMessage() throws Exception {
MessageChannel input = (MessageChannel) appContext.getBean("marshallingTransformerWithFullMessage");
GenericMessage<Object> message = new GenericMessage<Object>("hello");
input.send(message);
Message<?> result = output.receive(0);
assertTrue("Wrong payload type", result.getPayload() instanceof DOMResult);
Document doc = (Document) ((DOMResult) result.getPayload()).getNode();
String expected = "[Payload=hello][Headers=";
assertEquals("Wrong payload", expected, doc.getDocumentElement().getTextContent().substring(0, expected.length()));
}
}