diff options
author | Remko Tronçon <git@el-tramo.be> | 2012-05-05 07:11:25 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2012-05-05 07:11:25 (GMT) |
commit | 1824826fffbe9ebf508264db13843bd1a94f0778 (patch) | |
tree | 418ce84968cfd33c2ca160a58bf70a498e066f5c /Swiften/Serializer/PayloadSerializers/UnitTest | |
parent | 14215c76b373ee8bbb7e73d4577f40eec01f5d85 (diff) | |
download | swift-1824826fffbe9ebf508264db13843bd1a94f0778.zip swift-1824826fffbe9ebf508264db13843bd1a94f0778.tar.bz2 |
Serialize error payload.
Diffstat (limited to 'Swiften/Serializer/PayloadSerializers/UnitTest')
-rw-r--r-- | Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp index 27d4ac5..d1408f7 100644 --- a/Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp +++ b/Swiften/Serializer/PayloadSerializers/UnitTest/ErrorSerializerTest.cpp @@ -1,31 +1,45 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2012 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #include <cppunit/extensions/HelperMacros.h> #include <cppunit/extensions/TestFactoryRegistry.h> +#include <boost/smart_ptr/make_shared.hpp> #include <Swiften/Serializer/PayloadSerializers/ErrorSerializer.h> +#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h> +#include <Swiften/Elements/Delay.h> using namespace Swift; -class ErrorSerializerTest : public CppUnit::TestFixture -{ +class ErrorSerializerTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(ErrorSerializerTest); CPPUNIT_TEST(testSerialize); + CPPUNIT_TEST(testSerialize_Payload); CPPUNIT_TEST_SUITE_END(); public: - ErrorSerializerTest() {} - void testSerialize() { - ErrorSerializer testling; + ErrorSerializer testling(&serializers); boost::shared_ptr<ErrorPayload> error(new ErrorPayload(ErrorPayload::BadRequest, ErrorPayload::Cancel, "My Error")); CPPUNIT_ASSERT_EQUAL(std::string("<error type=\"cancel\"><bad-request xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/><text xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\">My Error</text></error>"), testling.serialize(error)); } + + void testSerialize_Payload() { + ErrorSerializer testling(&serializers); + boost::shared_ptr<ErrorPayload> error = boost::make_shared<ErrorPayload>(); + error->setPayload(boost::make_shared<Delay>()); + + CPPUNIT_ASSERT_EQUAL(std::string( + "<error type=\"cancel\"><undefined-condition xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/><delay stamp=\"not-a-date-timeZ\" xmlns=\"urn:xmpp:delay\"/></error>" + ), testling.serialize(error)); + } + + private: + FullPayloadSerializerCollection serializers; }; CPPUNIT_TEST_SUITE_REGISTRATION(ErrorSerializerTest); |