diff options
Diffstat (limited to 'Swiften/QA/NetworkTest')
-rw-r--r-- | Swiften/QA/NetworkTest/BoostConnectionTest.cpp | 8 | ||||
-rw-r--r-- | Swiften/QA/NetworkTest/DomainNameResolverTest.cpp | 28 | ||||
-rw-r--r-- | Swiften/QA/NetworkTest/SConscript | 3 |
3 files changed, 32 insertions, 7 deletions
diff --git a/Swiften/QA/NetworkTest/BoostConnectionTest.cpp b/Swiften/QA/NetworkTest/BoostConnectionTest.cpp index 335f2d2..53faff7 100644 --- a/Swiften/QA/NetworkTest/BoostConnectionTest.cpp +++ b/Swiften/QA/NetworkTest/BoostConnectionTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 Remko Tronçon + * Copyright (c) 2010-2013 Remko Tronçon * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ @@ -18,7 +18,7 @@ #include <Swiften/Network/BoostIOServiceThread.h> #include <Swiften/EventLoop/DummyEventLoop.h> -const unsigned char* address = reinterpret_cast<const unsigned char*>("\x41\x63\xde\x89"); +static const unsigned char* address = reinterpret_cast<const unsigned char*>("\x4A\x32\x3e\x31"); using namespace Swift; @@ -70,7 +70,7 @@ class BoostConnectionTest : public CppUnit::TestFixture { testling->onConnectFinished.connect(boost::bind(&BoostConnectionTest::doWrite, this, testling.get())); testling->onDataRead.connect(boost::bind(&BoostConnectionTest::handleDataRead, this, _1)); testling->onDisconnected.connect(boost::bind(&BoostConnectionTest::handleDisconnected, this)); - testling->connect(HostAddressPort(HostAddress("65.99.222.137"), 5222)); + testling->connect(HostAddressPort(HostAddress("74.50.62.49"), 5222)); while (receivedData.empty()) { Swift::sleep(10); eventLoop_->processEvents(); @@ -97,7 +97,7 @@ class BoostConnectionTest : public CppUnit::TestFixture { testling->onConnectFinished.connect(boost::bind(&BoostConnectionTest::handleConnectFinished, this)); testling->onDataRead.connect(boost::bind(&BoostConnectionTest::handleDataRead, this, _1)); testling->onDisconnected.connect(boost::bind(&BoostConnectionTest::handleDisconnected, this)); - testling->connect(HostAddressPort(HostAddress("65.99.222.137"), 5222)); + testling->connect(HostAddressPort(HostAddress("74.50.62.49"), 5222)); while (!connectFinished) { boostIOService->run_one(); eventLoop_->processEvents(); diff --git a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp b/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp index 7cb9ed3..bc4f1a3 100644 --- a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp +++ b/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp @@ -9,14 +9,22 @@ #include <boost/bind.hpp> #include <algorithm> - #include <Swiften/Base/sleep.h> #include <string> #include <Swiften/Base/ByteArray.h> +#ifdef USE_UNBOUND +#include <Swiften/Network/UnboundDomainNameResolver.h> +#else #include <Swiften/Network/PlatformDomainNameResolver.h> +#endif +#include <Swiften/Network/BoostTimerFactory.h> +#include <Swiften/Network/NetworkFactories.h> +#include <Swiften/Network/BoostIOServiceThread.h> #include <Swiften/Network/DomainNameAddressQuery.h> #include <Swiften/Network/DomainNameServiceQuery.h> #include <Swiften/EventLoop/DummyEventLoop.h> +#include <Swiften/IDN/IDNConverter.h> +#include <Swiften/IDN/PlatformIDNConverter.h> using namespace Swift; @@ -30,23 +38,34 @@ class DomainNameResolverTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(DomainNameResolverTest); CPPUNIT_TEST(testResolveAddress); CPPUNIT_TEST(testResolveAddress_Error); +#ifndef USE_UNBOUND CPPUNIT_TEST(testResolveAddress_IPv6); CPPUNIT_TEST(testResolveAddress_IPv4and6); CPPUNIT_TEST(testResolveAddress_International); +#endif CPPUNIT_TEST(testResolveAddress_Localhost); CPPUNIT_TEST(testResolveAddress_Parallel); +#ifndef USE_UNBOUND CPPUNIT_TEST(testResolveService); +#endif CPPUNIT_TEST(testResolveService_Error); CPPUNIT_TEST_SUITE_END(); public: void setUp() { + ioServiceThread = new BoostIOServiceThread(); eventLoop = new DummyEventLoop(); - resolver = new PlatformDomainNameResolver(eventLoop); +#ifdef USE_UNBOUND + resolver = new UnboundDomainNameResolver(ioServiceThread->getIOService(), eventLoop); +#else + idnConverter = boost::shared_ptr<IDNConverter>(PlatformIDNConverter::create()); + resolver = new PlatformDomainNameResolver(idnConverter.get(), eventLoop); +#endif resultsAvailable = false; } void tearDown() { + delete ioServiceThread; delete resolver; delete eventLoop; } @@ -208,13 +227,16 @@ class DomainNameResolverTest : public CppUnit::TestFixture { } private: + BoostIOServiceThread* ioServiceThread; DummyEventLoop* eventLoop; + boost::shared_ptr<IDNConverter> idnConverter; + boost::shared_ptr<TimerFactory> timerFactory; bool resultsAvailable; std::vector<HostAddress> addressQueryResult; std::vector<HostAddress> allAddressQueryResults; boost::optional<DomainNameResolveError> addressQueryError; std::vector<DomainNameServiceQuery::Result> serviceQueryResult; - PlatformDomainNameResolver* resolver; + DomainNameResolver* resolver; }; CPPUNIT_TEST_SUITE_REGISTRATION(DomainNameResolverTest); diff --git a/Swiften/QA/NetworkTest/SConscript b/Swiften/QA/NetworkTest/SConscript index e1dea26..b090165 100644 --- a/Swiften/QA/NetworkTest/SConscript +++ b/Swiften/QA/NetworkTest/SConscript @@ -11,6 +11,9 @@ if env["TEST"] : myenv.MergeFlags(myenv["SWIFTEN_DEP_FLAGS"]) myenv.MergeFlags(myenv["CPPUNIT_FLAGS"]) + if env.get("unbound", False) : + myenv.Append(CPPDEFINES = ["USE_UNBOUND"]) + tester = myenv.Program("NetworkTest", [ "BoostConnectionServerTest.cpp", "BoostConnectionTest.cpp", |