Support text/* contentType sent by non-SCSt applications
- When deserializing the payload at the consumer endpoint, the non-byte stream payload type requires to use `String` object when the underlying message content-type is of any `text` type contentType (text/plain, text/xml and text/html). - This fix is only needed to support any non-SCSt applications that will have the 'text/*` contentType of the message that is being deserialized - Add test This resolves #403
This commit is contained in:
@@ -111,6 +111,19 @@ public class MessageChannelBinderSupportTests {
|
||||
assertNull(reconstructed.get(MessageHeaders.CONTENT_TYPE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringXML() throws IOException {
|
||||
Message<?> message = MessageBuilder
|
||||
.withPayload("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><test></test>")
|
||||
.setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_XML)
|
||||
.build();
|
||||
Message<?> converted = binder.serializePayloadIfNecessary(message).toMessage();
|
||||
assertEquals(MimeTypeUtils.TEXT_PLAIN, contentTypeResolver.resolve(converted.getHeaders()));
|
||||
MessageValues reconstructed = binder.deserializePayloadIfNecessary(converted);
|
||||
assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><test></test>", reconstructed.getPayload());
|
||||
assertEquals(MimeTypeUtils.TEXT_XML.toString(), reconstructed.get(MessageHeaders.CONTENT_TYPE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testContentTypePreserved() throws IOException {
|
||||
Message<String> inbound = MessageBuilder.withPayload("{\"foo\":\"foo\"}")
|
||||
|
||||
Reference in New Issue
Block a user