summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/QA/NetworkTest/DomainNameResolverTest.cpp')
-rw-r--r--Swiften/QA/NetworkTest/DomainNameResolverTest.cpp34
1 files changed, 28 insertions, 6 deletions
diff --git a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp b/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp
index 7cb9ed3..dcd2be8 100644
--- a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp
+++ b/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp
@@ -10,12 +10,20 @@
#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;
@@ -31,10 +39,14 @@ class DomainNameResolverTest : public CppUnit::TestFixture {
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();
@@ -42,10 +54,17 @@ class DomainNameResolverTest : public CppUnit::TestFixture {
public:
void setUp() {
+ ioServiceThread = new BoostIOServiceThread();
eventLoop = new DummyEventLoop();
- resolver = new PlatformDomainNameResolver(eventLoop);
+ idnConverter = boost::shared_ptr<IDNConverter>(PlatformIDNConverter::create());
+#ifdef USE_UNBOUND
+ resolver = new UnboundDomainNameResolver(idnConverter.get(), ioServiceThread->getIOService(), eventLoop);
+#else
+ resolver = new PlatformDomainNameResolver(idnConverter.get(), eventLoop);
+#endif
resultsAvailable = false;
}
void tearDown() {
+ delete ioServiceThread;
delete resolver;
delete eventLoop;
@@ -142,5 +161,5 @@ class DomainNameResolverTest : public CppUnit::TestFixture {
void testResolveService() {
- boost::shared_ptr<DomainNameServiceQuery> query(createServiceQuery("_xmpp-client._tcp.xmpp-srv.test.swift.im"));
+ boost::shared_ptr<DomainNameServiceQuery> query(createServiceQuery("_xmpp-client._tcp.", "xmpp-srv.test.swift.im"));
query->run();
@@ -184,6 +203,6 @@ class DomainNameResolverTest : public CppUnit::TestFixture {
}
- boost::shared_ptr<DomainNameServiceQuery> createServiceQuery(const std::string& domain) {
- boost::shared_ptr<DomainNameServiceQuery> result = resolver->createServiceQuery(domain);
+ boost::shared_ptr<DomainNameServiceQuery> createServiceQuery(const std::string& serviceLookupPrefix, const std::string& domain) {
+ boost::shared_ptr<DomainNameServiceQuery> result = resolver->createServiceQuery(serviceLookupPrefix, domain);
result->onResult.connect(boost::bind(&DomainNameResolverTest::handleServiceQueryResult, this, _1));
return result;
@@ -209,5 +228,8 @@ 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;
@@ -215,5 +237,5 @@ class DomainNameResolverTest : public CppUnit::TestFixture {
boost::optional<DomainNameResolveError> addressQueryError;
std::vector<DomainNameServiceQuery::Result> serviceQueryResult;
- PlatformDomainNameResolver* resolver;
+ DomainNameResolver* resolver;
};