* Test formatting messages and sub-messages with value parts.
*/
public void testFormatValueParts() throws Exception
{
StringWriter writer = new StringWriter();
WriterOutput out = new WriterOutput(writer);
TransferObject root = new TransferObject("XML_Inherit_Parent_Referrer", 2);
TransferObject ref = new TransferObject(3);
TransferObject anyMsg = new TransferObject(2);
// Parent - hex value part
ref.setClassName("XML_Inherit_Parent");
ref.setValue("a", "Avalue");
ref.setValue("b", Primitive.createInteger(17));
ref.setValue("value", Binary.fromBase64("MTIz"));
root.setValue("name", "123");
root.setValue("ref", ref);
m_formatter.format(root, m_referrerMessage, out);
assertEquals(XML_HEADER +
"<referrer xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
"<name>123</name>" +
"<reference>" +
"<a>Avalue</a>" +
"<b>17</b>" +
"313233" +
"</reference>" +
"</referrer>", writer.toString());
// Child2 - base64 value part
writer = new StringWriter();
out = new WriterOutput(writer);
ref.setClassName("XML_Inherit_Child2");
ref.setValue("value", Binary.parse("313233"));
ref.setValue("b", "Bvalue");
m_formatter.format(root, m_referrerMessage, out);
assertEquals(XML_HEADER +
"<referrer xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
"<name>123</name>" +
"<reference xsi:type=\"Child2Type\">" +
"<a>Avalue</a>" +
"<b>Bvalue</b>" +
"MTIz" +
"</reference>" +
"</referrer>", writer.toString());
// Child4 - xsd:anyType value part (with interface)
writer = new StringWriter();
out = new WriterOutput(writer);
ref.setClassName("XML_Inherit_Child4");
ref.setValue("value", anyMsg);
ref.setValue("b", "Bvalue");
anyMsg.setClassName("XML_InternationalPrice");
anyMsg.setValue("currency", "CNY");
anyMsg.setValue("price", new BigDecimal("8.00"));
m_formatter.format(root, m_referrerMessage, out);
assertEquals(XML_HEADER +
"<referrer xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
"<name>123</name>" +
"<reference xsi:type=\"Child4Type\">" +
"<a>Avalue</a>" +
"<b>Bvalue</b>" +
"<internationalPrice currency=\"CNY\">8.00</internationalPrice>" +
"</reference>" +
"</referrer>", writer.toString());
// Child4Child - xsd:anyType value part (without interface)
writer = new StringWriter();
out = new WriterOutput(writer);
ref.setClassName("XML_Inherit_Child4_Child");
ref.removeValue("a");
ref.removeValue("b");
ref.setValue("value", "<a>Avalue</a><b>Bvalue</b><internationalPrice currency=\"CNY\">8.00</internationalPrice>");
m_formatter.format(root, m_referrerMessage, out);