blob: e8673b9c4bb942fda526eacc74b93e9cf4668dcf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/*
* Copyright (c) 2014-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <memory>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <Swiften/Elements/PubSubItem.h>
#include <Swiften/Elements/RawXMLPayload.h>
#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
#include <Swiften/Serializer/PayloadSerializers/PubSubItemSerializer.h>
using namespace Swift;
class PubSubItemSerializerTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(PubSubItemSerializerTest);
CPPUNIT_TEST(testSerialize);
CPPUNIT_TEST(testSerializeEmptyID);
CPPUNIT_TEST_SUITE_END();
public:
void testSerialize() {
PubSubItemSerializer serializer(&serializers);
std::shared_ptr<RawXMLPayload> payload(std::make_shared<RawXMLPayload>());
payload->setRawXML("<payload xmlns=\"tmp\"/>");
std::shared_ptr<PubSubItem> item(std::make_shared<PubSubItem>());
item->addData(payload);
item->setID("pubsub-item-1");
std::string expectedResult =
"<item id=\"pubsub-item-1\" xmlns=\"http://jabber.org/protocol/pubsub\">"
"<payload xmlns=\"tmp\"/>"
"</item>";
CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(item));
}
void testSerializeEmptyID() {
PubSubItemSerializer serializer(&serializers);
std::shared_ptr<PubSubItem> item(std::make_shared<PubSubItem>());
std::string expectedResult =
"<item xmlns=\"http://jabber.org/protocol/pubsub\"/>";
CPPUNIT_ASSERT_EQUAL(expectedResult, serializer.serialize(item));
}
private:
FullPayloadSerializerCollection serializers;
};
CPPUNIT_TEST_SUITE_REGISTRATION(PubSubItemSerializerTest);
|