blob: f00eddc896935a23d73704c2ea0bc88c0002bc2f (
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
|
/*
* Copyright (c) 2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <Swiften/Serializer/PayloadSerializers/FullPayloadSerializerCollection.h>
#include <Swiften/Serializer/PayloadSerializers/PubSubRetractSerializer.h>
using namespace Swift;
class PubSubRetractSerializerTest: public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(PubSubRetractSerializerTest);
CPPUNIT_TEST(testSerializeDefault);
CPPUNIT_TEST(testSerializeNotify);
CPPUNIT_TEST_SUITE_END();
public:
PubSubRetractSerializerTest() {}
std::shared_ptr<PubSubItem> somePubSubItem() {
auto item = std::make_shared<PubSubItem>();
item->setID("ae890ac52d0df67ed7cfdf51b644e901");
return item;
}
void testSerializeDefault() {
PubSubRetractSerializer testling(&serializer);
auto retract = std::make_shared<PubSubRetract>();
retract->setNode("princely_musings");
retract->setItems({somePubSubItem()});
CPPUNIT_ASSERT_EQUAL(std::string("<retract node=\"princely_musings\" xmlns=\"http://jabber.org/protocol/pubsub\"><item id=\"ae890ac52d0df67ed7cfdf51b644e901\" xmlns=\"http://jabber.org/protocol/pubsub\"/></retract>"), testling.serialize(retract));
}
void testSerializeNotify() {
PubSubRetractSerializer testling(&serializer);
auto retract = std::make_shared<PubSubRetract>();
retract->setNode("princely_musings");
retract->setItems({somePubSubItem()});
retract->setNotify(true);
CPPUNIT_ASSERT_EQUAL(std::string("<retract node=\"princely_musings\" notify=\"true\" xmlns=\"http://jabber.org/protocol/pubsub\"><item id=\"ae890ac52d0df67ed7cfdf51b644e901\" xmlns=\"http://jabber.org/protocol/pubsub\"/></retract>"), testling.serialize(retract));
retract = std::make_shared<PubSubRetract>();
retract->setNode("princely_musings");
retract->setItems({somePubSubItem()});
retract->setNotify(false);
CPPUNIT_ASSERT_EQUAL(std::string("<retract node=\"princely_musings\" notify=\"false\" xmlns=\"http://jabber.org/protocol/pubsub\"><item id=\"ae890ac52d0df67ed7cfdf51b644e901\" xmlns=\"http://jabber.org/protocol/pubsub\"/></retract>"), testling.serialize(retract));
}
private:
FullPayloadSerializerCollection serializer;
};
CPPUNIT_TEST_SUITE_REGISTRATION(PubSubRetractSerializerTest);
|