summaryrefslogtreecommitdiffstats
blob: 37c3adb2c331e55fcc319f3964e33f55cace3c41 (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
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>

#include "Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.h"
#include "Swiften/Elements/PrivateStorage.h"
#include "Swiften/Elements/Storage.h"

using namespace Swift;

class PrivateStorageSerializerTest : public CppUnit::TestFixture {
		CPPUNIT_TEST_SUITE(PrivateStorageSerializerTest);
		CPPUNIT_TEST(testSerialize);
		CPPUNIT_TEST_SUITE_END();

	public:
		PrivateStorageSerializerTest() {}

		void testSerialize() {
			PayloadsSerializer serializer;

			boost::shared_ptr<PrivateStorage> privateStorage(new PrivateStorage());
			boost::shared_ptr<Storage> storage(new Storage());
			Storage::Conference conference;
			conference.name = "Swift";
			conference.jid = JID("swift@rooms.swift.im");
			conference.nick = "Alice";
			storage->addConference(conference);
			privateStorage->setPayload(storage);

			CPPUNIT_ASSERT_EQUAL(String(
				"<query xmlns=\"jabber:iq:private\">"	
					"<storage xmlns=\"storage:bookmarks\">"
						"<conference "
								"autojoin=\"1\" "
								"jid=\"swift@rooms.swift.im\" "
								"name=\"Swift\">"
							"<nick>Alice</nick>"
						"</conference>"
					"</storage>"
				"</query>"), serializer.serialize(privateStorage));
		}
};

CPPUNIT_TEST_SUITE_REGISTRATION(PrivateStorageSerializerTest);