本文整理汇总了C++中PayloadsParserTester::getPayload方法的典型用法代码示例。如果您正苦于以下问题:C++ PayloadsParserTester::getPayload方法的具体用法?C++ PayloadsParserTester::getPayload怎么用?C++ PayloadsParserTester::getPayload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PayloadsParserTester
的用法示例。
在下文中一共展示了PayloadsParserTester::getPayload方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
示例2: testParseEmpty
void testParseEmpty() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse("<x xmlns=\"http://jabber.org/protocol/muc#user\"/>"));
MUCUserPayload::ref payload = std::dynamic_pointer_cast<MUCUserPayload>(parser.getPayload());
CPPUNIT_ASSERT(payload);
CPPUNIT_ASSERT(payload->getItems().empty());
}
示例3: testParse_Nickname
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());
}
示例4: testParse
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>[email protected]</USERID>"
"<HOME/>"
"<INTERNET/>"
"<PREF/>"
"</EMAIL>"
"<EMAIL>"
"<USERID>[email protected]t</USERID>"
"<WORK/>"
"<X400/>"
"</EMAIL>"
"<NICKNAME>DreamGirl</NICKNAME>"
"<BDAY>1234</BDAY>"
"<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(std::string("<BDAY xmlns=\"vcard-temp\">1234</BDAY><MAILER xmlns=\"vcard-temp\">mutt</MAILER>"), payload->getUnknownContent());
CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(payload->getEMailAddresses().size()));
CPPUNIT_ASSERT_EQUAL(std::string("[email protected]"), 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("[email protected]"), 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);
}
示例5: testParse
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(std::string("sha1-hash-of-image"), payload->getPhotoHash());
}
示例6: testParseDestroy
void testParseDestroy() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse("<x xmlns=\"http://jabber.org/protocol/muc#user\"><destroy jid='[email protected]'><reason>bert</reason></destroy></x>"));
MUCUserPayload::ref payload = std::dynamic_pointer_cast<MUCUserPayload>(parser.getPayload());
CPPUNIT_ASSERT(payload);
MUCDestroyPayload::ref destroy = std::dynamic_pointer_cast<MUCDestroyPayload>(payload->getPayload());
CPPUNIT_ASSERT(destroy);
CPPUNIT_ASSERT_EQUAL(std::string("bert"), destroy->getReason());
CPPUNIT_ASSERT_EQUAL(JID("[email protected]"), destroy->getNewVenue());
}
示例7: testParse
void testParse() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse("<query xmlns=\"http://jabber.org/protocol/muc#admin\"><item affiliation=\"owner\" role=\"visitor\"><actor jid=\"[email protected]\"/><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("[email protected]"), item.actor.get());
CPPUNIT_ASSERT_EQUAL(std::string("malice"), item.reason.get());
}
示例8:
void testExample10() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse("<unblock xmlns='urn:xmpp:blocking'>"
"<item jid='[email protected]'/>"
"</unblock>"));
UnblockPayload* payload = dynamic_cast<UnblockPayload*>(parser.getPayload().get());
CPPUNIT_ASSERT(payload);
CPPUNIT_ASSERT(1 == payload->getItems().size());
CPPUNIT_ASSERT_EQUAL(JID("[email protected]"), payload->getItems()[0]);
}
示例9: testParse_URL
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);
}
示例10: testParseInvite
void testParseInvite() {
PayloadsParserTester parser;
CPPUNIT_ASSERT(parser.parse("<x xmlns=\"http://jabber.org/protocol/muc#user\"><invite from='[email protected]/desktop' to='[email protected]/xxx'> <reason>Hey Hecate, this is the place for all good witches!</reason> </invite> <password>cauldronburn</password></x>"));
MUCUserPayload::ref payload = std::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("[email protected]/desktop"), invite.from);
CPPUNIT_ASSERT_EQUAL(JID("[email protected]/xxx"), invite.to);
}
示例11: testParse
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());
}
示例12: testParse
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 = std::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());
}
示例13: testParse_FormInformation
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());
}
示例14: testParseWithPayload
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='[email protected]/balcony' stamp='2002-09-10T23:41:07Z'/>"
"<text xmlns=\"urn:ietf:params:xml:ns:xmpp-stanzas\">boo</text>"
"</error>"));
ErrorPayload::ref payload = std::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(std::dynamic_pointer_cast<Delay>(payload->getPayload()));
}
示例15: testParse_Photo
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(ByteArray("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"), payload->getPhoto());
}