summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
committerTobias Markmann <tm@ayena.de>2016-03-31 14:57:35 (GMT)
commitcfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch)
tree18d94153a302445196fc0c18586abf44a1ce4a38 /Swiften/Parser/PayloadParsers/UnitTest
parent1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff)
downloadswift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip
swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines in the process. Changed CheckTabs.py tool to disallow hard tabs in source files. Test-Information: Manually checked 30 random files that the conversion worked as expected. Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'Swiften/Parser/PayloadParsers/UnitTest')
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/BlockParserTest.cpp98
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/BodyParserTest.cpp22
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/CarbonsParserTest.cpp204
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/CommandParserTest.cpp118
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/DeliveryReceiptParserTest.cpp34
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp152
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/DiscoItemsParserTest.cpp48
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/ErrorParserTest.cpp76
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp420
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/ForwardedParserTest.cpp188
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/IBBParserTest.cpp40
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/IdleParserTest.cpp36
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/InBandRegistrationPayloadParserTest.cpp80
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/JingleParserTest.cpp1172
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MAMFinParserTest.cpp80
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MAMQueryParserTest.cpp204
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MAMResultParserTest.cpp70
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MUCAdminPayloadParserTest.cpp30
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MUCUserPayloadParserTest.cpp144
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/PayloadParserTester.h2
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h82
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/PriorityParserTest.cpp34
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/PrivateStorageParserTest.cpp150
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/RawXMLPayloadParserTest.cpp42
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/ReplaceTest.cpp34
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/ResourceBindParserTest.cpp36
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/ResultSetParserTest.cpp96
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/RosterItemExchangeParserTest.cpp66
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/RosterParserTest.cpp164
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/SearchPayloadParserTest.cpp326
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelParserTest.cpp64
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelsCatalogParserTest.cpp88
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/SoftwareVersionParserTest.cpp44
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/StatusParserTest.cpp22
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/StatusShowParserTest.cpp110
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp136
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/StreamInitiationParserTest.cpp102
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/UserLocationParserTest.cpp154
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/UserTuneParserTest.cpp74
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp368
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/VCardUpdateParserTest.cpp28
41 files changed, 2719 insertions, 2719 deletions
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/BlockParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/BlockParserTest.cpp
index 4a104c8..17a800e 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/BlockParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/BlockParserTest.cpp
@@ -23,55 +23,55 @@ using namespace Swift;
class BlockParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(BlockParserTest);
- CPPUNIT_TEST(testExample4);
- CPPUNIT_TEST(testExample6);
- CPPUNIT_TEST(testExample10);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- BlockParserTest() {}
-
- void testExample4() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse("<blocklist xmlns='urn:xmpp:blocking'>"
- "<item jid='romeo@montague.net'/>"
- "<item jid='iago@shakespeare.lit'/>"
- "</blocklist>"));
-
- BlockListPayload* payload = dynamic_cast<BlockListPayload*>(parser.getPayload().get());
- CPPUNIT_ASSERT(payload);
- CPPUNIT_ASSERT(2 == payload->getItems().size());
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.net"), payload->getItems()[0]);
- CPPUNIT_ASSERT_EQUAL(JID("iago@shakespeare.lit"), payload->getItems()[1]);
- }
-
- void testExample6() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse("<block xmlns='urn:xmpp:blocking'>"
- "<item jid='romeo@montague.net'/>"
- "</block>"));
-
- BlockPayload* payload = dynamic_cast<BlockPayload*>(parser.getPayload().get());
- CPPUNIT_ASSERT(payload);
- CPPUNIT_ASSERT(1 == payload->getItems().size());
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.net"), payload->getItems()[0]);
- }
-
- void testExample10() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse("<unblock xmlns='urn:xmpp:blocking'>"
- "<item jid='romeo@montague.net'/>"
- "</unblock>"));
-
- UnblockPayload* payload = dynamic_cast<UnblockPayload*>(parser.getPayload().get());
- CPPUNIT_ASSERT(payload);
- CPPUNIT_ASSERT(1 == payload->getItems().size());
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.net"), payload->getItems()[0]);
- }
+ CPPUNIT_TEST_SUITE(BlockParserTest);
+ CPPUNIT_TEST(testExample4);
+ CPPUNIT_TEST(testExample6);
+ CPPUNIT_TEST(testExample10);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ BlockParserTest() {}
+
+ void testExample4() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse("<blocklist xmlns='urn:xmpp:blocking'>"
+ "<item jid='romeo@montague.net'/>"
+ "<item jid='iago@shakespeare.lit'/>"
+ "</blocklist>"));
+
+ BlockListPayload* payload = dynamic_cast<BlockListPayload*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(payload);
+ CPPUNIT_ASSERT(2 == payload->getItems().size());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.net"), payload->getItems()[0]);
+ CPPUNIT_ASSERT_EQUAL(JID("iago@shakespeare.lit"), payload->getItems()[1]);
+ }
+
+ void testExample6() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse("<block xmlns='urn:xmpp:blocking'>"
+ "<item jid='romeo@montague.net'/>"
+ "</block>"));
+
+ BlockPayload* payload = dynamic_cast<BlockPayload*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(payload);
+ CPPUNIT_ASSERT(1 == payload->getItems().size());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.net"), payload->getItems()[0]);
+ }
+
+ void testExample10() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse("<unblock xmlns='urn:xmpp:blocking'>"
+ "<item jid='romeo@montague.net'/>"
+ "</unblock>"));
+
+ UnblockPayload* payload = dynamic_cast<UnblockPayload*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(payload);
+ CPPUNIT_ASSERT(1 == payload->getItems().size());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.net"), payload->getItems()[0]);
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(BlockParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/BodyParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/BodyParserTest.cpp
index b409ed4..002da16 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/BodyParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/BodyParserTest.cpp
@@ -14,21 +14,21 @@ using namespace Swift;
class BodyParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(BodyParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(BodyParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST_SUITE_END();
- public:
- BodyParserTest() {}
+ public:
+ BodyParserTest() {}
- void testParse() {
- PayloadsParserTester parser;
+ void testParse() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<body>foo<baz>bar</baz>fum</body>"));
+ CPPUNIT_ASSERT(parser.parse("<body>foo<baz>bar</baz>fum</body>"));
- Body* payload = dynamic_cast<Body*>(parser.getPayload().get());
- CPPUNIT_ASSERT_EQUAL(std::string("foobarfum"), payload->getText());
- }
+ Body* payload = dynamic_cast<Body*>(parser.getPayload().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("foobarfum"), payload->getText());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(BodyParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/CarbonsParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/CarbonsParserTest.cpp
index 7700a5c..f85efb2 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/CarbonsParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/CarbonsParserTest.cpp
@@ -20,108 +20,108 @@
using namespace Swift;
class CarbonsParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(CarbonsParserTest);
- CPPUNIT_TEST(testParseExample3);
- CPPUNIT_TEST(testParseExample6);
- CPPUNIT_TEST(testParseExample12);
- CPPUNIT_TEST(testParseExample14);
- CPPUNIT_TEST(testParseExample15);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- CarbonsParserTest() {}
-
- /*
- * Test parsing of example 3 in XEP-0280.
- */
- void testParseExample3() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<enable xmlns='urn:xmpp:carbons:2' />"));
-
- CarbonsEnable::ref enable = parser.getPayload<CarbonsEnable>();
- CPPUNIT_ASSERT(enable);
- }
-
- /*
- * Test parsing of example 6 in XEP-0280.
- */
- void testParseExample6() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<disable xmlns='urn:xmpp:carbons:2' />"));
-
- CarbonsDisable::ref disable = parser.getPayload<CarbonsDisable>();
- CPPUNIT_ASSERT(disable);
- }
-
- /*
- * Test parsing of example 12 in XEP-0280.
- */
- void testParseExample12() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<received xmlns='urn:xmpp:carbons:2'>"
- "<forwarded xmlns='urn:xmpp:forward:0'>"
- "<message xmlns='jabber:client'"
- " from='juliet@capulet.example/balcony'"
- " to='romeo@montague.example/garden'"
- " type='chat'>"
- "<body>What man art thou that, thus bescreen'd in night, so stumblest on my counsel?</body>"
- "<thread>0e3141cd80894871a68e6fe6b1ec56fa</thread>"
- "</message>"
- "</forwarded>"
- "</received>"));
-
- CarbonsReceived::ref received = parser.getPayload<CarbonsReceived>();
- CPPUNIT_ASSERT(received);
-
- boost::shared_ptr<Forwarded> forwarded = received->getForwarded();
- CPPUNIT_ASSERT(forwarded);
-
- boost::shared_ptr<Message> message = boost::dynamic_pointer_cast<Message>(forwarded->getStanza());
- CPPUNIT_ASSERT(message);
- CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.example/balcony"), message->getFrom());
-
- boost::shared_ptr<Thread> thread = message->getPayload<Thread>();
- CPPUNIT_ASSERT(thread);
- CPPUNIT_ASSERT_EQUAL(std::string("0e3141cd80894871a68e6fe6b1ec56fa"), thread->getText());
- }
-
- /*
- * Test parsing of example 14 in XEP-0280.
- */
- void testParseExample14() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<sent xmlns='urn:xmpp:carbons:2'>"
- "<forwarded xmlns='urn:xmpp:forward:0'>"
- "<message xmlns='jabber:client'"
- " to='juliet@capulet.example/balcony'"
- " from='romeo@montague.example/home'"
- " type='chat'>"
- "<body>Neither, fair saint, if either thee dislike.</body>"
- "<thread>0e3141cd80894871a68e6fe6b1ec56fa</thread>"
- "</message>"
- "</forwarded>"
- "</sent>"));
-
- CarbonsSent::ref sent = parser.getPayload<CarbonsSent>();
- CPPUNIT_ASSERT(sent);
-
- boost::shared_ptr<Forwarded> forwarded = sent->getForwarded();
- CPPUNIT_ASSERT(forwarded);
-
- boost::shared_ptr<Message> message = boost::dynamic_pointer_cast<Message>(forwarded->getStanza());
- CPPUNIT_ASSERT(message);
- CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.example/balcony"), message->getTo());
- }
-
- /*
- * Test parsing of example 15 in XEP-0280.
- */
- void testParseExample15() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<private xmlns='urn:xmpp:carbons:2'/>"));
-
- CPPUNIT_ASSERT(parser.getPayload<CarbonsPrivate>());
- }
+ CPPUNIT_TEST_SUITE(CarbonsParserTest);
+ CPPUNIT_TEST(testParseExample3);
+ CPPUNIT_TEST(testParseExample6);
+ CPPUNIT_TEST(testParseExample12);
+ CPPUNIT_TEST(testParseExample14);
+ CPPUNIT_TEST(testParseExample15);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ CarbonsParserTest() {}
+
+ /*
+ * Test parsing of example 3 in XEP-0280.
+ */
+ void testParseExample3() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse("<enable xmlns='urn:xmpp:carbons:2' />"));
+
+ CarbonsEnable::ref enable = parser.getPayload<CarbonsEnable>();
+ CPPUNIT_ASSERT(enable);
+ }
+
+ /*
+ * Test parsing of example 6 in XEP-0280.
+ */
+ void testParseExample6() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse("<disable xmlns='urn:xmpp:carbons:2' />"));
+
+ CarbonsDisable::ref disable = parser.getPayload<CarbonsDisable>();
+ CPPUNIT_ASSERT(disable);
+ }
+
+ /*
+ * Test parsing of example 12 in XEP-0280.
+ */
+ void testParseExample12() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse("<received xmlns='urn:xmpp:carbons:2'>"
+ "<forwarded xmlns='urn:xmpp:forward:0'>"
+ "<message xmlns='jabber:client'"
+ " from='juliet@capulet.example/balcony'"
+ " to='romeo@montague.example/garden'"
+ " type='chat'>"
+ "<body>What man art thou that, thus bescreen'd in night, so stumblest on my counsel?</body>"
+ "<thread>0e3141cd80894871a68e6fe6b1ec56fa</thread>"
+ "</message>"
+ "</forwarded>"
+ "</received>"));
+
+ CarbonsReceived::ref received = parser.getPayload<CarbonsReceived>();
+ CPPUNIT_ASSERT(received);
+
+ boost::shared_ptr<Forwarded> forwarded = received->getForwarded();
+ CPPUNIT_ASSERT(forwarded);
+
+ boost::shared_ptr<Message> message = boost::dynamic_pointer_cast<Message>(forwarded->getStanza());
+ CPPUNIT_ASSERT(message);
+ CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.example/balcony"), message->getFrom());
+
+ boost::shared_ptr<Thread> thread = message->getPayload<Thread>();
+ CPPUNIT_ASSERT(thread);
+ CPPUNIT_ASSERT_EQUAL(std::string("0e3141cd80894871a68e6fe6b1ec56fa"), thread->getText());
+ }
+
+ /*
+ * Test parsing of example 14 in XEP-0280.
+ */
+ void testParseExample14() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse("<sent xmlns='urn:xmpp:carbons:2'>"
+ "<forwarded xmlns='urn:xmpp:forward:0'>"
+ "<message xmlns='jabber:client'"
+ " to='juliet@capulet.example/balcony'"
+ " from='romeo@montague.example/home'"
+ " type='chat'>"
+ "<body>Neither, fair saint, if either thee dislike.</body>"
+ "<thread>0e3141cd80894871a68e6fe6b1ec56fa</thread>"
+ "</message>"
+ "</forwarded>"
+ "</sent>"));
+
+ CarbonsSent::ref sent = parser.getPayload<CarbonsSent>();
+ CPPUNIT_ASSERT(sent);
+
+ boost::shared_ptr<Forwarded> forwarded = sent->getForwarded();
+ CPPUNIT_ASSERT(forwarded);
+
+ boost::shared_ptr<Message> message = boost::dynamic_pointer_cast<Message>(forwarded->getStanza());
+ CPPUNIT_ASSERT(message);
+ CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.example/balcony"), message->getTo());
+ }
+
+ /*
+ * Test parsing of example 15 in XEP-0280.
+ */
+ void testParseExample15() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse("<private xmlns='urn:xmpp:carbons:2'/>"));
+
+ CPPUNIT_ASSERT(parser.getPayload<CarbonsPrivate>());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(CarbonsParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/CommandParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/CommandParserTest.cpp
index c47682c..fa8d014 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/CommandParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/CommandParserTest.cpp
@@ -13,74 +13,74 @@
using namespace Swift;
class CommandParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(CommandParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testParse_Result);
- CPPUNIT_TEST(testParse_Form);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(CommandParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParse_Result);
+ CPPUNIT_TEST(testParse_Form);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testParse() {
- PayloadsParserTester parser;
+ public:
+ void testParse() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<command xmlns='http://jabber.org/protocol/commands' node='list' action='prev' sessionid='myid'/>"
- ));
+ CPPUNIT_ASSERT(parser.parse(
+ "<command xmlns='http://jabber.org/protocol/commands' node='list' action='prev' sessionid='myid'/>"
+ ));
- Command::ref payload = parser.getPayload<Command>();
- CPPUNIT_ASSERT_EQUAL(Command::Prev, payload->getAction());
- CPPUNIT_ASSERT_EQUAL(std::string("list"), payload->getNode());
- CPPUNIT_ASSERT_EQUAL(std::string("myid"), payload->getSessionID());
- }
+ Command::ref payload = parser.getPayload<Command>();
+ CPPUNIT_ASSERT_EQUAL(Command::Prev, payload->getAction());
+ CPPUNIT_ASSERT_EQUAL(std::string("list"), payload->getNode());
+ CPPUNIT_ASSERT_EQUAL(std::string("myid"), payload->getSessionID());
+ }
- void testParse_Result() {
- PayloadsParserTester parser;
+ void testParse_Result() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<command xmlns='http://jabber.org/protocol/commands' node='config' status='completed' sessionid='myid'>"
- "<note type='warn'>Service 'httpd' has been configured.</note>"
- "<note type='error'>I lied.</note>"
- "<actions execute='next'>"
- "<prev/>"
- "<next/>"
- "</actions>"
- "</command>"
- ));
+ CPPUNIT_ASSERT(parser.parse(
+ "<command xmlns='http://jabber.org/protocol/commands' node='config' status='completed' sessionid='myid'>"
+ "<note type='warn'>Service 'httpd' has been configured.</note>"
+ "<note type='error'>I lied.</note>"
+ "<actions execute='next'>"
+ "<prev/>"
+ "<next/>"
+ "</actions>"
+ "</command>"
+ ));
- Command::ref payload = parser.getPayload<Command>();
- CPPUNIT_ASSERT_EQUAL(Command::Completed, payload->getStatus());
- std::vector<Command::Note> notes = payload->getNotes();
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(notes.size()));
- CPPUNIT_ASSERT_EQUAL(Command::Note::Warn, notes[0].type);
- CPPUNIT_ASSERT_EQUAL(std::string("Service 'httpd' has been configured."), notes[0].note);
- CPPUNIT_ASSERT_EQUAL(Command::Note::Error, notes[1].type);
- CPPUNIT_ASSERT_EQUAL(std::string("I lied."), notes[1].note);
- std::vector<Command::Action> actions = payload->getAvailableActions();
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(actions.size()));
- CPPUNIT_ASSERT_EQUAL(Command::Prev, actions[0]);
- CPPUNIT_ASSERT_EQUAL(Command::Next, actions[1]);
- CPPUNIT_ASSERT_EQUAL(Command::Next, payload->getExecuteAction());
- }
+ Command::ref payload = parser.getPayload<Command>();
+ CPPUNIT_ASSERT_EQUAL(Command::Completed, payload->getStatus());
+ std::vector<Command::Note> notes = payload->getNotes();
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(notes.size()));
+ CPPUNIT_ASSERT_EQUAL(Command::Note::Warn, notes[0].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("Service 'httpd' has been configured."), notes[0].note);
+ CPPUNIT_ASSERT_EQUAL(Command::Note::Error, notes[1].type);
+ CPPUNIT_ASSERT_EQUAL(std::string("I lied."), notes[1].note);
+ std::vector<Command::Action> actions = payload->getAvailableActions();
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(actions.size()));
+ CPPUNIT_ASSERT_EQUAL(Command::Prev, actions[0]);
+ CPPUNIT_ASSERT_EQUAL(Command::Next, actions[1]);
+ CPPUNIT_ASSERT_EQUAL(Command::Next, payload->getExecuteAction());
+ }
- void testParse_Form() {
- PayloadsParserTester parser;
+ void testParse_Form() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<command xmlns='http://jabber.org/protocol/commands' node='config' status='completed'>"
- "<x type=\"result\" xmlns=\"jabber:x:data\">"
- "<title>Bot Configuration</title>"
- "<instructions>Hello!</instructions>"
- "<instructions>Fill out this form to configure your new bot!</instructions>"
- "</x>"
- "</command>"
- ));
+ CPPUNIT_ASSERT(parser.parse(
+ "<command xmlns='http://jabber.org/protocol/commands' node='config' status='completed'>"
+ "<x type=\"result\" xmlns=\"jabber:x:data\">"
+ "<title>Bot Configuration</title>"
+ "<instructions>Hello!</instructions>"
+ "<instructions>Fill out this form to configure your new bot!</instructions>"
+ "</x>"
+ "</command>"
+ ));
- Command::ref payload = parser.getPayload<Command>();
- Form::ref form = payload->getForm();
- CPPUNIT_ASSERT_EQUAL(std::string("Bot Configuration"), form->getTitle());
- CPPUNIT_ASSERT_EQUAL(std::string("Hello!\nFill out this form to configure your new bot!"), form->getInstructions());
- CPPUNIT_ASSERT_EQUAL(Form::ResultType, form->getType());
- }
+ Command::ref payload = parser.getPayload<Command>();
+ Form::ref form = payload->getForm();
+ CPPUNIT_ASSERT_EQUAL(std::string("Bot Configuration"), form->getTitle());
+ CPPUNIT_ASSERT_EQUAL(std::string("Hello!\nFill out this form to configure your new bot!"), form->getInstructions());
+ CPPUNIT_ASSERT_EQUAL(Form::ResultType, form->getType());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(CommandParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/DeliveryReceiptParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/DeliveryReceiptParserTest.cpp
index 919c342..d18e1b4 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/DeliveryReceiptParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/DeliveryReceiptParserTest.cpp
@@ -15,29 +15,29 @@
using namespace Swift;
class DeliveryReceiptParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(DeliveryReceiptParserTest);
- CPPUNIT_TEST(testParseXEP0184Example3);
- CPPUNIT_TEST(testParseXEP0184Example4);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(DeliveryReceiptParserTest);
+ CPPUNIT_TEST(testParseXEP0184Example3);
+ CPPUNIT_TEST(testParseXEP0184Example4);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testParseXEP0184Example3() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<request xmlns='urn:xmpp:receipts'/>"));
+ public:
+ void testParseXEP0184Example3() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse("<request xmlns='urn:xmpp:receipts'/>"));
- DeliveryReceiptRequest::ref request = boost::dynamic_pointer_cast<DeliveryReceiptRequest>(parser.getPayload());
+ DeliveryReceiptRequest::ref request = boost::dynamic_pointer_cast<DeliveryReceiptRequest>(parser.getPayload());
- CPPUNIT_ASSERT(request);
- }
+ CPPUNIT_ASSERT(request);
+ }
- void testParseXEP0184Example4() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<received xmlns='urn:xmpp:receipts' id='richard2-4.1.247'/>"));
+ void testParseXEP0184Example4() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse("<received xmlns='urn:xmpp:receipts' id='richard2-4.1.247'/>"));
- DeliveryReceipt::ref receipt = boost::dynamic_pointer_cast<DeliveryReceipt>(parser.getPayload());
+ DeliveryReceipt::ref receipt = boost::dynamic_pointer_cast<DeliveryReceipt>(parser.getPayload());
- CPPUNIT_ASSERT_EQUAL(std::string("richard2-4.1.247"), receipt->getReceivedID());
- }
+ CPPUNIT_ASSERT_EQUAL(std::string("richard2-4.1.247"), receipt->getReceivedID());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(DeliveryReceiptParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp
index 35995c9..c23b1d0 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp
@@ -13,91 +13,91 @@
using namespace Swift;
class DiscoInfoParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(DiscoInfoParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testParse_Node);
- CPPUNIT_TEST(testParse_Form);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(DiscoInfoParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParse_Node);
+ CPPUNIT_TEST(testParse_Form);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testParse() {
- PayloadsParserTester parser;
+ public:
+ void testParse() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<query xmlns=\"http://jabber.org/protocol/disco#info\">"
- "<identity name=\"Swift\" category=\"client\" type=\"pc\" xml:lang=\"en\"/>"
- "<identity name=\"Vlug\" category=\"client\" type=\"pc\" xml:lang=\"nl\"/>"
- "<feature var=\"foo-feature\"/>"
- "<feature var=\"bar-feature\"/>"
- "<feature var=\"baz-feature\"/>"
- "</query>"));
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns=\"http://jabber.org/protocol/disco#info\">"
+ "<identity name=\"Swift\" category=\"client\" type=\"pc\" xml:lang=\"en\"/>"
+ "<identity name=\"Vlug\" category=\"client\" type=\"pc\" xml:lang=\"nl\"/>"
+ "<feature var=\"foo-feature\"/>"
+ "<feature var=\"bar-feature\"/>"
+ "<feature var=\"baz-feature\"/>"
+ "</query>"));
- DiscoInfo::ref payload = boost::dynamic_pointer_cast<DiscoInfo>(parser.getPayload());
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getIdentities().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("Swift"), payload->getIdentities()[0].getName());
- CPPUNIT_ASSERT_EQUAL(std::string("pc"), payload->getIdentities()[0].getType());
- CPPUNIT_ASSERT_EQUAL(std::string("client"), payload->getIdentities()[0].getCategory());
- CPPUNIT_ASSERT_EQUAL(std::string("en"), payload->getIdentities()[0].getLanguage());
- CPPUNIT_ASSERT_EQUAL(std::string("Vlug"), payload->getIdentities()[1].getName());
- CPPUNIT_ASSERT_EQUAL(std::string("pc"), payload->getIdentities()[1].getType());
- CPPUNIT_ASSERT_EQUAL(std::string("client"), payload->getIdentities()[1].getCategory());
- CPPUNIT_ASSERT_EQUAL(std::string("nl"), payload->getIdentities()[1].getLanguage());
- CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(payload->getFeatures().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("foo-feature"), payload->getFeatures()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("bar-feature"), payload->getFeatures()[1]);
- CPPUNIT_ASSERT_EQUAL(std::string("baz-feature"), payload->getFeatures()[2]);
- CPPUNIT_ASSERT(payload->getNode().empty());
- }
+ DiscoInfo::ref payload = boost::dynamic_pointer_cast<DiscoInfo>(parser.getPayload());
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getIdentities().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("Swift"), payload->getIdentities()[0].getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("pc"), payload->getIdentities()[0].getType());
+ CPPUNIT_ASSERT_EQUAL(std::string("client"), payload->getIdentities()[0].getCategory());
+ CPPUNIT_ASSERT_EQUAL(std::string("en"), payload->getIdentities()[0].getLanguage());
+ CPPUNIT_ASSERT_EQUAL(std::string("Vlug"), payload->getIdentities()[1].getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("pc"), payload->getIdentities()[1].getType());
+ CPPUNIT_ASSERT_EQUAL(std::string("client"), payload->getIdentities()[1].getCategory());
+ CPPUNIT_ASSERT_EQUAL(std::string("nl"), payload->getIdentities()[1].getLanguage());
+ CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(payload->getFeatures().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("foo-feature"), payload->getFeatures()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("bar-feature"), payload->getFeatures()[1]);
+ CPPUNIT_ASSERT_EQUAL(std::string("baz-feature"), payload->getFeatures()[2]);
+ CPPUNIT_ASSERT(payload->getNode().empty());
+ }
- void testParse_Node() {
- PayloadsParserTester parser;
+ void testParse_Node() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<query xmlns=\"http://jabber.org/protocol/disco#info\" node=\"blahblah\">"
- "<identity name=\"Swift\" category=\"client\" type=\"pc\" xml:lang=\"en\"/>"
- "<identity name=\"Vlug\" category=\"client\" type=\"pc\" xml:lang=\"nl\"/>"
- "<feature var=\"foo-feature\"/>"
- "<feature var=\"bar-feature\"/>"
- "<feature var=\"baz-feature\"/>"
- "</query>"));
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns=\"http://jabber.org/protocol/disco#info\" node=\"blahblah\">"
+ "<identity name=\"Swift\" category=\"client\" type=\"pc\" xml:lang=\"en\"/>"
+ "<identity name=\"Vlug\" category=\"client\" type=\"pc\" xml:lang=\"nl\"/>"
+ "<feature var=\"foo-feature\"/>"
+ "<feature var=\"bar-feature\"/>"
+ "<feature var=\"baz-feature\"/>"
+ "</query>"));
- DiscoInfo::ref payload = boost::dynamic_pointer_cast<DiscoInfo>(parser.getPayload());
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getIdentities().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("Swift"), payload->getIdentities()[0].getName());
- CPPUNIT_ASSERT_EQUAL(std::string("pc"), payload->getIdentities()[0].getType());
- CPPUNIT_ASSERT_EQUAL(std::string("client"), payload->getIdentities()[0].getCategory());
- CPPUNIT_ASSERT_EQUAL(std::string("en"), payload->getIdentities()[0].getLanguage());
- CPPUNIT_ASSERT_EQUAL(std::string("Vlug"), payload->getIdentities()[1].getName());
- CPPUNIT_ASSERT_EQUAL(std::string("pc"), payload->getIdentities()[1].getType());
- CPPUNIT_ASSERT_EQUAL(std::string("client"), payload->getIdentities()[1].getCategory());
- CPPUNIT_ASSERT_EQUAL(std::string("nl"), payload->getIdentities()[1].getLanguage());
- CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(payload->getFeatures().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("foo-feature"), payload->getFeatures()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("bar-feature"), payload->getFeatures()[1]);
- CPPUNIT_ASSERT_EQUAL(std::string("baz-feature"), payload->getFeatures()[2]);
- CPPUNIT_ASSERT_EQUAL(std::string("blahblah"), payload->getNode());
- }
+ DiscoInfo::ref payload = boost::dynamic_pointer_cast<DiscoInfo>(parser.getPayload());
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getIdentities().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("Swift"), payload->getIdentities()[0].getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("pc"), payload->getIdentities()[0].getType());
+ CPPUNIT_ASSERT_EQUAL(std::string("client"), payload->getIdentities()[0].getCategory());
+ CPPUNIT_ASSERT_EQUAL(std::string("en"), payload->getIdentities()[0].getLanguage());
+ CPPUNIT_ASSERT_EQUAL(std::string("Vlug"), payload->getIdentities()[1].getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("pc"), payload->getIdentities()[1].getType());
+ CPPUNIT_ASSERT_EQUAL(std::string("client"), payload->getIdentities()[1].getCategory());
+ CPPUNIT_ASSERT_EQUAL(std::string("nl"), payload->getIdentities()[1].getLanguage());
+ CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(payload->getFeatures().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("foo-feature"), payload->getFeatures()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("bar-feature"), payload->getFeatures()[1]);
+ CPPUNIT_ASSERT_EQUAL(std::string("baz-feature"), payload->getFeatures()[2]);
+ CPPUNIT_ASSERT_EQUAL(std::string("blahblah"), payload->getNode());
+ }
- void testParse_Form() {
- PayloadsParserTester parser;
+ void testParse_Form() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<query xmlns=\"http://jabber.org/protocol/disco#info\">"
- "<feature var=\"foo-feature\"/>"
- "<x type=\"submit\" xmlns=\"jabber:x:data\">"
- "<title>Bot Configuration</title>"
- "<instructions>Hello!</instructions>"
- "</x>"
- "<feature var=\"bar-feature\"/>"
- "</query>"));
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns=\"http://jabber.org/protocol/disco#info\">"
+ "<feature var=\"foo-feature\"/>"
+ "<x type=\"submit\" xmlns=\"jabber:x:data\">"
+ "<title>Bot Configuration</title>"
+ "<instructions>Hello!</instructions>"
+ "</x>"
+ "<feature var=\"bar-feature\"/>"
+ "</query>"));
- DiscoInfo::ref payload = boost::dynamic_pointer_cast<DiscoInfo>(parser.getPayload());
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(payload->getExtensions().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("Bot Configuration"), payload->getExtensions()[0]->getTitle());
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getFeatures().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("foo-feature"), payload->getFeatures()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("bar-feature"), payload->getFeatures()[1]);
- }
+ DiscoInfo::ref payload = boost::dynamic_pointer_cast<DiscoInfo>(parser.getPayload());
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(payload->getExtensions().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("Bot Configuration"), payload->getExtensions()[0]->getTitle());
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getFeatures().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("foo-feature"), payload->getFeatures()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("bar-feature"), payload->getFeatures()[1]);
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(DiscoInfoParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/DiscoItemsParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/DiscoItemsParserTest.cpp
index ee234ad..01db978 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/DiscoItemsParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/DiscoItemsParserTest.cpp
@@ -13,30 +13,30 @@
using namespace Swift;
class DiscoItemsParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(DiscoItemsParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testParse() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<query xmlns='http://jabber.org/protocol/disco#items' node='http://jabber.org/protocol/commands'>"
- "<item jid='responder@domain' node='list' name='List Service Configurations'/>"
- "<item jid='responder@domain' node='config' name='Configure Service'/>"
- "</query>"));
-
- boost::shared_ptr<DiscoItems> payload = boost::dynamic_pointer_cast<DiscoItems>(parser.getPayload());
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getItems().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("List Service Configurations"), payload->getItems()[0].getName());
- CPPUNIT_ASSERT_EQUAL(std::string("list"), payload->getItems()[0].getNode());
- CPPUNIT_ASSERT_EQUAL(std::string("responder@domain"), payload->getItems()[0].getJID().toString());
- CPPUNIT_ASSERT_EQUAL(std::string("Configure Service"), payload->getItems()[1].getName());
- CPPUNIT_ASSERT_EQUAL(std::string("config"), payload->getItems()[1].getNode());
- CPPUNIT_ASSERT_EQUAL(std::string("responder@domain"), payload->getItems()[1].getJID().toString());
- CPPUNIT_ASSERT_EQUAL(std::string("http://jabber.org/protocol/commands"), payload->getNode());
- }
+ CPPUNIT_TEST_SUITE(DiscoItemsParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testParse() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns='http://jabber.org/protocol/disco#items' node='http://jabber.org/protocol/commands'>"
+ "<item jid='responder@domain' node='list' name='List Service Configurations'/>"
+ "<item jid='responder@domain' node='config' name='Configure Service'/>"
+ "</query>"));
+
+ boost::shared_ptr<DiscoItems> payload = boost::dynamic_pointer_cast<DiscoItems>(parser.getPayload());
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getItems().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("List Service Configurations"), payload->getItems()[0].getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("list"), payload->getItems()[0].getNode());
+ CPPUNIT_ASSERT_EQUAL(std::string("responder@domain"), payload->getItems()[0].getJID().toString());
+ CPPUNIT_ASSERT_EQUAL(std::string("Configure Service"), payload->getItems()[1].getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("config"), payload->getItems()[1].getNode());
+ CPPUNIT_ASSERT_EQUAL(std::string("responder@domain"), payload->getItems()[1].getJID().toString());
+ CPPUNIT_ASSERT_EQUAL(std::string("http://jabber.org/protocol/commands"), payload->getNode());
+ }
};
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/ErrorParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/ErrorParserTest.cpp
index 6b0391d..529d573 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/ErrorParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/ErrorParserTest.cpp
@@ -14,44 +14,44 @@
using namespace Swift;
class ErrorParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(ErrorParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testParseWithPayload);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testParse() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<error type=\"modify\">"
- "<bad-request xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>"
- "<text xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\">boo</text>"
- "</error>"));
-
- ErrorPayload::ref payload = boost::dynamic_pointer_cast<ErrorPayload>(parser.getPayload());
- CPPUNIT_ASSERT_EQUAL(ErrorPayload::BadRequest, payload->getCondition());
- CPPUNIT_ASSERT_EQUAL(ErrorPayload::Modify, payload->getType());
- CPPUNIT_ASSERT_EQUAL(std::string("boo"), payload->getText());
- CPPUNIT_ASSERT(!payload->getPayload());
- }
-
- void testParseWithPayload() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<error type=\"modify\">"
- "<bad-request xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>"
- "<delay xmlns='urn:xmpp:delay' from='juliet@capulet.com/balcony' stamp='2002-09-10T23:41:07Z'/>"
- "<text xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\">boo</text>"
- "</error>"));
-
- ErrorPayload::ref payload = boost::dynamic_pointer_cast<ErrorPayload>(parser.getPayload());
- CPPUNIT_ASSERT_EQUAL(ErrorPayload::BadRequest, payload->getCondition());
- CPPUNIT_ASSERT_EQUAL(ErrorPayload::Modify, payload->getType());
- CPPUNIT_ASSERT_EQUAL(std::string("boo"), payload->getText());
- CPPUNIT_ASSERT(boost::dynamic_pointer_cast<Delay>(payload->getPayload()));
- }
+ CPPUNIT_TEST_SUITE(ErrorParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParseWithPayload);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testParse() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<error type=\"modify\">"
+ "<bad-request xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>"
+ "<text xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\">boo</text>"
+ "</error>"));
+
+ ErrorPayload::ref payload = boost::dynamic_pointer_cast<ErrorPayload>(parser.getPayload());
+ CPPUNIT_ASSERT_EQUAL(ErrorPayload::BadRequest, payload->getCondition());
+ CPPUNIT_ASSERT_EQUAL(ErrorPayload::Modify, payload->getType());
+ CPPUNIT_ASSERT_EQUAL(std::string("boo"), payload->getText());
+ CPPUNIT_ASSERT(!payload->getPayload());
+ }
+
+ void testParseWithPayload() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<error type=\"modify\">"
+ "<bad-request xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\"/>"
+ "<delay xmlns='urn:xmpp:delay' from='juliet@capulet.com/balcony' stamp='2002-09-10T23:41:07Z'/>"
+ "<text xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\">boo</text>"
+ "</error>"));
+
+ ErrorPayload::ref payload = boost::dynamic_pointer_cast<ErrorPayload>(parser.getPayload());
+ CPPUNIT_ASSERT_EQUAL(ErrorPayload::BadRequest, payload->getCondition());
+ CPPUNIT_ASSERT_EQUAL(ErrorPayload::Modify, payload->getType());
+ CPPUNIT_ASSERT_EQUAL(std::string("boo"), payload->getText());
+ CPPUNIT_ASSERT(boost::dynamic_pointer_cast<Delay>(payload->getPayload()));
+ }
};
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp
index 0c70b5c..4ffc776 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/FormParserTest.cpp
@@ -13,216 +13,216 @@
using namespace Swift;
class FormParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(FormParserTest);
- CPPUNIT_TEST(testParse_FormInformation);
- CPPUNIT_TEST(testParse_FormLayout);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testParse_FormItems);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testParse_FormInformation() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<x type=\"submit\" xmlns=\"jabber:x:data\">"
- "<title>Bot Configuration</title>"
- "<instructions>Hello!</instructions>"
- "<instructions>Fill out this form to configure your new bot!</instructions>"
- "</x>"
- ));
-
- Form* payload = dynamic_cast<Form*>(parser.getPayload().get());
- CPPUNIT_ASSERT_EQUAL(std::string("Bot Configuration"), payload->getTitle());
- CPPUNIT_ASSERT_EQUAL(std::string("Hello!\nFill out this form to configure your new bot!"), payload->getInstructions());
- CPPUNIT_ASSERT_EQUAL(Form::SubmitType, payload->getType());
- }
-
- void testParse_FormLayout() {
- PayloadsParserTester parser;
-
- // P1 = page one, S1 = section one, F1 = field one, T1 = text one
- CPPUNIT_ASSERT(parser.parse(
- "<x type=\"form\" xmlns=\"jabber:x:data\">"
- "<page label=\"P1\" xmlns=\"http://jabber.org/protocol/xdata-layout\">"
- "<reportedref/>"
- "<text>P1T1</text>"
- "<fieldref var=\"P1F1\"/>"
- "<section label=\"P1S1\">"
- "<text>P1S1T1</text>"
- "<fieldref var=\"P1S1F1\"/>"
- "</section>"
- "</page>"
- "<page label=\"P2\" xmlns=\"http://jabber.org/protocol/xdata-layout\">"
- "<section label=\"P2S1\">"
- "<section label=\"P2S2\">"
- "<section label=\"P2S3\"/>"
- "</section>"
- "</section>"
- "</page>"
- "<field label=\"field one\" type=\"text-single\" var=\"P1F1\"/>"
- "<field label=\"field two\" type=\"text-single\" var=\"P1S1F1\"/>"
- "</x>"));
-
- Form* payload = dynamic_cast<Form*>(parser.getPayload().get());
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(payload->getFields().size()));
- // PAGE ONE - parsing of element types
- CPPUNIT_ASSERT_EQUAL(std::string("P1"), payload->getPages()[0]->getLabel());
- CPPUNIT_ASSERT(payload->getPages()[0]->getReportedRefs()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("P1T1"), payload->getPages()[0]->getTextElements()[0]->getTextString());
- CPPUNIT_ASSERT_EQUAL(std::string("P1F1"), payload->getPages()[0]->getFields()[0]->getName());
- CPPUNIT_ASSERT_EQUAL(std::string("P1S1"), payload->getPages()[0]->getChildSections()[0]->getLabel());
- CPPUNIT_ASSERT_EQUAL(std::string("P1S1T1"), payload->getPages()[0]->getChildSections()[0]->getTextElements()[0]->getTextString());
- CPPUNIT_ASSERT_EQUAL(std::string("P1S1F1"), payload->getPages()[0]->getChildSections()[0]->getFields()[0]->getName());
- // PAGE TWO - parsing of nested elements
- CPPUNIT_ASSERT_EQUAL(std::string("P2"), payload->getPages()[1]->getLabel());
- CPPUNIT_ASSERT_EQUAL(std::string("P2S1"), payload->getPages()[1]->getChildSections()[0]->getLabel());
- CPPUNIT_ASSERT_EQUAL(std::string("P2S2"), payload->getPages()[1]->getChildSections()[0]->getChildSections()[0]->getLabel());
- CPPUNIT_ASSERT_EQUAL(std::string("P2S3"), payload->getPages()[1]->getChildSections()[0]->getChildSections()[0]->getChildSections()[0]->getLabel());
- }
-
- void testParse() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<x type=\"form\" xmlns=\"jabber:x:data\">"
- "<field type=\"hidden\" var=\"FORM_TYPE\">"
- "<value>jabber:bot</value>"
- "</field>"
- "<field type=\"fixed\"><value>Section 1: Bot Info</value></field>"
- "<field label=\"The name of your bot\" type=\"text-single\" var=\"botname\"/>"
- "<field label=\"Helpful description of your bot\" type=\"text-multi\" var=\"description\"><value>This is a bot.</value><value>A quite good one actually</value></field>"
- "<field label=\"Public bot?\" type=\"boolean\" var=\"public\">"
- "<required/>"
- "<value>1</value>"
- "</field>"
- "<field label=\"Password for special access\" type=\"text-private\" var=\"password\"/>"
- "<field label=\"What features will the bot support?\" type=\"list-multi\" var=\"features\">"
- "<option label=\"Contests\"><value>contests</value></option>"
- "<option label=\"News\"><value>news</value></option>"
- "<option label=\"Polls\"><value>polls</value></option>"
- "<option label=\"Reminders\"><value>reminders</value></option>"
- "<option label=\"Search\"><value>search</value></option>"
- "<value>news</value>"
- "<value>search</value>"
- "</field>"
- "<field label=\"Maximum number of subscribers\" type=\"list-single\" var=\"maxsubs\">"
- "<value>20</value>"
- "<option label=\"10\"><value>10</value></option>"
- "<option label=\"20\"><value>20</value></option>"
- "<option label=\"30\"><value>30</value></option>"
- "<option label=\"50\"><value>50</value></option>"
- "<option label=\"100\"><value>100</value></option>"
- "<option label=\"None\"><value>none</value></option>"
- "</field>"
- "<field label=\"People to invite\" type=\"jid-multi\" var=\"invitelist\">"
- "<desc>Tell all your friends about your new bot!</desc>"
- "<value>foo@bar.com</value>"
- "<value>baz@fum.org</value>"
- "</field>"
- "<field var=\"untyped\">"
- "<value>foo</value>"
- "</field>"
- "</x>"));
-
- Form* payload = dynamic_cast<Form*>(parser.getPayload().get());
-
- CPPUNIT_ASSERT_EQUAL(10, static_cast<int>(payload->getFields().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("jabber:bot"), payload->getFields()[0]->getValues()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("FORM_TYPE"), payload->getFields()[0]->getName());
- CPPUNIT_ASSERT(!payload->getFields()[0]->getRequired());
-
- CPPUNIT_ASSERT_EQUAL(std::string("Section 1: Bot Info"), payload->getFields()[1]->getValues()[0]);
-
- CPPUNIT_ASSERT_EQUAL(std::string("The name of your bot"), payload->getFields()[2]->getLabel());
-
- CPPUNIT_ASSERT_EQUAL(std::string("This is a bot.\nA quite good one actually"), payload->getFields()[3]->getTextMultiValue());
-
- CPPUNIT_ASSERT_EQUAL(true, payload->getFields()[4]->getBoolValue());
- CPPUNIT_ASSERT(payload->getFields()[4]->getRequired());
- CPPUNIT_ASSERT_EQUAL(std::string("1"), payload->getFields()[4]->getValues()[0]);
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getFields()[6]->getValues().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("news"), payload->getFields()[6]->getValues()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("search"), payload->getFields()[6]->getValues()[1]);
- CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(payload->getFields()[6]->getOptions().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("Contests"), payload->getFields()[6]->getOptions()[0].label);
- CPPUNIT_ASSERT_EQUAL(std::string("contests"), payload->getFields()[6]->getOptions()[0].value);
- CPPUNIT_ASSERT_EQUAL(std::string("News"), payload->getFields()[6]->getOptions()[1].label);
- CPPUNIT_ASSERT_EQUAL(std::string("news"), payload->getFields()[6]->getOptions()[1].value);
-
- CPPUNIT_ASSERT_EQUAL(std::string("20"), payload->getFields()[7]->getValues()[0]);
-
- CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), payload->getFields()[8]->getJIDMultiValue(0));
- CPPUNIT_ASSERT_EQUAL(JID("baz@fum.org"), payload->getFields()[8]->getJIDMultiValue(1));
- CPPUNIT_ASSERT_EQUAL(std::string("Tell all your friends about your new bot!"), payload->getFields()[8]->getDescription());
-
- CPPUNIT_ASSERT_EQUAL(std::string("foo"), payload->getFields()[9]->getValues()[0]);
- }
-
- void testParse_FormItems() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<x xmlns='jabber:x:data' type='result'>"
- "<field type='hidden' var='FORM_TYPE'>"
- "<value>jabber:iq:search</value>"
- "</field>"
- "<reported>"
- "<field var='first' label='Given Name' type='text-single'/>"
- "<field var='last' label='Family Name' type='text-single'/>"
- "<field var='jid' label='Jabber ID' type='jid-single'/>"
- "<field var='x-gender' label='Gender' type='list-single'/>"
- "</reported>"
- "<item>"
- "<field var='first'><value>Benvolio</value></field>"
- "<field var='last'><value>Montague</value></field>"
- "<field var='jid'><value>benvolio@montague.net</value></field>"
- "<field var='x-gender'><value>male</value></field>"
- "</item>"
- "<item>"
- "<field var='first'><value>Romeo</value></field>"
- "<field var='last'><value>Montague</value></field>"
- "<field var='jid'><value>romeo@montague.net</value></field>"
- "<field var='x-gender'><value>male</value></field>"
- "</item>"
- "</x>"));
-
- Form* dataForm = dynamic_cast<Form*>(parser.getPayload().get());
- CPPUNIT_ASSERT(dataForm);
-
- Form::FormItem reported = dataForm->getReportedFields();
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), reported.size());
-
- std::vector<Form::FormItem> items = dataForm->getItems();
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items.size());
-
- Form::FormItem item = items[0];
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), item.size());
-
- CPPUNIT_ASSERT_EQUAL(std::string("Benvolio"), item[0]->getValues()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("first"), item[0]->getName());
- CPPUNIT_ASSERT_EQUAL(std::string("Montague"), item[1]->getValues()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("last"), item[1]->getName());
- boost::shared_ptr<FormField> jidField = item[2];
- CPPUNIT_ASSERT_EQUAL(JID("benvolio@montague.net"), jidField->getJIDSingleValue());
- CPPUNIT_ASSERT_EQUAL(std::string("jid"), item[2]->getName());
- CPPUNIT_ASSERT_EQUAL(std::string("male"), item[3]->getValues()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("x-gender"), item[3]->getName());
-
- item = items[1];
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), item.size());
-
- CPPUNIT_ASSERT_EQUAL(std::string("Romeo"), item[0]->getValues()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("first"), item[0]->getName());
- CPPUNIT_ASSERT_EQUAL(std::string("Montague"), item[1]->getValues()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("last"), item[1]->getName());
- jidField = item[2];
- CPPUNIT_ASSERT(jidField);
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.net"), jidField->getJIDSingleValue());
- CPPUNIT_ASSERT_EQUAL(std::string("jid"), item[2]->getName());
- CPPUNIT_ASSERT_EQUAL(std::string("male"), item[3]->getValues()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("x-gender"), item[3]->getName());
- }
+ CPPUNIT_TEST_SUITE(FormParserTest);
+ CPPUNIT_TEST(testParse_FormInformation);
+ CPPUNIT_TEST(testParse_FormLayout);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParse_FormItems);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testParse_FormInformation() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<x type=\"submit\" xmlns=\"jabber:x:data\">"
+ "<title>Bot Configuration</title>"
+ "<instructions>Hello!</instructions>"
+ "<instructions>Fill out this form to configure your new bot!</instructions>"
+ "</x>"
+ ));
+
+ Form* payload = dynamic_cast<Form*>(parser.getPayload().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("Bot Configuration"), payload->getTitle());
+ CPPUNIT_ASSERT_EQUAL(std::string("Hello!\nFill out this form to configure your new bot!"), payload->getInstructions());
+ CPPUNIT_ASSERT_EQUAL(Form::SubmitType, payload->getType());
+ }
+
+ void testParse_FormLayout() {
+ PayloadsParserTester parser;
+
+ // P1 = page one, S1 = section one, F1 = field one, T1 = text one
+ CPPUNIT_ASSERT(parser.parse(
+ "<x type=\"form\" xmlns=\"jabber:x:data\">"
+ "<page label=\"P1\" xmlns=\"http://jabber.org/protocol/xdata-layout\">"
+ "<reportedref/>"
+ "<text>P1T1</text>"
+ "<fieldref var=\"P1F1\"/>"
+ "<section label=\"P1S1\">"
+ "<text>P1S1T1</text>"
+ "<fieldref var=\"P1S1F1\"/>"
+ "</section>"
+ "</page>"
+ "<page label=\"P2\" xmlns=\"http://jabber.org/protocol/xdata-layout\">"
+ "<section label=\"P2S1\">"
+ "<section label=\"P2S2\">"
+ "<section label=\"P2S3\"/>"
+ "</section>"
+ "</section>"
+ "</page>"
+ "<field label=\"field one\" type=\"text-single\" var=\"P1F1\"/>"
+ "<field label=\"field two\" type=\"text-single\" var=\"P1S1F1\"/>"
+ "</x>"));
+
+ Form* payload = dynamic_cast<Form*>(parser.getPayload().get());
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(payload->getFields().size()));
+ // PAGE ONE - parsing of element types
+ CPPUNIT_ASSERT_EQUAL(std::string("P1"), payload->getPages()[0]->getLabel());
+ CPPUNIT_ASSERT(payload->getPages()[0]->getReportedRefs()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("P1T1"), payload->getPages()[0]->getTextElements()[0]->getTextString());
+ CPPUNIT_ASSERT_EQUAL(std::string("P1F1"), payload->getPages()[0]->getFields()[0]->getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("P1S1"), payload->getPages()[0]->getChildSections()[0]->getLabel());
+ CPPUNIT_ASSERT_EQUAL(std::string("P1S1T1"), payload->getPages()[0]->getChildSections()[0]->getTextElements()[0]->getTextString());
+ CPPUNIT_ASSERT_EQUAL(std::string("P1S1F1"), payload->getPages()[0]->getChildSections()[0]->getFields()[0]->getName());
+ // PAGE TWO - parsing of nested elements
+ CPPUNIT_ASSERT_EQUAL(std::string("P2"), payload->getPages()[1]->getLabel());
+ CPPUNIT_ASSERT_EQUAL(std::string("P2S1"), payload->getPages()[1]->getChildSections()[0]->getLabel());
+ CPPUNIT_ASSERT_EQUAL(std::string("P2S2"), payload->getPages()[1]->getChildSections()[0]->getChildSections()[0]->getLabel());
+ CPPUNIT_ASSERT_EQUAL(std::string("P2S3"), payload->getPages()[1]->getChildSections()[0]->getChildSections()[0]->getChildSections()[0]->getLabel());
+ }
+
+ void testParse() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<x type=\"form\" xmlns=\"jabber:x:data\">"
+ "<field type=\"hidden\" var=\"FORM_TYPE\">"
+ "<value>jabber:bot</value>"
+ "</field>"
+ "<field type=\"fixed\"><value>Section 1: Bot Info</value></field>"
+ "<field label=\"The name of your bot\" type=\"text-single\" var=\"botname\"/>"
+ "<field label=\"Helpful description of your bot\" type=\"text-multi\" var=\"description\"><value>This is a bot.</value><value>A quite good one actually</value></field>"
+ "<field label=\"Public bot?\" type=\"boolean\" var=\"public\">"
+ "<required/>"
+ "<value>1</value>"
+ "</field>"
+ "<field label=\"Password for special access\" type=\"text-private\" var=\"password\"/>"
+ "<field label=\"What features will the bot support?\" type=\"list-multi\" var=\"features\">"
+ "<option label=\"Contests\"><value>contests</value></option>"
+ "<option label=\"News\"><value>news</value></option>"
+ "<option label=\"Polls\"><value>polls</value></option>"
+ "<option label=\"Reminders\"><value>reminders</value></option>"
+ "<option label=\"Search\"><value>search</value></option>"
+ "<value>news</value>"
+ "<value>search</value>"
+ "</field>"
+ "<field label=\"Maximum number of subscribers\" type=\"list-single\" var=\"maxsubs\">"
+ "<value>20</value>"
+ "<option label=\"10\"><value>10</value></option>"
+ "<option label=\"20\"><value>20</value></option>"
+ "<option label=\"30\"><value>30</value></option>"
+ "<option label=\"50\"><value>50</value></option>"
+ "<option label=\"100\"><value>100</value></option>"
+ "<option label=\"None\"><value>none</value></option>"
+ "</field>"
+ "<field label=\"People to invite\" type=\"jid-multi\" var=\"invitelist\">"
+ "<desc>Tell all your friends about your new bot!</desc>"
+ "<value>foo@bar.com</value>"
+ "<value>baz@fum.org</value>"
+ "</field>"
+ "<field var=\"untyped\">"
+ "<value>foo</value>"
+ "</field>"
+ "</x>"));
+
+ Form* payload = dynamic_cast<Form*>(parser.getPayload().get());
+
+ CPPUNIT_ASSERT_EQUAL(10, static_cast<int>(payload->getFields().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("jabber:bot"), payload->getFields()[0]->getValues()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("FORM_TYPE"), payload->getFields()[0]->getName());
+ CPPUNIT_ASSERT(!payload->getFields()[0]->getRequired());
+
+ CPPUNIT_ASSERT_EQUAL(std::string("Section 1: Bot Info"), payload->getFields()[1]->getValues()[0]);
+
+ CPPUNIT_ASSERT_EQUAL(std::string("The name of your bot"), payload->getFields()[2]->getLabel());
+
+ CPPUNIT_ASSERT_EQUAL(std::string("This is a bot.\nA quite good one actually"), payload->getFields()[3]->getTextMultiValue());
+
+ CPPUNIT_ASSERT_EQUAL(true, payload->getFields()[4]->getBoolValue());
+ CPPUNIT_ASSERT(payload->getFields()[4]->getRequired());
+ CPPUNIT_ASSERT_EQUAL(std::string("1"), payload->getFields()[4]->getValues()[0]);
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getFields()[6]->getValues().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("news"), payload->getFields()[6]->getValues()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("search"), payload->getFields()[6]->getValues()[1]);
+ CPPUNIT_ASSERT_EQUAL(5, static_cast<int>(payload->getFields()[6]->getOptions().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("Contests"), payload->getFields()[6]->getOptions()[0].label);
+ CPPUNIT_ASSERT_EQUAL(std::string("contests"), payload->getFields()[6]->getOptions()[0].value);
+ CPPUNIT_ASSERT_EQUAL(std::string("News"), payload->getFields()[6]->getOptions()[1].label);
+ CPPUNIT_ASSERT_EQUAL(std::string("news"), payload->getFields()[6]->getOptions()[1].value);
+
+ CPPUNIT_ASSERT_EQUAL(std::string("20"), payload->getFields()[7]->getValues()[0]);
+
+ CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), payload->getFields()[8]->getJIDMultiValue(0));
+ CPPUNIT_ASSERT_EQUAL(JID("baz@fum.org"), payload->getFields()[8]->getJIDMultiValue(1));
+ CPPUNIT_ASSERT_EQUAL(std::string("Tell all your friends about your new bot!"), payload->getFields()[8]->getDescription());
+
+ CPPUNIT_ASSERT_EQUAL(std::string("foo"), payload->getFields()[9]->getValues()[0]);
+ }
+
+ void testParse_FormItems() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<x xmlns='jabber:x:data' type='result'>"
+ "<field type='hidden' var='FORM_TYPE'>"
+ "<value>jabber:iq:search</value>"
+ "</field>"
+ "<reported>"
+ "<field var='first' label='Given Name' type='text-single'/>"
+ "<field var='last' label='Family Name' type='text-single'/>"
+ "<field var='jid' label='Jabber ID' type='jid-single'/>"
+ "<field var='x-gender' label='Gender' type='list-single'/>"
+ "</reported>"
+ "<item>"
+ "<field var='first'><value>Benvolio</value></field>"
+ "<field var='last'><value>Montague</value></field>"
+ "<field var='jid'><value>benvolio@montague.net</value></field>"
+ "<field var='x-gender'><value>male</value></field>"
+ "</item>"
+ "<item>"
+ "<field var='first'><value>Romeo</value></field>"
+ "<field var='last'><value>Montague</value></field>"
+ "<field var='jid'><value>romeo@montague.net</value></field>"
+ "<field var='x-gender'><value>male</value></field>"
+ "</item>"
+ "</x>"));
+
+ Form* dataForm = dynamic_cast<Form*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(dataForm);
+
+ Form::FormItem reported = dataForm->getReportedFields();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), reported.size());
+
+ std::vector<Form::FormItem> items = dataForm->getItems();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items.size());
+
+ Form::FormItem item = items[0];
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), item.size());
+
+ CPPUNIT_ASSERT_EQUAL(std::string("Benvolio"), item[0]->getValues()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("first"), item[0]->getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("Montague"), item[1]->getValues()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("last"), item[1]->getName());
+ boost::shared_ptr<FormField> jidField = item[2];
+ CPPUNIT_ASSERT_EQUAL(JID("benvolio@montague.net"), jidField->getJIDSingleValue());
+ CPPUNIT_ASSERT_EQUAL(std::string("jid"), item[2]->getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("male"), item[3]->getValues()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("x-gender"), item[3]->getName());
+
+ item = items[1];
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), item.size());
+
+ CPPUNIT_ASSERT_EQUAL(std::string("Romeo"), item[0]->getValues()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("first"), item[0]->getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("Montague"), item[1]->getValues()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("last"), item[1]->getName());
+ jidField = item[2];
+ CPPUNIT_ASSERT(jidField);
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.net"), jidField->getJIDSingleValue());
+ CPPUNIT_ASSERT_EQUAL(std::string("jid"), item[2]->getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("male"), item[3]->getValues()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("x-gender"), item[3]->getName());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(FormParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/ForwardedParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/ForwardedParserTest.cpp
index fae259f..30af3ec 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/ForwardedParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/ForwardedParserTest.cpp
@@ -19,100 +19,100 @@ using namespace Swift;
class ForwardedParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(ForwardedParserTest);
- CPPUNIT_TEST(testParseIQ);
- CPPUNIT_TEST(testParseMessage);
- CPPUNIT_TEST(testParseMessageNoDelay);
- CPPUNIT_TEST(testParsePresence);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testParseIQ() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<forwarded xmlns=\"urn:xmpp:forward:0\">"
- "<delay xmlns=\"urn:xmpp:delay\" stamp=\"2010-07-10T23:08:25Z\"/>"
- "<iq xmlns=\"jabber:client\" type=\"get\" from=\"kindanormal@example.com/IM\" to=\"stupidnewbie@example.com\" id=\"id0\"/>"
- "</forwarded>"));
-
- boost::shared_ptr<Forwarded> payload = parser.getPayload<Forwarded>();
- CPPUNIT_ASSERT(!!payload);
- CPPUNIT_ASSERT(payload->getDelay());
- CPPUNIT_ASSERT_EQUAL(std::string("2010-07-10T23:08:25Z"), dateTimeToString(payload->getDelay()->getStamp()));
-
- boost::shared_ptr<IQ> iq = boost::dynamic_pointer_cast<IQ>(payload->getStanza());
- CPPUNIT_ASSERT(!!iq);
- CPPUNIT_ASSERT_EQUAL(JID("stupidnewbie@example.com"), iq->getTo());
- CPPUNIT_ASSERT_EQUAL(JID("kindanormal@example.com/IM"), iq->getFrom());
- CPPUNIT_ASSERT_EQUAL(std::string("id0"), iq->getID());
- CPPUNIT_ASSERT_EQUAL(IQ::Get, iq->getType());
- }
-
- void testParseMessage() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<forwarded xmlns=\"urn:xmpp:forward:0\">"
- "<delay xmlns=\"urn:xmpp:delay\" stamp=\"2010-07-10T23:08:25Z\"/>"
- "<message xmlns=\"jabber:client\" to=\"juliet@capulet.lit/balcony\" from=\"romeo@montague.lit/orchard\" type=\"chat\">"
- "<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>"
- "</message>"
- "</forwarded>"));
-
- boost::shared_ptr<Forwarded> payload = parser.getPayload<Forwarded>();
- CPPUNIT_ASSERT(!!payload);
- CPPUNIT_ASSERT(payload->getDelay());
- CPPUNIT_ASSERT_EQUAL(std::string("2010-07-10T23:08:25Z"), dateTimeToString(payload->getDelay()->getStamp()));
-
- boost::shared_ptr<Message> message = boost::dynamic_pointer_cast<Message>(payload->getStanza());
- CPPUNIT_ASSERT(!!message);
- const std::string expectedBody = "Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.";
- CPPUNIT_ASSERT_EQUAL(expectedBody, message->getBody().get());
- CPPUNIT_ASSERT_EQUAL(Message::Chat, message->getType());
- CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.lit/balcony"), message->getTo());
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), message->getFrom());
- }
-
- void testParseMessageNoDelay() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<forwarded xmlns=\"urn:xmpp:forward:0\">"
- "<message xmlns=\"jabber:client\" to=\"juliet@capulet.lit/balcony\" from=\"romeo@montague.lit/orchard\" type=\"chat\">"
- "<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>"
- "</message>"
- "</forwarded>"));
-
- boost::shared_ptr<Forwarded> payload = parser.getPayload<Forwarded>();
- CPPUNIT_ASSERT(!!payload);
- CPPUNIT_ASSERT(!payload->getDelay());
-
- boost::shared_ptr<Message> message = boost::dynamic_pointer_cast<Message>(payload->getStanza());
- CPPUNIT_ASSERT(!!message);
- const std::string expectedBody = "Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.";
- CPPUNIT_ASSERT_EQUAL(expectedBody, message->getBody().get());
- CPPUNIT_ASSERT_EQUAL(Message::Chat, message->getType());
- CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.lit/balcony"), message->getTo());
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), message->getFrom());
- }
-
- void testParsePresence() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<forwarded xmlns=\"urn:xmpp:forward:0\">"
- "<delay xmlns=\"urn:xmpp:delay\" stamp=\"2010-07-10T23:08:25Z\"/>"
- "<presence xmlns=\"jabber:client\" from=\"alice@wonderland.lit/rabbithole\" to=\"madhatter@wonderland.lit\" type=\"unavailable\"/>"
- "</forwarded>"));
-
- boost::shared_ptr<Forwarded> payload = parser.getPayload<Forwarded>();
- CPPUNIT_ASSERT(!!payload);
- CPPUNIT_ASSERT(payload->getDelay());
- CPPUNIT_ASSERT_EQUAL(std::string("2010-07-10T23:08:25Z"), dateTimeToString(payload->getDelay()->getStamp()));
-
- boost::shared_ptr<Presence> presence = boost::dynamic_pointer_cast<Presence>(payload->getStanza());
- CPPUNIT_ASSERT(!!presence);
- CPPUNIT_ASSERT_EQUAL(JID("madhatter@wonderland.lit"), presence->getTo());
- CPPUNIT_ASSERT_EQUAL(JID("alice@wonderland.lit/rabbithole"), presence->getFrom());
- CPPUNIT_ASSERT_EQUAL(Presence::Unavailable, presence->getType());
- }
+ CPPUNIT_TEST_SUITE(ForwardedParserTest);
+ CPPUNIT_TEST(testParseIQ);
+ CPPUNIT_TEST(testParseMessage);
+ CPPUNIT_TEST(testParseMessageNoDelay);
+ CPPUNIT_TEST(testParsePresence);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testParseIQ() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<forwarded xmlns=\"urn:xmpp:forward:0\">"
+ "<delay xmlns=\"urn:xmpp:delay\" stamp=\"2010-07-10T23:08:25Z\"/>"
+ "<iq xmlns=\"jabber:client\" type=\"get\" from=\"kindanormal@example.com/IM\" to=\"stupidnewbie@example.com\" id=\"id0\"/>"
+ "</forwarded>"));
+
+ boost::shared_ptr<Forwarded> payload = parser.getPayload<Forwarded>();
+ CPPUNIT_ASSERT(!!payload);
+ CPPUNIT_ASSERT(payload->getDelay());
+ CPPUNIT_ASSERT_EQUAL(std::string("2010-07-10T23:08:25Z"), dateTimeToString(payload->getDelay()->getStamp()));
+
+ boost::shared_ptr<IQ> iq = boost::dynamic_pointer_cast<IQ>(payload->getStanza());
+ CPPUNIT_ASSERT(!!iq);
+ CPPUNIT_ASSERT_EQUAL(JID("stupidnewbie@example.com"), iq->getTo());
+ CPPUNIT_ASSERT_EQUAL(JID("kindanormal@example.com/IM"), iq->getFrom());
+ CPPUNIT_ASSERT_EQUAL(std::string("id0"), iq->getID());
+ CPPUNIT_ASSERT_EQUAL(IQ::Get, iq->getType());
+ }
+
+ void testParseMessage() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<forwarded xmlns=\"urn:xmpp:forward:0\">"
+ "<delay xmlns=\"urn:xmpp:delay\" stamp=\"2010-07-10T23:08:25Z\"/>"
+ "<message xmlns=\"jabber:client\" to=\"juliet@capulet.lit/balcony\" from=\"romeo@montague.lit/orchard\" type=\"chat\">"
+ "<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>"
+ "</message>"
+ "</forwarded>"));
+
+ boost::shared_ptr<Forwarded> payload = parser.getPayload<Forwarded>();
+ CPPUNIT_ASSERT(!!payload);
+ CPPUNIT_ASSERT(payload->getDelay());
+ CPPUNIT_ASSERT_EQUAL(std::string("2010-07-10T23:08:25Z"), dateTimeToString(payload->getDelay()->getStamp()));
+
+ boost::shared_ptr<Message> message = boost::dynamic_pointer_cast<Message>(payload->getStanza());
+ CPPUNIT_ASSERT(!!message);
+ const std::string expectedBody = "Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.";
+ CPPUNIT_ASSERT_EQUAL(expectedBody, message->getBody().get());
+ CPPUNIT_ASSERT_EQUAL(Message::Chat, message->getType());
+ CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.lit/balcony"), message->getTo());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), message->getFrom());
+ }
+
+ void testParseMessageNoDelay() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<forwarded xmlns=\"urn:xmpp:forward:0\">"
+ "<message xmlns=\"jabber:client\" to=\"juliet@capulet.lit/balcony\" from=\"romeo@montague.lit/orchard\" type=\"chat\">"
+ "<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>"
+ "</message>"
+ "</forwarded>"));
+
+ boost::shared_ptr<Forwarded> payload = parser.getPayload<Forwarded>();
+ CPPUNIT_ASSERT(!!payload);
+ CPPUNIT_ASSERT(!payload->getDelay());
+
+ boost::shared_ptr<Message> message = boost::dynamic_pointer_cast<Message>(payload->getStanza());
+ CPPUNIT_ASSERT(!!message);
+ const std::string expectedBody = "Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.";
+ CPPUNIT_ASSERT_EQUAL(expectedBody, message->getBody().get());
+ CPPUNIT_ASSERT_EQUAL(Message::Chat, message->getType());
+ CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.lit/balcony"), message->getTo());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), message->getFrom());
+ }
+
+ void testParsePresence() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<forwarded xmlns=\"urn:xmpp:forward:0\">"
+ "<delay xmlns=\"urn:xmpp:delay\" stamp=\"2010-07-10T23:08:25Z\"/>"
+ "<presence xmlns=\"jabber:client\" from=\"alice@wonderland.lit/rabbithole\" to=\"madhatter@wonderland.lit\" type=\"unavailable\"/>"
+ "</forwarded>"));
+
+ boost::shared_ptr<Forwarded> payload = parser.getPayload<Forwarded>();
+ CPPUNIT_ASSERT(!!payload);
+ CPPUNIT_ASSERT(payload->getDelay());
+ CPPUNIT_ASSERT_EQUAL(std::string("2010-07-10T23:08:25Z"), dateTimeToString(payload->getDelay()->getStamp()));
+
+ boost::shared_ptr<Presence> presence = boost::dynamic_pointer_cast<Presence>(payload->getStanza());
+ CPPUNIT_ASSERT(!!presence);
+ CPPUNIT_ASSERT_EQUAL(JID("madhatter@wonderland.lit"), presence->getTo());
+ CPPUNIT_ASSERT_EQUAL(JID("alice@wonderland.lit/rabbithole"), presence->getFrom());
+ CPPUNIT_ASSERT_EQUAL(Presence::Unavailable, presence->getType());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(ForwardedParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/IBBParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/IBBParserTest.cpp
index b7adead..782cb32 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/IBBParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/IBBParserTest.cpp
@@ -14,26 +14,26 @@
using namespace Swift;
class IBBParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(IBBParserTest);
- CPPUNIT_TEST(testParse_Data);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testParse_Data() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<data xmlns='http://jabber.org/protocol/ibb' seq='4'>\n"
- "\t YWJjZGVmZ2loamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjEyMzQ1\n"
- "\t Njc4OTAK\n"
- "</data>"
- ));
-
- IBB::ref ibb = parser.getPayload<IBB>();
- CPPUNIT_ASSERT(ibb->getAction() == IBB::Data);
- CPPUNIT_ASSERT(createByteArray("abcdefgihjklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\x0a") == ibb->getData());
- CPPUNIT_ASSERT_EQUAL(4, ibb->getSequenceNumber());
- }
+ CPPUNIT_TEST_SUITE(IBBParserTest);
+ CPPUNIT_TEST(testParse_Data);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testParse_Data() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<data xmlns='http://jabber.org/protocol/ibb' seq='4'>\n"
+ "\t YWJjZGVmZ2loamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWjEyMzQ1\n"
+ "\t Njc4OTAK\n"
+ "</data>"
+ ));
+
+ IBB::ref ibb = parser.getPayload<IBB>();
+ CPPUNIT_ASSERT(ibb->getAction() == IBB::Data);
+ CPPUNIT_ASSERT(createByteArray("abcdefgihjklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890\x0a") == ibb->getData());
+ CPPUNIT_ASSERT_EQUAL(4, ibb->getSequenceNumber());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(IBBParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/IdleParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/IdleParserTest.cpp
index 7975352..462247a 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/IdleParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/IdleParserTest.cpp
@@ -21,24 +21,24 @@
using namespace Swift;
class IdleParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(IdleParserTest);
- CPPUNIT_TEST(testParse_XepWhatever_Example1);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(IdleParserTest);
+ CPPUNIT_TEST(testParse_XepWhatever_Example1);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testParse_XepWhatever_Example1() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<presence from='juliet@capulet.com/balcony'>\n"
- "<show>away</show>\n"
- "<idle xmlns='urn:xmpp:idle:1' since='1969-07-21T02:56:15Z'/>\n"
- "</presence>\n"
- ));
+ public:
+ void testParse_XepWhatever_Example1() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<presence from='juliet@capulet.com/balcony'>\n"
+ "<show>away</show>\n"
+ "<idle xmlns='urn:xmpp:idle:1' since='1969-07-21T02:56:15Z'/>\n"
+ "</presence>\n"
+ ));
- Presence::ref presence = parser.getPayload<Presence>();
- CPPUNIT_ASSERT(presence);
- Idle::ref idle = presence->getPayload<Idle>();
- CPPUNIT_ASSERT(idle);
- CPPUNIT_ASSERT(stringToDateTime("1969-07-21T02:56:15Z") == idle->getSince());
- }
+ Presence::ref presence = parser.getPayload<Presence>();
+ CPPUNIT_ASSERT(presence);
+ Idle::ref idle = presence->getPayload<Idle>();
+ CPPUNIT_ASSERT(idle);
+ CPPUNIT_ASSERT(stringToDateTime("1969-07-21T02:56:15Z") == idle->getSince());
+ }
};
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/InBandRegistrationPayloadParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/InBandRegistrationPayloadParserTest.cpp
index ea33e82..6d08812 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/InBandRegistrationPayloadParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/InBandRegistrationPayloadParserTest.cpp
@@ -14,7 +14,7 @@
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <Swiften/Elements/Form.h>
-#include <Swiften/Elements/InBandRegistrationPayload.h>
+#include <Swiften/Elements/InBandRegistrationPayload.h>
#include <Swiften/Parser/PayloadParsers/InBandRegistrationPayloadParser.h>
#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
@@ -22,53 +22,53 @@ using namespace Swift;
class InBandRegistrationPayloadParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(InBandRegistrationPayloadParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testParse_Form);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(InBandRegistrationPayloadParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParse_Form);
+ CPPUNIT_TEST_SUITE_END();
- public:
- InBandRegistrationPayloadParserTest() {}
+ public:
+ InBandRegistrationPayloadParserTest() {}
- void testParse() {
- PayloadsParserTester parser;
+ void testParse() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<query xmlns=\"jabber:iq:register\">"
- "<registered/>"
- "</query>"));
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns=\"jabber:iq:register\">"
+ "<registered/>"
+ "</query>"));
- InBandRegistrationPayload* payload = dynamic_cast<InBandRegistrationPayload*>(parser.getPayload().get());
- CPPUNIT_ASSERT(payload);
- CPPUNIT_ASSERT(payload->isRegistered());
- }
+ InBandRegistrationPayload* payload = dynamic_cast<InBandRegistrationPayload*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(payload);
+ CPPUNIT_ASSERT(payload->isRegistered());
+ }
- void testParse_Form() {
- PayloadsParserTester parser;
+ void testParse_Form() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<query xmlns=\"jabber:iq:register\">"
- "<instructions>Use the enclosed form to register.</instructions>"
- "<x type=\"form\" xmlns=\"jabber:x:data\">"
- "<title>Contest Registration</title>"
- "<field type=\"hidden\" var=\"FORM_TYPE\">"
- "<value>jabber:iq:register</value>"
- "</field>"
- "</x>"
- "</query>"));
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns=\"jabber:iq:register\">"
+ "<instructions>Use the enclosed form to register.</instructions>"
+ "<x type=\"form\" xmlns=\"jabber:x:data\">"
+ "<title>Contest Registration</title>"
+ "<field type=\"hidden\" var=\"FORM_TYPE\">"
+ "<value>jabber:iq:register</value>"
+ "</field>"
+ "</x>"
+ "</query>"));
- InBandRegistrationPayload* payload = dynamic_cast<InBandRegistrationPayload*>(parser.getPayload().get());
- CPPUNIT_ASSERT(payload);
- boost::optional<std::string> instruction = payload->getInstructions();
- CPPUNIT_ASSERT(instruction);
- CPPUNIT_ASSERT_EQUAL(std::string("Use the enclosed form to register."), instruction.get());
+ InBandRegistrationPayload* payload = dynamic_cast<InBandRegistrationPayload*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(payload);
+ boost::optional<std::string> instruction = payload->getInstructions();
+ CPPUNIT_ASSERT(instruction);
+ CPPUNIT_ASSERT_EQUAL(std::string("Use the enclosed form to register."), instruction.get());
- Form::ref form = payload->getForm();
- CPPUNIT_ASSERT(form);
- CPPUNIT_ASSERT_EQUAL(std::string("Contest Registration"), form->getTitle());
- CPPUNIT_ASSERT_EQUAL(Form::FormType, form->getType());
- CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:register"), form->getFormType());
- }
+ Form::ref form = payload->getForm();
+ CPPUNIT_ASSERT(form);
+ CPPUNIT_ASSERT_EQUAL(std::string("Contest Registration"), form->getTitle());
+ CPPUNIT_ASSERT_EQUAL(Form::FormType, form->getType());
+ CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:register"), form->getFormType());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(InBandRegistrationPayloadParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/JingleParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/JingleParserTest.cpp
index 56143ef..3bf79a5 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/JingleParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/JingleParserTest.cpp
@@ -26,592 +26,592 @@
using namespace Swift;
class JingleParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(JingleParserTest);
- CPPUNIT_TEST(testParse_Xep0166_Example3);
- CPPUNIT_TEST(testParse_Xep0166_Example8);
-
- CPPUNIT_TEST(testParse_Xep0261_Example1);
- CPPUNIT_TEST(testParse_Xep0261_Example3);
- CPPUNIT_TEST(testParse_Xep0261_Example9);
- CPPUNIT_TEST(testParse_Xep0261_Example13);
-
- CPPUNIT_TEST(testParse_Xep0234_Example1);
- CPPUNIT_TEST(testParse_Xep0234_Example3);
- CPPUNIT_TEST(testParse_Xep0234_Example5);
- CPPUNIT_TEST(testParse_Xep0234_Example8);
- CPPUNIT_TEST(testParse_Xep0234_Example10);
-
- CPPUNIT_TEST(testParse_Xep0260_Example1);
- CPPUNIT_TEST(testParse_Xep0260_Example3);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- //http://xmpp.org/extensions/xep-0166.html#example-3
- void testParse_Xep0166_Example3() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<jingle xmlns='urn:xmpp:jingle:1'\n"
- " action='session-terminate'\n"
- " sid='a73sjjvkla37jfea'>\n"
- " <reason>\n"
- " <success/>\n"
- " </reason>\n"
- "</jingle>\n"
- ));
-
- JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
- CPPUNIT_ASSERT(jingle);
- CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionTerminate, jingle->getAction());
- CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
- CPPUNIT_ASSERT_EQUAL(JinglePayload::Reason::Success,
- jingle->getReason().get_value_or(JinglePayload::Reason(JinglePayload::Reason::UnknownType, "")).type);
- }
-
- //http://xmpp.org/extensions/xep-0166.html#example-8
- void testParse_Xep0166_Example8() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<jingle xmlns='urn:xmpp:jingle:1'\n"
- " action='session-terminate'\n"
- " sid='a73sjjvkla37jfea'>\n"
- " <reason>\n"
- " <success/>\n"
- " <text>Sorry, gotta go!</text>\n"
- " </reason>\n"
- "</jingle>\n"
- ));
- JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
- CPPUNIT_ASSERT(jingle);
- CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionTerminate, jingle->getAction());
- CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
- CPPUNIT_ASSERT_EQUAL(JinglePayload::Reason::Success,
- jingle->getReason().get_value_or(JinglePayload::Reason(JinglePayload::Reason::UnknownType, "")).type);
- CPPUNIT_ASSERT_EQUAL(std::string("Sorry, gotta go!"),
- jingle->getReason().get_value_or(JinglePayload::Reason(JinglePayload::Reason::UnknownType, "")).text);
- }
-
- // IBB Transport Method Examples
-
- // http://xmpp.org/extensions/xep-0261.html#example-1
- void testParse_Xep0261_Example1() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<jingle xmlns='urn:xmpp:jingle:1'\n"
- " action='session-initiate'\n"
- " initiator='romeo@montague.lit/orchard'\n"
- " sid='a73sjjvkla37jfea'>\n"
- " <content creator='initiator' name='ex'>\n"
- " <description xmlns='urn:xmpp:example'/>\n"
- " <transport xmlns='urn:xmpp:jingle:transports:ibb:1'\n"
- " block-size='4096'\n"
- " sid='ch3d9s71'/>\n"
- " </content>\n"
- "</jingle>\n"
- ));
- JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
- CPPUNIT_ASSERT(jingle);
- CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionInitiate, jingle->getAction());
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
- CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
-
- std::vector<JingleContentPayload::ref> payloads = jingle->getContents();
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), payloads.size());
- JingleContentPayload::ref payload = payloads[0];
- CPPUNIT_ASSERT_EQUAL(JingleContentPayload::InitiatorCreator, payload->getCreator());
- CPPUNIT_ASSERT_EQUAL(std::string("ex"), payload->getName());
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), payload->getTransports().size());
-
- JingleIBBTransportPayload::ref transportPaylod = payload->getTransport<JingleIBBTransportPayload>();
- CPPUNIT_ASSERT(transportPaylod);
- CPPUNIT_ASSERT_EQUAL(4096U, *transportPaylod->getBlockSize());
- CPPUNIT_ASSERT_EQUAL(std::string("ch3d9s71"), transportPaylod->getSessionID());
- }
-
- // http://xmpp.org/extensions/xep-0261.html#example-1
- void testParse_Xep0261_Example3() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<jingle xmlns='urn:xmpp:jingle:1'\n"
- " action='session-accept'\n"
- " initiator='romeo@montague.lit/orchard'\n"
- " responder='juliet@capulet.lit/balcony'\n"
- " sid='a73sjjvkla37jfea'>\n"
- " <content creator='initiator' name='ex'>\n"
- " <description xmlns='urn:xmpp:example'/>\n"
- " <transport xmlns='urn:xmpp:jingle:transports:ibb:1'\n"
- " block-size='2048'\n"
- " sid='ch3d9s71'/>\n"
- " </content>\n"
- " </jingle>\n"
- ));
- JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
- CPPUNIT_ASSERT(jingle);
- CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionAccept, jingle->getAction());
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
- CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.lit/balcony"), jingle->getResponder());
- CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
-
- std::vector<JingleContentPayload::ref> payloads = jingle->getContents();
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), payloads.size());
- JingleContentPayload::ref payload = payloads[0];
- CPPUNIT_ASSERT_EQUAL(JingleContentPayload::InitiatorCreator, payload->getCreator());
- CPPUNIT_ASSERT_EQUAL(std::string("ex"), payload->getName());
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), payload->getTransports().size());
-
- JingleIBBTransportPayload::ref transportPaylod = payload->getTransport<JingleIBBTransportPayload>();
- CPPUNIT_ASSERT(transportPaylod);
- CPPUNIT_ASSERT_EQUAL(2048U, *transportPaylod->getBlockSize());
- CPPUNIT_ASSERT_EQUAL(std::string("ch3d9s71"), transportPaylod->getSessionID());
- }
-
- // http://xmpp.org/extensions/xep-0261.html#example-9
- void testParse_Xep0261_Example9() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<jingle xmlns='urn:xmpp:jingle:1'\n"
- " action='transport-info'\n"
- " initiator='romeo@montague.lit/orchard'\n"
- " sid='a73sjjvkla37jfea'>\n"
- " <content creator='initiator' name='ex'>\n"
- " <transport xmlns='urn:xmpp:jingle:transports:ibb:1'\n"
- " block-size='2048'\n"
- " sid='bt8a71h6'/>\n"
- " </content>\n"
- "</jingle>\n"
- ));
- JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
- CPPUNIT_ASSERT(jingle);
- CPPUNIT_ASSERT_EQUAL(JinglePayload::TransportInfo, jingle->getAction());
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
- CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
-
- std::vector<JingleContentPayload::ref> payloads = jingle->getContents();
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), payloads.size());
- JingleContentPayload::ref payload = payloads[0];
- CPPUNIT_ASSERT_EQUAL(JingleContentPayload::InitiatorCreator, payload->getCreator());
- CPPUNIT_ASSERT_EQUAL(std::string("ex"), payload->getName());
-
- JingleIBBTransportPayload::ref transportPaylod = payload->getTransport<JingleIBBTransportPayload>();
- CPPUNIT_ASSERT(transportPaylod);
- CPPUNIT_ASSERT_EQUAL(2048U, *transportPaylod->getBlockSize());
- CPPUNIT_ASSERT_EQUAL(std::string("bt8a71h6"), transportPaylod->getSessionID());
- }
-
- // http://xmpp.org/extensions/xep-0261.html#example-13
- void testParse_Xep0261_Example13() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<jingle xmlns='urn:xmpp:jingle:1'\n"
- " action='session-terminate'\n"
- " initiator='romeo@montague.lit/orchard'\n"
- " sid='a73sjjvkla37jfea'>\n"
- " <reason><success/></reason>\n"
- " </jingle>\n"
- ));
-
- JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
- CPPUNIT_ASSERT(jingle);
- CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionTerminate, jingle->getAction());
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
- CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
- CPPUNIT_ASSERT_EQUAL(JinglePayload::Reason::Success, jingle->getReason().get_value_or(JinglePayload::Reason()).type);
-
- }
-
- // Jingle File Transfer Examples
-
- // http://xmpp.org/extensions/xep-0234.html#example-1
- void testParse_Xep0234_Example1() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<jingle xmlns='urn:xmpp:jingle:1'\n"
- " action='session-initiate'\n"
- " initiator='romeo@montague.lit/orchard'\n"
- " sid='851ba2'>\n"
- "<content creator='initiator' name='a-file-offer'>\n"
- "<description xmlns='urn:xmpp:jingle:apps:file-transfer:4'>\n"
- "<file>\n"
- "<date>1969-07-21T02:56:15Z</date>\n"
- "<desc>This is a test. If this were a real file...</desc>\n"
- "<media-type>text/plain</media-type>\n"
- "<name>test.txt</name>\n"
- "<range/>\n"
- "<size>1022</size>\n"
- "<hash xmlns='urn:xmpp:hashes:1' algo='sha-1'>VS2nSZMIUsaa5dIUHTdmsQ==</hash>\n"
- "</file>\n"
- "</description>\n"
- "<transport xmlns='urn:xmpp:jingle:transports:s5b:1'\n"
- " mode='tcp'\n"
- " sid='vj3hs98y'>\n"
- "<candidate cid='hft54dqy'\n"
- " host='192.168.4.1'\n"
- " jid='romeo@montague.lit/orchard'\n"
- " port='5086'\n"
- " priority='8257636'\n"
- " type='direct'/>\n"
- "<candidate cid='hutr46fe'\n"
- " host='24.24.24.1'\n"
- " jid='romeo@montague.lit/orchard'\n"
- " port='5087'\n"
- " priority='8258636'\n"
- " type='direct'/>\n"
- "</transport>\n"
- "</content>\n"
- "</jingle>\n"
- ));
-
- JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
- CPPUNIT_ASSERT(jingle);
- CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionInitiate, jingle->getAction());
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
- CPPUNIT_ASSERT_EQUAL(std::string("851ba2"), jingle->getSessionID());
-
- std::vector<JingleContentPayload::ref> contents = jingle->getContents();
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), contents.size());
-
- JingleFileTransferDescription::ref description = contents[0]->getDescription<JingleFileTransferDescription>();
-
- CPPUNIT_ASSERT(description);
- JingleFileTransferFileInfo fileInfo = description->getFileInfo();
- CPPUNIT_ASSERT_EQUAL(std::string("test.txt"), fileInfo.getName());
- CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), fileInfo.getHashes().begin()->first);
- CPPUNIT_ASSERT_EQUAL(std::string("VS2nSZMIUsaa5dIUHTdmsQ=="), Base64::encode(fileInfo.getHashes().begin()->second));
- CPPUNIT_ASSERT(1022 == fileInfo.getSize());
- CPPUNIT_ASSERT_EQUAL(std::string("This is a test. If this were a real file..."), fileInfo.getDescription());
- CPPUNIT_ASSERT_EQUAL(true, fileInfo.getSupportsRangeRequests());
- CPPUNIT_ASSERT(stringToDateTime("1969-07-21T02:56:15Z") == fileInfo.getDate());
- }
-
- // http://xmpp.org/extensions/xep-0234.html#example-3
- void testParse_Xep0234_Example3() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<jingle xmlns='urn:xmpp:jingle:1'\n"
- " action='session-accept'\n"
- " initiator='romeo@montague.lit/orchard'\n"
- " sid='851ba2'>\n"
- "<content creator='initiator' name='a-file-offer'>\n"
- "<description xmlns='urn:xmpp:jingle:apps:file-transfer:4'>\n"
- "<file>\n"
- "<date>1969-07-21T02:56:15Z</date>\n"
- "<desc>This is a test. If this were a real file...</desc>\n"
- "<media-type>text/plain</media-type>\n"
- "<name>test.txt</name>\n"
- "<range/>\n"
- "<size>1022</size>\n"
- "<hash xmlns='urn:xmpp:hashes:1' algo='sha-1'>VS2nSZMIUsaa5dIUHTdmsQ==</hash>\n"
- "</file>\n"
- "</description>\n"
- " <transport xmlns='urn:xmpp:jingle:transports:s5b:1'\n"
- " mode='tcp'\n"
- " sid='vj3hs98y'>\n"
- " <candidate cid='ht567dq'\n"
- " host='192.169.1.10'\n"
- " jid='juliet@capulet.lit/balcony'\n"
- " port='6539'\n"
- " priority='8257636'\n"
- " type='direct'/>\n"
- " <candidate cid='hr65dqyd'\n"
- " host='134.102.201.180'\n"
- " jid='juliet@capulet.lit/balcony'\n"
- " port='16453'\n"
- " priority='7929856'\n"
- " type='assisted'/>\n"
- " <candidate cid='grt654q2'\n"
- " host='2001:638:708:30c9:219:d1ff:fea4:a17d'\n"
- " jid='juliet@capulet.lit/balcony'\n"
- " port='6539'\n"
- " priority='8257606'\n"
- " type='direct'/>\n"
- " </transport>\n"
- " </content>\n"
- "</jingle>\n"
- ));
-
- JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
- CPPUNIT_ASSERT(jingle);
- CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionAccept, jingle->getAction());
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
- CPPUNIT_ASSERT_EQUAL(std::string("851ba2"), jingle->getSessionID());
-
- std::vector<JingleContentPayload::ref> contents = jingle->getContents();
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), contents.size());
-
- JingleFileTransferDescription::ref description = contents[0]->getDescription<JingleFileTransferDescription>();
-
- CPPUNIT_ASSERT(description);
-
- JingleFileTransferFileInfo fileInfo = description->getFileInfo();
- CPPUNIT_ASSERT_EQUAL(std::string("test.txt"), fileInfo.getName());
- CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), fileInfo.getHashes().begin()->first);
- CPPUNIT_ASSERT_EQUAL(std::string("VS2nSZMIUsaa5dIUHTdmsQ=="), Base64::encode(fileInfo.getHashes().begin()->second));
- CPPUNIT_ASSERT(1022 == fileInfo.getSize());
- CPPUNIT_ASSERT_EQUAL(std::string("This is a test. If this were a real file..."), fileInfo.getDescription());
- CPPUNIT_ASSERT_EQUAL(true, fileInfo.getSupportsRangeRequests());
- CPPUNIT_ASSERT(stringToDateTime("1969-07-21T02:56:15Z") == fileInfo.getDate());
- }
-
- // http://xmpp.org/extensions/xep-0234.html#example-5
- void testParse_Xep0234_Example5() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<jingle xmlns='urn:xmpp:jingle:1'\n"
- " action='transport-info'\n"
- " initiator='romeo@montague.lit/orchard'\n"
- " sid='a73sjjvkla37jfea'>\n"
- " <content creator='initiator' name='ex'>\n"
- " <transport xmlns='urn:xmpp:jingle:transports:s5b:1'\n"
- " sid='vj3hs98y'>\n"
- " <candidate-used cid='hr65dqyd'/>\n"
- " </transport>\n"
- " </content>\n"
- "</jingle>\n"
- ));
-
- JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
- CPPUNIT_ASSERT(jingle);
- CPPUNIT_ASSERT_EQUAL(JinglePayload::TransportInfo, jingle->getAction());
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
- CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
-
- std::vector<JingleContentPayload::ref> contents = jingle->getContents();
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), contents.size());
-
- JingleS5BTransportPayload::ref transport = contents[0]->getTransport<JingleS5BTransportPayload>();
- CPPUNIT_ASSERT(transport);
-
- CPPUNIT_ASSERT_EQUAL(std::string("vj3hs98y"), transport->getSessionID());
- CPPUNIT_ASSERT_EQUAL(std::string("hr65dqyd"), transport->getCandidateUsed());
- }
-
- // http://xmpp.org/extensions/xep-0234.html#example-8
- void testParse_Xep0234_Example8() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<jingle xmlns='urn:xmpp:jingle:1'\n"
- " action='session-info'\n"
- " initiator='romeo@montague.lit/orchard'\n"
- " sid='a73sjjvkla37jfea'>\n"
- " <checksum xmlns='urn:xmpp:jingle:apps:file-transfer:4'>\n"
- " <file>\n"
- " <hash xmlns='urn:xmpp:hashes:0' algo='sha-1'>VS2nSZMIUsaa5dIUHTdmsQ==</hash>\n"
- " </file>\n"
- " </checksum>\n"
- "</jingle>\n"
- ));
- JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
- CPPUNIT_ASSERT(jingle);
- CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionInfo, jingle->getAction());
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
- CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
-
- JingleFileTransferHash::ref hash = jingle->getPayload<JingleFileTransferHash>();
- CPPUNIT_ASSERT(hash);
- CPPUNIT_ASSERT_EQUAL(std::string("VS2nSZMIUsaa5dIUHTdmsQ=="), Base64::encode(hash->getFileInfo().getHash("sha-1").get()));
- }
-
- // http://xmpp.org/extensions/xep-0234.html#example-10
- void testParse_Xep0234_Example10() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<jingle xmlns='urn:xmpp:jingle:1'\n"
- " action='session-initiate'\n"
- " initiator='romeo@montague.lit/orchard'\n"
- " sid='uj3b2'>\n"
- " <content creator='initiator' name='a-file-request'>\n"
- " <description xmlns='urn:xmpp:jingle:apps:file-transfer:4'>\n"
- " <file>\n"
- " <hash xmlns='urn:xmpp:hashes:1' algo='sha-1'>VS2nSZMIUsaa5dIUHTdmsQ==</hash>\n"
- " <range offset='270336'/>\n"
- " </file>\n"
- " </description>\n"
- " <transport xmlns='urn:xmpp:jingle:transports:s5b:1'\n"
- " mode='tcp'\n"
- " sid='xig361fj'>\n"
- " <candidate cid='ht567dq'\n"
- " host='192.169.1.10'\n"
- " jid='juliet@capulet.lit/balcony'\n"
- " port='6539'\n"
- " priority='8257636'\n"
- " type='direct'/>\n"
- " <candidate cid='hr65dqyd'\n"
- " host='134.102.201.180'\n"
- " jid='juliet@capulet.lit/balcony'\n"
- " port='16453'\n"
- " priority='7929856'\n"
- " type='assisted'/>\n"
- " <candidate cid='grt654q2'\n"
- " host='2001:638:708:30c9:219:d1ff:fea4:a17d'\n"
- " jid='juliet@capulet.lit/balcony'\n"
- " port='6539'\n"
- " priority='8257606'\n"
- " type='direct'/>\n"
- " </transport>\n"
- " </content>\n"
- "</jingle>\n"
- ));
-
- JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
- CPPUNIT_ASSERT(jingle);
- CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionInitiate, jingle->getAction());
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
- CPPUNIT_ASSERT_EQUAL(std::string("uj3b2"), jingle->getSessionID());
-
- JingleContentPayload::ref content = jingle->getPayload<JingleContentPayload>();
- CPPUNIT_ASSERT(content);
-
- JingleFileTransferFileInfo file = content->getDescription<JingleFileTransferDescription>()->getFileInfo();
- CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), file.getHashes().begin()->first);
- CPPUNIT_ASSERT_EQUAL(std::string("VS2nSZMIUsaa5dIUHTdmsQ=="), Base64::encode(file.getHashes().begin()->second));
- CPPUNIT_ASSERT_EQUAL(static_cast<boost::uintmax_t>(270336), file.getRangeOffset());
- CPPUNIT_ASSERT_EQUAL(true, file.getSupportsRangeRequests());
- }
-
- // http://xmpp.org/extensions/xep-0260.html#example-1
- void testParse_Xep0260_Example1() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<jingle xmlns='urn:xmpp:jingle:1'\n"
- " action='session-initiate'\n"
- " initiator='romeo@montague.lit/orchard'\n"
- " sid='a73sjjvkla37jfea'>\n"
- " <content creator='initiator' name='ex'>\n"
- " <description xmlns='urn:xmpp:example'/>\n"
- " <transport xmlns='urn:xmpp:jingle:transports:s5b:1'\n"
- " mode='tcp'\n"
- " sid='vj3hs98y'>\n"
- " <candidate cid='hft54dqy'\n"
- " host='192.168.4.1'\n"
- " jid='romeo@montague.lit/orchard'\n"
- " port='5086'\n"
- " priority='8257636'\n"
- " type='direct'/>\n"
- " <candidate cid='hutr46fe'\n"
- " host='24.24.24.1'\n"
- " jid='romeo@montague.lit/orchard'\n"
- " port='5087'\n"
- " priority='8258636'\n"
- " type='direct'/>\n"
- " </transport>\n"
- " </content>\n"
- "</jingle>\n"
- ));
- JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
- CPPUNIT_ASSERT(jingle);
- CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionInitiate, jingle->getAction());
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
- CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
-
- JingleContentPayload::ref content = jingle->getPayload<JingleContentPayload>();
- CPPUNIT_ASSERT(content);
-
- JingleS5BTransportPayload::ref s5bPayload = content->getTransport<JingleS5BTransportPayload>();
- CPPUNIT_ASSERT(s5bPayload);
-
- CPPUNIT_ASSERT_EQUAL(std::string("vj3hs98y"), s5bPayload->getSessionID());
- CPPUNIT_ASSERT_EQUAL(JingleS5BTransportPayload::TCPMode, s5bPayload->getMode());
- CPPUNIT_ASSERT_EQUAL(false, s5bPayload->hasCandidateError());
- CPPUNIT_ASSERT_EQUAL(false, s5bPayload->hasProxyError());
- CPPUNIT_ASSERT_EQUAL(std::string(), s5bPayload->getActivated());
- CPPUNIT_ASSERT_EQUAL(std::string(), s5bPayload->getCandidateUsed());
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), s5bPayload->getCandidates().size());
-
- JingleS5BTransportPayload::Candidate candidate;
- candidate = s5bPayload->getCandidates()[0];
- CPPUNIT_ASSERT_EQUAL(std::string("hft54dqy"), candidate.cid);
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), candidate.jid);
- CPPUNIT_ASSERT(HostAddressPort(HostAddress("192.168.4.1"), 5086) == candidate.hostPort);
- CPPUNIT_ASSERT_EQUAL(8257636, candidate.priority);
- CPPUNIT_ASSERT_EQUAL(JingleS5BTransportPayload::Candidate::DirectType, candidate.type);
-
- candidate = s5bPayload->getCandidates()[1];
- CPPUNIT_ASSERT_EQUAL(std::string("hutr46fe"), candidate.cid);
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), candidate.jid);
- CPPUNIT_ASSERT(HostAddressPort(HostAddress("24.24.24.1"), 5087) == candidate.hostPort);
- CPPUNIT_ASSERT_EQUAL(8258636, candidate.priority);
- CPPUNIT_ASSERT_EQUAL(JingleS5BTransportPayload::Candidate::DirectType, candidate.type);
- }
-
- // http://xmpp.org/extensions/xep-0260.html#example-3
- void testParse_Xep0260_Example3() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<jingle xmlns='urn:xmpp:jingle:1'\n"
- " action='session-accept'\n"
- " initiator='romeo@montague.lit/orchard'\n"
- " sid='a73sjjvkla37jfea'>\n"
- " <content creator='initiator' name='ex'>\n"
- " <description xmlns='urn:xmpp:example'/>\n"
- " <transport xmlns='urn:xmpp:jingle:transports:s5b:1'\n"
- " dstaddr='1a12fb7bc625e55f3ed5b29a53dbe0e4aa7d80ba'\n"
- " mode='tcp'\n"
- " sid='vj3hs98y'>\n"
- " <candidate cid='ht567dq'\n"
- " host='192.169.1.10'\n"
- " jid='juliet@capulet.lit/balcony'\n"
- " port='6539'\n"
- " priority='8257636'\n"
- " type='direct'/>\n"
- " <candidate cid='hr65dqyd'\n"
- " host='134.102.201.180'\n"
- " jid='juliet@capulet.lit/balcony'\n"
- " port='16453'\n"
- " priority='7929856'\n"
- " type='assisted'/>\n"
- " <candidate cid='grt654q2'\n"
- " host='2001:638:708:30c9:219:d1ff:fea4:a17d'\n"
- " jid='juliet@capulet.lit/balcony'\n"
- " port='6539'\n"
- " priority='8257606'\n"
- " type='direct'/>\n"
- " </transport>\n"
- " </content>\n"
- "</jingle>\n"
- ));
-
- JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
- CPPUNIT_ASSERT(jingle);
- CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionAccept, jingle->getAction());
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
- CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
-
- JingleContentPayload::ref content = jingle->getPayload<JingleContentPayload>();
- CPPUNIT_ASSERT(content);
-
- JingleS5BTransportPayload::ref s5bPayload = content->getTransport<JingleS5BTransportPayload>();
- CPPUNIT_ASSERT(s5bPayload);
-
- CPPUNIT_ASSERT_EQUAL(std::string("vj3hs98y"), s5bPayload->getSessionID());
- CPPUNIT_ASSERT_EQUAL(JingleS5BTransportPayload::TCPMode, s5bPayload->getMode());
- CPPUNIT_ASSERT_EQUAL(std::string("1a12fb7bc625e55f3ed5b29a53dbe0e4aa7d80ba"), s5bPayload->getDstAddr());
- CPPUNIT_ASSERT_EQUAL(false, s5bPayload->hasCandidateError());
- CPPUNIT_ASSERT_EQUAL(false, s5bPayload->hasProxyError());
- CPPUNIT_ASSERT_EQUAL(std::string(), s5bPayload->getActivated());
- CPPUNIT_ASSERT_EQUAL(std::string(), s5bPayload->getCandidateUsed());
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), s5bPayload->getCandidates().size());
-
- JingleS5BTransportPayload::Candidate candidate;
- candidate = s5bPayload->getCandidates()[0];
- CPPUNIT_ASSERT_EQUAL(std::string("ht567dq"), candidate.cid);
- CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.lit/balcony"), candidate.jid);
- CPPUNIT_ASSERT(HostAddressPort(HostAddress("192.169.1.10"), 6539) == candidate.hostPort);
- CPPUNIT_ASSERT_EQUAL(8257636, candidate.priority);
- CPPUNIT_ASSERT_EQUAL(JingleS5BTransportPayload::Candidate::DirectType, candidate.type);
-
- candidate = s5bPayload->getCandidates()[1];
- CPPUNIT_ASSERT_EQUAL(std::string("hr65dqyd"), candidate.cid);
- CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.lit/balcony"), candidate.jid);
- CPPUNIT_ASSERT(HostAddressPort(HostAddress("134.102.201.180"), 16453) == candidate.hostPort);
- CPPUNIT_ASSERT_EQUAL(7929856, candidate.priority);
- CPPUNIT_ASSERT_EQUAL(JingleS5BTransportPayload::Candidate::AssistedType, candidate.type);
-
- candidate = s5bPayload->getCandidates()[2];
- CPPUNIT_ASSERT_EQUAL(std::string("grt654q2"), candidate.cid);
- CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.lit/balcony"), candidate.jid);
- CPPUNIT_ASSERT(HostAddressPort(HostAddress("2001:638:708:30c9:219:d1ff:fea4:a17d"), 6539) == candidate.hostPort);
- CPPUNIT_ASSERT_EQUAL(8257606, candidate.priority);
- CPPUNIT_ASSERT_EQUAL(JingleS5BTransportPayload::Candidate::DirectType, candidate.type);
- }
+ CPPUNIT_TEST_SUITE(JingleParserTest);
+ CPPUNIT_TEST(testParse_Xep0166_Example3);
+ CPPUNIT_TEST(testParse_Xep0166_Example8);
+
+ CPPUNIT_TEST(testParse_Xep0261_Example1);
+ CPPUNIT_TEST(testParse_Xep0261_Example3);
+ CPPUNIT_TEST(testParse_Xep0261_Example9);
+ CPPUNIT_TEST(testParse_Xep0261_Example13);
+
+ CPPUNIT_TEST(testParse_Xep0234_Example1);
+ CPPUNIT_TEST(testParse_Xep0234_Example3);
+ CPPUNIT_TEST(testParse_Xep0234_Example5);
+ CPPUNIT_TEST(testParse_Xep0234_Example8);
+ CPPUNIT_TEST(testParse_Xep0234_Example10);
+
+ CPPUNIT_TEST(testParse_Xep0260_Example1);
+ CPPUNIT_TEST(testParse_Xep0260_Example3);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ //http://xmpp.org/extensions/xep-0166.html#example-3
+ void testParse_Xep0166_Example3() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<jingle xmlns='urn:xmpp:jingle:1'\n"
+ " action='session-terminate'\n"
+ " sid='a73sjjvkla37jfea'>\n"
+ " <reason>\n"
+ " <success/>\n"
+ " </reason>\n"
+ "</jingle>\n"
+ ));
+
+ JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
+ CPPUNIT_ASSERT(jingle);
+ CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionTerminate, jingle->getAction());
+ CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
+ CPPUNIT_ASSERT_EQUAL(JinglePayload::Reason::Success,
+ jingle->getReason().get_value_or(JinglePayload::Reason(JinglePayload::Reason::UnknownType, "")).type);
+ }
+
+ //http://xmpp.org/extensions/xep-0166.html#example-8
+ void testParse_Xep0166_Example8() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<jingle xmlns='urn:xmpp:jingle:1'\n"
+ " action='session-terminate'\n"
+ " sid='a73sjjvkla37jfea'>\n"
+ " <reason>\n"
+ " <success/>\n"
+ " <text>Sorry, gotta go!</text>\n"
+ " </reason>\n"
+ "</jingle>\n"
+ ));
+ JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
+ CPPUNIT_ASSERT(jingle);
+ CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionTerminate, jingle->getAction());
+ CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
+ CPPUNIT_ASSERT_EQUAL(JinglePayload::Reason::Success,
+ jingle->getReason().get_value_or(JinglePayload::Reason(JinglePayload::Reason::UnknownType, "")).type);
+ CPPUNIT_ASSERT_EQUAL(std::string("Sorry, gotta go!"),
+ jingle->getReason().get_value_or(JinglePayload::Reason(JinglePayload::Reason::UnknownType, "")).text);
+ }
+
+ // IBB Transport Method Examples
+
+ // http://xmpp.org/extensions/xep-0261.html#example-1
+ void testParse_Xep0261_Example1() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<jingle xmlns='urn:xmpp:jingle:1'\n"
+ " action='session-initiate'\n"
+ " initiator='romeo@montague.lit/orchard'\n"
+ " sid='a73sjjvkla37jfea'>\n"
+ " <content creator='initiator' name='ex'>\n"
+ " <description xmlns='urn:xmpp:example'/>\n"
+ " <transport xmlns='urn:xmpp:jingle:transports:ibb:1'\n"
+ " block-size='4096'\n"
+ " sid='ch3d9s71'/>\n"
+ " </content>\n"
+ "</jingle>\n"
+ ));
+ JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
+ CPPUNIT_ASSERT(jingle);
+ CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionInitiate, jingle->getAction());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
+ CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
+
+ std::vector<JingleContentPayload::ref> payloads = jingle->getContents();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), payloads.size());
+ JingleContentPayload::ref payload = payloads[0];
+ CPPUNIT_ASSERT_EQUAL(JingleContentPayload::InitiatorCreator, payload->getCreator());
+ CPPUNIT_ASSERT_EQUAL(std::string("ex"), payload->getName());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), payload->getTransports().size());
+
+ JingleIBBTransportPayload::ref transportPaylod = payload->getTransport<JingleIBBTransportPayload>();
+ CPPUNIT_ASSERT(transportPaylod);
+ CPPUNIT_ASSERT_EQUAL(4096U, *transportPaylod->getBlockSize());
+ CPPUNIT_ASSERT_EQUAL(std::string("ch3d9s71"), transportPaylod->getSessionID());
+ }
+
+ // http://xmpp.org/extensions/xep-0261.html#example-1
+ void testParse_Xep0261_Example3() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<jingle xmlns='urn:xmpp:jingle:1'\n"
+ " action='session-accept'\n"
+ " initiator='romeo@montague.lit/orchard'\n"
+ " responder='juliet@capulet.lit/balcony'\n"
+ " sid='a73sjjvkla37jfea'>\n"
+ " <content creator='initiator' name='ex'>\n"
+ " <description xmlns='urn:xmpp:example'/>\n"
+ " <transport xmlns='urn:xmpp:jingle:transports:ibb:1'\n"
+ " block-size='2048'\n"
+ " sid='ch3d9s71'/>\n"
+ " </content>\n"
+ " </jingle>\n"
+ ));
+ JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
+ CPPUNIT_ASSERT(jingle);
+ CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionAccept, jingle->getAction());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
+ CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.lit/balcony"), jingle->getResponder());
+ CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
+
+ std::vector<JingleContentPayload::ref> payloads = jingle->getContents();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), payloads.size());
+ JingleContentPayload::ref payload = payloads[0];
+ CPPUNIT_ASSERT_EQUAL(JingleContentPayload::InitiatorCreator, payload->getCreator());
+ CPPUNIT_ASSERT_EQUAL(std::string("ex"), payload->getName());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), payload->getTransports().size());
+
+ JingleIBBTransportPayload::ref transportPaylod = payload->getTransport<JingleIBBTransportPayload>();
+ CPPUNIT_ASSERT(transportPaylod);
+ CPPUNIT_ASSERT_EQUAL(2048U, *transportPaylod->getBlockSize());
+ CPPUNIT_ASSERT_EQUAL(std::string("ch3d9s71"), transportPaylod->getSessionID());
+ }
+
+ // http://xmpp.org/extensions/xep-0261.html#example-9
+ void testParse_Xep0261_Example9() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<jingle xmlns='urn:xmpp:jingle:1'\n"
+ " action='transport-info'\n"
+ " initiator='romeo@montague.lit/orchard'\n"
+ " sid='a73sjjvkla37jfea'>\n"
+ " <content creator='initiator' name='ex'>\n"
+ " <transport xmlns='urn:xmpp:jingle:transports:ibb:1'\n"
+ " block-size='2048'\n"
+ " sid='bt8a71h6'/>\n"
+ " </content>\n"
+ "</jingle>\n"
+ ));
+ JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
+ CPPUNIT_ASSERT(jingle);
+ CPPUNIT_ASSERT_EQUAL(JinglePayload::TransportInfo, jingle->getAction());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
+ CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
+
+ std::vector<JingleContentPayload::ref> payloads = jingle->getContents();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), payloads.size());
+ JingleContentPayload::ref payload = payloads[0];
+ CPPUNIT_ASSERT_EQUAL(JingleContentPayload::InitiatorCreator, payload->getCreator());
+ CPPUNIT_ASSERT_EQUAL(std::string("ex"), payload->getName());
+
+ JingleIBBTransportPayload::ref transportPaylod = payload->getTransport<JingleIBBTransportPayload>();
+ CPPUNIT_ASSERT(transportPaylod);
+ CPPUNIT_ASSERT_EQUAL(2048U, *transportPaylod->getBlockSize());
+ CPPUNIT_ASSERT_EQUAL(std::string("bt8a71h6"), transportPaylod->getSessionID());
+ }
+
+ // http://xmpp.org/extensions/xep-0261.html#example-13
+ void testParse_Xep0261_Example13() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<jingle xmlns='urn:xmpp:jingle:1'\n"
+ " action='session-terminate'\n"
+ " initiator='romeo@montague.lit/orchard'\n"
+ " sid='a73sjjvkla37jfea'>\n"
+ " <reason><success/></reason>\n"
+ " </jingle>\n"
+ ));
+
+ JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
+ CPPUNIT_ASSERT(jingle);
+ CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionTerminate, jingle->getAction());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
+ CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
+ CPPUNIT_ASSERT_EQUAL(JinglePayload::Reason::Success, jingle->getReason().get_value_or(JinglePayload::Reason()).type);
+
+ }
+
+ // Jingle File Transfer Examples
+
+ // http://xmpp.org/extensions/xep-0234.html#example-1
+ void testParse_Xep0234_Example1() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<jingle xmlns='urn:xmpp:jingle:1'\n"
+ " action='session-initiate'\n"
+ " initiator='romeo@montague.lit/orchard'\n"
+ " sid='851ba2'>\n"
+ "<content creator='initiator' name='a-file-offer'>\n"
+ "<description xmlns='urn:xmpp:jingle:apps:file-transfer:4'>\n"
+ "<file>\n"
+ "<date>1969-07-21T02:56:15Z</date>\n"
+ "<desc>This is a test. If this were a real file...</desc>\n"
+ "<media-type>text/plain</media-type>\n"
+ "<name>test.txt</name>\n"
+ "<range/>\n"
+ "<size>1022</size>\n"
+ "<hash xmlns='urn:xmpp:hashes:1' algo='sha-1'>VS2nSZMIUsaa5dIUHTdmsQ==</hash>\n"
+ "</file>\n"
+ "</description>\n"
+ "<transport xmlns='urn:xmpp:jingle:transports:s5b:1'\n"
+ " mode='tcp'\n"
+ " sid='vj3hs98y'>\n"
+ "<candidate cid='hft54dqy'\n"
+ " host='192.168.4.1'\n"
+ " jid='romeo@montague.lit/orchard'\n"
+ " port='5086'\n"
+ " priority='8257636'\n"
+ " type='direct'/>\n"
+ "<candidate cid='hutr46fe'\n"
+ " host='24.24.24.1'\n"
+ " jid='romeo@montague.lit/orchard'\n"
+ " port='5087'\n"
+ " priority='8258636'\n"
+ " type='direct'/>\n"
+ "</transport>\n"
+ "</content>\n"
+ "</jingle>\n"
+ ));
+
+ JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
+ CPPUNIT_ASSERT(jingle);
+ CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionInitiate, jingle->getAction());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
+ CPPUNIT_ASSERT_EQUAL(std::string("851ba2"), jingle->getSessionID());
+
+ std::vector<JingleContentPayload::ref> contents = jingle->getContents();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), contents.size());
+
+ JingleFileTransferDescription::ref description = contents[0]->getDescription<JingleFileTransferDescription>();
+
+ CPPUNIT_ASSERT(description);
+ JingleFileTransferFileInfo fileInfo = description->getFileInfo();
+ CPPUNIT_ASSERT_EQUAL(std::string("test.txt"), fileInfo.getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), fileInfo.getHashes().begin()->first);
+ CPPUNIT_ASSERT_EQUAL(std::string("VS2nSZMIUsaa5dIUHTdmsQ=="), Base64::encode(fileInfo.getHashes().begin()->second));
+ CPPUNIT_ASSERT(1022 == fileInfo.getSize());
+ CPPUNIT_ASSERT_EQUAL(std::string("This is a test. If this were a real file..."), fileInfo.getDescription());
+ CPPUNIT_ASSERT_EQUAL(true, fileInfo.getSupportsRangeRequests());
+ CPPUNIT_ASSERT(stringToDateTime("1969-07-21T02:56:15Z") == fileInfo.getDate());
+ }
+
+ // http://xmpp.org/extensions/xep-0234.html#example-3
+ void testParse_Xep0234_Example3() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<jingle xmlns='urn:xmpp:jingle:1'\n"
+ " action='session-accept'\n"
+ " initiator='romeo@montague.lit/orchard'\n"
+ " sid='851ba2'>\n"
+ "<content creator='initiator' name='a-file-offer'>\n"
+ "<description xmlns='urn:xmpp:jingle:apps:file-transfer:4'>\n"
+ "<file>\n"
+ "<date>1969-07-21T02:56:15Z</date>\n"
+ "<desc>This is a test. If this were a real file...</desc>\n"
+ "<media-type>text/plain</media-type>\n"
+ "<name>test.txt</name>\n"
+ "<range/>\n"
+ "<size>1022</size>\n"
+ "<hash xmlns='urn:xmpp:hashes:1' algo='sha-1'>VS2nSZMIUsaa5dIUHTdmsQ==</hash>\n"
+ "</file>\n"
+ "</description>\n"
+ " <transport xmlns='urn:xmpp:jingle:transports:s5b:1'\n"
+ " mode='tcp'\n"
+ " sid='vj3hs98y'>\n"
+ " <candidate cid='ht567dq'\n"
+ " host='192.169.1.10'\n"
+ " jid='juliet@capulet.lit/balcony'\n"
+ " port='6539'\n"
+ " priority='8257636'\n"
+ " type='direct'/>\n"
+ " <candidate cid='hr65dqyd'\n"
+ " host='134.102.201.180'\n"
+ " jid='juliet@capulet.lit/balcony'\n"
+ " port='16453'\n"
+ " priority='7929856'\n"
+ " type='assisted'/>\n"
+ " <candidate cid='grt654q2'\n"
+ " host='2001:638:708:30c9:219:d1ff:fea4:a17d'\n"
+ " jid='juliet@capulet.lit/balcony'\n"
+ " port='6539'\n"
+ " priority='8257606'\n"
+ " type='direct'/>\n"
+ " </transport>\n"
+ " </content>\n"
+ "</jingle>\n"
+ ));
+
+ JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
+ CPPUNIT_ASSERT(jingle);
+ CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionAccept, jingle->getAction());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
+ CPPUNIT_ASSERT_EQUAL(std::string("851ba2"), jingle->getSessionID());
+
+ std::vector<JingleContentPayload::ref> contents = jingle->getContents();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), contents.size());
+
+ JingleFileTransferDescription::ref description = contents[0]->getDescription<JingleFileTransferDescription>();
+
+ CPPUNIT_ASSERT(description);
+
+ JingleFileTransferFileInfo fileInfo = description->getFileInfo();
+ CPPUNIT_ASSERT_EQUAL(std::string("test.txt"), fileInfo.getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), fileInfo.getHashes().begin()->first);
+ CPPUNIT_ASSERT_EQUAL(std::string("VS2nSZMIUsaa5dIUHTdmsQ=="), Base64::encode(fileInfo.getHashes().begin()->second));
+ CPPUNIT_ASSERT(1022 == fileInfo.getSize());
+ CPPUNIT_ASSERT_EQUAL(std::string("This is a test. If this were a real file..."), fileInfo.getDescription());
+ CPPUNIT_ASSERT_EQUAL(true, fileInfo.getSupportsRangeRequests());
+ CPPUNIT_ASSERT(stringToDateTime("1969-07-21T02:56:15Z") == fileInfo.getDate());
+ }
+
+ // http://xmpp.org/extensions/xep-0234.html#example-5
+ void testParse_Xep0234_Example5() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<jingle xmlns='urn:xmpp:jingle:1'\n"
+ " action='transport-info'\n"
+ " initiator='romeo@montague.lit/orchard'\n"
+ " sid='a73sjjvkla37jfea'>\n"
+ " <content creator='initiator' name='ex'>\n"
+ " <transport xmlns='urn:xmpp:jingle:transports:s5b:1'\n"
+ " sid='vj3hs98y'>\n"
+ " <candidate-used cid='hr65dqyd'/>\n"
+ " </transport>\n"
+ " </content>\n"
+ "</jingle>\n"
+ ));
+
+ JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
+ CPPUNIT_ASSERT(jingle);
+ CPPUNIT_ASSERT_EQUAL(JinglePayload::TransportInfo, jingle->getAction());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
+ CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
+
+ std::vector<JingleContentPayload::ref> contents = jingle->getContents();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), contents.size());
+
+ JingleS5BTransportPayload::ref transport = contents[0]->getTransport<JingleS5BTransportPayload>();
+ CPPUNIT_ASSERT(transport);
+
+ CPPUNIT_ASSERT_EQUAL(std::string("vj3hs98y"), transport->getSessionID());
+ CPPUNIT_ASSERT_EQUAL(std::string("hr65dqyd"), transport->getCandidateUsed());
+ }
+
+ // http://xmpp.org/extensions/xep-0234.html#example-8
+ void testParse_Xep0234_Example8() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<jingle xmlns='urn:xmpp:jingle:1'\n"
+ " action='session-info'\n"
+ " initiator='romeo@montague.lit/orchard'\n"
+ " sid='a73sjjvkla37jfea'>\n"
+ " <checksum xmlns='urn:xmpp:jingle:apps:file-transfer:4'>\n"
+ " <file>\n"
+ " <hash xmlns='urn:xmpp:hashes:0' algo='sha-1'>VS2nSZMIUsaa5dIUHTdmsQ==</hash>\n"
+ " </file>\n"
+ " </checksum>\n"
+ "</jingle>\n"
+ ));
+ JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
+ CPPUNIT_ASSERT(jingle);
+ CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionInfo, jingle->getAction());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
+ CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
+
+ JingleFileTransferHash::ref hash = jingle->getPayload<JingleFileTransferHash>();
+ CPPUNIT_ASSERT(hash);
+ CPPUNIT_ASSERT_EQUAL(std::string("VS2nSZMIUsaa5dIUHTdmsQ=="), Base64::encode(hash->getFileInfo().getHash("sha-1").get()));
+ }
+
+ // http://xmpp.org/extensions/xep-0234.html#example-10
+ void testParse_Xep0234_Example10() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<jingle xmlns='urn:xmpp:jingle:1'\n"
+ " action='session-initiate'\n"
+ " initiator='romeo@montague.lit/orchard'\n"
+ " sid='uj3b2'>\n"
+ " <content creator='initiator' name='a-file-request'>\n"
+ " <description xmlns='urn:xmpp:jingle:apps:file-transfer:4'>\n"
+ " <file>\n"
+ " <hash xmlns='urn:xmpp:hashes:1' algo='sha-1'>VS2nSZMIUsaa5dIUHTdmsQ==</hash>\n"
+ " <range offset='270336'/>\n"
+ " </file>\n"
+ " </description>\n"
+ " <transport xmlns='urn:xmpp:jingle:transports:s5b:1'\n"
+ " mode='tcp'\n"
+ " sid='xig361fj'>\n"
+ " <candidate cid='ht567dq'\n"
+ " host='192.169.1.10'\n"
+ " jid='juliet@capulet.lit/balcony'\n"
+ " port='6539'\n"
+ " priority='8257636'\n"
+ " type='direct'/>\n"
+ " <candidate cid='hr65dqyd'\n"
+ " host='134.102.201.180'\n"
+ " jid='juliet@capulet.lit/balcony'\n"
+ " port='16453'\n"
+ " priority='7929856'\n"
+ " type='assisted'/>\n"
+ " <candidate cid='grt654q2'\n"
+ " host='2001:638:708:30c9:219:d1ff:fea4:a17d'\n"
+ " jid='juliet@capulet.lit/balcony'\n"
+ " port='6539'\n"
+ " priority='8257606'\n"
+ " type='direct'/>\n"
+ " </transport>\n"
+ " </content>\n"
+ "</jingle>\n"
+ ));
+
+ JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
+ CPPUNIT_ASSERT(jingle);
+ CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionInitiate, jingle->getAction());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
+ CPPUNIT_ASSERT_EQUAL(std::string("uj3b2"), jingle->getSessionID());
+
+ JingleContentPayload::ref content = jingle->getPayload<JingleContentPayload>();
+ CPPUNIT_ASSERT(content);
+
+ JingleFileTransferFileInfo file = content->getDescription<JingleFileTransferDescription>()->getFileInfo();
+ CPPUNIT_ASSERT_EQUAL(std::string("sha-1"), file.getHashes().begin()->first);
+ CPPUNIT_ASSERT_EQUAL(std::string("VS2nSZMIUsaa5dIUHTdmsQ=="), Base64::encode(file.getHashes().begin()->second));
+ CPPUNIT_ASSERT_EQUAL(static_cast<boost::uintmax_t>(270336), file.getRangeOffset());
+ CPPUNIT_ASSERT_EQUAL(true, file.getSupportsRangeRequests());
+ }
+
+ // http://xmpp.org/extensions/xep-0260.html#example-1
+ void testParse_Xep0260_Example1() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<jingle xmlns='urn:xmpp:jingle:1'\n"
+ " action='session-initiate'\n"
+ " initiator='romeo@montague.lit/orchard'\n"
+ " sid='a73sjjvkla37jfea'>\n"
+ " <content creator='initiator' name='ex'>\n"
+ " <description xmlns='urn:xmpp:example'/>\n"
+ " <transport xmlns='urn:xmpp:jingle:transports:s5b:1'\n"
+ " mode='tcp'\n"
+ " sid='vj3hs98y'>\n"
+ " <candidate cid='hft54dqy'\n"
+ " host='192.168.4.1'\n"
+ " jid='romeo@montague.lit/orchard'\n"
+ " port='5086'\n"
+ " priority='8257636'\n"
+ " type='direct'/>\n"
+ " <candidate cid='hutr46fe'\n"
+ " host='24.24.24.1'\n"
+ " jid='romeo@montague.lit/orchard'\n"
+ " port='5087'\n"
+ " priority='8258636'\n"
+ " type='direct'/>\n"
+ " </transport>\n"
+ " </content>\n"
+ "</jingle>\n"
+ ));
+ JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
+ CPPUNIT_ASSERT(jingle);
+ CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionInitiate, jingle->getAction());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
+ CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
+
+ JingleContentPayload::ref content = jingle->getPayload<JingleContentPayload>();
+ CPPUNIT_ASSERT(content);
+
+ JingleS5BTransportPayload::ref s5bPayload = content->getTransport<JingleS5BTransportPayload>();
+ CPPUNIT_ASSERT(s5bPayload);
+
+ CPPUNIT_ASSERT_EQUAL(std::string("vj3hs98y"), s5bPayload->getSessionID());
+ CPPUNIT_ASSERT_EQUAL(JingleS5BTransportPayload::TCPMode, s5bPayload->getMode());
+ CPPUNIT_ASSERT_EQUAL(false, s5bPayload->hasCandidateError());
+ CPPUNIT_ASSERT_EQUAL(false, s5bPayload->hasProxyError());
+ CPPUNIT_ASSERT_EQUAL(std::string(), s5bPayload->getActivated());
+ CPPUNIT_ASSERT_EQUAL(std::string(), s5bPayload->getCandidateUsed());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), s5bPayload->getCandidates().size());
+
+ JingleS5BTransportPayload::Candidate candidate;
+ candidate = s5bPayload->getCandidates()[0];
+ CPPUNIT_ASSERT_EQUAL(std::string("hft54dqy"), candidate.cid);
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), candidate.jid);
+ CPPUNIT_ASSERT(HostAddressPort(HostAddress("192.168.4.1"), 5086) == candidate.hostPort);
+ CPPUNIT_ASSERT_EQUAL(8257636, candidate.priority);
+ CPPUNIT_ASSERT_EQUAL(JingleS5BTransportPayload::Candidate::DirectType, candidate.type);
+
+ candidate = s5bPayload->getCandidates()[1];
+ CPPUNIT_ASSERT_EQUAL(std::string("hutr46fe"), candidate.cid);
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), candidate.jid);
+ CPPUNIT_ASSERT(HostAddressPort(HostAddress("24.24.24.1"), 5087) == candidate.hostPort);
+ CPPUNIT_ASSERT_EQUAL(8258636, candidate.priority);
+ CPPUNIT_ASSERT_EQUAL(JingleS5BTransportPayload::Candidate::DirectType, candidate.type);
+ }
+
+ // http://xmpp.org/extensions/xep-0260.html#example-3
+ void testParse_Xep0260_Example3() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<jingle xmlns='urn:xmpp:jingle:1'\n"
+ " action='session-accept'\n"
+ " initiator='romeo@montague.lit/orchard'\n"
+ " sid='a73sjjvkla37jfea'>\n"
+ " <content creator='initiator' name='ex'>\n"
+ " <description xmlns='urn:xmpp:example'/>\n"
+ " <transport xmlns='urn:xmpp:jingle:transports:s5b:1'\n"
+ " dstaddr='1a12fb7bc625e55f3ed5b29a53dbe0e4aa7d80ba'\n"
+ " mode='tcp'\n"
+ " sid='vj3hs98y'>\n"
+ " <candidate cid='ht567dq'\n"
+ " host='192.169.1.10'\n"
+ " jid='juliet@capulet.lit/balcony'\n"
+ " port='6539'\n"
+ " priority='8257636'\n"
+ " type='direct'/>\n"
+ " <candidate cid='hr65dqyd'\n"
+ " host='134.102.201.180'\n"
+ " jid='juliet@capulet.lit/balcony'\n"
+ " port='16453'\n"
+ " priority='7929856'\n"
+ " type='assisted'/>\n"
+ " <candidate cid='grt654q2'\n"
+ " host='2001:638:708:30c9:219:d1ff:fea4:a17d'\n"
+ " jid='juliet@capulet.lit/balcony'\n"
+ " port='6539'\n"
+ " priority='8257606'\n"
+ " type='direct'/>\n"
+ " </transport>\n"
+ " </content>\n"
+ "</jingle>\n"
+ ));
+
+ JinglePayload::ref jingle = parser.getPayload<JinglePayload>();
+ CPPUNIT_ASSERT(jingle);
+ CPPUNIT_ASSERT_EQUAL(JinglePayload::SessionAccept, jingle->getAction());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), jingle->getInitiator());
+ CPPUNIT_ASSERT_EQUAL(std::string("a73sjjvkla37jfea"), jingle->getSessionID());
+
+ JingleContentPayload::ref content = jingle->getPayload<JingleContentPayload>();
+ CPPUNIT_ASSERT(content);
+
+ JingleS5BTransportPayload::ref s5bPayload = content->getTransport<JingleS5BTransportPayload>();
+ CPPUNIT_ASSERT(s5bPayload);
+
+ CPPUNIT_ASSERT_EQUAL(std::string("vj3hs98y"), s5bPayload->getSessionID());
+ CPPUNIT_ASSERT_EQUAL(JingleS5BTransportPayload::TCPMode, s5bPayload->getMode());
+ CPPUNIT_ASSERT_EQUAL(std::string("1a12fb7bc625e55f3ed5b29a53dbe0e4aa7d80ba"), s5bPayload->getDstAddr());
+ CPPUNIT_ASSERT_EQUAL(false, s5bPayload->hasCandidateError());
+ CPPUNIT_ASSERT_EQUAL(false, s5bPayload->hasProxyError());
+ CPPUNIT_ASSERT_EQUAL(std::string(), s5bPayload->getActivated());
+ CPPUNIT_ASSERT_EQUAL(std::string(), s5bPayload->getCandidateUsed());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(3), s5bPayload->getCandidates().size());
+
+ JingleS5BTransportPayload::Candidate candidate;
+ candidate = s5bPayload->getCandidates()[0];
+ CPPUNIT_ASSERT_EQUAL(std::string("ht567dq"), candidate.cid);
+ CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.lit/balcony"), candidate.jid);
+ CPPUNIT_ASSERT(HostAddressPort(HostAddress("192.169.1.10"), 6539) == candidate.hostPort);
+ CPPUNIT_ASSERT_EQUAL(8257636, candidate.priority);
+ CPPUNIT_ASSERT_EQUAL(JingleS5BTransportPayload::Candidate::DirectType, candidate.type);
+
+ candidate = s5bPayload->getCandidates()[1];
+ CPPUNIT_ASSERT_EQUAL(std::string("hr65dqyd"), candidate.cid);
+ CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.lit/balcony"), candidate.jid);
+ CPPUNIT_ASSERT(HostAddressPort(HostAddress("134.102.201.180"), 16453) == candidate.hostPort);
+ CPPUNIT_ASSERT_EQUAL(7929856, candidate.priority);
+ CPPUNIT_ASSERT_EQUAL(JingleS5BTransportPayload::Candidate::AssistedType, candidate.type);
+
+ candidate = s5bPayload->getCandidates()[2];
+ CPPUNIT_ASSERT_EQUAL(std::string("grt654q2"), candidate.cid);
+ CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.lit/balcony"), candidate.jid);
+ CPPUNIT_ASSERT(HostAddressPort(HostAddress("2001:638:708:30c9:219:d1ff:fea4:a17d"), 6539) == candidate.hostPort);
+ CPPUNIT_ASSERT_EQUAL(8257606, candidate.priority);
+ CPPUNIT_ASSERT_EQUAL(JingleS5BTransportPayload::Candidate::DirectType, candidate.type);
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(JingleParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MAMFinParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MAMFinParserTest.cpp
index dd6263d..b045ca5 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MAMFinParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MAMFinParserTest.cpp
@@ -14,46 +14,46 @@ using namespace Swift;
class MAMFinParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(MAMFinParserTest);
- CPPUNIT_TEST(testParse_XEP0313_Exmaple1);
- CPPUNIT_TEST(testParse_XEP0313_Exmaple9);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testParse_XEP0313_Exmaple1() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<fin xmlns='urn:xmpp:mam:0' queryid='f27' />"));
-
- boost::shared_ptr<MAMFin> payload = parser.getPayload<MAMFin>();
- CPPUNIT_ASSERT(!!payload);
- CPPUNIT_ASSERT_EQUAL(false, payload->isComplete());
- CPPUNIT_ASSERT_EQUAL(true, payload->isStable());
-
- boost::optional<std::string> queryID = payload->getQueryID();
- CPPUNIT_ASSERT(queryID);
- CPPUNIT_ASSERT_EQUAL(std::string("f27"), queryID.get());
- }
-
- void testParse_XEP0313_Exmaple9() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<fin xmlns='urn:xmpp:mam:0' complete='true'>"
- "<set xmlns='http://jabber.org/protocol/rsm'>"
- "<first index='0'>23452-4534-1</first>"
- "<last>390-2342-22</last>"
- "<count>16</count>"
- "</set>"
- "</fin>"));
-
- boost::shared_ptr<MAMFin> payload = parser.getPayload<MAMFin>();
- CPPUNIT_ASSERT(!!payload);
- CPPUNIT_ASSERT_EQUAL(true, payload->isComplete());
- CPPUNIT_ASSERT_EQUAL(true, payload->isStable());
-
- CPPUNIT_ASSERT(!!payload->getResultSet());
- boost::shared_ptr<ResultSet> resultSet = payload->getResultSet();
- }
+ CPPUNIT_TEST_SUITE(MAMFinParserTest);
+ CPPUNIT_TEST(testParse_XEP0313_Exmaple1);
+ CPPUNIT_TEST(testParse_XEP0313_Exmaple9);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testParse_XEP0313_Exmaple1() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<fin xmlns='urn:xmpp:mam:0' queryid='f27' />"));
+
+ boost::shared_ptr<MAMFin> payload = parser.getPayload<MAMFin>();
+ CPPUNIT_ASSERT(!!payload);
+ CPPUNIT_ASSERT_EQUAL(false, payload->isComplete());
+ CPPUNIT_ASSERT_EQUAL(true, payload->isStable());
+
+ boost::optional<std::string> queryID = payload->getQueryID();
+ CPPUNIT_ASSERT(queryID);
+ CPPUNIT_ASSERT_EQUAL(std::string("f27"), queryID.get());
+ }
+
+ void testParse_XEP0313_Exmaple9() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<fin xmlns='urn:xmpp:mam:0' complete='true'>"
+ "<set xmlns='http://jabber.org/protocol/rsm'>"
+ "<first index='0'>23452-4534-1</first>"
+ "<last>390-2342-22</last>"
+ "<count>16</count>"
+ "</set>"
+ "</fin>"));
+
+ boost::shared_ptr<MAMFin> payload = parser.getPayload<MAMFin>();
+ CPPUNIT_ASSERT(!!payload);
+ CPPUNIT_ASSERT_EQUAL(true, payload->isComplete());
+ CPPUNIT_ASSERT_EQUAL(true, payload->isStable());
+
+ CPPUNIT_ASSERT(!!payload->getResultSet());
+ boost::shared_ptr<ResultSet> resultSet = payload->getResultSet();
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(MAMFinParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MAMQueryParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MAMQueryParserTest.cpp
index ff89ed1..8bdefc1 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MAMQueryParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MAMQueryParserTest.cpp
@@ -15,108 +15,108 @@ using namespace Swift;
class MAMQueryParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(MAMQueryParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testParse_XEP0313_Example3);
- CPPUNIT_TEST(testParse_XEP0313_Example4);
- CPPUNIT_TEST(testParseEmpty);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testParse() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<query queryid=\"id0\" xmlns=\"urn:xmpp:mam:0\" node=\"node1\">"
- "<x type=\"form\" xmlns=\"jabber:x:data\">"
- "<field type=\"text-single\" var=\"FORM_TYPE\">"
- "<value>urn:xmpp:mam:0</value>"
- "</field>"
- "<field type=\"text-single\" var=\"start\">"
- "<value>2010-08-07T00:00:00Z</value>"
- "</field>"
- "</x>"
- "<set xmlns=\"http://jabber.org/protocol/rsm\">"
- "<max>10</max>"
- "</set>"
- "</query>"));
-
-
- boost::shared_ptr<MAMQuery> payload = parser.getPayload<MAMQuery>();
- CPPUNIT_ASSERT(!!payload);
- CPPUNIT_ASSERT(payload->getQueryID());
- CPPUNIT_ASSERT_EQUAL(std::string("id0"), *payload->getQueryID());
- CPPUNIT_ASSERT_EQUAL(std::string("node1"), *payload->getNode());
-
- CPPUNIT_ASSERT(payload->getForm());
- boost::shared_ptr<FormField> fieldType = payload->getForm()->getField("FORM_TYPE");
- CPPUNIT_ASSERT(fieldType);
- CPPUNIT_ASSERT_EQUAL(std::string("urn:xmpp:mam:0"), fieldType->getTextSingleValue());
- boost::shared_ptr<FormField> fieldStart = payload->getForm()->getField("start");
- CPPUNIT_ASSERT(fieldStart);
- CPPUNIT_ASSERT_EQUAL(std::string("2010-08-07T00:00:00Z"), fieldStart->getTextSingleValue());
-
- CPPUNIT_ASSERT(payload->getResultSet());
- boost::shared_ptr<ResultSet> resultSet = payload->getResultSet();
- CPPUNIT_ASSERT(resultSet->getMaxItems());
- CPPUNIT_ASSERT_EQUAL(*resultSet->getMaxItems(), 10);
- }
-
- void testParse_XEP0313_Example3() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<query xmlns='urn:xmpp:mam:0'>"
- "<x xmlns='jabber:x:data'>"
- "<field var='FORM_TYPE'>"
- "<value>urn:xmpp:mam:0</value>"
- "</field>"
- "<field var='with'>"
- "<value>juliet@capulet.lit</value>"
- "</field>"
- "</x>"
- "</query>"));
-
- boost::shared_ptr<MAMQuery> payload = parser.getPayload<MAMQuery>();
- CPPUNIT_ASSERT(!!payload && !!payload->getForm() && !!payload->getForm()->getField("FORM_TYPE") && !!payload->getForm()->getField("with"));
- CPPUNIT_ASSERT_EQUAL(std::string("urn:xmpp:mam:0"), payload->getForm()->getField("FORM_TYPE")->getTextSingleValue());
- CPPUNIT_ASSERT_EQUAL(std::string("juliet@capulet.lit"), payload->getForm()->getField("with")->getTextSingleValue());
- }
-
- void testParse_XEP0313_Example4() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<query xmlns='urn:xmpp:mam:0'>"
- "<x xmlns='jabber:x:data'>"
- "<field var='FORM_TYPE'>"
- "<value>urn:xmpp:mam:0</value>"
- "</field>"
- "<field var='start'>"
- "<value>2010-06-07T00:00:00Z</value>"
- "</field>"
- "<field var='end'>"
- "<value>2010-07-07T13:23:54Z</value>"
- "</field>"
- "</x>"
- "</query>"));
- boost::shared_ptr<MAMQuery> payload = parser.getPayload<MAMQuery>();
- CPPUNIT_ASSERT(!!payload && !!payload->getForm() && !!payload->getForm()->getField("FORM_TYPE") && !!payload->getForm()->getField("start") && !!payload->getForm()->getField("start"));
- CPPUNIT_ASSERT_EQUAL(std::string("urn:xmpp:mam:0"), payload->getForm()->getField("FORM_TYPE")->getTextSingleValue());
- CPPUNIT_ASSERT_EQUAL(std::string("2010-06-07T00:00:00Z"), payload->getForm()->getField("start")->getTextSingleValue());
- CPPUNIT_ASSERT_EQUAL(std::string("2010-07-07T13:23:54Z"), payload->getForm()->getField("end")->getTextSingleValue());
- }
-
- void testParseEmpty() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<query queryid=\"id0\" xmlns=\"urn:xmpp:mam:0\">"
- "</query>"));
-
- boost::shared_ptr<MAMQuery> payload = parser.getPayload<MAMQuery>();
- CPPUNIT_ASSERT(!!payload);
- CPPUNIT_ASSERT(payload->getQueryID());
- CPPUNIT_ASSERT_EQUAL(std::string("id0"), *payload->getQueryID());
- CPPUNIT_ASSERT(!payload->getForm());
- CPPUNIT_ASSERT(!payload->getResultSet());
- }
+ CPPUNIT_TEST_SUITE(MAMQueryParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParse_XEP0313_Example3);
+ CPPUNIT_TEST(testParse_XEP0313_Example4);
+ CPPUNIT_TEST(testParseEmpty);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testParse() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<query queryid=\"id0\" xmlns=\"urn:xmpp:mam:0\" node=\"node1\">"
+ "<x type=\"form\" xmlns=\"jabber:x:data\">"
+ "<field type=\"text-single\" var=\"FORM_TYPE\">"
+ "<value>urn:xmpp:mam:0</value>"
+ "</field>"
+ "<field type=\"text-single\" var=\"start\">"
+ "<value>2010-08-07T00:00:00Z</value>"
+ "</field>"
+ "</x>"
+ "<set xmlns=\"http://jabber.org/protocol/rsm\">"
+ "<max>10</max>"
+ "</set>"
+ "</query>"));
+
+
+ boost::shared_ptr<MAMQuery> payload = parser.getPayload<MAMQuery>();
+ CPPUNIT_ASSERT(!!payload);
+ CPPUNIT_ASSERT(payload->getQueryID());
+ CPPUNIT_ASSERT_EQUAL(std::string("id0"), *payload->getQueryID());
+ CPPUNIT_ASSERT_EQUAL(std::string("node1"), *payload->getNode());
+
+ CPPUNIT_ASSERT(payload->getForm());
+ boost::shared_ptr<FormField> fieldType = payload->getForm()->getField("FORM_TYPE");
+ CPPUNIT_ASSERT(fieldType);
+ CPPUNIT_ASSERT_EQUAL(std::string("urn:xmpp:mam:0"), fieldType->getTextSingleValue());
+ boost::shared_ptr<FormField> fieldStart = payload->getForm()->getField("start");
+ CPPUNIT_ASSERT(fieldStart);
+ CPPUNIT_ASSERT_EQUAL(std::string("2010-08-07T00:00:00Z"), fieldStart->getTextSingleValue());
+
+ CPPUNIT_ASSERT(payload->getResultSet());
+ boost::shared_ptr<ResultSet> resultSet = payload->getResultSet();
+ CPPUNIT_ASSERT(resultSet->getMaxItems());
+ CPPUNIT_ASSERT_EQUAL(*resultSet->getMaxItems(), 10);
+ }
+
+ void testParse_XEP0313_Example3() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns='urn:xmpp:mam:0'>"
+ "<x xmlns='jabber:x:data'>"
+ "<field var='FORM_TYPE'>"
+ "<value>urn:xmpp:mam:0</value>"
+ "</field>"
+ "<field var='with'>"
+ "<value>juliet@capulet.lit</value>"
+ "</field>"
+ "</x>"
+ "</query>"));
+
+ boost::shared_ptr<MAMQuery> payload = parser.getPayload<MAMQuery>();
+ CPPUNIT_ASSERT(!!payload && !!payload->getForm() && !!payload->getForm()->getField("FORM_TYPE") && !!payload->getForm()->getField("with"));
+ CPPUNIT_ASSERT_EQUAL(std::string("urn:xmpp:mam:0"), payload->getForm()->getField("FORM_TYPE")->getTextSingleValue());
+ CPPUNIT_ASSERT_EQUAL(std::string("juliet@capulet.lit"), payload->getForm()->getField("with")->getTextSingleValue());
+ }
+
+ void testParse_XEP0313_Example4() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns='urn:xmpp:mam:0'>"
+ "<x xmlns='jabber:x:data'>"
+ "<field var='FORM_TYPE'>"
+ "<value>urn:xmpp:mam:0</value>"
+ "</field>"
+ "<field var='start'>"
+ "<value>2010-06-07T00:00:00Z</value>"
+ "</field>"
+ "<field var='end'>"
+ "<value>2010-07-07T13:23:54Z</value>"
+ "</field>"
+ "</x>"
+ "</query>"));
+ boost::shared_ptr<MAMQuery> payload = parser.getPayload<MAMQuery>();
+ CPPUNIT_ASSERT(!!payload && !!payload->getForm() && !!payload->getForm()->getField("FORM_TYPE") && !!payload->getForm()->getField("start") && !!payload->getForm()->getField("start"));
+ CPPUNIT_ASSERT_EQUAL(std::string("urn:xmpp:mam:0"), payload->getForm()->getField("FORM_TYPE")->getTextSingleValue());
+ CPPUNIT_ASSERT_EQUAL(std::string("2010-06-07T00:00:00Z"), payload->getForm()->getField("start")->getTextSingleValue());
+ CPPUNIT_ASSERT_EQUAL(std::string("2010-07-07T13:23:54Z"), payload->getForm()->getField("end")->getTextSingleValue());
+ }
+
+ void testParseEmpty() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<query queryid=\"id0\" xmlns=\"urn:xmpp:mam:0\">"
+ "</query>"));
+
+ boost::shared_ptr<MAMQuery> payload = parser.getPayload<MAMQuery>();
+ CPPUNIT_ASSERT(!!payload);
+ CPPUNIT_ASSERT(payload->getQueryID());
+ CPPUNIT_ASSERT_EQUAL(std::string("id0"), *payload->getQueryID());
+ CPPUNIT_ASSERT(!payload->getForm());
+ CPPUNIT_ASSERT(!payload->getResultSet());
+ }
};
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MAMResultParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MAMResultParserTest.cpp
index a4c2f08..7393630 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MAMResultParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MAMResultParserTest.cpp
@@ -18,41 +18,41 @@ using namespace Swift;
class MAMResultParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(MAMResultParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testParse() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<result id=\"28482-98726-73623\" queryid=\"f27\" xmlns=\"urn:xmpp:mam:0\">"
- "<forwarded xmlns=\"urn:xmpp:forward:0\">"
- "<delay stamp=\"2010-07-10T23:08:25Z\" xmlns=\"urn:xmpp:delay\"/>"
- "<message xmlns=\"jabber:client\" from=\"romeo@montague.lit/orchard\" to=\"juliet@capulet.lit/balcony\" type=\"chat\">"
- "<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>"
- "</message>"
- "</forwarded>"
- "</result>"));
-
- boost::shared_ptr<MAMResult> payload = parser.getPayload<MAMResult>();
- CPPUNIT_ASSERT(!!payload);
- CPPUNIT_ASSERT_EQUAL(std::string("28482-98726-73623"), payload->getID());
- CPPUNIT_ASSERT(payload->getQueryID());
- CPPUNIT_ASSERT_EQUAL(std::string("f27"), *payload->getQueryID());
-
- boost::shared_ptr<Forwarded> forwarded = payload->getPayload();
- CPPUNIT_ASSERT(forwarded->getDelay());
- CPPUNIT_ASSERT_EQUAL(std::string("2010-07-10T23:08:25Z"), dateTimeToString(forwarded->getDelay()->getStamp()));
-
- boost::shared_ptr<Message> message = boost::dynamic_pointer_cast<Message>(forwarded->getStanza());
- CPPUNIT_ASSERT(!!message);
- const std::string expectedBody = "Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.";
- CPPUNIT_ASSERT_EQUAL(expectedBody, message->getBody().get());
- CPPUNIT_ASSERT_EQUAL(Message::Chat, message->getType());
- CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.lit/balcony"), message->getTo());
- CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), message->getFrom());
- }
+ CPPUNIT_TEST_SUITE(MAMResultParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testParse() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<result id=\"28482-98726-73623\" queryid=\"f27\" xmlns=\"urn:xmpp:mam:0\">"
+ "<forwarded xmlns=\"urn:xmpp:forward:0\">"
+ "<delay stamp=\"2010-07-10T23:08:25Z\" xmlns=\"urn:xmpp:delay\"/>"
+ "<message xmlns=\"jabber:client\" from=\"romeo@montague.lit/orchard\" to=\"juliet@capulet.lit/balcony\" type=\"chat\">"
+ "<body>Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.</body>"
+ "</message>"
+ "</forwarded>"
+ "</result>"));
+
+ boost::shared_ptr<MAMResult> payload = parser.getPayload<MAMResult>();
+ CPPUNIT_ASSERT(!!payload);
+ CPPUNIT_ASSERT_EQUAL(std::string("28482-98726-73623"), payload->getID());
+ CPPUNIT_ASSERT(payload->getQueryID());
+ CPPUNIT_ASSERT_EQUAL(std::string("f27"), *payload->getQueryID());
+
+ boost::shared_ptr<Forwarded> forwarded = payload->getPayload();
+ CPPUNIT_ASSERT(forwarded->getDelay());
+ CPPUNIT_ASSERT_EQUAL(std::string("2010-07-10T23:08:25Z"), dateTimeToString(forwarded->getDelay()->getStamp()));
+
+ boost::shared_ptr<Message> message = boost::dynamic_pointer_cast<Message>(forwarded->getStanza());
+ CPPUNIT_ASSERT(!!message);
+ const std::string expectedBody = "Call me but love, and I'll be new baptized; Henceforth I never will be Romeo.";
+ CPPUNIT_ASSERT_EQUAL(expectedBody, message->getBody().get());
+ CPPUNIT_ASSERT_EQUAL(Message::Chat, message->getType());
+ CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.lit/balcony"), message->getTo());
+ CPPUNIT_ASSERT_EQUAL(JID("romeo@montague.lit/orchard"), message->getFrom());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(MAMResultParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MUCAdminPayloadParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MUCAdminPayloadParserTest.cpp
index f49ca19..495aefe 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MUCAdminPayloadParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MUCAdminPayloadParserTest.cpp
@@ -14,25 +14,25 @@ using namespace Swift;
class MUCAdminPayloadParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(MUCAdminPayloadParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(MUCAdminPayloadParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST_SUITE_END();
- public:
- MUCAdminPayloadParserTest() {}
+ public:
+ MUCAdminPayloadParserTest() {}
- void testParse() {
- PayloadsParserTester parser;
+ void testParse() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<query xmlns=\"http://jabber.org/protocol/muc#admin\"><item affiliation=\"owner\" role=\"visitor\"><actor jid=\"kev@tester.lit\"/><reason>malice</reason></item></query>"));
+ CPPUNIT_ASSERT(parser.parse("<query xmlns=\"http://jabber.org/protocol/muc#admin\"><item affiliation=\"owner\" role=\"visitor\"><actor jid=\"kev@tester.lit\"/><reason>malice</reason></item></query>"));
- MUCAdminPayload::ref payload = boost::dynamic_pointer_cast<MUCAdminPayload>(parser.getPayload());
- MUCItem item = payload->getItems()[0];
- CPPUNIT_ASSERT_EQUAL(MUCOccupant::Owner, item.affiliation.get());
- CPPUNIT_ASSERT_EQUAL(MUCOccupant::Visitor, item.role.get());
- CPPUNIT_ASSERT_EQUAL(JID("kev@tester.lit"), item.actor.get());
- CPPUNIT_ASSERT_EQUAL(std::string("malice"), item.reason.get());
- }
+ MUCAdminPayload::ref payload = boost::dynamic_pointer_cast<MUCAdminPayload>(parser.getPayload());
+ MUCItem item = payload->getItems()[0];
+ CPPUNIT_ASSERT_EQUAL(MUCOccupant::Owner, item.affiliation.get());
+ CPPUNIT_ASSERT_EQUAL(MUCOccupant::Visitor, item.role.get());
+ CPPUNIT_ASSERT_EQUAL(JID("kev@tester.lit"), item.actor.get());
+ CPPUNIT_ASSERT_EQUAL(std::string("malice"), item.reason.get());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(MUCAdminPayloadParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MUCUserPayloadParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MUCUserPayloadParserTest.cpp
index 89c51d8..a8cf246 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MUCUserPayloadParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MUCUserPayloadParserTest.cpp
@@ -16,78 +16,78 @@ using namespace Swift;
class MUCUserPayloadParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(MUCUserPayloadParserTest);
- CPPUNIT_TEST(testParseEmpty);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testParseDestroy);
- CPPUNIT_TEST(testParseInvite);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- MUCUserPayloadParserTest() {}
-
- void testParse() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse("<x xmlns=\"http://jabber.org/protocol/muc#user\"><status code='110'/><item affiliation=\"owner\" role=\"visitor\"><actor jid=\"kev@tester.lit\"/><reason>malice</reason></item><status code='210'/></x>"));
-
- bool found110 = false;
- bool found210 = false;
-
- MUCUserPayload::ref payload = boost::dynamic_pointer_cast<MUCUserPayload>(parser.getPayload());
-
- foreach (MUCUserPayload::StatusCode status, payload->getStatusCodes()) {
- if (status.code == 110) found110 = true;
- if (status.code == 210) found210 = true;
- }
-
- MUCItem item = payload->getItems()[0];
- CPPUNIT_ASSERT_EQUAL(MUCOccupant::Owner, item.affiliation.get());
- CPPUNIT_ASSERT_EQUAL(MUCOccupant::Visitor, item.role.get());
- CPPUNIT_ASSERT_EQUAL(JID("kev@tester.lit"), item.actor.get());
- CPPUNIT_ASSERT_EQUAL(std::string("malice"), item.reason.get());
- CPPUNIT_ASSERT(found110);
- CPPUNIT_ASSERT(found210);
- }
-
- void testParseEmpty() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse("<x xmlns=\"http://jabber.org/protocol/muc#user\"/>"));
-
- MUCUserPayload::ref payload = boost::dynamic_pointer_cast<MUCUserPayload>(parser.getPayload());
- CPPUNIT_ASSERT(payload);
- CPPUNIT_ASSERT(payload->getItems().empty());
- }
-
- void testParseDestroy() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse("<x xmlns=\"http://jabber.org/protocol/muc#user\"><destroy jid='alice@wonderland.lit'><reason>bert</reason></destroy></x>"));
-
- MUCUserPayload::ref payload = boost::dynamic_pointer_cast<MUCUserPayload>(parser.getPayload());
- CPPUNIT_ASSERT(payload);
- MUCDestroyPayload::ref destroy = boost::dynamic_pointer_cast<MUCDestroyPayload>(payload->getPayload());
- CPPUNIT_ASSERT(destroy);
- CPPUNIT_ASSERT_EQUAL(std::string("bert"), destroy->getReason());
- CPPUNIT_ASSERT_EQUAL(JID("alice@wonderland.lit"), destroy->getNewVenue());
- }
-
- void testParseInvite() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse("<x xmlns=\"http://jabber.org/protocol/muc#user\"><invite from='crone1@shakespeare.lit/desktop' to='alice@wonderland.lit/xxx'> <reason>Hey Hecate, this is the place for all good witches!</reason> </invite> <password>cauldronburn</password></x>"));
-
- MUCUserPayload::ref payload = boost::dynamic_pointer_cast<MUCUserPayload>(parser.getPayload());
- CPPUNIT_ASSERT(payload);
- CPPUNIT_ASSERT(payload->getInvite());
- CPPUNIT_ASSERT(payload->getPassword());
- CPPUNIT_ASSERT_EQUAL(std::string("cauldronburn"), *payload->getPassword());
- MUCUserPayload::Invite invite = *payload->getInvite();
- CPPUNIT_ASSERT_EQUAL(std::string("Hey Hecate, this is the place for all good witches!"), invite.reason);
- CPPUNIT_ASSERT_EQUAL(JID("crone1@shakespeare.lit/desktop"), invite.from);
- CPPUNIT_ASSERT_EQUAL(JID("alice@wonderland.lit/xxx"), invite.to);
- }
+ CPPUNIT_TEST_SUITE(MUCUserPayloadParserTest);
+ CPPUNIT_TEST(testParseEmpty);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParseDestroy);
+ CPPUNIT_TEST(testParseInvite);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ MUCUserPayloadParserTest() {}
+
+ void testParse() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse("<x xmlns=\"http://jabber.org/protocol/muc#user\"><status code='110'/><item affiliation=\"owner\" role=\"visitor\"><actor jid=\"kev@tester.lit\"/><reason>malice</reason></item><status code='210'/></x>"));
+
+ bool found110 = false;
+ bool found210 = false;
+
+ MUCUserPayload::ref payload = boost::dynamic_pointer_cast<MUCUserPayload>(parser.getPayload());
+
+ foreach (MUCUserPayload::StatusCode status, payload->getStatusCodes()) {
+ if (status.code == 110) found110 = true;
+ if (status.code == 210) found210 = true;
+ }
+
+ MUCItem item = payload->getItems()[0];
+ CPPUNIT_ASSERT_EQUAL(MUCOccupant::Owner, item.affiliation.get());
+ CPPUNIT_ASSERT_EQUAL(MUCOccupant::Visitor, item.role.get());
+ CPPUNIT_ASSERT_EQUAL(JID("kev@tester.lit"), item.actor.get());
+ CPPUNIT_ASSERT_EQUAL(std::string("malice"), item.reason.get());
+ CPPUNIT_ASSERT(found110);
+ CPPUNIT_ASSERT(found210);
+ }
+
+ void testParseEmpty() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse("<x xmlns=\"http://jabber.org/protocol/muc#user\"/>"));
+
+ MUCUserPayload::ref payload = boost::dynamic_pointer_cast<MUCUserPayload>(parser.getPayload());
+ CPPUNIT_ASSERT(payload);
+ CPPUNIT_ASSERT(payload->getItems().empty());
+ }
+
+ void testParseDestroy() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse("<x xmlns=\"http://jabber.org/protocol/muc#user\"><destroy jid='alice@wonderland.lit'><reason>bert</reason></destroy></x>"));
+
+ MUCUserPayload::ref payload = boost::dynamic_pointer_cast<MUCUserPayload>(parser.getPayload());
+ CPPUNIT_ASSERT(payload);
+ MUCDestroyPayload::ref destroy = boost::dynamic_pointer_cast<MUCDestroyPayload>(payload->getPayload());
+ CPPUNIT_ASSERT(destroy);
+ CPPUNIT_ASSERT_EQUAL(std::string("bert"), destroy->getReason());
+ CPPUNIT_ASSERT_EQUAL(JID("alice@wonderland.lit"), destroy->getNewVenue());
+ }
+
+ void testParseInvite() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse("<x xmlns=\"http://jabber.org/protocol/muc#user\"><invite from='crone1@shakespeare.lit/desktop' to='alice@wonderland.lit/xxx'> <reason>Hey Hecate, this is the place for all good witches!</reason> </invite> <password>cauldronburn</password></x>"));
+
+ MUCUserPayload::ref payload = boost::dynamic_pointer_cast<MUCUserPayload>(parser.getPayload());
+ CPPUNIT_ASSERT(payload);
+ CPPUNIT_ASSERT(payload->getInvite());
+ CPPUNIT_ASSERT(payload->getPassword());
+ CPPUNIT_ASSERT_EQUAL(std::string("cauldronburn"), *payload->getPassword());
+ MUCUserPayload::Invite invite = *payload->getInvite();
+ CPPUNIT_ASSERT_EQUAL(std::string("Hey Hecate, this is the place for all good witches!"), invite.reason);
+ CPPUNIT_ASSERT_EQUAL(JID("crone1@shakespeare.lit/desktop"), invite.from);
+ CPPUNIT_ASSERT_EQUAL(JID("alice@wonderland.lit/xxx"), invite.to);
+ }
};
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/PayloadParserTester.h b/Swiften/Parser/PayloadParsers/UnitTest/PayloadParserTester.h
index bb6450f..a85a692 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/PayloadParserTester.h
+++ b/Swiften/Parser/PayloadParsers/UnitTest/PayloadParserTester.h
@@ -10,5 +10,5 @@
#include <Swiften/Parser/UnitTest/ParserTester.h>
namespace Swift {
- typedef ParserTester<PayloadParser> PayloadParserTester;
+ typedef ParserTester<PayloadParser> PayloadParserTester;
}
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h b/Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h
index ca33d48..8e871b2 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h
+++ b/Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h
@@ -14,53 +14,53 @@
#include <Swiften/Parser/XMLParserClient.h>
namespace Swift {
- class PayloadsParserTester : public XMLParserClient {
- public:
- PayloadsParserTester() : level(0) {
- xmlParser = PlatformXMLParserFactory().createXMLParser(this);
- }
+ class PayloadsParserTester : public XMLParserClient {
+ public:
+ PayloadsParserTester() : level(0) {
+ xmlParser = PlatformXMLParserFactory().createXMLParser(this);
+ }
- ~PayloadsParserTester() {
- delete xmlParser;
- }
+ ~PayloadsParserTester() {
+ delete xmlParser;
+ }
- bool parse(const std::string& data) {
- return xmlParser->parse(data);
- }
+ bool parse(const std::string& data) {
+ return xmlParser->parse(data);
+ }
- virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
- if (level == 0) {
- assert(!payloadParser.get());
- PayloadParserFactory* payloadParserFactory = factories.getPayloadParserFactory(element, ns, attributes);
- assert(payloadParserFactory);
- payloadParser.reset(payloadParserFactory->createPayloadParser());
- }
- payloadParser->handleStartElement(element, ns, attributes);
- level++;
- }
+ virtual void handleStartElement(const std::string& element, const std::string& ns, const AttributeMap& attributes) {
+ if (level == 0) {
+ assert(!payloadParser.get());
+ PayloadParserFactory* payloadParserFactory = factories.getPayloadParserFactory(element, ns, attributes);
+ assert(payloadParserFactory);
+ payloadParser.reset(payloadParserFactory->createPayloadParser());
+ }
+ payloadParser->handleStartElement(element, ns, attributes);
+ level++;
+ }
- virtual void handleEndElement(const std::string& element, const std::string& ns) {
- level--;
- payloadParser->handleEndElement(element, ns);
- }
+ virtual void handleEndElement(const std::string& element, const std::string& ns) {
+ level--;
+ payloadParser->handleEndElement(element, ns);
+ }
- virtual void handleCharacterData(const std::string& data) {
- payloadParser->handleCharacterData(data);
- }
+ virtual void handleCharacterData(const std::string& data) {
+ payloadParser->handleCharacterData(data);
+ }
- boost::shared_ptr<Payload> getPayload() const {
- return payloadParser->getPayload();
- }
+ boost::shared_ptr<Payload> getPayload() const {
+ return payloadParser->getPayload();
+ }
- template<typename T>
- boost::shared_ptr<T> getPayload() const {
- return boost::dynamic_pointer_cast<T>(payloadParser->getPayload());
- }
+ template<typename T>
+ boost::shared_ptr<T> getPayload() const {
+ return boost::dynamic_pointer_cast<T>(payloadParser->getPayload());
+ }
- private:
- XMLParser* xmlParser;
- FullPayloadParserFactoryCollection factories;
- boost::shared_ptr<PayloadParser> payloadParser;
- int level;
- };
+ private:
+ XMLParser* xmlParser;
+ FullPayloadParserFactoryCollection factories;
+ boost::shared_ptr<PayloadParser> payloadParser;
+ int level;
+ };
}
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/PriorityParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/PriorityParserTest.cpp
index 285ac56..e724090 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/PriorityParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/PriorityParserTest.cpp
@@ -13,29 +13,29 @@
using namespace Swift;
class PriorityParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(PriorityParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testParse_Invalid);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(PriorityParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParse_Invalid);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testParse() {
- PayloadsParserTester parser;
+ public:
+ void testParse() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<priority>-120</priority>"));
+ CPPUNIT_ASSERT(parser.parse("<priority>-120</priority>"));
- boost::shared_ptr<Priority> payload = boost::dynamic_pointer_cast<Priority>(parser.getPayload());
- CPPUNIT_ASSERT_EQUAL(-120, payload->getPriority());
- }
+ boost::shared_ptr<Priority> payload = boost::dynamic_pointer_cast<Priority>(parser.getPayload());
+ CPPUNIT_ASSERT_EQUAL(-120, payload->getPriority());
+ }
- void testParse_Invalid() {
- PayloadsParserTester parser;
+ void testParse_Invalid() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<priority>invalid</priority>"));
+ CPPUNIT_ASSERT(parser.parse("<priority>invalid</priority>"));
- boost::shared_ptr<Priority> payload = boost::dynamic_pointer_cast<Priority>(parser.getPayload());
- CPPUNIT_ASSERT_EQUAL(0, payload->getPriority());
- }
+ boost::shared_ptr<Priority> payload = boost::dynamic_pointer_cast<Priority>(parser.getPayload());
+ CPPUNIT_ASSERT_EQUAL(0, payload->getPriority());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(PriorityParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/PrivateStorageParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/PrivateStorageParserTest.cpp
index f38a0bd..2975485 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/PrivateStorageParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/PrivateStorageParserTest.cpp
@@ -15,81 +15,81 @@
using namespace Swift;
class PrivateStorageParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(PrivateStorageParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testParse_NoPayload);
- CPPUNIT_TEST(testParse_MultiplePayloads);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- PrivateStorageParserTest() {}
-
- void testParse() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<query xmlns='jabber:iq:private'>"
- "<storage xmlns='storage:bookmarks'>"
- "<conference name='Swift' jid='swift@rooms.swift.im'>"
- "<nick>Alice</nick>"
- "</conference>"
- "</storage>"
- "</query>"));
-
- boost::shared_ptr<PrivateStorage> payload = boost::dynamic_pointer_cast<PrivateStorage>(parser.getPayload());
- CPPUNIT_ASSERT(payload);
- boost::shared_ptr<Storage> storage = boost::dynamic_pointer_cast<Storage>(payload->getPayload());
- CPPUNIT_ASSERT(storage);
- CPPUNIT_ASSERT_EQUAL(std::string("Alice"), storage->getRooms()[0].nick);
- CPPUNIT_ASSERT_EQUAL(JID("swift@rooms.swift.im"), storage->getRooms()[0].jid);
- }
-
- void testParse_NoPayload() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse("<query xmlns='jabber:iq:private'/>"));
-
- boost::shared_ptr<PrivateStorage> payload = boost::dynamic_pointer_cast<PrivateStorage>(parser.getPayload());
- CPPUNIT_ASSERT(payload);
- CPPUNIT_ASSERT(!payload->getPayload());
- }
-
- void testParse_MultiplePayloads() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<query xmlns='jabber:iq:private'>"
- "<storage xmlns='storage:bookmarks'>"
- "<conference name='Swift' jid='swift@rooms.swift.im'>"
- "<nick>Alice</nick>"
- "</conference>"
- "</storage>"
- "<storage xmlns='storage:bookmarks'>"
- "<conference name='Swift' jid='swift@rooms.swift.im'>"
- "<nick>Rabbit</nick>"
- "</conference>"
- "</storage>"
- "</query>"));
-
- boost::shared_ptr<PrivateStorage> payload = boost::dynamic_pointer_cast<PrivateStorage>(parser.getPayload());
- CPPUNIT_ASSERT(payload);
- boost::shared_ptr<Storage> storage = boost::dynamic_pointer_cast<Storage>(payload->getPayload());
- CPPUNIT_ASSERT(storage);
- CPPUNIT_ASSERT_EQUAL(std::string("Rabbit"), storage->getRooms()[0].nick);
- }
-
- void testParse_UnsupportedPayload() {
- PayloadParserFactoryCollection factories;
- PrivateStorageParser testling(&factories);
- PayloadParserTester parser(&testling);
-
- CPPUNIT_ASSERT(parser.parse(
- "<query xmlns='jabber:iq:private'>"
- "<foo>Bar</foo>"
- "</query>"));
-
- CPPUNIT_ASSERT(!boost::dynamic_pointer_cast<PrivateStorage>(testling.getPayload())->getPayload());
- }
+ CPPUNIT_TEST_SUITE(PrivateStorageParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParse_NoPayload);
+ CPPUNIT_TEST(testParse_MultiplePayloads);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ PrivateStorageParserTest() {}
+
+ void testParse() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns='jabber:iq:private'>"
+ "<storage xmlns='storage:bookmarks'>"
+ "<conference name='Swift' jid='swift@rooms.swift.im'>"
+ "<nick>Alice</nick>"
+ "</conference>"
+ "</storage>"
+ "</query>"));
+
+ boost::shared_ptr<PrivateStorage> payload = boost::dynamic_pointer_cast<PrivateStorage>(parser.getPayload());
+ CPPUNIT_ASSERT(payload);
+ boost::shared_ptr<Storage> storage = boost::dynamic_pointer_cast<Storage>(payload->getPayload());
+ CPPUNIT_ASSERT(storage);
+ CPPUNIT_ASSERT_EQUAL(std::string("Alice"), storage->getRooms()[0].nick);
+ CPPUNIT_ASSERT_EQUAL(JID("swift@rooms.swift.im"), storage->getRooms()[0].jid);
+ }
+
+ void testParse_NoPayload() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse("<query xmlns='jabber:iq:private'/>"));
+
+ boost::shared_ptr<PrivateStorage> payload = boost::dynamic_pointer_cast<PrivateStorage>(parser.getPayload());
+ CPPUNIT_ASSERT(payload);
+ CPPUNIT_ASSERT(!payload->getPayload());
+ }
+
+ void testParse_MultiplePayloads() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns='jabber:iq:private'>"
+ "<storage xmlns='storage:bookmarks'>"
+ "<conference name='Swift' jid='swift@rooms.swift.im'>"
+ "<nick>Alice</nick>"
+ "</conference>"
+ "</storage>"
+ "<storage xmlns='storage:bookmarks'>"
+ "<conference name='Swift' jid='swift@rooms.swift.im'>"
+ "<nick>Rabbit</nick>"
+ "</conference>"
+ "</storage>"
+ "</query>"));
+
+ boost::shared_ptr<PrivateStorage> payload = boost::dynamic_pointer_cast<PrivateStorage>(parser.getPayload());
+ CPPUNIT_ASSERT(payload);
+ boost::shared_ptr<Storage> storage = boost::dynamic_pointer_cast<Storage>(payload->getPayload());
+ CPPUNIT_ASSERT(storage);
+ CPPUNIT_ASSERT_EQUAL(std::string("Rabbit"), storage->getRooms()[0].nick);
+ }
+
+ void testParse_UnsupportedPayload() {
+ PayloadParserFactoryCollection factories;
+ PrivateStorageParser testling(&factories);
+ PayloadParserTester parser(&testling);
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns='jabber:iq:private'>"
+ "<foo>Bar</foo>"
+ "</query>"));
+
+ CPPUNIT_ASSERT(!boost::dynamic_pointer_cast<PrivateStorage>(testling.getPayload())->getPayload());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(PrivateStorageParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/RawXMLPayloadParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/RawXMLPayloadParserTest.cpp
index 800f48c..2deca6e 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/RawXMLPayloadParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/RawXMLPayloadParserTest.cpp
@@ -14,27 +14,27 @@ using namespace Swift;
class RawXMLPayloadParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(RawXMLPayloadParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- RawXMLPayloadParserTest() {}
-
- void testParse() {
- RawXMLPayloadParser testling;
- PayloadParserTester parser(&testling);
-
- std::string xml =
- "<foo foo-attr=\"foo-val\" xmlns=\"ns:foo\">"
- "<bar bar-attr=\"bar-val\" xmlns=\"ns:bar\"/>"
- "<baz baz-attr=\"baz-val\" xmlns=\"ns:baz\"/>"
- "</foo>";
- CPPUNIT_ASSERT(parser.parse(xml));
-
- RawXMLPayload* payload = dynamic_cast<RawXMLPayload*>(testling.getPayload().get());
- CPPUNIT_ASSERT_EQUAL(xml, payload->getRawXML());
- }
+ CPPUNIT_TEST_SUITE(RawXMLPayloadParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ RawXMLPayloadParserTest() {}
+
+ void testParse() {
+ RawXMLPayloadParser testling;
+ PayloadParserTester parser(&testling);
+
+ std::string xml =
+ "<foo foo-attr=\"foo-val\" xmlns=\"ns:foo\">"
+ "<bar bar-attr=\"bar-val\" xmlns=\"ns:bar\"/>"
+ "<baz baz-attr=\"baz-val\" xmlns=\"ns:baz\"/>"
+ "</foo>";
+ CPPUNIT_ASSERT(parser.parse(xml));
+
+ RawXMLPayload* payload = dynamic_cast<RawXMLPayload*>(testling.getPayload().get());
+ CPPUNIT_ASSERT_EQUAL(xml, payload->getRawXML());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(RawXMLPayloadParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/ReplaceTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/ReplaceTest.cpp
index c3f410f..3e42788 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/ReplaceTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/ReplaceTest.cpp
@@ -13,24 +13,24 @@
using namespace Swift;
class ReplaceParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(ReplaceParserTest);
- CPPUNIT_TEST(testParseTrivial);
- CPPUNIT_TEST(testParseChild);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(ReplaceParserTest);
+ CPPUNIT_TEST(testParseTrivial);
+ CPPUNIT_TEST(testParseChild);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testParseTrivial() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<replace id='bad1' xmlns='http://swift.im/protocol/replace'/>"));
- Replace::ref payload = boost::dynamic_pointer_cast <Replace>(parser.getPayload());
- CPPUNIT_ASSERT_EQUAL(std::string("bad1"), payload->getID());
- }
- void testParseChild() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<replace id='bad1' xmlns='http://swift.im/protocol/replace' ><child xmlns='blah' id=\"hi\"/></replace>"));
- Replace::ref payload = boost::dynamic_pointer_cast <Replace>(parser.getPayload());
- CPPUNIT_ASSERT_EQUAL(std::string("bad1"), payload->getID());
- }
+ public:
+ void testParseTrivial() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse("<replace id='bad1' xmlns='http://swift.im/protocol/replace'/>"));
+ Replace::ref payload = boost::dynamic_pointer_cast <Replace>(parser.getPayload());
+ CPPUNIT_ASSERT_EQUAL(std::string("bad1"), payload->getID());
+ }
+ void testParseChild() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse("<replace id='bad1' xmlns='http://swift.im/protocol/replace' ><child xmlns='blah' id=\"hi\"/></replace>"));
+ Replace::ref payload = boost::dynamic_pointer_cast <Replace>(parser.getPayload());
+ CPPUNIT_ASSERT_EQUAL(std::string("bad1"), payload->getID());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(ReplaceParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/ResourceBindParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/ResourceBindParserTest.cpp
index 4c2b377..5c786c5 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/ResourceBindParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/ResourceBindParserTest.cpp
@@ -14,31 +14,31 @@ using namespace Swift;
class ResourceBindParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(ResourceBindParserTest);
- CPPUNIT_TEST(testParse_JID);
- CPPUNIT_TEST(testParse_Resource);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(ResourceBindParserTest);
+ CPPUNIT_TEST(testParse_JID);
+ CPPUNIT_TEST(testParse_Resource);
+ CPPUNIT_TEST_SUITE_END();
- public:
- ResourceBindParserTest() {}
+ public:
+ ResourceBindParserTest() {}
- void testParse_JID() {
- PayloadsParserTester parser;
+ void testParse_JID() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>somenode@example.com/someresource</jid></bind>"));
+ CPPUNIT_ASSERT(parser.parse("<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>somenode@example.com/someresource</jid></bind>"));
- ResourceBind* payload = dynamic_cast<ResourceBind*>(parser.getPayload().get());
- CPPUNIT_ASSERT_EQUAL(JID("somenode@example.com/someresource"), payload->getJID());
- }
+ ResourceBind* payload = dynamic_cast<ResourceBind*>(parser.getPayload().get());
+ CPPUNIT_ASSERT_EQUAL(JID("somenode@example.com/someresource"), payload->getJID());
+ }
- void testParse_Resource() {
- PayloadsParserTester parser;
+ void testParse_Resource() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>someresource</resource></bind>"));
+ CPPUNIT_ASSERT(parser.parse("<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>someresource</resource></bind>"));
- ResourceBind* payload = dynamic_cast<ResourceBind*>(parser.getPayload().get());
- CPPUNIT_ASSERT_EQUAL(std::string("someresource"), payload->getResource());
- }
+ ResourceBind* payload = dynamic_cast<ResourceBind*>(parser.getPayload().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("someresource"), payload->getResource());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(ResourceBindParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/ResultSetParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/ResultSetParserTest.cpp
index e01a811..7924e05 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/ResultSetParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/ResultSetParserTest.cpp
@@ -14,58 +14,58 @@ using namespace Swift;
class ResultSetParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(ResultSetParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testParseFirstNoIndex);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(ResultSetParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParseFirstNoIndex);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testParse() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<set xmlns=\"http://jabber.org/protocol/rsm\">"
- "<max>100</max>"
- "<count>800</count>"
- "<index>0</index>"
- "<first index=\"123\">stpeter@jabber.org</first>"
- "<last>peterpan@neverland.lit</last>"
- "<before>decaf-badba-dbad1</before>"
- "<after>09af3-cc343-b409f</after>"
- "</set>"));
+ public:
+ void testParse() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<set xmlns=\"http://jabber.org/protocol/rsm\">"
+ "<max>100</max>"
+ "<count>800</count>"
+ "<index>0</index>"
+ "<first index=\"123\">stpeter@jabber.org</first>"
+ "<last>peterpan@neverland.lit</last>"
+ "<before>decaf-badba-dbad1</before>"
+ "<after>09af3-cc343-b409f</after>"
+ "</set>"));
- boost::shared_ptr<ResultSet> payload = parser.getPayload<ResultSet>();
- CPPUNIT_ASSERT(!!payload);
- CPPUNIT_ASSERT(payload->getMaxItems());
- CPPUNIT_ASSERT_EQUAL(100, *payload->getMaxItems());
- CPPUNIT_ASSERT(payload->getCount());
- CPPUNIT_ASSERT_EQUAL(800, *payload->getCount());
- CPPUNIT_ASSERT(payload->getIndex());
- CPPUNIT_ASSERT_EQUAL(0, *payload->getIndex());
- CPPUNIT_ASSERT(payload->getFirstID());
- CPPUNIT_ASSERT_EQUAL(std::string("stpeter@jabber.org"), *payload->getFirstID());
- CPPUNIT_ASSERT(payload->getFirstIDIndex());
- CPPUNIT_ASSERT_EQUAL(123, *payload->getFirstIDIndex());
- CPPUNIT_ASSERT(payload->getLastID());
- CPPUNIT_ASSERT_EQUAL(std::string("peterpan@neverland.lit"), *payload->getLastID());
- CPPUNIT_ASSERT(payload->getBefore());
- CPPUNIT_ASSERT_EQUAL(std::string("decaf-badba-dbad1"), *payload->getBefore());
- CPPUNIT_ASSERT(payload->getAfter());
- CPPUNIT_ASSERT_EQUAL(std::string("09af3-cc343-b409f"), *payload->getAfter());
- }
+ boost::shared_ptr<ResultSet> payload = parser.getPayload<ResultSet>();
+ CPPUNIT_ASSERT(!!payload);
+ CPPUNIT_ASSERT(payload->getMaxItems());
+ CPPUNIT_ASSERT_EQUAL(100, *payload->getMaxItems());
+ CPPUNIT_ASSERT(payload->getCount());
+ CPPUNIT_ASSERT_EQUAL(800, *payload->getCount());
+ CPPUNIT_ASSERT(payload->getIndex());
+ CPPUNIT_ASSERT_EQUAL(0, *payload->getIndex());
+ CPPUNIT_ASSERT(payload->getFirstID());
+ CPPUNIT_ASSERT_EQUAL(std::string("stpeter@jabber.org"), *payload->getFirstID());
+ CPPUNIT_ASSERT(payload->getFirstIDIndex());
+ CPPUNIT_ASSERT_EQUAL(123, *payload->getFirstIDIndex());
+ CPPUNIT_ASSERT(payload->getLastID());
+ CPPUNIT_ASSERT_EQUAL(std::string("peterpan@neverland.lit"), *payload->getLastID());
+ CPPUNIT_ASSERT(payload->getBefore());
+ CPPUNIT_ASSERT_EQUAL(std::string("decaf-badba-dbad1"), *payload->getBefore());
+ CPPUNIT_ASSERT(payload->getAfter());
+ CPPUNIT_ASSERT_EQUAL(std::string("09af3-cc343-b409f"), *payload->getAfter());
+ }
- void testParseFirstNoIndex() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<set xmlns=\"http://jabber.org/protocol/rsm\">"
- "<first>stpeter@jabber.org</first>"
- "</set>"));
+ void testParseFirstNoIndex() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<set xmlns=\"http://jabber.org/protocol/rsm\">"
+ "<first>stpeter@jabber.org</first>"
+ "</set>"));
- boost::shared_ptr<ResultSet> payload = parser.getPayload<ResultSet>();
- CPPUNIT_ASSERT(!!payload);
- CPPUNIT_ASSERT(payload->getFirstID());
- CPPUNIT_ASSERT_EQUAL(std::string("stpeter@jabber.org"), *payload->getFirstID());
- CPPUNIT_ASSERT(!payload->getFirstIDIndex());
- }
+ boost::shared_ptr<ResultSet> payload = parser.getPayload<ResultSet>();
+ CPPUNIT_ASSERT(!!payload);
+ CPPUNIT_ASSERT(payload->getFirstID());
+ CPPUNIT_ASSERT_EQUAL(std::string("stpeter@jabber.org"), *payload->getFirstID());
+ CPPUNIT_ASSERT(!payload->getFirstIDIndex());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(ResultSetParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/RosterItemExchangeParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/RosterItemExchangeParserTest.cpp
index 1a18d6d..a94a6fe 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/RosterItemExchangeParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/RosterItemExchangeParserTest.cpp
@@ -14,39 +14,39 @@ using namespace Swift;
class RosterItemExchangeParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(RosterItemExchangeParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testParse() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<x xmlns=\"http://jabber.org/protocol/rosterx\">"
- "<item action=\"add\" jid=\"foo@bar.com\" name=\"Foo @ Bar\">"
- "<group>Group 1</group>"
- "<group>Group 2</group>"
- "</item>"
- "<item action=\"modify\" jid=\"baz@blo.com\" name=\"Baz\"/>"
- "</x>"));
-
- RosterItemExchangePayload* payload = dynamic_cast<RosterItemExchangePayload*>(parser.getPayload().get());
- const RosterItemExchangePayload::RosterItemExchangePayloadItems& items = payload->getItems();
-
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items.size());
-
- CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), items[0].getJID());
- CPPUNIT_ASSERT_EQUAL(std::string("Foo @ Bar"), items[0].getName());
- CPPUNIT_ASSERT_EQUAL(RosterItemExchangePayload::Item::Add, items[0].getAction());
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items[0].getGroups().size());
- CPPUNIT_ASSERT_EQUAL(std::string("Group 1"), items[0].getGroups()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("Group 2"), items[0].getGroups()[1]);
-
- CPPUNIT_ASSERT_EQUAL(JID("baz@blo.com"), items[1].getJID());
- CPPUNIT_ASSERT_EQUAL(std::string("Baz"), items[1].getName());
- CPPUNIT_ASSERT_EQUAL(RosterItemExchangePayload::Item::Modify, items[1].getAction());
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), items[1].getGroups().size());
- }
+ CPPUNIT_TEST_SUITE(RosterItemExchangeParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testParse() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<x xmlns=\"http://jabber.org/protocol/rosterx\">"
+ "<item action=\"add\" jid=\"foo@bar.com\" name=\"Foo @ Bar\">"
+ "<group>Group 1</group>"
+ "<group>Group 2</group>"
+ "</item>"
+ "<item action=\"modify\" jid=\"baz@blo.com\" name=\"Baz\"/>"
+ "</x>"));
+
+ RosterItemExchangePayload* payload = dynamic_cast<RosterItemExchangePayload*>(parser.getPayload().get());
+ const RosterItemExchangePayload::RosterItemExchangePayloadItems& items = payload->getItems();
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items.size());
+
+ CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), items[0].getJID());
+ CPPUNIT_ASSERT_EQUAL(std::string("Foo @ Bar"), items[0].getName());
+ CPPUNIT_ASSERT_EQUAL(RosterItemExchangePayload::Item::Add, items[0].getAction());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items[0].getGroups().size());
+ CPPUNIT_ASSERT_EQUAL(std::string("Group 1"), items[0].getGroups()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("Group 2"), items[0].getGroups()[1]);
+
+ CPPUNIT_ASSERT_EQUAL(JID("baz@blo.com"), items[1].getJID());
+ CPPUNIT_ASSERT_EQUAL(std::string("Baz"), items[1].getName());
+ CPPUNIT_ASSERT_EQUAL(RosterItemExchangePayload::Item::Modify, items[1].getAction());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), items[1].getGroups().size());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(RosterItemExchangeParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/RosterParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/RosterParserTest.cpp
index d1e1b45..261dad2 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/RosterParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/RosterParserTest.cpp
@@ -14,88 +14,88 @@ using namespace Swift;
class RosterParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(RosterParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testParse_ItemWithUnknownContent);
- CPPUNIT_TEST(testParse_WithVersion);
- CPPUNIT_TEST(testParse_WithEmptyVersion);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testParse() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<query xmlns='jabber:iq:roster'>"
- " <item jid='foo@bar.com' name='Foo @ Bar' subscription='from' ask='subscribe'>"
- " <group>Group 1</group>"
- " <group>Group 2</group>"
- " </item>"
- " <item jid='baz@blo.com' name='Baz'/>"
- "</query>"));
-
- RosterPayload* payload = dynamic_cast<RosterPayload*>(parser.getPayload().get());
-
- CPPUNIT_ASSERT(!payload->getVersion());
- const RosterPayload::RosterItemPayloads& items = payload->getItems();
-
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items.size());
-
- CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), items[0].getJID());
- CPPUNIT_ASSERT_EQUAL(std::string("Foo @ Bar"), items[0].getName());
- CPPUNIT_ASSERT_EQUAL(RosterItemPayload::From, items[0].getSubscription());
- CPPUNIT_ASSERT(items[0].getSubscriptionRequested());
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items[0].getGroups().size());
- CPPUNIT_ASSERT_EQUAL(std::string("Group 1"), items[0].getGroups()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("Group 2"), items[0].getGroups()[1]);
-
- CPPUNIT_ASSERT_EQUAL(JID("baz@blo.com"), items[1].getJID());
- CPPUNIT_ASSERT_EQUAL(std::string("Baz"), items[1].getName());
- CPPUNIT_ASSERT_EQUAL(RosterItemPayload::None, items[1].getSubscription());
- CPPUNIT_ASSERT(!items[1].getSubscriptionRequested());
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), items[1].getGroups().size());
- }
-
- void testParse_ItemWithUnknownContent() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<query xmlns='jabber:iq:roster'>"
- " <item jid='foo@bar.com' name='Foo @ Bar' subscription='from' ask='subscribe'>"
- " <group>Group 1</group>"
- " <foo xmlns=\"http://example.com\"><bar>Baz</bar></foo>"
- " <group>Group 2</group>"
- " <baz><fum>foo</fum></baz>"
- " </item>"
- "</query>"));
-
- RosterPayload* payload = dynamic_cast<RosterPayload*>(parser.getPayload().get());
- const RosterPayload::RosterItemPayloads& items = payload->getItems();
-
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), items.size());
- CPPUNIT_ASSERT_EQUAL(std::string("Group 1"), items[0].getGroups()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("Group 2"), items[0].getGroups()[1]);
- CPPUNIT_ASSERT_EQUAL(std::string(
- "<foo xmlns=\"http://example.com\"><bar xmlns=\"http://example.com\">Baz</bar></foo>"
- "<baz xmlns=\"jabber:iq:roster\"><fum xmlns=\"jabber:iq:roster\">foo</fum></baz>"
- ), items[0].getUnknownContent());
- }
-
- void testParse_WithVersion() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<query xmlns='jabber:iq:roster' ver='ver10'/>"));
-
- RosterPayload* payload = dynamic_cast<RosterPayload*>(parser.getPayload().get());
- CPPUNIT_ASSERT(payload->getVersion());
- CPPUNIT_ASSERT_EQUAL(std::string("ver10"), *payload->getVersion());
- }
-
- void testParse_WithEmptyVersion() {
- PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<query xmlns='jabber:iq:roster' ver=''/>"));
-
- RosterPayload* payload = dynamic_cast<RosterPayload*>(parser.getPayload().get());
- CPPUNIT_ASSERT(payload->getVersion());
- CPPUNIT_ASSERT_EQUAL(std::string(""), *payload->getVersion());
- }
+ CPPUNIT_TEST_SUITE(RosterParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParse_ItemWithUnknownContent);
+ CPPUNIT_TEST(testParse_WithVersion);
+ CPPUNIT_TEST(testParse_WithEmptyVersion);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testParse() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns='jabber:iq:roster'>"
+ " <item jid='foo@bar.com' name='Foo @ Bar' subscription='from' ask='subscribe'>"
+ " <group>Group 1</group>"
+ " <group>Group 2</group>"
+ " </item>"
+ " <item jid='baz@blo.com' name='Baz'/>"
+ "</query>"));
+
+ RosterPayload* payload = dynamic_cast<RosterPayload*>(parser.getPayload().get());
+
+ CPPUNIT_ASSERT(!payload->getVersion());
+ const RosterPayload::RosterItemPayloads& items = payload->getItems();
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items.size());
+
+ CPPUNIT_ASSERT_EQUAL(JID("foo@bar.com"), items[0].getJID());
+ CPPUNIT_ASSERT_EQUAL(std::string("Foo @ Bar"), items[0].getName());
+ CPPUNIT_ASSERT_EQUAL(RosterItemPayload::From, items[0].getSubscription());
+ CPPUNIT_ASSERT(items[0].getSubscriptionRequested());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items[0].getGroups().size());
+ CPPUNIT_ASSERT_EQUAL(std::string("Group 1"), items[0].getGroups()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("Group 2"), items[0].getGroups()[1]);
+
+ CPPUNIT_ASSERT_EQUAL(JID("baz@blo.com"), items[1].getJID());
+ CPPUNIT_ASSERT_EQUAL(std::string("Baz"), items[1].getName());
+ CPPUNIT_ASSERT_EQUAL(RosterItemPayload::None, items[1].getSubscription());
+ CPPUNIT_ASSERT(!items[1].getSubscriptionRequested());
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(0), items[1].getGroups().size());
+ }
+
+ void testParse_ItemWithUnknownContent() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns='jabber:iq:roster'>"
+ " <item jid='foo@bar.com' name='Foo @ Bar' subscription='from' ask='subscribe'>"
+ " <group>Group 1</group>"
+ " <foo xmlns=\"http://example.com\"><bar>Baz</bar></foo>"
+ " <group>Group 2</group>"
+ " <baz><fum>foo</fum></baz>"
+ " </item>"
+ "</query>"));
+
+ RosterPayload* payload = dynamic_cast<RosterPayload*>(parser.getPayload().get());
+ const RosterPayload::RosterItemPayloads& items = payload->getItems();
+
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), items.size());
+ CPPUNIT_ASSERT_EQUAL(std::string("Group 1"), items[0].getGroups()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("Group 2"), items[0].getGroups()[1]);
+ CPPUNIT_ASSERT_EQUAL(std::string(
+ "<foo xmlns=\"http://example.com\"><bar xmlns=\"http://example.com\">Baz</bar></foo>"
+ "<baz xmlns=\"jabber:iq:roster\"><fum xmlns=\"jabber:iq:roster\">foo</fum></baz>"
+ ), items[0].getUnknownContent());
+ }
+
+ void testParse_WithVersion() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse("<query xmlns='jabber:iq:roster' ver='ver10'/>"));
+
+ RosterPayload* payload = dynamic_cast<RosterPayload*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(payload->getVersion());
+ CPPUNIT_ASSERT_EQUAL(std::string("ver10"), *payload->getVersion());
+ }
+
+ void testParse_WithEmptyVersion() {
+ PayloadsParserTester parser;
+ CPPUNIT_ASSERT(parser.parse("<query xmlns='jabber:iq:roster' ver=''/>"));
+
+ RosterPayload* payload = dynamic_cast<RosterPayload*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(payload->getVersion());
+ CPPUNIT_ASSERT_EQUAL(std::string(""), *payload->getVersion());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(RosterParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/SearchPayloadParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/SearchPayloadParserTest.cpp
index 4b903e0..5fe4168 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/SearchPayloadParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/SearchPayloadParserTest.cpp
@@ -13,169 +13,169 @@
using namespace Swift;
class SearchPayloadParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(SearchPayloadParserTest);
- CPPUNIT_TEST(testParse_FormRequestResponse);
- CPPUNIT_TEST(testParse_Results);
- CPPUNIT_TEST(testParse_FormRequestResponse_XDATA);
- CPPUNIT_TEST(testParse_Results_XDATA);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testParse_FormRequestResponse() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<query xmlns=\"jabber:iq:search\">"
- "<instructions>Foo</instructions>"
- "<first/>"
- "<last/>"
- "</query>"
- ));
-
- SearchPayload::ref payload = parser.getPayload<SearchPayload>();
- CPPUNIT_ASSERT_EQUAL(std::string("Foo"), *payload->getInstructions());
- CPPUNIT_ASSERT(payload->getFirst());
- CPPUNIT_ASSERT(payload->getLast());
- CPPUNIT_ASSERT(!payload->getNick());
- }
-
- void testParse_Results() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<query xmlns=\"jabber:iq:search\">"
- "<item jid=\"juliet@capulet.com\">"
- "<first>Juliet</first>"
- "<last>Capulet</last>"
- "<nick>JuliC</nick>"
- "<email>juliet@shakespeare.lit</email>"
- "</item>"
- "<item jid=\"tybalt@shakespeare.lit\">"
- "<first>Tybalt</first>"
- "<last>Capulet</last>"
- "<nick>ty</nick>"
- "<email>tybalt@shakespeare.lit</email>"
- "</item>"
- "</query>"
- ));
-
- SearchPayload::ref payload = parser.getPayload<SearchPayload>();
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getItems().size()));
- CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.com"), payload->getItems()[0].jid);
- CPPUNIT_ASSERT_EQUAL(std::string("Juliet"), payload->getItems()[0].first);
- CPPUNIT_ASSERT_EQUAL(std::string("Capulet"), payload->getItems()[0].last);
- CPPUNIT_ASSERT_EQUAL(std::string("JuliC"), payload->getItems()[0].nick);
- CPPUNIT_ASSERT_EQUAL(std::string("juliet@shakespeare.lit"), payload->getItems()[0].email);
- CPPUNIT_ASSERT_EQUAL(JID("tybalt@shakespeare.lit"), payload->getItems()[1].jid);
- }
-
- void testParse_FormRequestResponse_XDATA() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<query xmlns='jabber:iq:search'>"
- "<instructions>"
- "Use the enclosed form to search. If your Jabber client does not"
- " support Data Forms, visit http://shakespeare.lit/"
- "</instructions>"
- "<x xmlns='jabber:x:data' type='form'>"
- "<title>User Directory Search</title>"
- "<instructions>"
- "Please provide the following information"
- " to search for Shakespearean characters."
- "</instructions>"
- "<field type='hidden'"
- " var='FORM_TYPE'>"
- "<value>jabber:iq:search</value>"
- "</field>"
- "<field type='text-single'"
- " label='Given Name'"
- " var='first'/>"
- "<field type='text-single'"
- " label='Family Name'"
- " var='last'/>"
- "<field type='list-single'"
- " label='Gender'"
- " var='x-gender'>"
- "<option label='Male'><value>male</value></option>"
- "<option label='Female'><value>female</value></option>"
- "</field>"
- "</x>"
- "</query>"
- ));
-
- SearchPayload::ref payload = parser.getPayload<SearchPayload>();
- CPPUNIT_ASSERT_EQUAL(std::string("Use the enclosed form to search. If your Jabber client does not"
- " support Data Forms, visit http://shakespeare.lit/"), *payload->getInstructions());
- CPPUNIT_ASSERT(payload->getForm());
- CPPUNIT_ASSERT_EQUAL(std::string("Please provide the following information"
- " to search for Shakespearean characters."), payload->getForm()->getInstructions());
- }
-
- void testParse_Results_XDATA() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse("<query xmlns='jabber:iq:search'>"
- " <x xmlns='jabber:x:data' type='result'>"
- " <field type='hidden' var='FORM_TYPE'>"
- " <value>jabber:iq:search</value>"
- " </field>"
- " <reported>"
- " <field var='first' label='Given Name' type='text-single'/>"
- " <field var='last' label='Family Name' type='text-single'/>"
- " <field var='jid' label='Jabber ID' type='jid-single'/>"
- " <field var='x-gender' label='Gender' type='list-single'/>"
- " </reported>"
- " <item>"
- " <field var='first'><value>Benvolio</value></field>"
- " <field var='last'><value>Montague</value></field>"
- " <field var='jid'><value>benvolio@montague.net</value></field>"
- " <field var='x-gender'><value>male</value></field>"
- " </item>"
- " <item>"
- " <field var='first'><value>Romeo</value></field>"
- " <field var='last'><value>Montague</value></field>"
- " <field var='jid'><value>romeo@montague.net</value></field>"
- " <field var='x-gender'><value>male</value></field>"
- " </item>"
- " </x>"
- "</query>"));
- SearchPayload::ref payload = parser.getPayload<SearchPayload>();
- CPPUNIT_ASSERT(payload);
-
- Form::ref dataForm = payload->getForm();
- CPPUNIT_ASSERT(dataForm);
-
- Form::FormItem reported = dataForm->getReportedFields();
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), reported.size());
-
- std::vector<Form::FormItem> items = dataForm->getItems();
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items.size());
-
- Form::FormItem item = items[0];
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), item.size());
-
- CPPUNIT_ASSERT_EQUAL(std::string("Benvolio"), item[0]->getValues()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("first"), item[0]->getName());
- CPPUNIT_ASSERT_EQUAL(std::string("Montague"), item[1]->getValues()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("last"), item[1]->getName());
- CPPUNIT_ASSERT_EQUAL(std::string("benvolio@montague.net"), item[2]->getValues()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("jid"), item[2]->getName());
- CPPUNIT_ASSERT_EQUAL(std::string("male"), item[3]->getValues()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("x-gender"), item[3]->getName());
-
- item = items[1];
- CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), item.size());
-
- CPPUNIT_ASSERT_EQUAL(std::string("Romeo"), item[0]->getValues()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("first"), item[0]->getName());
- CPPUNIT_ASSERT_EQUAL(std::string("Montague"), item[1]->getValues()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("last"), item[1]->getName());
- CPPUNIT_ASSERT_EQUAL(std::string("romeo@montague.net"), item[2]->getValues()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("jid"), item[2]->getName());
- CPPUNIT_ASSERT_EQUAL(std::string("male"), item[3]->getValues()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("x-gender"), item[3]->getName());
- }
+ CPPUNIT_TEST_SUITE(SearchPayloadParserTest);
+ CPPUNIT_TEST(testParse_FormRequestResponse);
+ CPPUNIT_TEST(testParse_Results);
+ CPPUNIT_TEST(testParse_FormRequestResponse_XDATA);
+ CPPUNIT_TEST(testParse_Results_XDATA);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testParse_FormRequestResponse() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns=\"jabber:iq:search\">"
+ "<instructions>Foo</instructions>"
+ "<first/>"
+ "<last/>"
+ "</query>"
+ ));
+
+ SearchPayload::ref payload = parser.getPayload<SearchPayload>();
+ CPPUNIT_ASSERT_EQUAL(std::string("Foo"), *payload->getInstructions());
+ CPPUNIT_ASSERT(payload->getFirst());
+ CPPUNIT_ASSERT(payload->getLast());
+ CPPUNIT_ASSERT(!payload->getNick());
+ }
+
+ void testParse_Results() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns=\"jabber:iq:search\">"
+ "<item jid=\"juliet@capulet.com\">"
+ "<first>Juliet</first>"
+ "<last>Capulet</last>"
+ "<nick>JuliC</nick>"
+ "<email>juliet@shakespeare.lit</email>"
+ "</item>"
+ "<item jid=\"tybalt@shakespeare.lit\">"
+ "<first>Tybalt</first>"
+ "<last>Capulet</last>"
+ "<nick>ty</nick>"
+ "<email>tybalt@shakespeare.lit</email>"
+ "</item>"
+ "</query>"
+ ));
+
+ SearchPayload::ref payload = parser.getPayload<SearchPayload>();
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getItems().size()));
+ CPPUNIT_ASSERT_EQUAL(JID("juliet@capulet.com"), payload->getItems()[0].jid);
+ CPPUNIT_ASSERT_EQUAL(std::string("Juliet"), payload->getItems()[0].first);
+ CPPUNIT_ASSERT_EQUAL(std::string("Capulet"), payload->getItems()[0].last);
+ CPPUNIT_ASSERT_EQUAL(std::string("JuliC"), payload->getItems()[0].nick);
+ CPPUNIT_ASSERT_EQUAL(std::string("juliet@shakespeare.lit"), payload->getItems()[0].email);
+ CPPUNIT_ASSERT_EQUAL(JID("tybalt@shakespeare.lit"), payload->getItems()[1].jid);
+ }
+
+ void testParse_FormRequestResponse_XDATA() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns='jabber:iq:search'>"
+ "<instructions>"
+ "Use the enclosed form to search. If your Jabber client does not"
+ " support Data Forms, visit http://shakespeare.lit/"
+ "</instructions>"
+ "<x xmlns='jabber:x:data' type='form'>"
+ "<title>User Directory Search</title>"
+ "<instructions>"
+ "Please provide the following information"
+ " to search for Shakespearean characters."
+ "</instructions>"
+ "<field type='hidden'"
+ " var='FORM_TYPE'>"
+ "<value>jabber:iq:search</value>"
+ "</field>"
+ "<field type='text-single'"
+ " label='Given Name'"
+ " var='first'/>"
+ "<field type='text-single'"
+ " label='Family Name'"
+ " var='last'/>"
+ "<field type='list-single'"
+ " label='Gender'"
+ " var='x-gender'>"
+ "<option label='Male'><value>male</value></option>"
+ "<option label='Female'><value>female</value></option>"
+ "</field>"
+ "</x>"
+ "</query>"
+ ));
+
+ SearchPayload::ref payload = parser.getPayload<SearchPayload>();
+ CPPUNIT_ASSERT_EQUAL(std::string("Use the enclosed form to search. If your Jabber client does not"
+ " support Data Forms, visit http://shakespeare.lit/"), *payload->getInstructions());
+ CPPUNIT_ASSERT(payload->getForm());
+ CPPUNIT_ASSERT_EQUAL(std::string("Please provide the following information"
+ " to search for Shakespearean characters."), payload->getForm()->getInstructions());
+ }
+
+ void testParse_Results_XDATA() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse("<query xmlns='jabber:iq:search'>"
+ " <x xmlns='jabber:x:data' type='result'>"
+ " <field type='hidden' var='FORM_TYPE'>"
+ " <value>jabber:iq:search</value>"
+ " </field>"
+ " <reported>"
+ " <field var='first' label='Given Name' type='text-single'/>"
+ " <field var='last' label='Family Name' type='text-single'/>"
+ " <field var='jid' label='Jabber ID' type='jid-single'/>"
+ " <field var='x-gender' label='Gender' type='list-single'/>"
+ " </reported>"
+ " <item>"
+ " <field var='first'><value>Benvolio</value></field>"
+ " <field var='last'><value>Montague</value></field>"
+ " <field var='jid'><value>benvolio@montague.net</value></field>"
+ " <field var='x-gender'><value>male</value></field>"
+ " </item>"
+ " <item>"
+ " <field var='first'><value>Romeo</value></field>"
+ " <field var='last'><value>Montague</value></field>"
+ " <field var='jid'><value>romeo@montague.net</value></field>"
+ " <field var='x-gender'><value>male</value></field>"
+ " </item>"
+ " </x>"
+ "</query>"));
+ SearchPayload::ref payload = parser.getPayload<SearchPayload>();
+ CPPUNIT_ASSERT(payload);
+
+ Form::ref dataForm = payload->getForm();
+ CPPUNIT_ASSERT(dataForm);
+
+ Form::FormItem reported = dataForm->getReportedFields();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), reported.size());
+
+ std::vector<Form::FormItem> items = dataForm->getItems();
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), items.size());
+
+ Form::FormItem item = items[0];
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), item.size());
+
+ CPPUNIT_ASSERT_EQUAL(std::string("Benvolio"), item[0]->getValues()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("first"), item[0]->getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("Montague"), item[1]->getValues()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("last"), item[1]->getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("benvolio@montague.net"), item[2]->getValues()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("jid"), item[2]->getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("male"), item[3]->getValues()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("x-gender"), item[3]->getName());
+
+ item = items[1];
+ CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(4), item.size());
+
+ CPPUNIT_ASSERT_EQUAL(std::string("Romeo"), item[0]->getValues()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("first"), item[0]->getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("Montague"), item[1]->getValues()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("last"), item[1]->getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("romeo@montague.net"), item[2]->getValues()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("jid"), item[2]->getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("male"), item[3]->getValues()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("x-gender"), item[3]->getName());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(SearchPayloadParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelParserTest.cpp
index 14f1f17..c27b716 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelParserTest.cpp
@@ -14,38 +14,38 @@ using namespace Swift;
class SecurityLabelParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(SecurityLabelParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- SecurityLabelParserTest() {}
-
- void testParse() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
- "<displaymarking fgcolor=\"black\" bgcolor=\"red\">SECRET</displaymarking>"
- "<label>"
- "<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>"
- "</label>"
- "<equivalentlabel>"
- "<icismlabel xmlns=\"http://example.gov/IC-ISM/0\" classification=\"S\" ownerProducer=\"USA\" disseminationControls=\"FOUO\"/>"
- "</equivalentlabel>"
- "<equivalentlabel>"
- "<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk=</esssecuritylabel>"
- "</equivalentlabel>"
- "</securitylabel>"));
-
- SecurityLabel* payload = dynamic_cast<SecurityLabel*>(parser.getPayload().get());
- CPPUNIT_ASSERT_EQUAL(std::string("SECRET"), payload->getDisplayMarking());
- CPPUNIT_ASSERT_EQUAL(std::string("black"), payload->getForegroundColor());
- CPPUNIT_ASSERT_EQUAL(std::string("red"), payload->getBackgroundColor());
- CPPUNIT_ASSERT_EQUAL(std::string("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>"), payload->getLabel());
- CPPUNIT_ASSERT_EQUAL(std::string("<icismlabel classification=\"S\" disseminationControls=\"FOUO\" ownerProducer=\"USA\" xmlns=\"http://example.gov/IC-ISM/0\"/>"), payload->getEquivalentLabels()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk=</esssecuritylabel>"), payload->getEquivalentLabels()[1]);
- }
+ CPPUNIT_TEST_SUITE(SecurityLabelParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ SecurityLabelParserTest() {}
+
+ void testParse() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
+ "<displaymarking fgcolor=\"black\" bgcolor=\"red\">SECRET</displaymarking>"
+ "<label>"
+ "<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>"
+ "</label>"
+ "<equivalentlabel>"
+ "<icismlabel xmlns=\"http://example.gov/IC-ISM/0\" classification=\"S\" ownerProducer=\"USA\" disseminationControls=\"FOUO\"/>"
+ "</equivalentlabel>"
+ "<equivalentlabel>"
+ "<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk=</esssecuritylabel>"
+ "</equivalentlabel>"
+ "</securitylabel>"));
+
+ SecurityLabel* payload = dynamic_cast<SecurityLabel*>(parser.getPayload().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("SECRET"), payload->getDisplayMarking());
+ CPPUNIT_ASSERT_EQUAL(std::string("black"), payload->getForegroundColor());
+ CPPUNIT_ASSERT_EQUAL(std::string("red"), payload->getBackgroundColor());
+ CPPUNIT_ASSERT_EQUAL(std::string("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>"), payload->getLabel());
+ CPPUNIT_ASSERT_EQUAL(std::string("<icismlabel classification=\"S\" disseminationControls=\"FOUO\" ownerProducer=\"USA\" xmlns=\"http://example.gov/IC-ISM/0\"/>"), payload->getEquivalentLabels()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MRUCAgD9DA9BcXVhIChvYnNvbGV0ZSk=</esssecuritylabel>"), payload->getEquivalentLabels()[1]);
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(SecurityLabelParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelsCatalogParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelsCatalogParserTest.cpp
index f1745d0..2b992b1 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelsCatalogParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelsCatalogParserTest.cpp
@@ -14,50 +14,50 @@ using namespace Swift;
class SecurityLabelsCatalogParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(SecurityLabelsCatalogParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- SecurityLabelsCatalogParserTest() {}
-
- void testParse() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<catalog desc=\"an example set of labels\" name=\"Default\" to=\"example.com\" xmlns=\"urn:xmpp:sec-label:catalog:2\">"
- "<item selector='Classified|SECRET'>"
- "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
- "<displaymarking bgcolor=\"red\" fgcolor=\"black\">SECRET</displaymarking>"
- "<label><esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel></label>"
- "</securitylabel>"
- "</item>"
- "<item selector='Classified|CONFIDENTIAL' default='true'>"
- "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
- "<displaymarking bgcolor=\"navy\" fgcolor=\"black\">CONFIDENTIAL</displaymarking>"
- "<label><esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQMGASk=</esssecuritylabel></label>"
- "</securitylabel>"
- "</item>"
- "<item selector='Unclassified|UNCLASSIFIED'/>"
- "</catalog>"));
-
- SecurityLabelsCatalog* payload = dynamic_cast<SecurityLabelsCatalog*>(parser.getPayload().get());
- CPPUNIT_ASSERT_EQUAL(std::string("Default"), payload->getName());
- CPPUNIT_ASSERT_EQUAL(std::string("an example set of labels"), payload->getDescription());
- CPPUNIT_ASSERT_EQUAL(JID("example.com"), payload->getTo());
- CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(payload->getItems().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("SECRET"), payload->getItems()[0].getLabel()->getDisplayMarking());
- CPPUNIT_ASSERT_EQUAL(std::string("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>"), payload->getItems()[0].getLabel()->getLabel());
- CPPUNIT_ASSERT_EQUAL(false, payload->getItems()[0].getIsDefault());
- CPPUNIT_ASSERT_EQUAL(std::string("Classified|SECRET"), payload->getItems()[0].getSelector());
- CPPUNIT_ASSERT_EQUAL(std::string("CONFIDENTIAL"), payload->getItems()[1].getLabel()->getDisplayMarking());
- CPPUNIT_ASSERT_EQUAL(std::string("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQMGASk=</esssecuritylabel>"), payload->getItems()[1].getLabel()->getLabel());
- CPPUNIT_ASSERT_EQUAL(true, payload->getItems()[1].getIsDefault());
- CPPUNIT_ASSERT_EQUAL(std::string("Classified|CONFIDENTIAL"), payload->getItems()[1].getSelector());
- CPPUNIT_ASSERT_EQUAL(false, payload->getItems()[2].getIsDefault());
- CPPUNIT_ASSERT_EQUAL(std::string("Unclassified|UNCLASSIFIED"), payload->getItems()[2].getSelector());
- CPPUNIT_ASSERT(!payload->getItems()[2].getLabel());
- }
+ CPPUNIT_TEST_SUITE(SecurityLabelsCatalogParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ SecurityLabelsCatalogParserTest() {}
+
+ void testParse() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<catalog desc=\"an example set of labels\" name=\"Default\" to=\"example.com\" xmlns=\"urn:xmpp:sec-label:catalog:2\">"
+ "<item selector='Classified|SECRET'>"
+ "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
+ "<displaymarking bgcolor=\"red\" fgcolor=\"black\">SECRET</displaymarking>"
+ "<label><esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel></label>"
+ "</securitylabel>"
+ "</item>"
+ "<item selector='Classified|CONFIDENTIAL' default='true'>"
+ "<securitylabel xmlns=\"urn:xmpp:sec-label:0\">"
+ "<displaymarking bgcolor=\"navy\" fgcolor=\"black\">CONFIDENTIAL</displaymarking>"
+ "<label><esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQMGASk=</esssecuritylabel></label>"
+ "</securitylabel>"
+ "</item>"
+ "<item selector='Unclassified|UNCLASSIFIED'/>"
+ "</catalog>"));
+
+ SecurityLabelsCatalog* payload = dynamic_cast<SecurityLabelsCatalog*>(parser.getPayload().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("Default"), payload->getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("an example set of labels"), payload->getDescription());
+ CPPUNIT_ASSERT_EQUAL(JID("example.com"), payload->getTo());
+ CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(payload->getItems().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("SECRET"), payload->getItems()[0].getLabel()->getDisplayMarking());
+ CPPUNIT_ASSERT_EQUAL(std::string("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>"), payload->getItems()[0].getLabel()->getLabel());
+ CPPUNIT_ASSERT_EQUAL(false, payload->getItems()[0].getIsDefault());
+ CPPUNIT_ASSERT_EQUAL(std::string("Classified|SECRET"), payload->getItems()[0].getSelector());
+ CPPUNIT_ASSERT_EQUAL(std::string("CONFIDENTIAL"), payload->getItems()[1].getLabel()->getDisplayMarking());
+ CPPUNIT_ASSERT_EQUAL(std::string("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQMGASk=</esssecuritylabel>"), payload->getItems()[1].getLabel()->getLabel());
+ CPPUNIT_ASSERT_EQUAL(true, payload->getItems()[1].getIsDefault());
+ CPPUNIT_ASSERT_EQUAL(std::string("Classified|CONFIDENTIAL"), payload->getItems()[1].getSelector());
+ CPPUNIT_ASSERT_EQUAL(false, payload->getItems()[2].getIsDefault());
+ CPPUNIT_ASSERT_EQUAL(std::string("Unclassified|UNCLASSIFIED"), payload->getItems()[2].getSelector());
+ CPPUNIT_ASSERT(!payload->getItems()[2].getLabel());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(SecurityLabelsCatalogParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/SoftwareVersionParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/SoftwareVersionParserTest.cpp
index 6650cb7..7471856 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/SoftwareVersionParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/SoftwareVersionParserTest.cpp
@@ -14,28 +14,28 @@ using namespace Swift;
class SoftwareVersionParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(SoftwareVersionParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- SoftwareVersionParserTest() {}
-
- void testParse() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<query xmlns=\"jabber:iq:version\">"
- "<name>myclient</name>"
- "<version>1.0</version>"
- "<os>Mac OS X</os>"
- "</query>"));
-
- SoftwareVersion* payload = dynamic_cast<SoftwareVersion*>(parser.getPayload().get());
- CPPUNIT_ASSERT_EQUAL(std::string("myclient"), payload->getName());
- CPPUNIT_ASSERT_EQUAL(std::string("1.0"), payload->getVersion());
- CPPUNIT_ASSERT_EQUAL(std::string("Mac OS X"), payload->getOS());
- }
+ CPPUNIT_TEST_SUITE(SoftwareVersionParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ SoftwareVersionParserTest() {}
+
+ void testParse() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<query xmlns=\"jabber:iq:version\">"
+ "<name>myclient</name>"
+ "<version>1.0</version>"
+ "<os>Mac OS X</os>"
+ "</query>"));
+
+ SoftwareVersion* payload = dynamic_cast<SoftwareVersion*>(parser.getPayload().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("myclient"), payload->getName());
+ CPPUNIT_ASSERT_EQUAL(std::string("1.0"), payload->getVersion());
+ CPPUNIT_ASSERT_EQUAL(std::string("Mac OS X"), payload->getOS());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(SoftwareVersionParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/StatusParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/StatusParserTest.cpp
index 5c7f467..6b93637 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/StatusParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/StatusParserTest.cpp
@@ -14,21 +14,21 @@ using namespace Swift;
class StatusParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(StatusParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(StatusParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST_SUITE_END();
- public:
- StatusParserTest() {}
+ public:
+ StatusParserTest() {}
- void testParse() {
- PayloadsParserTester parser;
+ void testParse() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse("<status>foo<baz>bar</baz>fum</status>"));
+ CPPUNIT_ASSERT(parser.parse("<status>foo<baz>bar</baz>fum</status>"));
- Status* payload = dynamic_cast<Status*>(parser.getPayload().get());
- CPPUNIT_ASSERT_EQUAL(std::string("foobarfum"), payload->getText());
- }
+ Status* payload = dynamic_cast<Status*>(parser.getPayload().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("foobarfum"), payload->getText());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(StatusParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/StatusShowParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/StatusShowParserTest.cpp
index 98653ef..94f14c6 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/StatusShowParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/StatusShowParserTest.cpp
@@ -14,61 +14,61 @@ using namespace Swift;
class StatusShowParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(StatusShowParserTest);
- CPPUNIT_TEST(testParse_Invalid);
- CPPUNIT_TEST(testParse_Away);
- CPPUNIT_TEST(testParse_FFC);
- CPPUNIT_TEST(testParse_XA);
- CPPUNIT_TEST(testParse_DND);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- StatusShowParserTest() {}
-
- void testParse_Invalid() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse("<show>invalid</show>"));
-
- StatusShow* payload = dynamic_cast<StatusShow*>(parser.getPayload().get());
- CPPUNIT_ASSERT(StatusShow::Online == payload->getType());
- }
-
- void testParse_Away() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse("<show>away</show>"));
-
- StatusShow* payload = dynamic_cast<StatusShow*>(parser.getPayload().get());
- CPPUNIT_ASSERT(StatusShow::Away == payload->getType());
- }
-
- void testParse_FFC() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse("<show>chat</show>"));
-
- StatusShow* payload = dynamic_cast<StatusShow*>(parser.getPayload().get());
- CPPUNIT_ASSERT(StatusShow::FFC == payload->getType());
- }
-
- void testParse_XA() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse("<show>xa</show>"));
-
- StatusShow* payload = dynamic_cast<StatusShow*>(parser.getPayload().get());
- CPPUNIT_ASSERT(StatusShow::XA == payload->getType());
- }
-
- void testParse_DND() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse("<show>dnd</show>"));
-
- StatusShow* payload = dynamic_cast<StatusShow*>(parser.getPayload().get());
- CPPUNIT_ASSERT(StatusShow::DND == payload->getType());
- }
+ CPPUNIT_TEST_SUITE(StatusShowParserTest);
+ CPPUNIT_TEST(testParse_Invalid);
+ CPPUNIT_TEST(testParse_Away);
+ CPPUNIT_TEST(testParse_FFC);
+ CPPUNIT_TEST(testParse_XA);
+ CPPUNIT_TEST(testParse_DND);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ StatusShowParserTest() {}
+
+ void testParse_Invalid() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse("<show>invalid</show>"));
+
+ StatusShow* payload = dynamic_cast<StatusShow*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(StatusShow::Online == payload->getType());
+ }
+
+ void testParse_Away() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse("<show>away</show>"));
+
+ StatusShow* payload = dynamic_cast<StatusShow*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(StatusShow::Away == payload->getType());
+ }
+
+ void testParse_FFC() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse("<show>chat</show>"));
+
+ StatusShow* payload = dynamic_cast<StatusShow*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(StatusShow::FFC == payload->getType());
+ }
+
+ void testParse_XA() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse("<show>xa</show>"));
+
+ StatusShow* payload = dynamic_cast<StatusShow*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(StatusShow::XA == payload->getType());
+ }
+
+ void testParse_DND() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse("<show>dnd</show>"));
+
+ StatusShow* payload = dynamic_cast<StatusShow*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(StatusShow::DND == payload->getType());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(StatusShowParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp
index 9797b6a..4430668 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp
@@ -13,74 +13,74 @@
using namespace Swift;
class StorageParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(StorageParserTest);
- CPPUNIT_TEST(testParse_Room);
- CPPUNIT_TEST(testParse_MultipleRooms);
- CPPUNIT_TEST(testParse_URL);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- StorageParserTest() {}
-
- void testParse_Room() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<storage xmlns='storage:bookmarks'>"
- "<conference "
- "name='Council of Oberon' "
- "autojoin='true' jid='council@conference.underhill.org'>"
- "<nick>Puck</nick>"
- "<password>MyPass</password>"
- "</conference>"
- "</storage>"));
-
- Storage* payload = dynamic_cast<Storage*>(parser.getPayload().get());
- std::vector<Storage::Room> rooms = payload->getRooms();
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(rooms.size()));
- CPPUNIT_ASSERT_EQUAL(std::string("Council of Oberon"), rooms[0].name);
- CPPUNIT_ASSERT_EQUAL(JID("council@conference.underhill.org"), rooms[0].jid);
- CPPUNIT_ASSERT(rooms[0].autoJoin);
- CPPUNIT_ASSERT_EQUAL(std::string("Puck"), rooms[0].nick);
- CPPUNIT_ASSERT_EQUAL(std::string("MyPass"), *rooms[0].password);
- }
-
- void testParse_MultipleRooms() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<storage xmlns='storage:bookmarks'>"
- "<conference "
- "name='Council of Oberon' "
- "jid='council@conference.underhill.org' />"
- "<conference "
- "name='Tea &amp; jam party' "
- "jid='teaparty@wonderland.lit' />"
- "</storage>"));
-
- Storage* payload = dynamic_cast<Storage*>(parser.getPayload().get());
- std::vector<Storage::Room> rooms = payload->getRooms();
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(rooms.size()));
- CPPUNIT_ASSERT_EQUAL(std::string("Council of Oberon"), rooms[0].name);
- CPPUNIT_ASSERT_EQUAL(JID("council@conference.underhill.org"), rooms[0].jid);
- CPPUNIT_ASSERT_EQUAL(std::string("Tea & jam party"), rooms[1].name);
- CPPUNIT_ASSERT_EQUAL(JID("teaparty@wonderland.lit"), rooms[1].jid);
- }
-
- void testParse_URL() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<storage xmlns='storage:bookmarks'>"
- "<url name='Complete Works of Shakespeare' url='http://the-tech.mit.edu/Shakespeare/'/>"
- "</storage>"));
-
- Storage* payload = dynamic_cast<Storage*>(parser.getPayload().get());
- std::vector<Storage::URL> urls = payload->getURLs();
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(urls.size()));
- CPPUNIT_ASSERT_EQUAL(std::string("Complete Works of Shakespeare"), urls[0].name);
- CPPUNIT_ASSERT_EQUAL(std::string("http://the-tech.mit.edu/Shakespeare/"), urls[0].url);
- }
+ CPPUNIT_TEST_SUITE(StorageParserTest);
+ CPPUNIT_TEST(testParse_Room);
+ CPPUNIT_TEST(testParse_MultipleRooms);
+ CPPUNIT_TEST(testParse_URL);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ StorageParserTest() {}
+
+ void testParse_Room() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<storage xmlns='storage:bookmarks'>"
+ "<conference "
+ "name='Council of Oberon' "
+ "autojoin='true' jid='council@conference.underhill.org'>"
+ "<nick>Puck</nick>"
+ "<password>MyPass</password>"
+ "</conference>"
+ "</storage>"));
+
+ Storage* payload = dynamic_cast<Storage*>(parser.getPayload().get());
+ std::vector<Storage::Room> rooms = payload->getRooms();
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(rooms.size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("Council of Oberon"), rooms[0].name);
+ CPPUNIT_ASSERT_EQUAL(JID("council@conference.underhill.org"), rooms[0].jid);
+ CPPUNIT_ASSERT(rooms[0].autoJoin);
+ CPPUNIT_ASSERT_EQUAL(std::string("Puck"), rooms[0].nick);
+ CPPUNIT_ASSERT_EQUAL(std::string("MyPass"), *rooms[0].password);
+ }
+
+ void testParse_MultipleRooms() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<storage xmlns='storage:bookmarks'>"
+ "<conference "
+ "name='Council of Oberon' "
+ "jid='council@conference.underhill.org' />"
+ "<conference "
+ "name='Tea &amp; jam party' "
+ "jid='teaparty@wonderland.lit' />"
+ "</storage>"));
+
+ Storage* payload = dynamic_cast<Storage*>(parser.getPayload().get());
+ std::vector<Storage::Room> rooms = payload->getRooms();
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(rooms.size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("Council of Oberon"), rooms[0].name);
+ CPPUNIT_ASSERT_EQUAL(JID("council@conference.underhill.org"), rooms[0].jid);
+ CPPUNIT_ASSERT_EQUAL(std::string("Tea & jam party"), rooms[1].name);
+ CPPUNIT_ASSERT_EQUAL(JID("teaparty@wonderland.lit"), rooms[1].jid);
+ }
+
+ void testParse_URL() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<storage xmlns='storage:bookmarks'>"
+ "<url name='Complete Works of Shakespeare' url='http://the-tech.mit.edu/Shakespeare/'/>"
+ "</storage>"));
+
+ Storage* payload = dynamic_cast<Storage*>(parser.getPayload().get());
+ std::vector<Storage::URL> urls = payload->getURLs();
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(urls.size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("Complete Works of Shakespeare"), urls[0].name);
+ CPPUNIT_ASSERT_EQUAL(std::string("http://the-tech.mit.edu/Shakespeare/"), urls[0].url);
+ }
};
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/StreamInitiationParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/StreamInitiationParserTest.cpp
index dbbaca8..9b0679d 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/StreamInitiationParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/StreamInitiationParserTest.cpp
@@ -13,63 +13,63 @@
using namespace Swift;
class StreamInitiationParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(StreamInitiationParserTest);
- CPPUNIT_TEST(testParse_Request);
- CPPUNIT_TEST(testParse_Response);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(StreamInitiationParserTest);
+ CPPUNIT_TEST(testParse_Request);
+ CPPUNIT_TEST(testParse_Response);
+ CPPUNIT_TEST_SUITE_END();
- public:
- void testParse_Request() {
- PayloadsParserTester parser;
+ public:
+ void testParse_Request() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<si xmlns='http://jabber.org/protocol/si' id='a0' mime-type='text/plain' profile='http://jabber.org/protocol/si/profile/file-transfer'>"
- "<file xmlns='http://jabber.org/protocol/si/profile/file-transfer' name='test.txt' size='1022'>"
- "<desc>This is info about the file.</desc>"
- "</file>"
- "<feature xmlns='http://jabber.org/protocol/feature-neg'>"
- "<x xmlns='jabber:x:data' type='form'>"
- "<field var='stream-method' type='list-single'>"
- "<option><value>http://jabber.org/protocol/bytestreams</value></option>"
- "<option><value>jabber:iq:oob</value></option>"
- "<option><value>http://jabber.org/protocol/ibb</value></option>"
- "</field>"
- "</x>"
- "</feature>"
- "</si>"
- ));
+ CPPUNIT_ASSERT(parser.parse(
+ "<si xmlns='http://jabber.org/protocol/si' id='a0' mime-type='text/plain' profile='http://jabber.org/protocol/si/profile/file-transfer'>"
+ "<file xmlns='http://jabber.org/protocol/si/profile/file-transfer' name='test.txt' size='1022'>"
+ "<desc>This is info about the file.</desc>"
+ "</file>"
+ "<feature xmlns='http://jabber.org/protocol/feature-neg'>"
+ "<x xmlns='jabber:x:data' type='form'>"
+ "<field var='stream-method' type='list-single'>"
+ "<option><value>http://jabber.org/protocol/bytestreams</value></option>"
+ "<option><value>jabber:iq:oob</value></option>"
+ "<option><value>http://jabber.org/protocol/ibb</value></option>"
+ "</field>"
+ "</x>"
+ "</feature>"
+ "</si>"
+ ));
- StreamInitiation::ref si = parser.getPayload<StreamInitiation>();
- CPPUNIT_ASSERT(si->getIsFileTransfer());
- CPPUNIT_ASSERT(si->getFileInfo());
- CPPUNIT_ASSERT_EQUAL(std::string("test.txt"), si->getFileInfo()->getName());
- CPPUNIT_ASSERT(1022 == si->getFileInfo()->getSize());
- CPPUNIT_ASSERT_EQUAL(std::string("This is info about the file."), si->getFileInfo()->getDescription());
- CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(si->getProvidedMethods().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("http://jabber.org/protocol/bytestreams"), si->getProvidedMethods()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:oob"), si->getProvidedMethods()[1]);
- CPPUNIT_ASSERT_EQUAL(std::string("http://jabber.org/protocol/ibb"), si->getProvidedMethods()[2]);
- }
+ StreamInitiation::ref si = parser.getPayload<StreamInitiation>();
+ CPPUNIT_ASSERT(si->getIsFileTransfer());
+ CPPUNIT_ASSERT(si->getFileInfo());
+ CPPUNIT_ASSERT_EQUAL(std::string("test.txt"), si->getFileInfo()->getName());
+ CPPUNIT_ASSERT(1022 == si->getFileInfo()->getSize());
+ CPPUNIT_ASSERT_EQUAL(std::string("This is info about the file."), si->getFileInfo()->getDescription());
+ CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(si->getProvidedMethods().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("http://jabber.org/protocol/bytestreams"), si->getProvidedMethods()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("jabber:iq:oob"), si->getProvidedMethods()[1]);
+ CPPUNIT_ASSERT_EQUAL(std::string("http://jabber.org/protocol/ibb"), si->getProvidedMethods()[2]);
+ }
- void testParse_Response() {
- PayloadsParserTester parser;
+ void testParse_Response() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<si xmlns='http://jabber.org/protocol/si'>"
- "<feature xmlns='http://jabber.org/protocol/feature-neg'>"
- "<x xmlns='jabber:x:data' type='submit'>"
- "<field var='stream-method'>"
- "<value>http://jabber.org/protocol/bytestreams</value>"
- "</field>"
- "</x>"
- "</feature>"
- "</si>"
- ));
+ CPPUNIT_ASSERT(parser.parse(
+ "<si xmlns='http://jabber.org/protocol/si'>"
+ "<feature xmlns='http://jabber.org/protocol/feature-neg'>"
+ "<x xmlns='jabber:x:data' type='submit'>"
+ "<field var='stream-method'>"
+ "<value>http://jabber.org/protocol/bytestreams</value>"
+ "</field>"
+ "</x>"
+ "</feature>"
+ "</si>"
+ ));
- StreamInitiation::ref si = parser.getPayload<StreamInitiation>();
- CPPUNIT_ASSERT(si->getIsFileTransfer());
- CPPUNIT_ASSERT_EQUAL(std::string("http://jabber.org/protocol/bytestreams"), si->getRequestedMethod());
- }
+ StreamInitiation::ref si = parser.getPayload<StreamInitiation>();
+ CPPUNIT_ASSERT(si->getIsFileTransfer());
+ CPPUNIT_ASSERT_EQUAL(std::string("http://jabber.org/protocol/bytestreams"), si->getRequestedMethod());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(StreamInitiationParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/UserLocationParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/UserLocationParserTest.cpp
index d3bf378..6d16377 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/UserLocationParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/UserLocationParserTest.cpp
@@ -13,7 +13,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <Swiften/Base/DateTime.h>
+#include <Swiften/Base/DateTime.h>
#include <Swiften/Elements/UserLocation.h>
#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
#include <Swiften/Parser/PayloadParsers/UserLocationParser.h>
@@ -22,89 +22,89 @@ using namespace Swift;
class UserLocationParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(UserLocationParserTest);
- CPPUNIT_TEST(testParse_with_all_variables);
- CPPUNIT_TEST(testParse_with_Some_variables);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(UserLocationParserTest);
+ CPPUNIT_TEST(testParse_with_all_variables);
+ CPPUNIT_TEST(testParse_with_Some_variables);
+ CPPUNIT_TEST_SUITE_END();
- public:
- UserLocationParserTest() {}
+ public:
+ UserLocationParserTest() {}
- void testParse_with_all_variables() {
- PayloadsParserTester parser;
+ void testParse_with_all_variables() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<geoloc xmlns=\"http://jabber.org/protocol/geoloc\">"
- "<area>Barbaric</area><alt>5.75</alt><locality>Near</locality>"
- "<lat>1.67</lat><accuracy>0.95</accuracy><description>Nice</description>"
- "<countrycode>+91</countrycode><timestamp>2015-06-11T20:55:50Z</timestamp><floor>3</floor>"
- "<building>First</building><room>E315</room><country>USA</country>"
- "<region>NewSode</region><uri>URIs</uri><lon>6.7578</lon><error>5.66</error>"
- "<postalcode>67</postalcode><bearing>12.89</bearing><text>Hello</text>"
- "<datum>Datee</datum><street>Highway</street><speed>56.77</speed></geoloc>"));
+ CPPUNIT_ASSERT(parser.parse(
+ "<geoloc xmlns=\"http://jabber.org/protocol/geoloc\">"
+ "<area>Barbaric</area><alt>5.75</alt><locality>Near</locality>"
+ "<lat>1.67</lat><accuracy>0.95</accuracy><description>Nice</description>"
+ "<countrycode>+91</countrycode><timestamp>2015-06-11T20:55:50Z</timestamp><floor>3</floor>"
+ "<building>First</building><room>E315</room><country>USA</country>"
+ "<region>NewSode</region><uri>URIs</uri><lon>6.7578</lon><error>5.66</error>"
+ "<postalcode>67</postalcode><bearing>12.89</bearing><text>Hello</text>"
+ "<datum>Datee</datum><street>Highway</street><speed>56.77</speed></geoloc>"));
- UserLocation* payload = dynamic_cast<UserLocation*>(parser.getPayload().get());
- CPPUNIT_ASSERT(payload);
- CPPUNIT_ASSERT_EQUAL(std::string("Barbaric"), payload->getArea().get());
- CPPUNIT_ASSERT_EQUAL(5.75F, payload->getAltitude().get());
- CPPUNIT_ASSERT_EQUAL(std::string("Near"), payload->getLocality().get());
- CPPUNIT_ASSERT_EQUAL(1.670F, payload->getLatitude().get());
- CPPUNIT_ASSERT_EQUAL(0.95F, payload->getAccuracy().get());
- CPPUNIT_ASSERT_EQUAL(std::string("Nice"), payload->getDescription().get());
- CPPUNIT_ASSERT_EQUAL(std::string("+91"), payload->getCountryCode().get());
- CPPUNIT_ASSERT_EQUAL(std::string("2015-06-11T20:55:50Z"), dateTimeToString(payload->getTimestamp().get()));
- CPPUNIT_ASSERT_EQUAL(std::string("3"), payload->getFloor().get());
- CPPUNIT_ASSERT_EQUAL(std::string("First"), payload->getBuilding().get());
- CPPUNIT_ASSERT_EQUAL(std::string("E315"), payload->getRoom().get());
- CPPUNIT_ASSERT_EQUAL(std::string("USA"), payload->getCountry().get());
- CPPUNIT_ASSERT_EQUAL(std::string("NewSode"), payload->getRegion().get());
- CPPUNIT_ASSERT_EQUAL(std::string("URIs"), payload->getURI().get());
- CPPUNIT_ASSERT_EQUAL(6.7578F, payload->getLongitude().get());
- CPPUNIT_ASSERT_EQUAL(5.66F, payload->getError().get());
- CPPUNIT_ASSERT_EQUAL(std::string("67"), payload->getPostalCode().get());
- CPPUNIT_ASSERT_EQUAL(12.89F, payload->getBearing().get());
- CPPUNIT_ASSERT_EQUAL(std::string("Hello"), payload->getText().get());
- CPPUNIT_ASSERT_EQUAL(std::string("Datee"), payload->getDatum().get());
- CPPUNIT_ASSERT_EQUAL(std::string("Highway"), payload->getStreet().get());
- CPPUNIT_ASSERT_EQUAL(56.77F, payload->getSpeed().get());
- }
+ UserLocation* payload = dynamic_cast<UserLocation*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(payload);
+ CPPUNIT_ASSERT_EQUAL(std::string("Barbaric"), payload->getArea().get());
+ CPPUNIT_ASSERT_EQUAL(5.75F, payload->getAltitude().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("Near"), payload->getLocality().get());
+ CPPUNIT_ASSERT_EQUAL(1.670F, payload->getLatitude().get());
+ CPPUNIT_ASSERT_EQUAL(0.95F, payload->getAccuracy().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("Nice"), payload->getDescription().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("+91"), payload->getCountryCode().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("2015-06-11T20:55:50Z"), dateTimeToString(payload->getTimestamp().get()));
+ CPPUNIT_ASSERT_EQUAL(std::string("3"), payload->getFloor().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("First"), payload->getBuilding().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("E315"), payload->getRoom().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("USA"), payload->getCountry().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("NewSode"), payload->getRegion().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("URIs"), payload->getURI().get());
+ CPPUNIT_ASSERT_EQUAL(6.7578F, payload->getLongitude().get());
+ CPPUNIT_ASSERT_EQUAL(5.66F, payload->getError().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("67"), payload->getPostalCode().get());
+ CPPUNIT_ASSERT_EQUAL(12.89F, payload->getBearing().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("Hello"), payload->getText().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("Datee"), payload->getDatum().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("Highway"), payload->getStreet().get());
+ CPPUNIT_ASSERT_EQUAL(56.77F, payload->getSpeed().get());
+ }
- void testParse_with_Some_variables() {
- PayloadsParserTester parser;
+ void testParse_with_Some_variables() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<geoloc xmlns=\"http://jabber.org/protocol/geoloc\">"
- "<area>Barbaric</area><alt>5.75</alt><locality>Near</locality>"
- "<accuracy>0.95</accuracy><description>Nice</description>"
- "<countrycode>+91</countrycode><timestamp>2015-06-11T20:55:50Z</timestamp><floor>3</floor>"
- "<region>NewSode</region><uri>URIs</uri><lon>6.7578</lon><error>5.66</error>"
- "<postalcode>67</postalcode><bearing>12.89</bearing><text>Hello</text></geoloc>"));
+ CPPUNIT_ASSERT(parser.parse(
+ "<geoloc xmlns=\"http://jabber.org/protocol/geoloc\">"
+ "<area>Barbaric</area><alt>5.75</alt><locality>Near</locality>"
+ "<accuracy>0.95</accuracy><description>Nice</description>"
+ "<countrycode>+91</countrycode><timestamp>2015-06-11T20:55:50Z</timestamp><floor>3</floor>"
+ "<region>NewSode</region><uri>URIs</uri><lon>6.7578</lon><error>5.66</error>"
+ "<postalcode>67</postalcode><bearing>12.89</bearing><text>Hello</text></geoloc>"));
- UserLocation* payload = dynamic_cast<UserLocation*>(parser.getPayload().get());
- CPPUNIT_ASSERT(payload);
- CPPUNIT_ASSERT_EQUAL(std::string("Barbaric"), payload->getArea().get());
- CPPUNIT_ASSERT_EQUAL(5.75F, payload->getAltitude().get());
- CPPUNIT_ASSERT_EQUAL(std::string("Near"), payload->getLocality().get());
- CPPUNIT_ASSERT(!payload->getLatitude());
- CPPUNIT_ASSERT_EQUAL(0.95F, payload->getAccuracy().get());
- CPPUNIT_ASSERT_EQUAL(std::string("Nice"), payload->getDescription().get());
- CPPUNIT_ASSERT_EQUAL(std::string("+91"), payload->getCountryCode().get());
- CPPUNIT_ASSERT_EQUAL(std::string("2015-06-11T20:55:50Z"), dateTimeToString(payload->getTimestamp().get()));
- CPPUNIT_ASSERT_EQUAL(std::string("3"), payload->getFloor().get());
- CPPUNIT_ASSERT(!payload->getBuilding());
- CPPUNIT_ASSERT(!payload->getRoom());
- CPPUNIT_ASSERT(!payload->getCountry());
- CPPUNIT_ASSERT_EQUAL(std::string("NewSode"), payload->getRegion().get());
- CPPUNIT_ASSERT_EQUAL(std::string("URIs"), payload->getURI().get());
- CPPUNIT_ASSERT_EQUAL(6.7578F, payload->getLongitude().get());
- CPPUNIT_ASSERT_EQUAL(5.66F, payload->getError().get());
- CPPUNIT_ASSERT_EQUAL(std::string("67"), payload->getPostalCode().get());
- CPPUNIT_ASSERT_EQUAL(12.89F, payload->getBearing().get());
- CPPUNIT_ASSERT_EQUAL(std::string("Hello"), payload->getText().get());
- CPPUNIT_ASSERT(!payload->getDatum());
- CPPUNIT_ASSERT(!payload->getStreet());
- CPPUNIT_ASSERT(!payload->getSpeed());
- }
+ UserLocation* payload = dynamic_cast<UserLocation*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(payload);
+ CPPUNIT_ASSERT_EQUAL(std::string("Barbaric"), payload->getArea().get());
+ CPPUNIT_ASSERT_EQUAL(5.75F, payload->getAltitude().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("Near"), payload->getLocality().get());
+ CPPUNIT_ASSERT(!payload->getLatitude());
+ CPPUNIT_ASSERT_EQUAL(0.95F, payload->getAccuracy().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("Nice"), payload->getDescription().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("+91"), payload->getCountryCode().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("2015-06-11T20:55:50Z"), dateTimeToString(payload->getTimestamp().get()));
+ CPPUNIT_ASSERT_EQUAL(std::string("3"), payload->getFloor().get());
+ CPPUNIT_ASSERT(!payload->getBuilding());
+ CPPUNIT_ASSERT(!payload->getRoom());
+ CPPUNIT_ASSERT(!payload->getCountry());
+ CPPUNIT_ASSERT_EQUAL(std::string("NewSode"), payload->getRegion().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("URIs"), payload->getURI().get());
+ CPPUNIT_ASSERT_EQUAL(6.7578F, payload->getLongitude().get());
+ CPPUNIT_ASSERT_EQUAL(5.66F, payload->getError().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("67"), payload->getPostalCode().get());
+ CPPUNIT_ASSERT_EQUAL(12.89F, payload->getBearing().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("Hello"), payload->getText().get());
+ CPPUNIT_ASSERT(!payload->getDatum());
+ CPPUNIT_ASSERT(!payload->getStreet());
+ CPPUNIT_ASSERT(!payload->getSpeed());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(UserLocationParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/UserTuneParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/UserTuneParserTest.cpp
index b1070c5..3783231 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/UserTuneParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/UserTuneParserTest.cpp
@@ -13,7 +13,7 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <Swiften/Base/DateTime.h>
+#include <Swiften/Base/DateTime.h>
#include <Swiften/Elements/UserTune.h>
#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
#include <Swiften/Parser/PayloadParsers/UserTuneParser.h>
@@ -22,49 +22,49 @@ using namespace Swift;
class UserTuneParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(UserTuneParserTest);
- CPPUNIT_TEST(testParse_with_all_variables);
- CPPUNIT_TEST(testParse_with_Some_variables);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(UserTuneParserTest);
+ CPPUNIT_TEST(testParse_with_all_variables);
+ CPPUNIT_TEST(testParse_with_Some_variables);
+ CPPUNIT_TEST_SUITE_END();
- public:
- UserTuneParserTest() {}
+ public:
+ UserTuneParserTest() {}
- void testParse_with_all_variables() {
- PayloadsParserTester parser;
+ void testParse_with_all_variables() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<tune xmlns=\"http://jabber.org/protocol/tune\">"
- "<rating>5</rating><title>Minion</title><track>Yellow</track><artist>Ice</artist><URI>Fire</URI><source>Origin</source><length>226</length></tune>"));
+ CPPUNIT_ASSERT(parser.parse(
+ "<tune xmlns=\"http://jabber.org/protocol/tune\">"
+ "<rating>5</rating><title>Minion</title><track>Yellow</track><artist>Ice</artist><URI>Fire</URI><source>Origin</source><length>226</length></tune>"));
- UserTune* payload = dynamic_cast<UserTune*>(parser.getPayload().get());
- CPPUNIT_ASSERT(payload);
- CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(5), payload->getRating().get());
- CPPUNIT_ASSERT_EQUAL(std::string("Minion"), payload->getTitle().get());
- CPPUNIT_ASSERT_EQUAL(std::string("Yellow"), payload->getTrack().get());
- CPPUNIT_ASSERT_EQUAL(std::string("Ice"), payload->getArtist().get());
- CPPUNIT_ASSERT_EQUAL(std::string("Fire"), payload->getURI().get());
- CPPUNIT_ASSERT_EQUAL(std::string("Origin"), payload->getSource().get());
- CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(226), payload->getLength().get());
- }
+ UserTune* payload = dynamic_cast<UserTune*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(payload);
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(5), payload->getRating().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("Minion"), payload->getTitle().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("Yellow"), payload->getTrack().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("Ice"), payload->getArtist().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("Fire"), payload->getURI().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("Origin"), payload->getSource().get());
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(226), payload->getLength().get());
+ }
- void testParse_with_Some_variables() {
- PayloadsParserTester parser;
+ void testParse_with_Some_variables() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<tune xmlns=\"http://jabber.org/protocol/tune\">"
- "<title>Minion</title><track>Yellow</track><source>Origin</source><length>226</length></tune>"));
+ CPPUNIT_ASSERT(parser.parse(
+ "<tune xmlns=\"http://jabber.org/protocol/tune\">"
+ "<title>Minion</title><track>Yellow</track><source>Origin</source><length>226</length></tune>"));
- UserTune* payload = dynamic_cast<UserTune*>(parser.getPayload().get());
- CPPUNIT_ASSERT(payload);
- CPPUNIT_ASSERT(!payload->getRating());
- CPPUNIT_ASSERT_EQUAL(std::string("Minion"), payload->getTitle().get());
- CPPUNIT_ASSERT_EQUAL(std::string("Yellow"), payload->getTrack().get());
- CPPUNIT_ASSERT(!payload->getArtist());
- CPPUNIT_ASSERT(!payload->getURI());
- CPPUNIT_ASSERT_EQUAL(std::string("Origin"), payload->getSource().get());
- CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(226), payload->getLength().get());
- }
+ UserTune* payload = dynamic_cast<UserTune*>(parser.getPayload().get());
+ CPPUNIT_ASSERT(payload);
+ CPPUNIT_ASSERT(!payload->getRating());
+ CPPUNIT_ASSERT_EQUAL(std::string("Minion"), payload->getTitle().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("Yellow"), payload->getTrack().get());
+ CPPUNIT_ASSERT(!payload->getArtist());
+ CPPUNIT_ASSERT(!payload->getURI());
+ CPPUNIT_ASSERT_EQUAL(std::string("Origin"), payload->getSource().get());
+ CPPUNIT_ASSERT_EQUAL(static_cast<unsigned int>(226), payload->getLength().get());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(UserTuneParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp
index 9e841a7..e02eb7a 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp
@@ -18,190 +18,190 @@
using namespace Swift;
class VCardParserTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(VCardParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST(testParse_Photo);
- CPPUNIT_TEST(testParse_NewlinedPhoto);
- CPPUNIT_TEST(testParse_Nickname);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- void testParse() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<vCard xmlns=\"vcard-temp\">"
- "<VERSION>2.0</VERSION>"
- "<FN>Alice In Wonderland</FN>"
- "<N>"
- "<FAMILY>Wonderland</FAMILY>"
- "<GIVEN>Alice</GIVEN>"
- "<MIDDLE>In</MIDDLE>"
- "<PREFIX>Mrs</PREFIX>"
- "<SUFFIX>PhD</SUFFIX>"
- "</N>"
- "<EMAIL>"
- "<USERID>alice@wonderland.lit</USERID>"
- "<HOME/>"
- "<INTERNET/>"
- "<PREF/>"
- "</EMAIL>"
- "<EMAIL>"
- "<USERID>alice@teaparty.lit</USERID>"
- "<WORK/>"
- "<X400/>"
- "</EMAIL>"
- "<TEL>"
- "<NUMBER>555-6273</NUMBER>"
- "<HOME/>"
- "<VOICE/>"
- "</TEL>"
- "<ADR>"
- "<LOCALITY>Any Town</LOCALITY>"
- "<STREET>Fake Street 123</STREET>"
- "<PCODE>12345</PCODE>"
- "<CTRY>USA</CTRY>"
- "<HOME/>"
- "</ADR>"
- "<LABEL>"
- "<LINE>Fake Street 123</LINE>"
- "<LINE>12345 Any Town</LINE>"
- "<LINE>USA</LINE>"
- "<HOME/>"
- "</LABEL>"
- "<NICKNAME>DreamGirl</NICKNAME>"
- "<BDAY>1865-05-04</BDAY>"
- "<JID>alice@teaparty.lit</JID>"
- "<JID>alice@wonderland.lit</JID>"
- "<DESC>I once fell down a rabbit hole.</DESC>"
- "<ORG>"
- "<ORGNAME>Alice In Wonderland Inc.</ORGNAME>"
- "</ORG>"
- "<TITLE>Some Title</TITLE>"
- "<ROLE>Main Character</ROLE>"
- "<URL>http://wonderland.lit/~alice</URL>"
- "<URL>http://teaparty.lit/~alice2</URL>"
- "<MAILER>mutt</MAILER>"
- "</vCard>"));
-
- boost::shared_ptr<VCard> payload = boost::dynamic_pointer_cast<VCard>(parser.getPayload());
- CPPUNIT_ASSERT_EQUAL(std::string("2.0"), payload->getVersion());
- CPPUNIT_ASSERT_EQUAL(std::string("Alice In Wonderland"), payload->getFullName());
- CPPUNIT_ASSERT_EQUAL(std::string("Alice"), payload->getGivenName());
- CPPUNIT_ASSERT_EQUAL(std::string("In"), payload->getMiddleName());
- CPPUNIT_ASSERT_EQUAL(std::string("Wonderland"), payload->getFamilyName());
- CPPUNIT_ASSERT_EQUAL(std::string("Mrs"), payload->getPrefix());
- CPPUNIT_ASSERT_EQUAL(std::string("PhD"), payload->getSuffix());
- CPPUNIT_ASSERT_EQUAL(std::string("DreamGirl"), payload->getNickname());
- CPPUNIT_ASSERT_EQUAL(boost::posix_time::ptime(boost::gregorian::date(1865, 5, 4)), payload->getBirthday());
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getEMailAddresses().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("alice@wonderland.lit"), payload->getEMailAddresses()[0].address);
- CPPUNIT_ASSERT(payload->getEMailAddresses()[0].isHome);
- CPPUNIT_ASSERT(payload->getEMailAddresses()[0].isInternet);
- CPPUNIT_ASSERT(payload->getEMailAddresses()[0].isPreferred);
- CPPUNIT_ASSERT(!payload->getEMailAddresses()[0].isWork);
- CPPUNIT_ASSERT(!payload->getEMailAddresses()[0].isX400);
- CPPUNIT_ASSERT_EQUAL(std::string("alice@teaparty.lit"), payload->getEMailAddresses()[1].address);
- CPPUNIT_ASSERT(!payload->getEMailAddresses()[1].isHome);
- CPPUNIT_ASSERT(!payload->getEMailAddresses()[1].isInternet);
- CPPUNIT_ASSERT(!payload->getEMailAddresses()[1].isPreferred);
- CPPUNIT_ASSERT(payload->getEMailAddresses()[1].isWork);
- CPPUNIT_ASSERT(payload->getEMailAddresses()[1].isX400);
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(payload->getTelephones().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("555-6273"), payload->getTelephones()[0].number);
- CPPUNIT_ASSERT(payload->getTelephones()[0].isHome);
- CPPUNIT_ASSERT(payload->getTelephones()[0].isVoice);
- CPPUNIT_ASSERT(!payload->getTelephones()[0].isPreferred);
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(payload->getAddresses().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("Any Town"), payload->getAddresses()[0].locality);
- CPPUNIT_ASSERT_EQUAL(std::string("Fake Street 123"), payload->getAddresses()[0].street);
- CPPUNIT_ASSERT_EQUAL(std::string("12345"), payload->getAddresses()[0].postalCode);
- CPPUNIT_ASSERT_EQUAL(std::string("USA"), payload->getAddresses()[0].country);
- CPPUNIT_ASSERT(payload->getAddresses()[0].isHome);
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(payload->getAddressLabels().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("Fake Street 123"), payload->getAddressLabels()[0].lines[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("12345 Any Town"), payload->getAddressLabels()[0].lines[1]);
- CPPUNIT_ASSERT_EQUAL(std::string("USA"), payload->getAddressLabels()[0].lines[2]);
- CPPUNIT_ASSERT(payload->getAddressLabels()[0].isHome);
-
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getJIDs().size()));
- CPPUNIT_ASSERT_EQUAL(JID("alice@teaparty.lit"), payload->getJIDs()[0]);
- CPPUNIT_ASSERT_EQUAL(JID("alice@wonderland.lit"), payload->getJIDs()[1]);
-
- CPPUNIT_ASSERT_EQUAL(std::string("I once fell down a rabbit hole."), payload->getDescription());
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(payload->getOrganizations().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("Alice In Wonderland Inc."), payload->getOrganizations()[0].name);
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(payload->getOrganizations()[0].units.size()));
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(payload->getTitles().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("Some Title"), payload->getTitles()[0]);
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(payload->getRoles().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("Main Character"), payload->getRoles()[0]);
- CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getURLs().size()));
- CPPUNIT_ASSERT_EQUAL(std::string("http://wonderland.lit/~alice"), payload->getURLs()[0]);
- CPPUNIT_ASSERT_EQUAL(std::string("http://teaparty.lit/~alice2"), payload->getURLs()[1]);
-
- CPPUNIT_ASSERT_EQUAL(std::string("<MAILER xmlns=\"vcard-temp\">mutt</MAILER>"), payload->getUnknownContent());
- }
-
- void testParse_Photo() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<vCard xmlns='vcard-temp'>"
- "<PHOTO>"
- "<TYPE>image/jpeg</TYPE>"
- "<BINVAL>"
- "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ej"
- "EyMzQ1Njc4OTA="
- "</BINVAL>"
- "</PHOTO>"
- "</vCard>"));
-
- VCard* payload = dynamic_cast<VCard*>(parser.getPayload().get());
- CPPUNIT_ASSERT_EQUAL(std::string("image/jpeg"), payload->getPhotoType());
- CPPUNIT_ASSERT_EQUAL(createByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"), payload->getPhoto());
- }
-
- void testParse_NewlinedPhoto() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<vCard xmlns='vcard-temp'>"
- "<PHOTO>"
- "<TYPE>image/jpeg</TYPE>"
- "<BINVAL>"
- "dTsETKSAskgu2/BqVO+ogcu3DJy4QATGJqpsa6znWwNGiLnVElVVB6PtS+mTiHUXsrOlKvRjtvzV\n"
- "VDknNaRF58Elmu5EC6VoCllBEEB/lFf0emYn2gkp0X1khNi75dl+rOj95Ar6XuwLh+ZoSStqwOWj\n"
- "pIpxmZmVw7E69qr0FY0oI3zcaxXwzHw7Lx9Qf4sH7ufQvIN88ga+hwp8MiXevh3Ac8pN00kgINlq\n"
- "9AY/bYJL418Y/6wWsJbgmrJ/N78wSMpC7VVszLBZVv8uFnupubyi8Ophd/1wIWWzPPwAbBhepWVb\n"
- "1oPiFEBT5MNKCMTPEi0npXtedVz0HQbbPNIVwmo="
- "</BINVAL>"
- "</PHOTO>"
- "</vCard>"));
-
- VCard* payload = dynamic_cast<VCard*>(parser.getPayload().get());
- CPPUNIT_ASSERT_EQUAL(std::string("image/jpeg"), payload->getPhotoType());
- CPPUNIT_ASSERT_EQUAL(createByteArray("\x75\x3B\x04\x4C\xA4\x80\xB2\x48\x2E\xDB\xF0\x6A\x54\xEF\xA8\x81\xCB\xB7\x0C\x9C\xB8\x40\x04\xC6\x26\xAA\x6C\x6B\xAC\xE7\x5B\x03\x46\x88\xB9\xD5\x12\x55\x55\x07\xA3\xED\x4B\xE9\x93\x88\x75\x17\xB2\xB3\xA5\x2A\xF4\x63\xB6\xFC\xD5\x54\x39\x27\x35\xA4\x45\xE7\xC1\x25\x9A\xEE\x44\x0B\xA5\x68\x0A\x59\x41\x10\x40\x7F\x94\x57\xF4\x7A\x66\x27\xDA\x09\x29\xD1\x7D\x64\x84\xD8\xBB\xE5\xD9\x7E\xAC\xE8\xFD\xE4\x0A\xFA\x5E\xEC\x0B\x87\xE6\x68\x49\x2B\x6A\xC0\xE5\xA3\xA4\x8A\x71\x99\x99\x95\xC3\xB1\x3A\xF6\xAA\xF4\x15\x8D\x28\x23\x7C\xDC\x6B\x15\xF0\xCC\x7C\x3B\x2F\x1F\x50\x7F\x8B\x07\xEE\xE7\xD0\xBC\x83\x7C\xF2\x06\xBE\x87\x0A\x7C\x32\x25\xDE\xBE\x1D\xC0\x73\xCA\x4D\xD3\x49\x20\x20\xD9\x6A\xF4\x06\x3F\x6D\x82\x4B\xE3\x5F\x18\xFF\xAC\x16\xB0\x96\xE0\x9A\xB2\x7F\x37\xBF\x30\x48\xCA\x42\xED\x55\x6C\xCC\xB0\x59\x56\xFF\x2E\x16\x7B\xA9\xB9\xBC\xA2\xF0\xEA\x61\x77\xFD\x70\x21\x65\xB3\x3C\xFC\x00\x6C\x18\x5E\xA5\x65\x5B\xD6\x83\xE2\x14\x40\x53\xE4\xC3\x4A\x08\xC4\xCF\x12\x2D\x27\xA5\x7B\x5E\x75\x5C\xF4\x1D\x06\xDB\x3C\xD2\x15\xC2\x6A", 257), payload->getPhoto());
- }
-
-
-
- void testParse_Nickname() {
- PayloadsParserTester parser;
-
- CPPUNIT_ASSERT(parser.parse(
- "<vCard xmlns='vcard-temp'>"
- "<NICKNAME>mynick</NICKNAME>"
- "</vCard>"));
-
- VCard* payload = dynamic_cast<VCard*>(parser.getPayload().get());
- CPPUNIT_ASSERT_EQUAL(std::string("mynick"), payload->getNickname());
- }
+ CPPUNIT_TEST_SUITE(VCardParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST(testParse_Photo);
+ CPPUNIT_TEST(testParse_NewlinedPhoto);
+ CPPUNIT_TEST(testParse_Nickname);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void testParse() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<vCard xmlns=\"vcard-temp\">"
+ "<VERSION>2.0</VERSION>"
+ "<FN>Alice In Wonderland</FN>"
+ "<N>"
+ "<FAMILY>Wonderland</FAMILY>"
+ "<GIVEN>Alice</GIVEN>"
+ "<MIDDLE>In</MIDDLE>"
+ "<PREFIX>Mrs</PREFIX>"
+ "<SUFFIX>PhD</SUFFIX>"
+ "</N>"
+ "<EMAIL>"
+ "<USERID>alice@wonderland.lit</USERID>"
+ "<HOME/>"
+ "<INTERNET/>"
+ "<PREF/>"
+ "</EMAIL>"
+ "<EMAIL>"
+ "<USERID>alice@teaparty.lit</USERID>"
+ "<WORK/>"
+ "<X400/>"
+ "</EMAIL>"
+ "<TEL>"
+ "<NUMBER>555-6273</NUMBER>"
+ "<HOME/>"
+ "<VOICE/>"
+ "</TEL>"
+ "<ADR>"
+ "<LOCALITY>Any Town</LOCALITY>"
+ "<STREET>Fake Street 123</STREET>"
+ "<PCODE>12345</PCODE>"
+ "<CTRY>USA</CTRY>"
+ "<HOME/>"
+ "</ADR>"
+ "<LABEL>"
+ "<LINE>Fake Street 123</LINE>"
+ "<LINE>12345 Any Town</LINE>"
+ "<LINE>USA</LINE>"
+ "<HOME/>"
+ "</LABEL>"
+ "<NICKNAME>DreamGirl</NICKNAME>"
+ "<BDAY>1865-05-04</BDAY>"
+ "<JID>alice@teaparty.lit</JID>"
+ "<JID>alice@wonderland.lit</JID>"
+ "<DESC>I once fell down a rabbit hole.</DESC>"
+ "<ORG>"
+ "<ORGNAME>Alice In Wonderland Inc.</ORGNAME>"
+ "</ORG>"
+ "<TITLE>Some Title</TITLE>"
+ "<ROLE>Main Character</ROLE>"
+ "<URL>http://wonderland.lit/~alice</URL>"
+ "<URL>http://teaparty.lit/~alice2</URL>"
+ "<MAILER>mutt</MAILER>"
+ "</vCard>"));
+
+ boost::shared_ptr<VCard> payload = boost::dynamic_pointer_cast<VCard>(parser.getPayload());
+ CPPUNIT_ASSERT_EQUAL(std::string("2.0"), payload->getVersion());
+ CPPUNIT_ASSERT_EQUAL(std::string("Alice In Wonderland"), payload->getFullName());
+ CPPUNIT_ASSERT_EQUAL(std::string("Alice"), payload->getGivenName());
+ CPPUNIT_ASSERT_EQUAL(std::string("In"), payload->getMiddleName());
+ CPPUNIT_ASSERT_EQUAL(std::string("Wonderland"), payload->getFamilyName());
+ CPPUNIT_ASSERT_EQUAL(std::string("Mrs"), payload->getPrefix());
+ CPPUNIT_ASSERT_EQUAL(std::string("PhD"), payload->getSuffix());
+ CPPUNIT_ASSERT_EQUAL(std::string("DreamGirl"), payload->getNickname());
+ CPPUNIT_ASSERT_EQUAL(boost::posix_time::ptime(boost::gregorian::date(1865, 5, 4)), payload->getBirthday());
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getEMailAddresses().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("alice@wonderland.lit"), payload->getEMailAddresses()[0].address);
+ CPPUNIT_ASSERT(payload->getEMailAddresses()[0].isHome);
+ CPPUNIT_ASSERT(payload->getEMailAddresses()[0].isInternet);
+ CPPUNIT_ASSERT(payload->getEMailAddresses()[0].isPreferred);
+ CPPUNIT_ASSERT(!payload->getEMailAddresses()[0].isWork);
+ CPPUNIT_ASSERT(!payload->getEMailAddresses()[0].isX400);
+ CPPUNIT_ASSERT_EQUAL(std::string("alice@teaparty.lit"), payload->getEMailAddresses()[1].address);
+ CPPUNIT_ASSERT(!payload->getEMailAddresses()[1].isHome);
+ CPPUNIT_ASSERT(!payload->getEMailAddresses()[1].isInternet);
+ CPPUNIT_ASSERT(!payload->getEMailAddresses()[1].isPreferred);
+ CPPUNIT_ASSERT(payload->getEMailAddresses()[1].isWork);
+ CPPUNIT_ASSERT(payload->getEMailAddresses()[1].isX400);
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(payload->getTelephones().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("555-6273"), payload->getTelephones()[0].number);
+ CPPUNIT_ASSERT(payload->getTelephones()[0].isHome);
+ CPPUNIT_ASSERT(payload->getTelephones()[0].isVoice);
+ CPPUNIT_ASSERT(!payload->getTelephones()[0].isPreferred);
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(payload->getAddresses().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("Any Town"), payload->getAddresses()[0].locality);
+ CPPUNIT_ASSERT_EQUAL(std::string("Fake Street 123"), payload->getAddresses()[0].street);
+ CPPUNIT_ASSERT_EQUAL(std::string("12345"), payload->getAddresses()[0].postalCode);
+ CPPUNIT_ASSERT_EQUAL(std::string("USA"), payload->getAddresses()[0].country);
+ CPPUNIT_ASSERT(payload->getAddresses()[0].isHome);
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(payload->getAddressLabels().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("Fake Street 123"), payload->getAddressLabels()[0].lines[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("12345 Any Town"), payload->getAddressLabels()[0].lines[1]);
+ CPPUNIT_ASSERT_EQUAL(std::string("USA"), payload->getAddressLabels()[0].lines[2]);
+ CPPUNIT_ASSERT(payload->getAddressLabels()[0].isHome);
+
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getJIDs().size()));
+ CPPUNIT_ASSERT_EQUAL(JID("alice@teaparty.lit"), payload->getJIDs()[0]);
+ CPPUNIT_ASSERT_EQUAL(JID("alice@wonderland.lit"), payload->getJIDs()[1]);
+
+ CPPUNIT_ASSERT_EQUAL(std::string("I once fell down a rabbit hole."), payload->getDescription());
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(payload->getOrganizations().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("Alice In Wonderland Inc."), payload->getOrganizations()[0].name);
+ CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(payload->getOrganizations()[0].units.size()));
+
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(payload->getTitles().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("Some Title"), payload->getTitles()[0]);
+ CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(payload->getRoles().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("Main Character"), payload->getRoles()[0]);
+ CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getURLs().size()));
+ CPPUNIT_ASSERT_EQUAL(std::string("http://wonderland.lit/~alice"), payload->getURLs()[0]);
+ CPPUNIT_ASSERT_EQUAL(std::string("http://teaparty.lit/~alice2"), payload->getURLs()[1]);
+
+ CPPUNIT_ASSERT_EQUAL(std::string("<MAILER xmlns=\"vcard-temp\">mutt</MAILER>"), payload->getUnknownContent());
+ }
+
+ void testParse_Photo() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<vCard xmlns='vcard-temp'>"
+ "<PHOTO>"
+ "<TYPE>image/jpeg</TYPE>"
+ "<BINVAL>"
+ "QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ej"
+ "EyMzQ1Njc4OTA="
+ "</BINVAL>"
+ "</PHOTO>"
+ "</vCard>"));
+
+ VCard* payload = dynamic_cast<VCard*>(parser.getPayload().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("image/jpeg"), payload->getPhotoType());
+ CPPUNIT_ASSERT_EQUAL(createByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"), payload->getPhoto());
+ }
+
+ void testParse_NewlinedPhoto() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<vCard xmlns='vcard-temp'>"
+ "<PHOTO>"
+ "<TYPE>image/jpeg</TYPE>"
+ "<BINVAL>"
+ "dTsETKSAskgu2/BqVO+ogcu3DJy4QATGJqpsa6znWwNGiLnVElVVB6PtS+mTiHUXsrOlKvRjtvzV\n"
+ "VDknNaRF58Elmu5EC6VoCllBEEB/lFf0emYn2gkp0X1khNi75dl+rOj95Ar6XuwLh+ZoSStqwOWj\n"
+ "pIpxmZmVw7E69qr0FY0oI3zcaxXwzHw7Lx9Qf4sH7ufQvIN88ga+hwp8MiXevh3Ac8pN00kgINlq\n"
+ "9AY/bYJL418Y/6wWsJbgmrJ/N78wSMpC7VVszLBZVv8uFnupubyi8Ophd/1wIWWzPPwAbBhepWVb\n"
+ "1oPiFEBT5MNKCMTPEi0npXtedVz0HQbbPNIVwmo="
+ "</BINVAL>"
+ "</PHOTO>"
+ "</vCard>"));
+
+ VCard* payload = dynamic_cast<VCard*>(parser.getPayload().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("image/jpeg"), payload->getPhotoType());
+ CPPUNIT_ASSERT_EQUAL(createByteArray("\x75\x3B\x04\x4C\xA4\x80\xB2\x48\x2E\xDB\xF0\x6A\x54\xEF\xA8\x81\xCB\xB7\x0C\x9C\xB8\x40\x04\xC6\x26\xAA\x6C\x6B\xAC\xE7\x5B\x03\x46\x88\xB9\xD5\x12\x55\x55\x07\xA3\xED\x4B\xE9\x93\x88\x75\x17\xB2\xB3\xA5\x2A\xF4\x63\xB6\xFC\xD5\x54\x39\x27\x35\xA4\x45\xE7\xC1\x25\x9A\xEE\x44\x0B\xA5\x68\x0A\x59\x41\x10\x40\x7F\x94\x57\xF4\x7A\x66\x27\xDA\x09\x29\xD1\x7D\x64\x84\xD8\xBB\xE5\xD9\x7E\xAC\xE8\xFD\xE4\x0A\xFA\x5E\xEC\x0B\x87\xE6\x68\x49\x2B\x6A\xC0\xE5\xA3\xA4\x8A\x71\x99\x99\x95\xC3\xB1\x3A\xF6\xAA\xF4\x15\x8D\x28\x23\x7C\xDC\x6B\x15\xF0\xCC\x7C\x3B\x2F\x1F\x50\x7F\x8B\x07\xEE\xE7\xD0\xBC\x83\x7C\xF2\x06\xBE\x87\x0A\x7C\x32\x25\xDE\xBE\x1D\xC0\x73\xCA\x4D\xD3\x49\x20\x20\xD9\x6A\xF4\x06\x3F\x6D\x82\x4B\xE3\x5F\x18\xFF\xAC\x16\xB0\x96\xE0\x9A\xB2\x7F\x37\xBF\x30\x48\xCA\x42\xED\x55\x6C\xCC\xB0\x59\x56\xFF\x2E\x16\x7B\xA9\xB9\xBC\xA2\xF0\xEA\x61\x77\xFD\x70\x21\x65\xB3\x3C\xFC\x00\x6C\x18\x5E\xA5\x65\x5B\xD6\x83\xE2\x14\x40\x53\xE4\xC3\x4A\x08\xC4\xCF\x12\x2D\x27\xA5\x7B\x5E\x75\x5C\xF4\x1D\x06\xDB\x3C\xD2\x15\xC2\x6A", 257), payload->getPhoto());
+ }
+
+
+
+ void testParse_Nickname() {
+ PayloadsParserTester parser;
+
+ CPPUNIT_ASSERT(parser.parse(
+ "<vCard xmlns='vcard-temp'>"
+ "<NICKNAME>mynick</NICKNAME>"
+ "</vCard>"));
+
+ VCard* payload = dynamic_cast<VCard*>(parser.getPayload().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("mynick"), payload->getNickname());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(VCardParserTest);
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/VCardUpdateParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/VCardUpdateParserTest.cpp
index 7cf975a..11e8ded 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/VCardUpdateParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/VCardUpdateParserTest.cpp
@@ -14,24 +14,24 @@ using namespace Swift;
class VCardUpdateParserTest : public CppUnit::TestFixture
{
- CPPUNIT_TEST_SUITE(VCardUpdateParserTest);
- CPPUNIT_TEST(testParse);
- CPPUNIT_TEST_SUITE_END();
+ CPPUNIT_TEST_SUITE(VCardUpdateParserTest);
+ CPPUNIT_TEST(testParse);
+ CPPUNIT_TEST_SUITE_END();
- public:
- VCardUpdateParserTest() {}
+ public:
+ VCardUpdateParserTest() {}
- void testParse() {
- PayloadsParserTester parser;
+ void testParse() {
+ PayloadsParserTester parser;
- CPPUNIT_ASSERT(parser.parse(
- "<x xmlns='vcard-temp:x:update'>"
- "<photo>sha1-hash-of-image</photo>"
- "</x>"));
+ CPPUNIT_ASSERT(parser.parse(
+ "<x xmlns='vcard-temp:x:update'>"
+ "<photo>sha1-hash-of-image</photo>"
+ "</x>"));
- VCardUpdate* payload = dynamic_cast<VCardUpdate*>(parser.getPayload().get());
- CPPUNIT_ASSERT_EQUAL(std::string("sha1-hash-of-image"), payload->getPhotoHash());
- }
+ VCardUpdate* payload = dynamic_cast<VCardUpdate*>(parser.getPayload().get());
+ CPPUNIT_ASSERT_EQUAL(std::string("sha1-hash-of-image"), payload->getPhotoHash());
+ }
};
CPPUNIT_TEST_SUITE_REGISTRATION(VCardUpdateParserTest);