summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Parser/PayloadParsers/UnitTest')
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXCreateParserTest.cpp8
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParser.cpp2
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParserTest.cpp2
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXJoinParserTest.cpp62
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXLeaveParserTest.cpp32
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXParticipantParserTest.cpp3
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXPayloadParserTest.cpp85
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXRegisterNickParserTest.cpp23
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXSetNickParserTest.cpp23
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXUpdateSubscriptionParserTest.cpp49
-rw-r--r--Swiften/Parser/PayloadParsers/UnitTest/MIXUserPreferenceParserTest.cpp6
11 files changed, 250 insertions, 45 deletions
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXCreateParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXCreateParserTest.cpp
index 85c79c6..f48bbc7 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MIXCreateParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXCreateParserTest.cpp
@@ -14,7 +14,7 @@ using namespace Swift;
TEST(MIXCreateParserTest, XEP0369_Example68) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<create xmlns=\"urn:xmpp:mix:1\"/>"
+ "<create xmlns=\"urn:xmpp:mix:0\"/>"
));
auto payload = parser.getPayload<MIXCreate>();
@@ -27,7 +27,7 @@ TEST(MIXCreateParserTest, XEP0369_Example68) {
TEST(MIXCreateParserTest, XEP0369_Example66) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<create channel=\"coven\" xmlns=\"urn:xmpp:mix:1\"/>"
+ "<create channel=\"coven\" xmlns=\"urn:xmpp:mix:0\"/>"
));
auto payload = parser.getPayload<MIXCreate>();
@@ -42,10 +42,10 @@ TEST(MIXCreateParserTest, XEP0369_Example66) {
TEST(MIXCreateParserTest, XEP0369_Example67) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<create channel=\"coven\" xmlns=\"urn:xmpp:mix:1\">"
+ "<create channel=\"coven\" xmlns=\"urn:xmpp:mix:0\">"
"<x xmlns=\"jabber:x:data\" type=\"result\">"
"<field var=\"FORM_TYPE\" type=\"hidden\">"
- "<value>urn:xmpp:mix:1</value>"
+ "<value>urn:xmpp:mix:0</value>"
"</field>"
"<field var=\"Owner\">"
"<value>hecate@shakespeare.lit</value>"
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParser.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParser.cpp
index fc2588a..80eb144 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParser.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParser.cpp
@@ -14,7 +14,7 @@ using namespace Swift;
TEST(MIXDestroyParserTest, XEP0369_Example70) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<destroy channel=\"coven\" xmlns=\"urn:xmpp:mix:1\"/>"
+ "<destroy channel=\"coven\" xmlns=\"urn:xmpp:mix:0\"/>"
));
auto payload = parser.getPayload<MIXDestroy>();
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParserTest.cpp
index 8e4dff2..5fa321e 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXDestroyParserTest.cpp
@@ -14,7 +14,7 @@ using namespace Swift;
TEST(MIXDestroyParserTest, XEP0369_Example70) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<destroy channel=\"coven\" xmlns=\"urn:xmpp:mix:1\"/>"
+ "<destroy channel=\"coven\" xmlns=\"urn:xmpp:mix:0\"/>"
));
auto payload = parser.getPayload<MIXDestroy>();
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXJoinParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXJoinParserTest.cpp
index 7a422f4..0ad4589 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MIXJoinParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXJoinParserTest.cpp
@@ -14,7 +14,7 @@ using namespace Swift;
TEST(MIXJoinParserTest, XEP0369_Example22) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<join xmlns=\"urn:xmpp:mix:1\" channel=\"coven@mix.shakespeare.example\">"
+ "<join xmlns=\"urn:xmpp:mix:0\" channel=\"coven@mix.shakespeare.example\">"
"<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:participants\"/>"
@@ -30,18 +30,17 @@ TEST(MIXJoinParserTest, XEP0369_Example22) {
ASSERT_FALSE(payload->getJID());
ASSERT_FALSE(payload->getForm());
- const std::vector<MIXSubscribe::ref> items = payload->getSubscriptions();
- ASSERT_EQ(static_cast<size_t>(4), items.size());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:messages"), items[0]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:presence"), items[1]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:participants"), items[2]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:config"), items[3]->getNode());
+ ASSERT_EQ(static_cast<size_t>(4), payload->getSubscriptions().size());
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:presence")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:participants")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:config")));
}
TEST(MIXJoinParserTest, XEP0369_Example23) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<join xmlns=\"urn:xmpp:mix:1\">"
+ "<join xmlns=\"urn:xmpp:mix:0\">"
"<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:participants\"/>"
@@ -56,18 +55,17 @@ TEST(MIXJoinParserTest, XEP0369_Example23) {
ASSERT_FALSE(payload->getJID());
ASSERT_FALSE(payload->getForm());
- const std::vector<MIXSubscribe::ref> items = payload->getSubscriptions();
- ASSERT_EQ(static_cast<size_t>(4), items.size());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:messages"), items[0]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:presence"), items[1]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:participants"), items[2]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:config"), items[3]->getNode());
+ ASSERT_EQ(static_cast<size_t>(4), payload->getSubscriptions().size());
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:presence")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:participants")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:config")));
}
TEST(MIXJoinParserTest, XEP0369_Example24) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<join xmlns=\"urn:xmpp:mix:1\" jid=\"123456#coven@mix.shakespeare.example\">"
+ "<join xmlns=\"urn:xmpp:mix:0\" jid=\"123456#coven@mix.shakespeare.example\">"
"<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:participants\"/>"
@@ -83,23 +81,22 @@ TEST(MIXJoinParserTest, XEP0369_Example24) {
ASSERT_EQ(JID("123456#coven@mix.shakespeare.example"), *payload->getJID());
ASSERT_FALSE(payload->getForm());
- const std::vector<MIXSubscribe::ref> items = payload->getSubscriptions();
- ASSERT_EQ(static_cast<size_t>(4), items.size());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:messages"), items[0]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:presence"), items[1]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:participants"), items[2]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:config"), items[3]->getNode());
+ ASSERT_EQ(static_cast<size_t>(4), payload->getSubscriptions().size());
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:presence")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:participants")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:config")));
}
TEST(MIXJoinParserTest, XEP0369_Example29) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<join xmlns=\"urn:xmpp:mix:1\">"
+ "<join xmlns=\"urn:xmpp:mix:0\">"
"<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"<x xmlns=\"jabber:x:data\" type=\"submit\">"
"<field var=\"FORM_TYPE\" type=\"hidden\">"
- "<value>urn:xmpp:mix:1</value>"
+ "<value>urn:xmpp:mix:0</value>"
"</field>"
"<field var=\"JID Visibility\">"
"<value>never</value>"
@@ -112,10 +109,10 @@ TEST(MIXJoinParserTest, XEP0369_Example29) {
ASSERT_FALSE(payload->getChannel());
ASSERT_FALSE(payload->getJID());
- const std::vector<MIXSubscribe::ref> items = payload->getSubscriptions();
- ASSERT_EQ(static_cast<size_t>(2), items.size());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:messages"), items[0]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:presence"), items[1]->getNode());
+
+ ASSERT_EQ(static_cast<size_t>(2), payload->getSubscriptions().size());
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:presence")));
ASSERT_TRUE(payload->getForm());
ASSERT_EQ(Form::Type::SubmitType, payload->getForm()->getType());
@@ -130,12 +127,12 @@ TEST(MIXJoinParserTest, XEP0369_Example29) {
TEST(MIXJoinParserTest, XEP0369_Example30) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<join xmlns=\"urn:xmpp:mix:1\" jid=\"hag66@shakespeare.example\">"
+ "<join xmlns=\"urn:xmpp:mix:0\" jid=\"hag66@shakespeare.example\">"
"<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
"<subscribe node=\"urn:xmpp:mix:nodes:presence\"/>"
"<x xmlns=\"jabber:x:data\" type=\"result\">"
"<field var=\"FORM_TYPE\" type=\"hidden\">"
- "<value>urn:xmpp:mix:1</value>"
+ "<value>urn:xmpp:mix:0</value>"
"</field>"
"<field var=\"JID Visibility\">"
"<value>never</value>"
@@ -156,10 +153,9 @@ TEST(MIXJoinParserTest, XEP0369_Example30) {
ASSERT_TRUE(payload->getJID());
ASSERT_EQ(JID("hag66@shakespeare.example"), *payload->getJID());
- const std::vector<MIXSubscribe::ref> items = payload->getSubscriptions();
- ASSERT_EQ(static_cast<size_t>(2), items.size());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:messages"), items[0]->getNode());
- ASSERT_EQ(std::string("urn:xmpp:mix:nodes:presence"), items[1]->getNode());
+ ASSERT_EQ(static_cast<size_t>(2), payload->getSubscriptions().size());
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:presence")));
ASSERT_TRUE(payload->getForm());
ASSERT_EQ(Form::Type::ResultType, payload->getForm()->getType());
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXLeaveParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXLeaveParserTest.cpp
new file mode 100644
index 0000000..0a2839e
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXLeaveParserTest.cpp
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <gtest/gtest.h>
+
+#include <Swiften/Elements/MIXLeave.h>
+#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
+
+using namespace Swift;
+
+TEST(MIXLeaveParserTest, XEP0369_Example33) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse("<leave xmlns=\"urn:xmpp:mix:0\" channel=\"coven@mix.shakespeare.example\"/>"));
+
+ auto payload = parser.getPayload<MIXLeave>();
+ ASSERT_TRUE(payload);
+
+ ASSERT_TRUE(payload->getChannel());
+ ASSERT_EQ(JID("coven@mix.shakespeare.example"), *payload->getChannel());
+}
+
+TEST(MIXLeaveParserTest, XEP0369_Example34) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse("<leave xmlns=\"urn:xmpp:mix:0\"/>"));
+
+ auto payload = parser.getPayload<MIXLeave>();
+ ASSERT_TRUE(payload);
+ ASSERT_FALSE(payload->getChannel());
+}
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXParticipantParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXParticipantParserTest.cpp
index 27c02e7..57d4b35 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MIXParticipantParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXParticipantParserTest.cpp
@@ -54,6 +54,3 @@ TEST(MIXParticipantParserTest, XEP0369_Example27_ParticipantEmpty) {
ASSERT_FALSE(payload->getNick());
ASSERT_FALSE(payload->getJID());
}
-
-
-
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXPayloadParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXPayloadParserTest.cpp
new file mode 100644
index 0000000..920aca7
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXPayloadParserTest.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <gtest/gtest.h>
+
+#include <Swiften/Elements/MIXPayload.h>
+#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
+
+using namespace Swift;
+
+TEST(MIXPayloadParserTest, WithNick) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<mix xmlns=\"urn:xmpp:mix:0\"> <nick>thirdwitch</nick> </mix>"
+ ));
+
+ auto payload = parser.getPayload<MIXPayload>();
+ ASSERT_TRUE(payload);
+
+ ASSERT_TRUE(payload->getNick());
+ std::string nick = *payload->getNick();
+ ASSERT_EQ("thirdwitch", nick);
+
+ ASSERT_FALSE(payload->getJID());
+ ASSERT_FALSE(payload->getSubmissionID());
+}
+
+TEST(MIXPayloadParserTest, WithJID) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<mix xmlns=\"urn:xmpp:mix:0\"> <jid>hecate@mix.shakespeare.example</jid> </mix>"
+ ));
+
+ auto payload = parser.getPayload<MIXPayload>();
+ ASSERT_TRUE(payload);
+
+ ASSERT_TRUE(payload->getJID());
+ JID jid = *payload->getJID();
+ ASSERT_EQ("hecate@mix.shakespeare.example", jid.toString());
+
+ ASSERT_FALSE(payload->getNick());
+ ASSERT_FALSE(payload->getSubmissionID());
+}
+
+TEST(MIXPayloadParserTest, WithAll) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<mix xmlns=\"urn:xmpp:mix:0\">"
+ "<nick>thirdwitch</nick>"
+ "<jid>hecate@mix.shakespeare.example</jid>"
+ "<submission-id>92vax143g</submission-id>"
+ "</mix>"
+ ));
+
+ auto payload = parser.getPayload<MIXPayload>();
+ ASSERT_TRUE(payload);
+
+ ASSERT_TRUE(payload->getNick());
+ std::string nick = *payload->getNick();
+ ASSERT_EQ("thirdwitch", nick);
+
+ ASSERT_TRUE(payload->getJID());
+ JID jid = *payload->getJID();
+ ASSERT_EQ("hecate@mix.shakespeare.example", jid.toString());
+
+ ASSERT_TRUE(payload->getSubmissionID());
+ std::string subID = *payload->getSubmissionID();
+ ASSERT_EQ("92vax143g", subID);
+}
+
+TEST(MIXPayloadParserTest, Empty) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<mix xmlns=\"urn:xmpp:mix:0\"/>"
+ ));
+
+ auto payload = parser.getPayload<MIXPayload>();
+ ASSERT_TRUE(payload);
+ ASSERT_FALSE(payload->getNick());
+ ASSERT_FALSE(payload->getJID());
+ ASSERT_FALSE(payload->getSubmissionID());
+}
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXRegisterNickParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXRegisterNickParserTest.cpp
new file mode 100644
index 0000000..d0539fd
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXRegisterNickParserTest.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <gtest/gtest.h>
+
+#include <Swiften/Elements/MIXRegisterNick.h>
+#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
+
+using namespace Swift;
+
+TEST(MIXRegisterNickParserTest, WithNick) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<register xmlns=\"urn:xmpp:mix:0\"> <nick>thirdwitch</nick> </register>"
+ ));
+
+ auto payload = parser.getPayload<MIXRegisterNick>();
+ ASSERT_TRUE(payload);
+ ASSERT_EQ("thirdwitch", payload->getNick());
+}
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXSetNickParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXSetNickParserTest.cpp
new file mode 100644
index 0000000..84f8a5e
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXSetNickParserTest.cpp
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <gtest/gtest.h>
+
+#include <Swiften/Elements/MIXSetNick.h>
+#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
+
+using namespace Swift;
+
+TEST(MIXSetNickParserTest, WithNick) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<setnick xmlns=\"urn:xmpp:mix:0\"> <nick>thirdwitch</nick> </setnick>"
+ ));
+
+ auto payload = parser.getPayload<MIXSetNick>();
+ ASSERT_TRUE(payload);
+ ASSERT_EQ("thirdwitch", payload->getNick());
+}
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXUpdateSubscriptionParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXUpdateSubscriptionParserTest.cpp
new file mode 100644
index 0000000..985a34b
--- /dev/null
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXUpdateSubscriptionParserTest.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2017 Tarun Gupta
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+#include <gtest/gtest.h>
+
+#include <Swiften/Elements/MIXUpdateSubscription.h>
+#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>
+
+using namespace Swift;
+
+TEST(MIXUpdateSubscriptionParserTest, XEP0369_Example28) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<update-subscription xmlns=\"urn:xmpp:mix:0\">"
+ "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
+ "</update-subscription>"
+ ));
+
+ auto payload = parser.getPayload<MIXUpdateSubscription>();
+ ASSERT_TRUE(payload);
+
+ ASSERT_FALSE(payload->getJID());
+
+ auto items = payload->getSubscriptions();
+ ASSERT_EQ(static_cast<size_t>(1), items.size());
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+}
+
+TEST(MIXUpdateSubscriptionParserTest, XEP0369_Example28_WithJID) {
+ PayloadsParserTester parser;
+ ASSERT_TRUE(parser.parse(
+ "<update-subscription xmlns=\"urn:xmpp:mix:0\" jid=\"hag66@shakespeare.example\">"
+ "<subscribe node=\"urn:xmpp:mix:nodes:messages\"/>"
+ "</update-subscription>"
+ ));
+
+ auto payload = parser.getPayload<MIXUpdateSubscription>();
+ ASSERT_TRUE(payload);
+
+ ASSERT_TRUE(payload->getJID());
+ ASSERT_EQ(JID("hag66@shakespeare.example"), *payload->getJID());
+
+ auto items = payload->getSubscriptions();
+ ASSERT_EQ(static_cast<size_t>(1), items.size());
+ ASSERT_TRUE(payload->hasSubscription(std::string("urn:xmpp:mix:nodes:messages")));
+}
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/MIXUserPreferenceParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/MIXUserPreferenceParserTest.cpp
index 3d048a5..7115f2a 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/MIXUserPreferenceParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/MIXUserPreferenceParserTest.cpp
@@ -14,7 +14,7 @@ using namespace Swift;
TEST(MIXUserPreferenceParserTest, XEP0369_Example31) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<user-preference xmlns='urn:xmpp:mix:1'/>"
+ "<user-preference xmlns='urn:xmpp:mix:0'/>"
));
auto payload = parser.getPayload<MIXUserPreference>();
@@ -26,10 +26,10 @@ TEST(MIXUserPreferenceParserTest, XEP0369_Example31) {
TEST(MIXUserPreferenceParserTest, XEP0369_Example32) {
PayloadsParserTester parser;
ASSERT_TRUE(parser.parse(
- "<user-preference xmlns='urn:xmpp:mix:1'>"
+ "<user-preference xmlns='urn:xmpp:mix:0'>"
"<x xmlns='jabber:x:data' type='result'>"
"<field var='FORM_TYPE' type='hidden'>"
- "<value>urn:xmpp:mix:1</value>"
+ "<value>urn:xmpp:mix:0</value>"
"</field>"
"<field var='JID Visibility'>"
"<value>never</value>"