diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-08-10 07:45:39 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-08-10 07:45:39 +0000 |
| commit | 1147c4f57591397a53bc045ae77106e337c2d940 (patch) | |
| tree | b6fb54139ad68fefb7b1df6baee7ee45fcbe5428 /example/tests/tests.cpp | |
| parent | 0e9455bc58f89d242b4e58ed00fe88835833a412 (diff) | |
| download | qxmpp-1147c4f57591397a53bc045ae77106e337c2d940.tar.gz | |
test XML-RPC invoke/response IQs
Diffstat (limited to 'example/tests/tests.cpp')
| -rw-r--r-- | example/tests/tests.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/example/tests/tests.cpp b/example/tests/tests.cpp index 8e175844..21888856 100644 --- a/example/tests/tests.cpp +++ b/example/tests/tests.cpp @@ -32,6 +32,7 @@ #include "QXmppJingleIq.h" #include "QXmppMessage.h" #include "QXmppPresence.h" +#include "QXmppRpcIq.h" #include "QXmppSession.h" #include "QXmppUtils.h" #include "tests.h" @@ -415,6 +416,59 @@ void TestXmlRpc::testStruct() "</struct></value>")); } +void TestXmlRpc::testInvoke() +{ + const QByteArray xml( + "<iq" + " id=\"rpc1\"" + " to=\"responder@company-a.com/jrpc-server\"" + " from=\"requester@company-b.com/jrpc-client\"" + " type=\"set\">" + "<query xmlns=\"jabber:iq:rpc\">" + "<methodCall>" + "<methodName>examples.getStateName</methodName>" + "<params>" + "<param>" + "<value><i4>6</i4></value>" + "</param>" + "</params>" + "</methodCall>" + "</query>" + "</iq>"); + + QXmppRpcInvokeIq iq; + parsePacket(iq, xml); + QCOMPARE(iq.interface(), QLatin1String("examples")); + QCOMPARE(iq.method(), QLatin1String("getStateName")); + QCOMPARE(iq.arguments(), QVariantList() << int(6)); + serializePacket(iq, xml); +} + +void TestXmlRpc::testResponse() +{ + const QByteArray xml( + "<iq" + " id=\"rpc1\"" + " to=\"requester@company-b.com/jrpc-client\"" + " from=\"responder@company-a.com/jrpc-server\"" + " type=\"result\">" + "<query xmlns=\"jabber:iq:rpc\">" + "<methodResponse>" + "<params>" + "<param>" + "<value><string>Colorado</string></value>" + "</param>" + "</params>" + "</methodResponse>" + "</query>" + "</iq>"); + + QXmppRpcResponseIq iq; + parsePacket(iq, xml); + QCOMPARE(iq.values(), QVariantList() << QString("Colorado")); + serializePacket(iq, xml); +} + int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); |
