summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-09-13 08:21:00 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-09-14 10:42:18 (GMT)
commit052e7c52424e0db0f622bd99ab02318b7cdf4d31 (patch)
tree8b1f92485dd46402026433411ebf5d818d59159c /Swiften/Serializer
parent7585bf84c6d6405cfb97ae2509d43eb77cac94de (diff)
downloadswift-052e7c52424e0db0f622bd99ab02318b7cdf4d31.zip
swift-052e7c52424e0db0f622bd99ab02318b7cdf4d31.tar.bz2
Added PayloadsSerializer.
By using PayloadsSerializer in unit tests, we also test whether the serializer has been added to the full collection.
Diffstat (limited to 'Swiften/Serializer')
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp21
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h17
-rw-r--r--Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp11
3 files changed, 44 insertions, 5 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp
new file mode 100644
index 0000000..23ff4a0
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp
@@ -0,0 +1,21 @@
+#include "Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h"
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include "Swiften/Serializer/PayloadSerializer.h"
+
+namespace Swift {
+
+String PayloadsSerializer::serialize(boost::shared_ptr<Payload> payload) {
+ PayloadSerializer* serializer = serializers.getPayloadSerializer(payload);
+ if (serializer) {
+ return serializer->serialize(payload);
+ }
+ else {
+ CPPUNIT_ASSERT(false);
+ return "";
+ }
+}
+
+
+}
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h
new file mode 100644
index 0000000..9fca334
--- /dev/null
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h
@@ -0,0 +1,17 @@
+#pragma once
+
+#include <boost/shared_ptr.hpp>
+
+#include "Swiften/Elements/Payload.h"
+#include "Swiften/Base/String.h"
+#include "Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h"
+
+namespace Swift {
+ class PayloadsSerializer {
+ public:
+ String serialize(boost::shared_ptr<Payload> payload);
+
+ private:
+ FullPayloadSerializerCollection serializers;
+ };
+}
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp
index 158e7f1..daf43c5 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/StorageSerializerTest.cpp
@@ -1,7 +1,8 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
-#include "Swiften/Serializer/PayloadSerializers/StorageSerializer.h"
+#include "Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h"
+#include "Swiften/Elements/Storage.h"
using namespace Swift;
@@ -15,7 +16,7 @@ class StorageSerializerTest : public CppUnit::TestFixture {
StorageSerializerTest() {}
void testSerialize() {
- StorageSerializer testling;
+ PayloadsSerializer serializer;
boost::shared_ptr<Storage> storage(new Storage());
Storage::Conference conference;
conference.name = "Council of Oberon";
@@ -34,11 +35,11 @@ class StorageSerializerTest : public CppUnit::TestFixture {
"<nick>Puck</nick>"
"<password>MyPass</password>"
"</conference>"
- "</storage>"), testling.serialize(storage));
+ "</storage>"), serializer.serialize(storage));
}
void testSerialize_NoNickOrPassword() {
- StorageSerializer testling;
+ PayloadsSerializer serializer;
boost::shared_ptr<Storage> storage(new Storage());
Storage::Conference conference;
conference.name = "Council of Oberon";
@@ -52,7 +53,7 @@ class StorageSerializerTest : public CppUnit::TestFixture {
"autojoin=\"1\" "
"jid=\"council@conference.underhill.org\" "
"name=\"Council of Oberon\"/>"
- "</storage>"), testling.serialize(storage));
+ "</storage>"), serializer.serialize(storage));
}
};