diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-09-13 08:21:00 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-09-14 10:42:18 (GMT) |
commit | 052e7c52424e0db0f622bd99ab02318b7cdf4d31 (patch) | |
tree | 8b1f92485dd46402026433411ebf5d818d59159c /Swiften | |
parent | 7585bf84c6d6405cfb97ae2509d43eb77cac94de (diff) | |
download | swift-contrib-052e7c52424e0db0f622bd99ab02318b7cdf4d31.zip swift-contrib-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')
4 files changed, 45 insertions, 5 deletions
diff --git a/Swiften/SConscript b/Swiften/SConscript index ece2c0e..77cb61d 100644 --- a/Swiften/SConscript +++ b/Swiften/SConscript @@ -247,6 +247,7 @@ env.Append(UNITTEST_SOURCES = [ File("Roster/UnitTest/OfflineRosterFilterTest.cpp"), File("Roster/UnitTest/RosterTest.cpp"), File("SASL/UnitTest/PLAINMessageTest.cpp"), + File("Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.cpp"), File("Serializer/PayloadSerializers/UnitTest/CapsInfoSerializerTest.cpp"), File("Serializer/PayloadSerializers/UnitTest/DiscoInfoSerializerTest.cpp"), File("Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp"), 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)); } }; |