diff options
Diffstat (limited to 'Swiften/Parser/PayloadParsers/UnitTest')
19 files changed, 0 insertions, 778 deletions
diff --git a/Swiften b/Swiften new file mode 160000 +Subproject 8213ba16d0043d2461f4b031c881d61dda5a38c diff --git a/Swiften/Parser/PayloadParsers/UnitTest/BodyParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/BodyParserTest.cpp deleted file mode 100644 index 2fc6180..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/BodyParserTest.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Parser/PayloadParsers/BodyParser.h" -#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h" - -using namespace Swift; - -class BodyParserTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(BodyParserTest); - CPPUNIT_TEST(testParse); - CPPUNIT_TEST_SUITE_END(); - - public: - BodyParserTest() {} - - void testParse() { - PayloadsParserTester parser; - - CPPUNIT_ASSERT(parser.parse("<body>foo<baz>bar</baz>fum</body>")); - - Body* payload = dynamic_cast<Body*>(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(String("foobarfum"), payload->getText()); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(BodyParserTest); diff --git a/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp deleted file mode 100644 index 49b706e..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/DiscoInfoParserTest.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Parser/PayloadParsers/DiscoInfoParser.h" -#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h" - -using namespace Swift; - -class DiscoInfoParserTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(DiscoInfoParserTest); - CPPUNIT_TEST(testParse); - CPPUNIT_TEST_SUITE_END(); - - public: - DiscoInfoParserTest() {} - - 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>")); - - DiscoInfo* payload = dynamic_cast<DiscoInfo*>(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getIdentities().size())); - CPPUNIT_ASSERT_EQUAL(String("Swift"), payload->getIdentities()[0].getName()); - CPPUNIT_ASSERT_EQUAL(String("pc"), payload->getIdentities()[0].getType()); - CPPUNIT_ASSERT_EQUAL(String("client"), payload->getIdentities()[0].getCategory()); - CPPUNIT_ASSERT_EQUAL(String("en"), payload->getIdentities()[0].getLanguage()); - CPPUNIT_ASSERT_EQUAL(String("Vlug"), payload->getIdentities()[1].getName()); - CPPUNIT_ASSERT_EQUAL(String("pc"), payload->getIdentities()[1].getType()); - CPPUNIT_ASSERT_EQUAL(String("client"), payload->getIdentities()[1].getCategory()); - CPPUNIT_ASSERT_EQUAL(String("nl"), payload->getIdentities()[1].getLanguage()); - CPPUNIT_ASSERT_EQUAL(3, static_cast<int>(payload->getFeatures().size())); - CPPUNIT_ASSERT_EQUAL(String("foo-feature"), payload->getFeatures()[0]); - CPPUNIT_ASSERT_EQUAL(String("bar-feature"), payload->getFeatures()[1]); - CPPUNIT_ASSERT_EQUAL(String("baz-feature"), payload->getFeatures()[2]); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(DiscoInfoParserTest); diff --git a/Swiften/Parser/PayloadParsers/UnitTest/ErrorParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/ErrorParserTest.cpp deleted file mode 100644 index dcd3172..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/ErrorParserTest.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Parser/PayloadParsers/ErrorParser.h" -#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h" - -using namespace Swift; - -class ErrorParserTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(ErrorParserTest); - CPPUNIT_TEST(testParse); - CPPUNIT_TEST_SUITE_END(); - - public: - ErrorParserTest() {} - - 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* payload = dynamic_cast<ErrorPayload*>(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(ErrorPayload::BadRequest, payload->getCondition()); - CPPUNIT_ASSERT_EQUAL(ErrorPayload::Modify, payload->getType()); - CPPUNIT_ASSERT_EQUAL(String("boo"), payload->getText()); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(ErrorParserTest); diff --git a/Swiften/Parser/PayloadParsers/UnitTest/PayloadParserTester.h b/Swiften/Parser/PayloadParsers/UnitTest/PayloadParserTester.h deleted file mode 100644 index 20a5feb..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/PayloadParserTester.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -#include "Swiften/Parser/UnitTest/ParserTester.h" -#include "Swiften/Parser/PayloadParser.h" - -namespace Swift { - typedef ParserTester<PayloadParser> PayloadParserTester; -} diff --git a/Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h b/Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h deleted file mode 100644 index ac167cf..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once - -#include <cppunit/extensions/HelperMacros.h> - -#include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h" -#include "Swiften/Parser/XMLParser.h" -#include "Swiften/Parser/XMLParserClient.h" -#include "Swiften/Parser/PlatformXMLParserFactory.h" - -namespace Swift { - class PayloadsParserTester : public XMLParserClient { - public: - PayloadsParserTester() : level(0) { - xmlParser = PlatformXMLParserFactory().createXMLParser(this); - } - - ~PayloadsParserTester() { - delete xmlParser; - } - - bool parse(const String& data) { - return xmlParser->parse(data); - } - - virtual void handleStartElement(const String& element, const String& ns, const AttributeMap& attributes) { - if (level == 0) { - CPPUNIT_ASSERT(!payloadParser.get()); - PayloadParserFactory* payloadParserFactory = factories.getPayloadParserFactory(element, ns, attributes); - CPPUNIT_ASSERT(payloadParserFactory); - payloadParser.reset(payloadParserFactory->createPayloadParser()); - } - payloadParser->handleStartElement(element, ns, attributes); - level++; - } - - virtual void handleEndElement(const String& element, const String& ns) { - level--; - payloadParser->handleEndElement(element, ns); - } - - virtual void handleCharacterData(const String& data) { - payloadParser->handleCharacterData(data); - } - - boost::shared_ptr<Payload> getPayload() const { - return payloadParser->getPayload(); - } - - private: - XMLParser* xmlParser; - FullPayloadParserFactoryCollection factories; - std::auto_ptr<PayloadParser> payloadParser; - int level; - }; -} diff --git a/Swiften/Parser/PayloadParsers/UnitTest/PriorityParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/PriorityParserTest.cpp deleted file mode 100644 index acea437..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/PriorityParserTest.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Parser/PayloadParsers/PriorityParser.h" -#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h" - -using namespace Swift; - -class PriorityParserTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(PriorityParserTest); - CPPUNIT_TEST(testParse); - CPPUNIT_TEST_SUITE_END(); - - public: - PriorityParserTest() {} - - void testParse() { - PayloadsParserTester parser; - - CPPUNIT_ASSERT(parser.parse("<priority>-120</priority>")); - - Priority* payload = dynamic_cast<Priority*>(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(-120, payload->getPriority()); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(PriorityParserTest); diff --git a/Swiften/Parser/PayloadParsers/UnitTest/PrivateStorageParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/PrivateStorageParserTest.cpp deleted file mode 100644 index e820083..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/PrivateStorageParserTest.cpp +++ /dev/null @@ -1,89 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Elements/Storage.h" -#include "Swiften/Parser/PayloadParsers/PrivateStorageParser.h" -#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h" -#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadParserTester.h" - -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(String("Alice"), storage->getConferences()[0].nick); - CPPUNIT_ASSERT_EQUAL(JID("swift@rooms.swift.im"), storage->getConferences()[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(String("Rabbit"), storage->getConferences()[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 deleted file mode 100644 index 81cc207..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/RawXMLPayloadParserTest.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Parser/PayloadParsers/RawXMLPayloadParser.h" -#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadParserTester.h" - -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); - - 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/ResourceBindParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/ResourceBindParserTest.cpp deleted file mode 100644 index b1b61ef..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/ResourceBindParserTest.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Parser/PayloadParsers/ResourceBindParser.h" -#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h" - -using namespace Swift; - -class ResourceBindParserTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(ResourceBindParserTest); - CPPUNIT_TEST(testParse_JID); - CPPUNIT_TEST(testParse_Resource); - CPPUNIT_TEST_SUITE_END(); - - public: - ResourceBindParserTest() {} - - 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>")); - - ResourceBind* payload = dynamic_cast<ResourceBind*>(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(JID("somenode@example.com/someresource"), payload->getJID()); - } - - void testParse_Resource() { - PayloadsParserTester parser; - - 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(String("someresource"), payload->getResource()); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(ResourceBindParserTest); diff --git a/Swiften/Parser/PayloadParsers/UnitTest/RosterParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/RosterParserTest.cpp deleted file mode 100644 index 4c8db07..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/RosterParserTest.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Parser/PayloadParsers/RosterParser.h" -#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h" - -using namespace Swift; - -class RosterParserTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(RosterParserTest); - CPPUNIT_TEST(testParse); - CPPUNIT_TEST_SUITE_END(); - - public: - RosterParserTest() {} - - void testParse() { - PayloadsParserTester parser; - 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()); - 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(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(String("Group 1"), items[0].getGroups()[0]); - CPPUNIT_ASSERT_EQUAL(String("Group 2"), items[0].getGroups()[1]); - - CPPUNIT_ASSERT_EQUAL(JID("baz@blo.com"), items[1].getJID()); - CPPUNIT_ASSERT_EQUAL(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()); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(RosterParserTest); diff --git a/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelParserTest.cpp deleted file mode 100644 index 8272bee..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelParserTest.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Parser/PayloadParsers/SecurityLabelParser.h" -#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h" - -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(String("SECRET"), payload->getDisplayMarking()); - CPPUNIT_ASSERT_EQUAL(String("black"), payload->getForegroundColor()); - CPPUNIT_ASSERT_EQUAL(String("red"), payload->getBackgroundColor()); - CPPUNIT_ASSERT_EQUAL(String("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>"), payload->getLabel()); - CPPUNIT_ASSERT_EQUAL(String("<icismlabel classification=\"S\" disseminationControls=\"FOUO\" ownerProducer=\"USA\" xmlns=\"http://example.gov/IC-ISM/0\"/>"), payload->getEquivalentLabels()[0]); - CPPUNIT_ASSERT_EQUAL(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 deleted file mode 100644 index b2378b6..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/SecurityLabelsCatalogParserTest.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Parser/PayloadParsers/SecurityLabelsCatalogParser.h" -#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h" - -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:0\">" - "<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>" - "<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>" - "</catalog>")); - - SecurityLabelsCatalog* payload = dynamic_cast<SecurityLabelsCatalog*>(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(String("Default"), payload->getName()); - CPPUNIT_ASSERT_EQUAL(String("an example set of labels"), payload->getDescription()); - CPPUNIT_ASSERT_EQUAL(JID("example.com"), payload->getTo()); - CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getLabels().size())); - CPPUNIT_ASSERT_EQUAL(String("SECRET"), payload->getLabels()[0].getDisplayMarking()); - CPPUNIT_ASSERT_EQUAL(String("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQYCAQQGASk=</esssecuritylabel>"), payload->getLabels()[0].getLabel()); - CPPUNIT_ASSERT_EQUAL(String("CONFIDENTIAL"), payload->getLabels()[1].getDisplayMarking()); - CPPUNIT_ASSERT_EQUAL(String("<esssecuritylabel xmlns=\"urn:xmpp:sec-label:ess:0\">MQMGASk=</esssecuritylabel>"), payload->getLabels()[1].getLabel()); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(SecurityLabelsCatalogParserTest); diff --git a/Swiften/Parser/PayloadParsers/UnitTest/SoftwareVersionParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/SoftwareVersionParserTest.cpp deleted file mode 100644 index eeaa8d9..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/SoftwareVersionParserTest.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Parser/PayloadParsers/SoftwareVersionParser.h" -#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h" - -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(String("myclient"), payload->getName()); - CPPUNIT_ASSERT_EQUAL(String("1.0"), payload->getVersion()); - CPPUNIT_ASSERT_EQUAL(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 deleted file mode 100644 index 71d5b0b..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/StatusParserTest.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Parser/PayloadParsers/StatusParser.h" -#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h" - -using namespace Swift; - -class StatusParserTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(StatusParserTest); - CPPUNIT_TEST(testParse); - CPPUNIT_TEST_SUITE_END(); - - public: - StatusParserTest() {} - - void testParse() { - PayloadsParserTester parser; - - CPPUNIT_ASSERT(parser.parse("<status>foo<baz>bar</baz>fum</status>")); - - Status* payload = dynamic_cast<Status*>(parser.getPayload().get()); - CPPUNIT_ASSERT_EQUAL(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 deleted file mode 100644 index d45e98b..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/StatusShowParserTest.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Parser/PayloadParsers/StatusShowParser.h" -#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h" - -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_REGISTRATION(StatusShowParserTest); diff --git a/Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp deleted file mode 100644 index 3fbf27a..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/StorageParserTest.cpp +++ /dev/null @@ -1,64 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Parser/PayloadParsers/StorageParser.h" -#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h" - -using namespace Swift; - -class StorageParserTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(StorageParserTest); - CPPUNIT_TEST(testParse_Conference); - CPPUNIT_TEST(testParse_MultipleConferences); - CPPUNIT_TEST_SUITE_END(); - - public: - StorageParserTest() {} - - void testParse_Conference() { - 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::Conference> conferences = payload->getConferences(); - CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(conferences.size())); - CPPUNIT_ASSERT_EQUAL(String("Council of Oberon"), conferences[0].name); - CPPUNIT_ASSERT_EQUAL(JID("council@conference.underhill.org"), conferences[0].jid); - CPPUNIT_ASSERT(conferences[0].autoJoin); - CPPUNIT_ASSERT_EQUAL(String("Puck"), conferences[0].nick); - CPPUNIT_ASSERT_EQUAL(String("MyPass"), conferences[0].password); - } - - void testParse_MultipleConferences() { - PayloadsParserTester parser; - - CPPUNIT_ASSERT(parser.parse( - "<storage xmlns='storage:bookmarks'>" - "<conference " - "name='Council of Oberon' " - "jid='council@conference.underhill.org' />" - "<conference " - "name='Tea party' " - "jid='teaparty@wonderland.lit' />" - "</storage>")); - - Storage* payload = dynamic_cast<Storage*>(parser.getPayload().get()); - std::vector<Storage::Conference> conferences = payload->getConferences(); - CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(conferences.size())); - CPPUNIT_ASSERT_EQUAL(String("Council of Oberon"), conferences[0].name); - CPPUNIT_ASSERT_EQUAL(JID("council@conference.underhill.org"), conferences[0].jid); - CPPUNIT_ASSERT_EQUAL(String("Tea party"), conferences[1].name); - CPPUNIT_ASSERT_EQUAL(JID("teaparty@wonderland.lit"), conferences[1].jid); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(StorageParserTest); diff --git a/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp deleted file mode 100644 index d1ddba3..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/VCardParserTest.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Parser/PayloadParsers/VCardParser.h" -#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h" - -using namespace Swift; - -class VCardParserTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(VCardParserTest); - CPPUNIT_TEST(testParse_Photo); - CPPUNIT_TEST(testParse_Nickname); - CPPUNIT_TEST_SUITE_END(); - - public: - VCardParserTest() {} - - 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(String("image/jpeg"), payload->getPhotoType()); - CPPUNIT_ASSERT_EQUAL(ByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"), 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(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 deleted file mode 100644 index ef6c78e..0000000 --- a/Swiften/Parser/PayloadParsers/UnitTest/VCardUpdateParserTest.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> - -#include "Swiften/Parser/PayloadParsers/VCardUpdateParser.h" -#include "Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h" - -using namespace Swift; - -class VCardUpdateParserTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE(VCardUpdateParserTest); - CPPUNIT_TEST(testParse); - CPPUNIT_TEST_SUITE_END(); - - public: - VCardUpdateParserTest() {} - - void testParse() { - PayloadsParserTester parser; - - 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(String("sha1-hash-of-image"), payload->getPhotoHash()); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(VCardUpdateParserTest); |