/* * Copyright (c) 2015 Tarun Gupta * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ /* * Copyright (c) 2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace Swift; class IsodeIQDelegationSerializerTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(IsodeIQDelegationSerializerTest); CPPUNIT_TEST(testSerialize_Forwarded_IQ); CPPUNIT_TEST(testSerialize_Forwarded_Message); CPPUNIT_TEST(testSerialize_Forwarded_MessageNoDelay); CPPUNIT_TEST(testSerialize_Forwarded_Presence); CPPUNIT_TEST_SUITE_END(); public: IsodeIQDelegationSerializerTest() {} void testSerialize_Forwarded_IQ() { IsodeIQDelegationSerializer testling(&serializers); std::shared_ptr isodeIQDelegation = std::make_shared(); std::shared_ptr iq = IQ::createResult(JID("juliet@capulet.lit/balcony"), JID("romeo@montague.lit/orchard"), "id0", std::make_shared("text")); std::shared_ptr forwarded(std::make_shared()); forwarded->setStanza(iq); forwarded->setDelay(std::make_shared(stringToDateTime(std::string("2010-07-10T23:08:25Z")))); isodeIQDelegation->setForward(forwarded); CPPUNIT_ASSERT_EQUAL(std::string("" "" "" "text" "" ""), testling.serialize(isodeIQDelegation)); } void testSerialize_Forwarded_Message() { IsodeIQDelegationSerializer testling(&serializers); std::shared_ptr isodeIQDelegation = std::make_shared(); std::shared_ptr message(std::make_shared()); message->setType(Message::Chat); message->setTo(JID("juliet@capulet.lit/balcony")); message->setFrom(JID("romeo@montague.lit/orchard")); message->setBody("Call me but love, and I'll be new baptized; Henceforth I never will be Romeo."); std::shared_ptr forwarded(std::make_shared()); forwarded->setStanza(message); forwarded->setDelay(std::make_shared(stringToDateTime(std::string("2010-07-10T23:08:25Z")))); isodeIQDelegation->setForward(forwarded); CPPUNIT_ASSERT_EQUAL(std::string("" "" "" "" "Call me but love, and I'll be new baptized; Henceforth I never will be Romeo." "" "" ""), testling.serialize(isodeIQDelegation)); } void testSerialize_Forwarded_MessageNoDelay() { IsodeIQDelegationSerializer testling(&serializers); std::shared_ptr isodeIQDelegation = std::make_shared(); std::shared_ptr message(std::make_shared()); message->setType(Message::Chat); message->setTo(JID("juliet@capulet.lit/balcony")); message->setFrom(JID("romeo@montague.lit/orchard")); message->setBody("Call me but love, and I'll be new baptized; Henceforth I never will be Romeo."); std::shared_ptr forwarded(std::make_shared()); forwarded->setStanza(message); isodeIQDelegation->setForward(forwarded); CPPUNIT_ASSERT_EQUAL(std::string("" "" "" "Call me but love, and I'll be new baptized; Henceforth I never will be Romeo." "" "" ""), testling.serialize(isodeIQDelegation)); } void testSerialize_Forwarded_Presence() { IsodeIQDelegationSerializer testling(&serializers); std::shared_ptr isodeIQDelegation = std::make_shared(); std::shared_ptr presence(std::make_shared()); presence->setType(Presence::Subscribe); std::shared_ptr forwarded(std::make_shared()); forwarded->setStanza(presence); forwarded->setDelay(std::make_shared(stringToDateTime(std::string("2010-07-10T23:08:25Z")))); isodeIQDelegation->setForward(forwarded); CPPUNIT_ASSERT_EQUAL(std::string("" "" "" "" "" ""), testling.serialize(isodeIQDelegation)); } private: FullPayloadSerializerCollection serializers; }; CPPUNIT_TEST_SUITE_REGISTRATION(IsodeIQDelegationSerializerTest);