summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2009-11-20 18:23:09 (GMT)
committerRemko Tronçon <git@el-tramo.be>2009-11-20 18:23:09 (GMT)
commitcf8e2aca04c9a4021448f829e5b264dad25b28c8 (patch)
tree6f11cb1a32a9d73f3b9a62db6d06e6ae2dcab6ab /Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp
parent97bdf1a66d321bcd059a0ee218bec0cc92d1bc7b (diff)
downloadswift-cf8e2aca04c9a4021448f829e5b264dad25b28c8.zip
swift-cf8e2aca04c9a4021448f829e5b264dad25b28c8.tar.bz2
Fixed connection leak.
Diffstat (limited to 'Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp')
-rw-r--r--Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp b/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp
index a5c51aa..926c9ae 100644
--- a/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp
+++ b/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp
@@ -1,72 +1,75 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <boost/shared_ptr.hpp>
#include "Swiften/Base/String.h"
#include "Swiften/Network/BoostConnectionServer.h"
#include "Swiften/Network/BoostIOServiceThread.h"
#include "Swiften/EventLoop/DummyEventLoop.h"
using namespace Swift;
class BoostConnectionServerTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(BoostConnectionServerTest);
CPPUNIT_TEST(testConstructor_TwoServersOnSamePort);
CPPUNIT_TEST(testStart_Conflict);
CPPUNIT_TEST(testStop);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
boostIOServiceThread_ = new BoostIOServiceThread();
eventLoop_ = new DummyEventLoop();
stopped = false;
stoppedError.reset();
}
void tearDown() {
+ while (eventLoop_->hasEvents()) {
+ eventLoop_->processEvents();
+ }
delete eventLoop_;
delete boostIOServiceThread_;
}
void testConstructor_TwoServersOnSamePort() {
boost::shared_ptr<BoostConnectionServer> testling(new BoostConnectionServer(9999, &boostIOServiceThread_->getIOService()));
boost::shared_ptr<BoostConnectionServer> testling2(new BoostConnectionServer(9999, &boostIOServiceThread_->getIOService()));
}
void testStart_Conflict() {
boost::shared_ptr<BoostConnectionServer> testling(new BoostConnectionServer(9999, &boostIOServiceThread_->getIOService()));
testling->start();
boost::shared_ptr<BoostConnectionServer> testling2(new BoostConnectionServer(9999, &boostIOServiceThread_->getIOService()));
testling2->onStopped.connect(
boost::bind(&BoostConnectionServerTest::handleStopped, this, _1));
testling->stop();
}
void testStop() {
boost::shared_ptr<BoostConnectionServer> testling(new BoostConnectionServer(9999, &boostIOServiceThread_->getIOService()));
testling->start();
testling->stop();
boost::shared_ptr<BoostConnectionServer> testling2(new BoostConnectionServer(9999, &boostIOServiceThread_->getIOService()));
testling2->start();
testling2->stop();
}
void handleStopped(boost::optional<BoostConnectionServer::Error> e) {
stopped = true;
stoppedError = e;
}
private:
BoostIOServiceThread* boostIOServiceThread_;
DummyEventLoop* eventLoop_;
bool stopped;
boost::optional<BoostConnectionServer::Error> stoppedError;
};
CPPUNIT_TEST_SUITE_REGISTRATION(BoostConnectionServerTest);