blob: 663a81cf1489076f7ee3615d1917c6d32db6f628 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/*
* Copyright (c) 2010 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#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(std::string("someresource"), payload->getResource());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(ResourceBindParserTest);
|