diff options
author | Tobias Markmann <tm@ayena.de> | 2016-05-11 15:38:57 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2016-06-14 20:28:20 (GMT) |
commit | 9b1c1ec6922047fa30c19c0744619dc458a12b78 (patch) | |
tree | 230a96de2a104324b8ab179834a7b9914c0443f9 /Swiften/Parser/PayloadParsers/UnitTest | |
parent | 0d5dcec01a396ab64c559a5b0cd04eb38f2f1954 (diff) | |
download | swift-9b1c1ec6922047fa30c19c0744619dc458a12b78.zip swift-9b1c1ec6922047fa30c19c0744619dc458a12b78.tar.bz2 |
Fix handling of notify attribute in PubSub retract elements
Test-Information:
Added serializer and parser unit tests. All tests pass on
Mac OS X 10.11.4.
Change-Id: I8550c76ba182a67613d55634c72c0f2979f8b80a
Diffstat (limited to 'Swiften/Parser/PayloadParsers/UnitTest')
-rw-r--r-- | Swiften/Parser/PayloadParsers/UnitTest/PubSubRetractParserTest.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/PubSubRetractParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/PubSubRetractParserTest.cpp new file mode 100644 index 0000000..91bc123 --- /dev/null +++ b/Swiften/Parser/PayloadParsers/UnitTest/PubSubRetractParserTest.cpp @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2016 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/extensions/TestFactoryRegistry.h> + +#include <Swiften/Elements/ContainerPayload.h> +#include <Swiften/Parser/PayloadParsers/PubSubRetractParser.h> +#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h> + +using namespace Swift; + +class PubSubRetractParserTest : public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE(PubSubRetractParserTest); + CPPUNIT_TEST(testParse); + CPPUNIT_TEST(testParseNotify); + CPPUNIT_TEST_SUITE_END(); + + public: + void testParse() { + PayloadsParserTester parser; + + CPPUNIT_ASSERT(parser.parse("<pubsub xmlns='http://jabber.org/protocol/pubsub'>" + "<retract node='princely_musings' xmlns='http://jabber.org/protocol/pubsub'>" + "<item id='ae890ac52d0df67ed7cfdf51b644e901' xmlns='http://jabber.org/protocol/pubsub'/>" + "</retract>" + "</pubsub>")); + + auto payload = parser.getPayload<ContainerPayload<PubSubPayload>>(); + std::shared_ptr<PubSubRetract> retract = std::dynamic_pointer_cast<PubSubRetract>(payload->getPayload()); + CPPUNIT_ASSERT(retract); + CPPUNIT_ASSERT_EQUAL(std::string("princely_musings"), retract->getNode()); + CPPUNIT_ASSERT_EQUAL(false, retract->isNotify().is_initialized()); + } + + void testParseNotify() { + { + PayloadsParserTester parser; + + CPPUNIT_ASSERT(parser.parse("<pubsub xmlns='http://jabber.org/protocol/pubsub'>" + "<retract node='princely_musings' notify='true' xmlns='http://jabber.org/protocol/pubsub'>" + "<item id='ae890ac52d0df67ed7cfdf51b644e901' xmlns='http://jabber.org/protocol/pubsub'/>" + "</retract>" + "</pubsub>")); + + auto payload = parser.getPayload<ContainerPayload<PubSubPayload>>(); + std::shared_ptr<PubSubRetract> retract = std::dynamic_pointer_cast<PubSubRetract>(payload->getPayload()); + CPPUNIT_ASSERT(retract); + CPPUNIT_ASSERT_EQUAL(std::string("princely_musings"), retract->getNode()); + CPPUNIT_ASSERT_EQUAL(true, retract->isNotify().get()); + } + + { + PayloadsParserTester parser; + CPPUNIT_ASSERT(parser.parse("<pubsub xmlns='http://jabber.org/protocol/pubsub'>" + "<retract node='princely_musings' notify='0' xmlns='http://jabber.org/protocol/pubsub'>" + "<item id='ae890ac52d0df67ed7cfdf51b644e901' xmlns='http://jabber.org/protocol/pubsub'/>" + "</retract>" + "</pubsub>")); + + auto payload = parser.getPayload<ContainerPayload<PubSubPayload>>(); + auto retract = std::dynamic_pointer_cast<PubSubRetract>(payload->getPayload()); + CPPUNIT_ASSERT(retract); + CPPUNIT_ASSERT_EQUAL(std::string("princely_musings"), retract->getNode()); + CPPUNIT_ASSERT_EQUAL(false, retract->isNotify().get()); + } + } +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(PubSubRetractParserTest); |