本文整理汇总了C++中StanzaExtensionFactory::addExtensions方法的典型用法代码示例。如果您正苦于以下问题:C++ StanzaExtensionFactory::addExtensions方法的具体用法?C++ StanzaExtensionFactory::addExtensions怎么用?C++ StanzaExtensionFactory::addExtensions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StanzaExtensionFactory
的用法示例。
在下文中一共展示了StanzaExtensionFactory::addExtensions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int /*argc*/, char** /*argv*/ )
{
int fail = 0;
std::string name;
Tag *t;
// -------
{
name = "empty vcard request";
VCard v;
t = v.tag();
if( !t || t->xml() != "<vCard xmlns='" + XMLNS_VCARD_TEMP + "' version='3.0'/>" )
{
++fail;
printf( "test '%s' failed\n", name.c_str() );
}
delete t;
t = 0;
}
// -------
name = "VCard/SEFactory test";
StanzaExtensionFactory sef;
sef.registerExtension( new VCard() );
Tag* f = new Tag( "iq" );
new Tag( f, "vCard", "xmlns", XMLNS_VCARD_TEMP );
IQ iq( IQ::Set, JID(), "" );
sef.addExtensions( iq, f );
const VCard* se = iq.findExtension<VCard>( ExtVCard );
if( se == 0 )
{
++fail;
printf( "test '%s' failed\n", name.c_str() );
}
delete f;
printf( "VCard: " );
if( fail == 0 )
{
printf( "OK\n" );
return 0;
}
else
{
printf( "%d test(s) failed\n", fail );
return 1;
}
}
示例2: main
int main( int /*argc*/, char** /*argv*/ )
{
int fail = 0;
std::string name;
// -------
{
name = "empty tag() test";
FlexibleOffline::Offline foo;
if( false )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
}
StanzaExtensionFactory sef;
sef.registerExtension( new FlexibleOffline::Offline() );
// -------
{
name = "FlexibleOffline::Offline/SEFactory test";
Tag* f = new Tag( "iq" );
new Tag( f, "offline", "xmlns", XMLNS_OFFLINE );
IQ iq( IQ::Set, JID(), "" );
sef.addExtensions( iq, f );
const FlexibleOffline::Offline* se = iq.findExtension<FlexibleOffline::Offline>( ExtFlexOffline );
if( se == 0 )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete f;
}
printf( "FlexibleOffline::Offline: " );
if( fail == 0 )
{
printf( "OK\n" );
return 0;
}
else
{
fprintf( stderr, "%d test(s) failed\n", fail );
return 1;
}
}
示例3: main
int main()
{
std::string name;
int fail = 0;
// -------
{
}
// -------
{
name = "PubSub::Manager::PubSub/SEFactory test";
StanzaExtensionFactory sef;
sef.registerExtension( new PubSub::Manager::PubSub() );
Tag* f = new Tag( "iq" );
new Tag( f, "pubsub", "xmlns", XMLNS_PUBSUB );
IQ iq( IQ::Get, JID(), "" );
sef.addExtensions( iq, f );
const PubSub::Manager::PubSub* se = iq.findExtension<PubSub::Manager::PubSub>( ExtPubSub );
if( se == 0 )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete f;
}
printf( "PubSub::Manager::PubSub: " );
if( fail )
fprintf( stderr, "%d test(s) failed\n", fail );
else
printf( "OK\n" );
}
示例4: main
//.........这里部分代码省略.........
delete t;
}
// -------
{
name = "request affiliation list: 'member'";
MUCRoom::MUCAdmin ma( RequestMemberList );
t = ma.tag();
if( !t || t->xml() != "<query xmlns='" + XMLNS_MUC_ADMIN + "'>"
"<item affiliation='member'/>"
"</query>" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete t;
}
// -------
{
name = "store affiliation list: 'member'";
MUCListItemList list;
list.push_back( MUCListItem( JID( "[email protected]" ) ) );
list.push_back( MUCListItem( JID( "[email protected]" ) ) );
MUCRoom::MUCAdmin ma( StoreMemberList, list );
t = ma.tag();
if( !t || t->xml() != "<query xmlns='" + XMLNS_MUC_ADMIN + "'>"
"<item jid='[email protected]' affiliation='member'/>"
"<item jid='[email protected]' affiliation='member'/>"
"</query>" )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
delete t;
}
// -------
{
name = "store role list: 'participant'";
MUCListItemList list;
list.push_back( MUCListItem( JID( "[email protected]" ) ) );
list.push_back( MUCListItem( JID( "[email protected]" ) ) );
MUCRoom::MUCAdmin ma( StoreVoiceList, list );
t = ma.tag();
if( !t || t->xml() != "<query xmlns='" + XMLNS_MUC_ADMIN + "'>"
"<item jid='[email protected]' role='participant'/>"
"<item jid='[email protected]' role='participant'/>"
"</query>" )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
delete t;
}
// -------
{
name = "parse member list from Tag";
Tag q( "query" );
q.setXmlns( XMLNS_MUC_ADMIN );
Tag* i = new Tag( &q, "item", "jid", "[email protected]" );
i->addAttribute( "affiliation", "member" );
i = new Tag( &q, "item", "jid", "[email protected]" );
i->addAttribute( "affiliation", "member" );
MUCRoom::MUCAdmin ma( &q );
Tag* t = ma.tag();
if( !t || q != *t )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
delete t;
}
// -------
name = "MUCRoom::MUCAdmin/SEFactory test";
StanzaExtensionFactory sef;
sef.registerExtension( new MUCRoom::MUCAdmin() );
Tag* f = new Tag( "iq" );
new Tag( f, "query", "xmlns", XMLNS_MUC_ADMIN );
IQ iq( IQ::Set, JID(), "" );
sef.addExtensions( iq, f );
const MUCRoom::MUCAdmin* se = iq.findExtension<MUCRoom::MUCAdmin>( ExtMUCAdmin );
if( se == 0 )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete f;
printf( "MUCRoom::MUCAdmin: " );
if( !fail )
printf( "OK\n" );
else
fprintf( stderr, "%d test(s) failed\n", fail );
return fail;
}
示例5: main
int main( int /*argc*/, char** /*argv*/ )
{
int fail = 0;
std::string name;
Tag *t;
// -------
{
name = "empty tag() test";
SHIM shim;
t = shim.tag();
if( t )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete t;
t = 0;
}
// -------
{
name = "headers to tag to headers, part 1/2";
SHIM::HeaderList hl;
hl.insert( std::make_pair( "created", "yesterday" ) );
hl.insert( std::make_pair( "name", "foo" ) );
SHIM shim( hl );
t = shim.tag();
if( t->xml() != "<headers xmlns='"+ XMLNS_SHIM + "'><header name='created'>yesterday</header><header name='name'>foo</header></headers>" )
{
++fail;
fprintf( stderr, "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
name = "headers to tag to headers, part 2/2";
SHIM s( t );
if( s.headers() != hl )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete t;
t = 0;
}
StanzaExtensionFactory sef;
sef.registerExtension( new SHIM() );
// -------
{
name = "SHIM/SEFactory test";
Tag* f = new Tag( "message" );
new Tag( f, "headers", "xmlns", XMLNS_SHIM );
Message msg( Message::Normal, JID(), "" );
sef.addExtensions( msg, f );
const SHIM* se = msg.findExtension<SHIM>( ExtSHIM );
if( se == 0 )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete f;
}
printf( "SHIM: " );
if( fail == 0 )
{
printf( "OK\n" );
return 0;
}
else
{
fprintf( stderr, "%d test(s) failed\n", fail );
return 1;
}
}
示例6: main
//.........这里部分代码省略.........
a.addRule( new AMP::Rule( "foodate", AMP::ActionDrop ) );
t = a.tag();
if( !t || t->xml() != "<amp xmlns='" + XMLNS_AMP + "' per-hop='true'>"
"<rule condition='expire-at' action='drop' value='foodate'/>"
"</amp>" )
{
++fail;
printf( "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
delete t;
t = 0;
}
// -------
{
name = "2 rules, per-hop = true";
AMP a( true );
a.addRule( new AMP::Rule( "foodate", AMP::ActionDrop ) );
a.addRule( new AMP::Rule( AMP::DeliverNone, AMP::ActionDrop ) );
t = a.tag();
if( !t || t->xml() != "<amp xmlns='" + XMLNS_AMP + "' per-hop='true'>"
"<rule condition='expire-at' action='drop' value='foodate'/>"
"<rule condition='deliver' action='drop' value='none'/>"
"</amp>" )
{
++fail;
printf( "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
delete t;
t = 0;
}
// -------
{
name = "2 rules()";
AMP a( true );
a.addRule( new AMP::Rule( "foodate", AMP::ActionDrop ) );
a.addRule( new AMP::Rule( AMP::DeliverNone, AMP::ActionDrop ) );
if( a.rules().size() != 2 )
{
++fail;
printf( "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
}
// -------
{
name = "Tag ctor";
Tag* q = new Tag( "amp" );
q->setXmlns( XMLNS_AMP );
q->addAttribute( "from", "foofrom" );
q->addAttribute( "to", "footo" );
q->addAttribute( "status", "notify" );
q->addAttribute( "per-hop", "true" );
Tag* r = new Tag( q, "rule" );
r->addAttribute( "condition", "deliver" );
r->addAttribute( "action", "error" );
r->addAttribute( "value", "forward" );
AMP a( q );
t = a.tag();
if( *t != *q )
{
++fail;
printf( "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
delete t;
t = 0;
delete q;
q = 0;
}
// -------
name = "AMP/SEFactory test";
StanzaExtensionFactory sef;
sef.registerExtension( new AMP() );
Tag* f = new Tag( "message" );
new Tag( f, "amp", "xmlns", XMLNS_AMP );
Message msg( Message::Normal, JID() );
sef.addExtensions( msg, f );
const AMP* se = msg.findExtension<AMP>( ExtAMP );
if( se == 0 )
{
++fail;
printf( "test '%s' failed\n", name.c_str() );
}
delete f;
if( fail == 0 )
{
printf( "AMP: OK\n" );
return 0;
}
else
{
printf( "AMP: %d test(s) failed\n", fail );
return 1;
}
}
示例7: main
//.........这里部分代码省略.........
{
++fail;
fprintf( stderr, "test '%s' failed:%s \n", name.c_str(), t->xml().c_str() );
}
delete t;
}
// -------
{
name = "parse decline";
Tag* x = new Tag( "x" );
x->setXmlns( XMLNS_MUC_USER );
Tag* i = new Tag( x, "decline" );
i->addAttribute( "from", "[email protected]" );
new Tag( i, "reason", "because." );
MUCRoom::MUCUser mu( x );
t = mu.tag();
if( !t || t->xml() != "<x xmlns='" + XMLNS_MUC_USER + "'>"
"<decline from='[email protected]'>"
"<reason>because.</reason>"
"</decline>"
"</x>" )
{
++fail;
fprintf( stderr, "test '%s' failed:%s \n", name.c_str(), t->xml().c_str() );
}
delete t;
delete x;
}
// -------
{
// this is for parsing incoming stanzas only.
// for actively destroying a room (as the owner), see MUCOwner
name = "destroying a room";
Tag* x = new Tag( "x" );
x->setXmlns( XMLNS_MUC_USER );
Tag* d = new Tag( x, "destroy" );
d->addAttribute( "jid", "[email protected]" );
new Tag( d, "reason", "fooreason" );
MUCRoom::MUCUser mu( x );
t = mu.tag();
if( !t || t->xml() != "<x xmlns='" + XMLNS_MUC_USER + "'>"
"<destroy jid='[email protected]'>"
"<reason>fooreason</reason>"
"</destroy>"
"</x>" )
{
++fail;
fprintf( stderr, "test '%s' failed:%s \n", name.c_str(), t->xml().c_str() );
}
delete t;
delete x;
}
// -------
{
name = "MUCRoom::MUCUser/SEFactory test (message)";
StanzaExtensionFactory sef;
sef.registerExtension( new MUCRoom::MUCUser() );
Tag* f = new Tag( "message" );
new Tag( f, "x", "xmlns", XMLNS_MUC_USER );
Message msg( Message::Groupchat, JID(), "" );
sef.addExtensions( msg, f );
const MUCRoom::MUCUser* se = msg.findExtension<MUCRoom::MUCUser>( ExtMUCUser );
if( se == 0 )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete f;
}
// -------
{
name = "MUCRoom::MUCUser/SEFactory test (presence)";
StanzaExtensionFactory sef;
sef.registerExtension( new MUCRoom::MUCUser() );
Tag* f = new Tag( "presence" );
new Tag( f, "x", "xmlns", XMLNS_MUC_USER );
Presence pres( Presence::Available, JID(), "" );
sef.addExtensions( pres, f );
const MUCRoom::MUCUser* se = pres.findExtension<MUCRoom::MUCUser>( ExtMUCUser );
if( se == 0 )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete f;
}
printf( "MUCRoom::MUCUser: " );
if( !fail )
printf( "OK\n" );
else
fprintf( stderr, "%d test(s) failed\n", fail );
return fail;
}
示例8: main
//.........这里部分代码省略.........
delete x;
x = 0;
x = new Tag( "query" );
x->addAttribute( "xmlns", XMLNS_IQ_OOB );
new Tag( x, "url", "invalidurl" );
new Tag( x, "desc", "description" );
// -------
name = "filled object/getters";
d = new OOB( "invalidurl", "description", true );
if( d->url() != "invalidurl" || d->desc() != "description" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete d;
d = 0;
// -------
name = "filled object/tag()";
d = new OOB( "invalidurl", "description", true );
t = d->tag();
if( !t || !t->hasAttribute( "xmlns", XMLNS_IQ_OOB )
|| !t->hasChild( "url" ) || t->findChild( "url" )->cdata() != "invalidurl"
|| !t->hasChild( "desc" ) || t->findChild( "desc" )->cdata() != "description")
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete d;
delete t;
d = 0;
t = 0;
// -------
name = "from Tag/getters";
d = new OOB( x );
if( d->url() != "invalidurl" || d->desc() != "description" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete d;
d = 0;
// -------
name = "from Tag/tag()";
d = new OOB( x );
t = d->tag();
if( !t || !t->hasAttribute( "xmlns", XMLNS_IQ_OOB )
|| !t->hasChild( "url" ) || t->findChild( "url" )->cdata() != "invalidurl"
|| !t->hasChild( "desc" ) || t->findChild( "desc" )->cdata() != "description")
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete d;
delete t;
d = 0;
t = 0;
delete x;
x = 0;
StanzaExtensionFactory sef;
// -------
name = "OOB/SEFactory test";
OOB* oob = new OOB( 0 ); // deleted by StanzaExtensionFactory sef;
sef.registerExtension( oob );
Tag* f = new Tag( "iq" );
Tag* b = new Tag( f, "query", "xmlns", XMLNS_IQ_OOB );
new Tag( b, "url", "url" );
new Tag( b, "desc", "desc" );
IQ iq( IQ::Set, JID(), "" );
sef.addExtensions( iq, f );
const OOB* se = iq.findExtension<OOB>( ExtOOB );
if( se == 0 || se->url() != "url" || se->desc() != "desc" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete f;
if( fail == 0 )
{
printf( "OOB: OK\n" );
return 0;
}
else
{
fprintf( stderr, "OOB: %d test(s) failed\n", fail );
return 1;
}
}
示例9: main
int main( int /*argc*/, char** /*argv*/ )
{
int fail = 0;
std::string name;
Tag *t;
// -------
{
name = "create Tag";
UniqueMUCRoom::Unique uq;
t = uq.tag();
if( !t || t->xml() != "<unique xmlns='" + XMLNS_MUC_UNIQUE + "'/>" )
{
++fail;
printf( "test '%s' failed\n", name.c_str() );
}
delete t;
}
// -------
{
name = "parse Tag";
Tag u( "unique" );
u.setXmlns( XMLNS_MUC_UNIQUE );
u.setCData( "foo" );
UniqueMUCRoom::Unique uq( &u );
t = uq.tag();
if( !t || t->xml() != "<unique xmlns='" + XMLNS_MUC_UNIQUE + "'>"
"foo</unique>"
|| uq.name() != "foo" )
{
++fail;
printf( "test '%s' failed\n", name.c_str() );
}
delete t;
}
// -------
name = "UniqueMUCRoom::Unique/SEFactory test";
StanzaExtensionFactory sef;
sef.registerExtension( new UniqueMUCRoom::Unique() );
Tag* f = new Tag( "iq" );
new Tag( f, "unique", "xmlns", XMLNS_MUC_UNIQUE );
IQ iq( IQ::Set, JID(), "" );
sef.addExtensions( iq, f );
const UniqueMUCRoom::Unique* se = iq.findExtension<UniqueMUCRoom::Unique>( ExtMUCUnique );
if( se == 0 )
{
++fail;
printf( "test '%s' failed\n", name.c_str() );
}
delete f;
printf( "UniqueMUCRoom::Unique: " );
if( !fail )
printf( "OK\n" );
else
printf( "%d test(s) failed\n", fail );
return fail;
}
示例10: main
//.........这里部分代码省略.........
++fail;
printf( "test '%s' failed\n", name.c_str() );
}
delete t;
t = 0;
}
// -------
{
name = "remove item";
RosterManager::Query rq( JID( "foof" ) );
t = rq.tag();
if( t->xml() != "<query xmlns='" + XMLNS_ROSTER + "'>"
"<item jid='foof' subscription='remove'/>"
"</query>" )
{
++fail;
printf( "test '%s' failed\n", name.c_str() );
}
delete t;
t = 0;
}
// -------
{
name = "initial roster";
Tag* q = new Tag( "query" );
q->setXmlns( XMLNS_ROSTER );
Tag* i = new Tag( q, "item", "jid", "foo1" );
i->addAttribute( "name", "name1" );
i->addAttribute( "subscription", "from" );
i = new Tag( q, "item", "jid", "foo2" );
i->addAttribute( "name", "name2" );
i->addAttribute( "subscription", "both" );
RosterManager::Query rq( q );
t = rq.tag();
if( *t != *q || rq.roster().size() != 2 )
{
++fail;
printf( "test '%s' failed\n", name.c_str() );
}
delete t;
t = 0;
delete q;
}
// -------
{
name = "roster push";
Tag* q = new Tag( "query" );
q->setXmlns( XMLNS_ROSTER );
Tag* i = new Tag( q, "item", "jid", "foo1" );
i->addAttribute( "name", "name1" );
i->addAttribute( "subscription", "from" );
new Tag( i, "group", "group1" );
new Tag( i, "group", "group2" );
RosterManager::Query rq( q );
t = rq.tag();
if( *t != *q )
{
++fail;
printf( "test '%s' failed\n", name.c_str() );
printf( " got: %s\n", t->xml().c_str() );
printf( "expected: %s\n", q->xml().c_str() );
}
delete t;
t = 0;
delete q;
}
// -------
name = "RosterManager::Query/SEFactory test";
StanzaExtensionFactory sef;
sef.registerExtension( new RosterManager::Query() );
Tag* f = new Tag( "iq" );
new Tag( f, "query", "xmlns", XMLNS_ROSTER );
IQ iq( IQ::Set, JID(), "" );
sef.addExtensions( iq, f );
const RosterManager::Query* se = iq.findExtension<RosterManager::Query>( ExtRoster );
if( se == 0 )
{
++fail;
printf( "test '%s' failed\n", name.c_str() );
}
delete f;
if( fail == 0 )
{
printf( "RosterManager::Query: OK\n" );
return 0;
}
else
{
printf( "RosterManager::Query: %d test(s) failed\n", fail );
return 1;
}
}
示例11: main
int main( int /*argc*/, char** /*argv*/ )
{
int fail = 0;
std::string name;
Tag *t;
// -------
{
name = "empty tag() test";
FeatureNeg fn;
t = fn.tag();
if( t )
{
++fail;
printf( "test '%s' failed\n", name.c_str() );
}
delete t;
t = 0;
}
// -------
{
name = "tag() test";
FeatureNeg fn( new DataForm( TypeForm ) );
t = fn.tag();
if( !t || t->xml() != "<feature xmlns='" + XMLNS_FEATURE_NEG + "'>"
"<x xmlns='" + XMLNS_X_DATA + "' type='form'/>"
"</feature>" )
{
++fail;
printf( "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
// t re-used in next test
}
// -------
{
name = "parse tag";
FeatureNeg fn( t ); // re-using t from previous test
Tag* t2 = fn.tag();
if( !t2 || *t2 != *t )
{
++fail;
printf( "test '%s' failed: %s\n", name.c_str(), t->xml().c_str() );
}
delete t2;
delete t;
t = 0;
}
// -------
name = "FeatureNeg/SEFactory test (IQ)";
StanzaExtensionFactory sef;
sef.registerExtension( new FeatureNeg() );
Tag* f = new Tag( "iq" );
new Tag( f, "feature", "xmlns", XMLNS_FEATURE_NEG );
IQ iq( IQ::Set, JID(), "" );
sef.addExtensions( iq, f );
const FeatureNeg* se = iq.findExtension<FeatureNeg>( ExtFeatureNeg );
if( se == 0 )
{
++fail;
printf( "test '%s' failed\n", name.c_str() );
}
delete f;
// -------
name = "FeatureNeg/SEFactory test (Message)";
f = new Tag( "message" );
new Tag( f, "feature", "xmlns", XMLNS_FEATURE_NEG );
Message msg( Message::Normal, JID() );
sef.addExtensions( msg, f );
se = msg.findExtension<FeatureNeg>( ExtFeatureNeg );
if( se == 0 )
{
++fail;
printf( "test '%s' failed\n", name.c_str() );
}
delete f;
if( fail == 0 )
{
printf( "FeatureNeg: OK\n" );
return 0;
}
else
{
printf( "FeatureNeg: %d test(s) failed\n", fail );
return 1;
}
}
示例12: laq
TEST(Gloox, LastActivityQuery)
{
int fail = 0;
std::string name;
// -------
{
name = "empty tag() test";
LastActivity::Query laq;
if( false )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
}
// -------
{
name = "parse test";
Tag* t = new Tag( "query" );
t->setXmlns( XMLNS_LAST );
t->addAttribute( "seconds", "123" );
t->setCData( "foo" );
LastActivity::Query laq( t );
if( laq.seconds() != 123 || laq.status() != "foo" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
// -------
name = "tag() test"; // uses t from previous test
Tag* s = laq.tag();
if( *t != *s )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete t;
delete s;
}
StanzaExtensionFactory sef;
sef.registerExtension( new LastActivity::Query() );
// -------
{
name = "LastActivity::Query/SEFactory test";
Tag* f = new Tag( "iq" );
new Tag( f, "query", "xmlns", XMLNS_LAST );
IQ iq( IQ::Set, JID(), "" );
sef.addExtensions( iq, f );
const LastActivity::Query* se = iq.findExtension<LastActivity::Query>( ExtLastActivity );
if( se == 0 )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete f;
}
EXPECT_EQ(0, fail);
//printf( "LastActivity::Query: " );
// if( fail == 0 )
// {
// printf( "OK\n" );
// return 0;
// }
// else
// {
// fprintf( stderr, "%d test(s) failed\n", fail );
// return 1;
// }
}
示例13: main
//.........这里部分代码省略.........
MUCRoom::MUC mu( "foopwd" );
t = mu.tag();
if( !t || t->xml() != "<x xmlns='" + XMLNS_MUC + "'>"
"<password>foopwd</password>"
"</x>" )
{
++fail;
printf( "test '%s' failed:%s \n", name.c_str(), t->xml().c_str() );
}
delete t;
}
// -------
{
name = "joining room, requesting room history 1";
MUCRoom::MUC mu( EmptyString, MUCRoom::HistorySince, "foodate" );
t = mu.tag();
if( !t || t->xml() != "<x xmlns='" + XMLNS_MUC + "'>"
"<history since='foodate'/>"
"</x>" )
{
++fail;
printf( "test '%s' failed:%s \n", name.c_str(), t->xml().c_str() );
}
delete t;
}
// -------
{
name = "joining room, requesting room history 2";
MUCRoom::MUC mu( EmptyString, MUCRoom::HistoryMaxChars, EmptyString, 100 );
t = mu.tag();
if( !t || t->xml() != "<x xmlns='" + XMLNS_MUC + "'>"
"<history maxchars='100'/>"
"</x>" )
{
++fail;
printf( "test '%s' failed:%s \n", name.c_str(), t->xml().c_str() );
}
delete t;
}
// -------
{
name = "joining room, requesting room history 3";
MUCRoom::MUC mu( EmptyString, MUCRoom::HistoryMaxStanzas, EmptyString, 100 );
t = mu.tag();
if( !t || t->xml() != "<x xmlns='" + XMLNS_MUC + "'>"
"<history maxstanzas='100'/>"
"</x>" )
{
++fail;
printf( "test '%s' failed:%s \n", name.c_str(), t->xml().c_str() );
}
delete t;
}
// -------
{
name = "joining room, requesting room history 4 + password";
MUCRoom::MUC mu( "foopwd", MUCRoom::HistorySeconds, EmptyString, 100 );
t = mu.tag();
if( !t || t->xml() != "<x xmlns='" + XMLNS_MUC + "'>"
"<history seconds='100'/>"
"<password>foopwd</password>"
"</x>" )
{
++fail;
printf( "test '%s' failed:%s \n", name.c_str(), t->xml().c_str() );
}
delete t;
}
// -------
{
name = "MUCRoom::MUC/SEFactory test (presence)";
StanzaExtensionFactory sef;
sef.registerExtension( new MUCRoom::MUC() );
Tag* f = new Tag( "presence" );
new Tag( f, "x", "xmlns", XMLNS_MUC );
Presence pres( Presence::Available, JID(), "" );
sef.addExtensions( pres, f );
const MUCRoom::MUC* se = pres.findExtension<MUCRoom::MUC>( ExtMUC );
if( se == 0 )
{
++fail;
printf( "test '%s' failed\n", name.c_str() );
}
delete f;
}
printf( "MUCRoom::MUC: " );
if( !fail )
printf( "OK\n" );
else
printf( "%d test(s) failed\n", fail );
return fail;
}
示例14: main
int main( int /*argc*/, char** /*argv*/ )
{
int fail = 0;
std::string name;
Tag *t;
// -------
{
name = "execute specific command";
Adhoc::Command ac( "somecmd", Adhoc::Command::Execute );
t = ac.tag();
if( t->xml() != "<command xmlns='" + XMLNS_ADHOC_COMMANDS + "' node='somecmd' action='execute'/>"
|| ac.node() != "somecmd" || ac.action() != Adhoc::Command::Execute )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete t;
t = 0;
}
// -------
{
name = "execute specific command /w session";
Adhoc::Command ac( "somecmd", "somesession", Adhoc::Command::Execute );
t = ac.tag();
if( t->xml() != "<command xmlns='" + XMLNS_ADHOC_COMMANDS + "' node='somecmd' action='execute' sessionid='somesession'/>"
|| ac.node() != "somecmd" || ac.sessionID() != "somesession"
|| ac.action() != Adhoc::Command::Execute )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete t;
t = 0;
}
// -------
{
name = "Tag ctor";
t = new Tag( "command" );
t->setXmlns( XMLNS_ADHOC_COMMANDS );
t->addAttribute( "node", "somecmd" );
t->addAttribute( "sessionid", "somesession" );
t->addAttribute( "action", "execute" );
Tag* f = new Tag( t, "x" );
f->setXmlns( XMLNS_X_DATA );
Adhoc::Command ac( t );
if( ac.node() != "somecmd" || ac.sessionID() != "somesession"
|| ac.action() != Adhoc::Command::Execute || ac.form() == 0 )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete t;
t = 0;
}
// -------
name = "Adhoc::Command/SEFactory test";
StanzaExtensionFactory sef;
sef.registerExtension( new Adhoc::Command( "foo", Adhoc::Command::Execute) );
Tag* f = new Tag( "iq" );
new Tag( f, "command", "xmlns", XMLNS_ADHOC_COMMANDS );
IQ iq( IQ::Set, JID(), "" );
sef.addExtensions( iq, f );
const Adhoc::Command* se = iq.findExtension<Adhoc::Command>( ExtAdhocCommand );
if( se == 0 )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete f;
if( fail == 0 )
{
printf( "Adhoc::Command: OK\n" );
return 0;
}
else
{
fprintf( stderr, "Adhoc::Command: %d test(s) failed\n", fail );
return 1;
}
}
示例15: main
//.........这里部分代码省略.........
"</query>" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete t;
}
// ------
{
name = "destroy room";
MUCRoom::MUCOwner mo( JID( "foo" ), "foobar", "foopwd" );
t = mo.tag();
if( !t || t->xml() != "<query xmlns='" + XMLNS_MUC_OWNER + "'>"
"<destroy jid='foo'>"
"<reason>foobar</reason>"
"<password>foopwd</password>"
"</destroy></query>" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete t;
}
// ------
{
name = "destroy room w/o alternate venue";
MUCRoom::MUCOwner mo;
t = mo.tag();
if( !t || t->xml() != "<query xmlns='" + XMLNS_MUC_OWNER + "'>"
"<destroy/></query>" )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete t;
}
// ------
{
name = "from Tag: request room config";
Tag* d = new Tag( "query" );
d->setXmlns( XMLNS_MUC_OWNER );
MUCRoom::MUCOwner mo( d );
t = mo.tag();
if( !t || *t != *d )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete t;
delete d;
}
// ------
{
name = "from Tag: destroy room";
Tag* d = new Tag( "query" );
d->setXmlns( XMLNS_MUC_OWNER );
Tag* destroy = new Tag( d, "destroy" );
destroy->addAttribute( "jid", "alternate" );
new Tag( destroy, "reason", "reason" );
new Tag( destroy, "password", "pwd" );
MUCRoom::MUCOwner mo( d );
t = mo.tag();
if( !t || *t != *d )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete t;
delete d;
}
// -------
name = "MUCRoom::MUCOwner/SEFactory test";
StanzaExtensionFactory sef;
sef.registerExtension( new MUCRoom::MUCOwner() );
Tag* f = new Tag( "iq" );
new Tag( f, "query", "xmlns", XMLNS_MUC_OWNER );
IQ iq( IQ::Set, JID(), "" );
sef.addExtensions( iq, f );
const MUCRoom::MUCOwner* se = iq.findExtension<MUCRoom::MUCOwner>( ExtMUCOwner );
if( se == 0 )
{
++fail;
fprintf( stderr, "test '%s' failed\n", name.c_str() );
}
delete f;
printf( "MUCRoom::MUCOwner: " );
if( !fail )
printf( "OK\n" );
else
fprintf( stderr, "%d test(s) failed\n", fail );
return fail;
}