summaryrefslogtreecommitdiffstats
blob: 4e77e7d6924ccd74d7a09454d14d61497ee1ba25 (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
/*
 * Copyright (c) 2010-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/Elements/PrivateStorage.h>
#include <Swiften/Elements/Storage.h>
#include <Swiften/Serializer/PayloadSerializers/UnitTest/PayloadsSerializer.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;

            std::shared_ptr<PrivateStorage> privateStorage(new PrivateStorage());
            std::shared_ptr<Storage> storage(new Storage());
            Storage::Room room;
            room.name = "Swift";
            room.jid = JID("swift@rooms.swift.im");
            room.nick = "Alice";
            storage->addRoom(room);
            privateStorage->setPayload(storage);

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

CPPUNIT_TEST_SUITE_REGISTRATION(PrivateStorageSerializerTest);