diff options
author | Tobias Markmann <tm@ayena.de> | 2014-10-24 09:57:13 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2014-10-30 18:55:14 (GMT) |
commit | 8096f80861667381b777af774cfd446d6fc8cda8 (patch) | |
tree | 46d050b1e678609c241d162b06cc511fba698888 /Swiften/Serializer/PayloadSerializers/UnitTest | |
parent | 5cf50d46aed4d2dac333e5e3b3bc2f57f7a1b835 (diff) | |
download | swift-8096f80861667381b777af774cfd446d6fc8cda8.zip swift-8096f80861667381b777af774cfd446d6fc8cda8.tar.bz2 |
Brining XEP-0313 (MAM) implementation in line with version 3.0.
Added support for <fin/> element, including serializer/parsers and unit tests for
them. Added more unit tests based on XEP examples for existing parsers. Removed
unneccesarry includes from existing MAM implementation.
Test-Information:
Existing and new unit tests pass successfully.
Change-Id: I7e6bf85e0961d59801b452e4559cc1db9e9e6ed8
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/UnitTest')
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/UnitTest/MAMArchivedSerializerTest.cpp | 41 | ||||
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/UnitTest/MAMFinSerializerTest.cpp | 64 |
2 files changed, 64 insertions, 41 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MAMArchivedSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MAMArchivedSerializerTest.cpp deleted file mode 100644 index 2bd5c6a..0000000 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/MAMArchivedSerializerTest.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2014 Kevin Smith and Remko Tronçon - * Licensed under the GNU General Public License v3. - * See Documentation/Licenses/GPLv3.txt for more information. - */ - -#include <boost/smart_ptr/make_shared.hpp> - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include <Swiften/Base/DateTime.h> -#include <Swiften/Serializer/PayloadSerializers/MAMArchivedSerializer.h> -#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h> - -using namespace Swift; - -class MAMArchivedSerializerTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(MAMArchivedSerializerTest); - CPPUNIT_TEST(testSerialize); - CPPUNIT_TEST_SUITE_END(); - - public: - void testSerialize() { - MAMArchivedSerializer serializer; - - boost::shared_ptr<MAMArchived> archived(boost::make_shared<MAMArchived>()); - archived->setBy("juliet@capulet.lit"); - archived->setID("28482-98726-73623"); - - std::string expectedResult = - "<archived by=\"juliet@capulet.lit\" id=\"28482-98726-73623\" xmlns=\"urn:xmpp:mam:0\"/>"; - - CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(archived)); - } - - private: - FullPayloadSerializerCollection serializers; -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(MAMArchivedSerializerTest); diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/MAMFinSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/MAMFinSerializerTest.cpp new file mode 100644 index 0000000..372af97 --- /dev/null +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/MAMFinSerializerTest.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2014 Kevin Smith and Remko Tronçon + * Licensed under the GNU General Public License v3. + * See Documentation/Licenses/GPLv3.txt for more information. + */ + +#include <boost/smart_ptr/make_shared.hpp> + +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/extensions/TestFactoryRegistry.h> + +#include <Swiften/Serializer/PayloadSerializers/MAMFinSerializer.h> +#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h> + +using namespace Swift; + +class MAMFinSerializerTest : public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE(MAMFinSerializerTest); + CPPUNIT_TEST(testSerialize_XEP0313_Exmaple1); + CPPUNIT_TEST(testSerialize_XEP0313_Exmaple9); + CPPUNIT_TEST_SUITE_END(); + + public: + void testSerialize_XEP0313_Exmaple1() { + MAMFinSerializer serializer; + + boost::shared_ptr<MAMFin> fin = boost::make_shared<MAMFin>(); + fin->setQueryID("f27"); + + std::string expectedResult = + "<fin queryid=\"f27\" xmlns=\"urn:xmpp:mam:0\"/>"; + CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(fin)); + } + + void testSerialize_XEP0313_Exmaple9() { + MAMFinSerializer serializer; + + boost::shared_ptr<MAMFin> fin = boost::make_shared<MAMFin>(); + fin->setComplete(true); + + boost::shared_ptr<ResultSet> set = boost::make_shared<ResultSet>(); + set->setFirstID(std::string("23452-4534-1")); + set->setFirstIDIndex(0); + set->setLastID(std::string("390-2342-22")); + set->setCount(16); + + fin->setResultSet(set); + + std::string expectedResult = + "<fin complete=\"true\" xmlns=\"urn:xmpp:mam:0\">" + "<set xmlns=\"http://jabber.org/protocol/rsm\">" + "<count>16</count>" + "<first index=\"0\">23452-4534-1</first>" + "<last>390-2342-22</last>" + "</set>" + "</fin>"; + CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(fin)); + } + + private: + FullPayloadSerializerCollection serializers; +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(MAMFinSerializerTest); |