summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-01-03 09:57:25 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-01-03 09:57:25 (GMT)
commit3ca52c5c19d3e750f6ed8b5f7c06b78183eaabfb (patch)
tree7e283eed7e3565d03b60be1c55b613fbdcf46ae6 /Swiften
parente30322061756a64cd23d949e16f21dfe2f18b192 (diff)
downloadswift-contrib-3ca52c5c19d3e750f6ed8b5f7c06b78183eaabfb.zip
swift-contrib-3ca52c5c19d3e750f6ed8b5f7c06b78183eaabfb.tar.bz2
Always send <label/> element.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp10
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp19
2 files changed, 20 insertions, 9 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp
index f155f22..dcce4dc 100644
--- a/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp
+++ b/Swiften/Serializer/PayloadSerializers/SecurityLabelSerializer.cpp
@@ -22,11 +22,11 @@ String SecurityLabelSerializer::serializePayload(boost::shared_ptr<SecurityLabel
displayMarking->addNode(boost::shared_ptr<XMLTextNode>(new XMLTextNode(label->getDisplayMarking())));
element.addNode(displayMarking);
}
- if (!label->getLabel().isEmpty()) {
- boost::shared_ptr<XMLElement> labelElement(new XMLElement("label"));
- labelElement->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(label->getLabel())));
- element.addNode(labelElement);
- }
+
+ boost::shared_ptr<XMLElement> labelElement(new XMLElement("label"));
+ labelElement->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(label->getLabel())));
+ element.addNode(labelElement);
+
foreach(const String& equivalentLabel, label->getEquivalentLabels()) {
boost::shared_ptr<XMLElement> equivalentLabelElement(new XMLElement("equivalentlabel"));
equivalentLabelElement->addNode(boost::shared_ptr<XMLRawTextNode>(new XMLRawTextNode(equivalentLabel)));
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp
index c95ae10..e75695f 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/SecurityLabelSerializerTest.cpp
@@ -5,15 +5,13 @@
using namespace Swift;
-class SecurityLabelSerializerTest : public CppUnit::TestFixture
-{
+class SecurityLabelSerializerTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(SecurityLabelSerializerTest);
CPPUNIT_TEST(testSerialize);
+ CPPUNIT_TEST(testSerialize_EmptyLabel);
CPPUNIT_TEST_SUITE_END();
public:
- SecurityLabelSerializerTest() {}
-
void testSerialize() {
SecurityLabelSerializer testling;
boost::shared_ptr<SecurityLabel> securityLabel(new SecurityLabel());
@@ -38,6 +36,19 @@ class SecurityLabelSerializerTest : public CppUnit::TestFixture
"</equivalentlabel>"
"</securitylabel>"), testling.serialize(securityLabel));
}
+
+ void testSerialize_EmptyLabel() {
+ SecurityLabelSerializer testling;
+ boost::shared_ptr<SecurityLabel> securityLabel(new SecurityLabel());
+ securityLabel->setDisplayMarking("SECRET");
+ securityLabel->setLabel("");
+
+ CPPUNIT_ASSERT_EQUAL(String(
+ "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
+ "<displaymarking>SECRET</displaymarking>"
+ "<label></label>"
+ "</securitylabel>"), testling.serialize(securityLabel));
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(SecurityLabelSerializerTest);