diff options
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers')
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp | 6 | ||||
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp | 28 |
2 files changed, 34 insertions, 0 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp b/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp index fc3c03a..b56f404 100644 --- a/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp +++ b/Swiften/Serializer/PayloadSerializers/RosterSerializer.cpp @@ -10,6 +10,7 @@ #include "Swiften/Base/foreach.h" #include "Swiften/Serializer/XML/XMLTextNode.h" +#include "Swiften/Serializer/XML/XMLRawTextNode.h" #include "Swiften/Serializer/XML/XMLElement.h" namespace Swift { @@ -42,6 +43,11 @@ String RosterSerializer::serializePayload(boost::shared_ptr<RosterPayload> roste itemElement->addNode(groupElement); } + if (!item.getUnknownContent().isEmpty()) { + itemElement->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(item.getUnknownContent()))); + } + + queryElement.addNode(itemElement); } diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp index fdf93a9..bf30db8 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/RosterSerializerTest.cpp @@ -15,6 +15,7 @@ class RosterSerializerTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(RosterSerializerTest); CPPUNIT_TEST(testSerialize); + CPPUNIT_TEST(testSerialize_ItemWithUnknownContent); CPPUNIT_TEST_SUITE_END(); public: @@ -49,6 +50,33 @@ class RosterSerializerTest : public CppUnit::TestFixture CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(roster)); } + + void testSerialize_ItemWithUnknownContent() { + RosterSerializer testling; + boost::shared_ptr<RosterPayload> roster(new RosterPayload()); + + RosterItemPayload item; + item.setJID(JID("baz@blo.com")); + item.setName("Baz"); + item.addGroup("Group 1"); + item.addGroup("Group 2"); + item.addUnknownContent(String( + "<foo xmlns=\"http://example.com\"><bar xmlns=\"http://example.com\">Baz</bar></foo>" + "<baz xmlns=\"jabber:iq:roster\"><fum xmlns=\"jabber:iq:roster\">foo</fum></baz>")); + roster->addItem(item); + + String expectedResult = + "<query xmlns=\"jabber:iq:roster\">" + "<item jid=\"baz@blo.com\" name=\"Baz\" subscription=\"none\">" + "<group>Group 1</group>" + "<group>Group 2</group>" + "<foo xmlns=\"http://example.com\"><bar xmlns=\"http://example.com\">Baz</bar></foo>" + "<baz xmlns=\"jabber:iq:roster\"><fum xmlns=\"jabber:iq:roster\">foo</fum></baz>" + "</item>" + "</query>"; + + CPPUNIT_ASSERT_EQUAL(expectedResult, testling.serialize(roster)); + } }; CPPUNIT_TEST_SUITE_REGISTRATION(RosterSerializerTest); |