summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-10-21 19:44:13 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-10-21 19:54:06 (GMT)
commitbbb77132775e69b6df7df4ddf38a429aff733d2b (patch)
treea512aaa8292ea4afe175446d672261921c2d27c0 /Swiften/Queries/Responders/UnitTest/DiscoInfoResponderTest.cpp
parent4943167a6451d7a483a2aacb5f3f2bebb82adf0d (diff)
downloadswift-bbb77132775e69b6df7df4ddf38a429aff733d2b.zip
swift-bbb77132775e69b6df7df4ddf38a429aff733d2b.tar.bz2
Moving queries & responders around.
Diffstat (limited to 'Swiften/Queries/Responders/UnitTest/DiscoInfoResponderTest.cpp')
-rw-r--r--Swiften/Queries/Responders/UnitTest/DiscoInfoResponderTest.cpp96
1 files changed, 0 insertions, 96 deletions
diff --git a/Swiften/Queries/Responders/UnitTest/DiscoInfoResponderTest.cpp b/Swiften/Queries/Responders/UnitTest/DiscoInfoResponderTest.cpp
deleted file mode 100644
index 20fa9ff..0000000
--- a/Swiften/Queries/Responders/UnitTest/DiscoInfoResponderTest.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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 <typeinfo>
-
-#include "Swiften/Queries/Responders/DiscoInfoResponder.h"
-#include "Swiften/Queries/IQRouter.h"
-#include "Swiften/Queries/DummyIQChannel.h"
-
-using namespace Swift;
-
-class DiscoInfoResponderTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(DiscoInfoResponderTest);
- CPPUNIT_TEST(testHandleRequest_GetToplevelInfo);
- CPPUNIT_TEST(testHandleRequest_GetNodeInfo);
- CPPUNIT_TEST(testHandleRequest_GetInvalidNodeInfo);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- DiscoInfoResponderTest() {}
-
- void setUp() {
- channel_ = new DummyIQChannel();
- router_ = new IQRouter(channel_);
- }
-
- void tearDown() {
- delete router_;
- delete channel_;
- }
-
- void testHandleRequest_GetToplevelInfo() {
- DiscoInfoResponder testling(router_);
- testling.start();
- DiscoInfo discoInfo;
- discoInfo.addFeature("foo");
- testling.setDiscoInfo(discoInfo);
-
- boost::shared_ptr<DiscoInfo> query(new DiscoInfo());
- channel_->onIQReceived(IQ::createRequest(IQ::Get, JID("foo@bar.com"), "id-1", query));
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size()));
- boost::shared_ptr<DiscoInfo> payload(channel_->iqs_[0]->getPayload<DiscoInfo>());
- CPPUNIT_ASSERT(payload);
- CPPUNIT_ASSERT_EQUAL(String(""), payload->getNode());
- CPPUNIT_ASSERT(payload->hasFeature("foo"));
-
- testling.stop();
- }
-
- void testHandleRequest_GetNodeInfo() {
- DiscoInfoResponder testling(router_);
- testling.start();
- DiscoInfo discoInfo;
- discoInfo.addFeature("foo");
- testling.setDiscoInfo(discoInfo);
- DiscoInfo discoInfoBar;
- discoInfoBar.addFeature("bar");
- testling.setDiscoInfo("bar-node", discoInfoBar);
-
- boost::shared_ptr<DiscoInfo> query(new DiscoInfo());
- query->setNode("bar-node");
- channel_->onIQReceived(IQ::createRequest(IQ::Get, JID("foo@bar.com"), "id-1", query));
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size()));
- boost::shared_ptr<DiscoInfo> payload(channel_->iqs_[0]->getPayload<DiscoInfo>());
- CPPUNIT_ASSERT(payload);
- CPPUNIT_ASSERT_EQUAL(String("bar-node"), payload->getNode());
- CPPUNIT_ASSERT(payload->hasFeature("bar"));
-
- testling.stop();
- }
-
- void testHandleRequest_GetInvalidNodeInfo() {
- DiscoInfoResponder testling(router_);
-
- boost::shared_ptr<DiscoInfo> query(new DiscoInfo());
- query->setNode("bar-node");
- channel_->onIQReceived(IQ::createRequest(IQ::Get, JID("foo@bar.com"), "id-1", query));
-
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(channel_->iqs_.size()));
- boost::shared_ptr<ErrorPayload> payload(channel_->iqs_[0]->getPayload<ErrorPayload>());
- CPPUNIT_ASSERT(payload);
- }
-
- private:
- IQRouter* router_;
- DummyIQChannel* channel_;
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(DiscoInfoResponderTest);