/* * Copyright (c) 2010 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ #include #include #include #include using namespace Swift; class StreamInitiationParserTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(StreamInitiationParserTest); CPPUNIT_TEST(testParse_Request); CPPUNIT_TEST(testParse_Response); CPPUNIT_TEST_SUITE_END(); public: void testParse_Request() { PayloadsParserTester parser; CPPUNIT_ASSERT(parser.parse( "" "" "This is info about the file." "" "" "" "" "" "" "" "" "" "" "" )); StreamInitiation::ref si = parser.getPayload(); 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(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]); } void testParse_Response() { PayloadsParserTester parser; CPPUNIT_ASSERT(parser.parse( "" "" "" "" "http://jabber.org/protocol/bytestreams" "" "" "" "" )); StreamInitiation::ref si = parser.getPayload(); CPPUNIT_ASSERT(si->getIsFileTransfer()); CPPUNIT_ASSERT_EQUAL(std::string("http://jabber.org/protocol/bytestreams"), si->getRequestedMethod()); } }; CPPUNIT_TEST_SUITE_REGISTRATION(StreamInitiationParserTest);