本文整理汇总了C++中PayloadsParserTester::parse方法的典型用法代码示例。如果您正苦于以下问题:C++ PayloadsParserTester::parse方法的具体用法?C++ PayloadsParserTester::parse怎么用?C++ PayloadsParserTester::parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PayloadsParserTester
的用法示例。
在下文中一共展示了PayloadsParserTester::parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testParse
void testParse() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse(
"<query xmlns='jabber:iq:roster'>"
" <item jid='[email protected]' name='Foo @ Bar' subscription='from' ask='subscribe'>"
" <group>Group 1</group>"
" <group>Group 2</group>"
" </item>"
" <item jid='[email protected]' 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("[email protected]"), 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("[email protected]"), 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());
}
示例2: testParse_Results
void testParse_Results() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse(
"<query xmlns=\"jabber:iq:search\">"
"<item jid=\"[email protected]\">"
"<first>Juliet</first>"
"<last>Capulet</last>"
"<nick>JuliC</nick>"
"<email>[email protected]</email>"
"</item>"
"<item jid=\"[email protected]\">"
"<first>Tybalt</first>"
"<last>Capulet</last>"
"<nick>ty</nick>"
"<email>[email protected]</email>"
"</item>"
"</query>"
));
SearchPayload::ref payload = parser.getPayload<SearchPayload>();
CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getItems().size()));
CPPUNIT_ASSERT_EQUAL(JID("[email protected]"), 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("[email protected]"), payload->getItems()[0].email);
CPPUNIT_ASSERT_EQUAL(JID("[email protected]"), payload->getItems()[1].jid);
}
示例3: testParse
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]);
}
示例4:
/*
* 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='[email protected]/balcony'"
" to='[email protected]/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("[email protected]/balcony"), message->getFrom());
boost::shared_ptr<Thread> thread = message->getPayload<Thread>();
CPPUNIT_ASSERT(thread);
CPPUNIT_ASSERT_EQUAL(std::string("0e3141cd80894871a68e6fe6b1ec56fa"), thread->getText());
}
示例5: testParse
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\">[email protected]</first>"
"<last>[email protected]</last>"
"<before>decaf-badba-dbad1</before>"
"<after>09af3-cc343-b409f</after>"
"</set>"));
std::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("[email protected]"), *payload->getFirstID());
CPPUNIT_ASSERT(payload->getFirstIDIndex());
CPPUNIT_ASSERT_EQUAL(123, *payload->getFirstIDIndex());
CPPUNIT_ASSERT(payload->getLastID());
CPPUNIT_ASSERT_EQUAL(std::string("[email protected]"), *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());
}
示例6: testParse_Result
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>"
));
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());
}
示例7: testParse_Node
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>"));
DiscoInfo::ref payload = std::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());
}
示例8: testParse_Request
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>"
));
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]);
}
示例9: testParse_WithEmptyVersion
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());
}
示例10:
void testParseXEP0184Example4() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse("<received xmlns='urn:xmpp:receipts' id='richard2-4.1.247'/>"));
DeliveryReceipt::ref receipt = std::dynamic_pointer_cast<DeliveryReceipt>(parser.getPayload());
CPPUNIT_ASSERT_EQUAL(std::string("richard2-4.1.247"), receipt->getReceivedID());
}
示例11: testParse_Resource
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(std::string("someresource"), payload->getResource());
}
示例12: testParse_JID
void testParse_JID() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse("<bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><jid>[email protected]/someresource</jid></bind>"));
ResourceBind* payload = dynamic_cast<ResourceBind*>(parser.getPayload().get());
CPPUNIT_ASSERT_EQUAL(JID("[email protected]/someresource"), payload->getJID());
}
示例13: testParse_DND
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());
}
示例14: testParse_Invalid
void testParse_Invalid() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse("<priority>invalid</priority>"));
std::shared_ptr<Priority> payload = std::dynamic_pointer_cast<Priority>(parser.getPayload());
CPPUNIT_ASSERT_EQUAL(0, payload->getPriority());
}
示例15: testParse
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(std::string("foobarfum"), payload->getText());
}