diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-03-28 13:40:14 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-03-28 13:40:43 (GMT) |
commit | b61486fefe602e0d18fa5279021006f87b965307 (patch) | |
tree | 437585cbef1179e1ec31f79789591d5610200c29 /Swiften/QA | |
parent | dae28dd45e43fc6e6ef2ec4c6c65d5d736ed86f8 (diff) | |
download | swift-b61486fefe602e0d18fa5279021006f87b965307.zip swift-b61486fefe602e0d18fa5279021006f87b965307.tar.bz2 |
Moved Swiften to a separate module.
Diffstat (limited to 'Swiften/QA')
m--------- | Swiften | 0 | ||||
-rw-r--r-- | Swiften/QA/ClientTest/.gitignore | 1 | ||||
-rw-r--r-- | Swiften/QA/ClientTest/ClientTest.cpp | 68 | ||||
-rw-r--r-- | Swiften/QA/ClientTest/SConscript | 22 | ||||
-rw-r--r-- | Swiften/QA/NetworkTest/.gitignore | 1 | ||||
-rw-r--r-- | Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp | 75 | ||||
-rw-r--r-- | Swiften/QA/NetworkTest/BoostConnectionTest.cpp | 88 | ||||
-rw-r--r-- | Swiften/QA/NetworkTest/DomainNameResolverTest.cpp | 168 | ||||
-rw-r--r-- | Swiften/QA/NetworkTest/SConscript | 18 | ||||
-rw-r--r-- | Swiften/QA/SConscript | 4 |
10 files changed, 0 insertions, 445 deletions
diff --git a/Swiften b/Swiften new file mode 160000 +Subproject 8213ba16d0043d2461f4b031c881d61dda5a38c diff --git a/Swiften/QA/ClientTest/.gitignore b/Swiften/QA/ClientTest/.gitignore deleted file mode 100644 index 9fb3e67..0000000 --- a/Swiften/QA/ClientTest/.gitignore +++ /dev/null @@ -1 +0,0 @@ -ClientTest diff --git a/Swiften/QA/ClientTest/ClientTest.cpp b/Swiften/QA/ClientTest/ClientTest.cpp deleted file mode 100644 index 74ec908..0000000 --- a/Swiften/QA/ClientTest/ClientTest.cpp +++ /dev/null @@ -1,68 +0,0 @@ -#include <boost/bind.hpp> -#include <boost/thread.hpp> - -#include "Swiften/Client/Client.h" -#include "Swiften/Network/BoostTimer.h" -#include "Swiften/EventLoop/MainEventLoop.h" -#include "Swiften/EventLoop/SimpleEventLoop.h" -#include "Swiften/Queries/Requests/GetRosterRequest.h" -#include "Swiften/Client/ClientXMLTracer.h" -#include "Swiften/Network/BoostIOServiceThread.h" -#include "Swiften/Network/MainBoostIOServiceThread.h" - -using namespace Swift; - -SimpleEventLoop eventLoop; - -Client* client = 0; -bool reconnected = false; -bool rosterReceived = false; - -void handleRosterReceived(boost::shared_ptr<Payload>) { - if (reconnected) { - rosterReceived = true; - client->disconnect(); - eventLoop.stop(); - } - else { - reconnected = true; - client->disconnect(); - client->connect(); - } -} - -void handleConnected() { - boost::shared_ptr<GetRosterRequest> rosterRequest(new GetRosterRequest(client)); - rosterRequest->onResponse.connect(boost::bind(&handleRosterReceived, _1)); - rosterRequest->send(); -} - -int main(int, char**) { - char* jid = getenv("SWIFT_CLIENTTEST_JID"); - if (!jid) { - std::cerr << "Please set the SWIFT_CLIENTTEST_JID environment variable" << std::endl; - return -1; - } - char* pass = getenv("SWIFT_CLIENTTEST_PASS"); - if (!pass) { - std::cerr << "Please set the SWIFT_CLIENTTEST_PASS environment variable" << std::endl; - return -1; - } - - client = new Swift::Client(JID(jid), String(pass)); - ClientXMLTracer* tracer = new ClientXMLTracer(client); - client->onConnected.connect(&handleConnected); - client->connect(); - - { - boost::shared_ptr<BoostTimer> timer(new BoostTimer(30000, &MainBoostIOServiceThread::getInstance().getIOService())); - timer->onTick.connect(boost::bind(&SimpleEventLoop::stop, &eventLoop)); - timer->start(); - - eventLoop.run(); - } - - delete tracer; - delete client; - return !rosterReceived; -} diff --git a/Swiften/QA/ClientTest/SConscript b/Swiften/QA/ClientTest/SConscript deleted file mode 100644 index bc9cf95..0000000 --- a/Swiften/QA/ClientTest/SConscript +++ /dev/null @@ -1,22 +0,0 @@ -import os - -Import("env") - -if env["TEST"] : - myenv = env.Clone() - myenv.MergeFlags(myenv["SWIFTEN_FLAGS"]) - myenv.MergeFlags(myenv["CPPUNIT_FLAGS"]) - myenv.MergeFlags(myenv["LIBIDN_FLAGS"]) - myenv.MergeFlags(myenv["BOOST_FLAGS"]) - myenv.MergeFlags(myenv.get("SQLITE_FLAGS", "")) - myenv.MergeFlags(myenv["ZLIB_FLAGS"]) - myenv.MergeFlags(myenv["OPENSSL_FLAGS"]) - myenv.MergeFlags(myenv.get("LIBXML_FLAGS", "")) - myenv.MergeFlags(myenv.get("EXPAT_FLAGS", "")) - - for i in ["SWIFT_CLIENTTEST_JID", "SWIFT_CLIENTTEST_PASS"]: - if os.environ.get(i, "") : - myenv["ENV"][i] = os.environ[i] - - tester = myenv.Program("ClientTest", ["ClientTest.cpp"]) - myenv.Test(tester, "system") diff --git a/Swiften/QA/NetworkTest/.gitignore b/Swiften/QA/NetworkTest/.gitignore deleted file mode 100644 index 5a3caca..0000000 --- a/Swiften/QA/NetworkTest/.gitignore +++ /dev/null @@ -1 +0,0 @@ -NetworkTest diff --git a/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp b/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp deleted file mode 100644 index 926c9ae..0000000 --- a/Swiften/QA/NetworkTest/BoostConnectionServerTest.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#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); diff --git a/Swiften/QA/NetworkTest/BoostConnectionTest.cpp b/Swiften/QA/NetworkTest/BoostConnectionTest.cpp deleted file mode 100644 index af4e003..0000000 --- a/Swiften/QA/NetworkTest/BoostConnectionTest.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> -#include <boost/shared_ptr.hpp> - -#include "Swiften/Base/String.h" -#include "Swiften/Base/sleep.h" -#include "Swiften/Network/BoostConnection.h" -#include "Swiften/Network/HostAddress.h" -#include "Swiften/Network/HostAddressPort.h" -#include "Swiften/Network/BoostIOServiceThread.h" -#include "Swiften/EventLoop/DummyEventLoop.h" - -const unsigned char* address = reinterpret_cast<const unsigned char*>("\x41\x63\xde\x89"); - -using namespace Swift; - -class BoostConnectionTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(BoostConnectionTest); - CPPUNIT_TEST(testDestructor); - CPPUNIT_TEST(testDestructor_PendingEvents); - CPPUNIT_TEST(testWrite); - CPPUNIT_TEST_SUITE_END(); - - public: - BoostConnectionTest() {} - - void setUp() { - boostIOServiceThread_ = new BoostIOServiceThread(); - eventLoop_ = new DummyEventLoop(); - disconnected = false; - } - - void tearDown() { - delete eventLoop_; - delete boostIOServiceThread_; - } - - void testDestructor() { - { - boost::shared_ptr<BoostConnection> testling(new BoostConnection(&boostIOServiceThread_->getIOService())); - testling->connect(HostAddressPort(HostAddress(address, 4), 5222)); - } - } - - void testDestructor_PendingEvents() { - { - boost::shared_ptr<BoostConnection> testling(new BoostConnection(&boostIOServiceThread_->getIOService())); - testling->connect(HostAddressPort(HostAddress(address, 4), 5222)); - while (!eventLoop_->hasEvents()) { - Swift::sleep(10); - } - } - eventLoop_->processEvents(); - } - - void testWrite() { - boost::shared_ptr<BoostConnection> testling(new BoostConnection(&boostIOServiceThread_->getIOService())); - 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)); - while (receivedData.isEmpty()) { - Swift::sleep(10); - eventLoop_->processEvents(); - } - testling->disconnect(); - } - - void doWrite(BoostConnection* connection) { - connection->write(ByteArray("<stream:stream>")); - } - - void handleDataRead(const ByteArray& data) { - receivedData += data; - } - - void handleDisconnected() { - disconnected = true; - } - - private: - BoostIOServiceThread* boostIOServiceThread_; - DummyEventLoop* eventLoop_; - ByteArray receivedData; - bool disconnected; -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(BoostConnectionTest); diff --git a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp b/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp deleted file mode 100644 index 09837d6..0000000 --- a/Swiften/QA/NetworkTest/DomainNameResolverTest.cpp +++ /dev/null @@ -1,168 +0,0 @@ -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/extensions/TestFactoryRegistry.h> -#include <boost/bind.hpp> - -#include "Swiften/Base/sleep.h" -#include "Swiften/Base/String.h" -#include "Swiften/Base/ByteArray.h" -#include "Swiften/Network/PlatformDomainNameResolver.h" -#include "Swiften/Network/DomainNameAddressQuery.h" -#include "Swiften/Network/DomainNameServiceQuery.h" -#include "Swiften/EventLoop/DummyEventLoop.h" - -using namespace Swift; - -class DomainNameResolverTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(DomainNameResolverTest); - CPPUNIT_TEST(testResolveAddress); - CPPUNIT_TEST(testResolveAddress_Error); - //CPPUNIT_TEST(testResolveAddress_IPv6); - CPPUNIT_TEST(testResolveAddress_International); - CPPUNIT_TEST(testResolveAddress_Localhost); - CPPUNIT_TEST(testResolveService); - CPPUNIT_TEST(testResolveService_Error); - CPPUNIT_TEST_SUITE_END(); - - public: - DomainNameResolverTest() {} - - void setUp() { - eventLoop = new DummyEventLoop(); - resolver = new PlatformDomainNameResolver(); - resultsAvailable = false; - } - - void tearDown() { - delete resolver; - delete eventLoop; - } - - void testResolveAddress() { - boost::shared_ptr<DomainNameAddressQuery> query(createAddressQuery("xmpp.test.swift.im")); - - query->run(); - waitForResults(); - - CPPUNIT_ASSERT(!addressQueryError); - CPPUNIT_ASSERT_EQUAL(std::string("10.0.0.0"), addressQueryResult.toString()); - } - - void testResolveAddress_Error() { - boost::shared_ptr<DomainNameAddressQuery> query(createAddressQuery("invalid.test.swift.im")); - - query->run(); - waitForResults(); - - CPPUNIT_ASSERT(addressQueryError); - } - - void testResolveAddress_IPv6() { - boost::shared_ptr<DomainNameAddressQuery> query(createAddressQuery("xmpp-ipv6.test.swift.im")); - - query->run(); - waitForResults(); - - CPPUNIT_ASSERT(!addressQueryError); - CPPUNIT_ASSERT_EQUAL(std::string("0000:0000:0000:0000:0000:ffff:0a00:0104"), addressQueryResult.toString()); - } - - void testResolveAddress_International() { - boost::shared_ptr<DomainNameAddressQuery> query(createAddressQuery("tron\xc3\xa7on.test.swift.im")); - - query->run(); - waitForResults(); - - CPPUNIT_ASSERT(!addressQueryError); - CPPUNIT_ASSERT_EQUAL(std::string("10.0.0.3"), addressQueryResult.toString()); - } - - void testResolveAddress_Localhost() { - boost::shared_ptr<DomainNameAddressQuery> query(createAddressQuery("localhost")); - - query->run(); - waitForResults(); - - CPPUNIT_ASSERT(!addressQueryError); - CPPUNIT_ASSERT_EQUAL(std::string("127.0.0.1"), addressQueryResult.toString()); - } - - - void testResolveService() { - boost::shared_ptr<DomainNameServiceQuery> query(createServiceQuery("_xmpp-client._tcp.xmpp-srv.test.swift.im")); - - query->run(); - waitForResults(); - - CPPUNIT_ASSERT_EQUAL(4, static_cast<int>(serviceQueryResult.size())); - CPPUNIT_ASSERT_EQUAL(String("xmpp1.test.swift.im"), serviceQueryResult[0].hostname); - CPPUNIT_ASSERT_EQUAL(5000, serviceQueryResult[0].port); - CPPUNIT_ASSERT_EQUAL(0, serviceQueryResult[0].priority); - CPPUNIT_ASSERT_EQUAL(1, serviceQueryResult[0].weight); - CPPUNIT_ASSERT_EQUAL(String("xmpp-invalid.test.swift.im"), serviceQueryResult[1].hostname); - CPPUNIT_ASSERT_EQUAL(5000, serviceQueryResult[1].port); - CPPUNIT_ASSERT_EQUAL(1, serviceQueryResult[1].priority); - CPPUNIT_ASSERT_EQUAL(100, serviceQueryResult[1].weight); - CPPUNIT_ASSERT_EQUAL(String("xmpp3.test.swift.im"), serviceQueryResult[2].hostname); - CPPUNIT_ASSERT_EQUAL(5000, serviceQueryResult[2].port); - CPPUNIT_ASSERT_EQUAL(3, serviceQueryResult[2].priority); - CPPUNIT_ASSERT_EQUAL(100, serviceQueryResult[2].weight); - CPPUNIT_ASSERT_EQUAL(String("xmpp2.test.swift.im"), serviceQueryResult[3].hostname); - CPPUNIT_ASSERT_EQUAL(5000, serviceQueryResult[3].port); - CPPUNIT_ASSERT_EQUAL(5, serviceQueryResult[3].priority); - CPPUNIT_ASSERT_EQUAL(100, serviceQueryResult[3].weight); - } - - void testResolveService_Error() { - } - -/* - } - */ - - private: - boost::shared_ptr<DomainNameAddressQuery> createAddressQuery(const String& domain) { - boost::shared_ptr<DomainNameAddressQuery> result = resolver->createAddressQuery(domain); - result->onResult.connect(boost::bind(&DomainNameResolverTest::handleAddressQueryResult, this, _1, _2)); - return result; - } - - void handleAddressQueryResult(const HostAddress& address, boost::optional<DomainNameResolveError> error) { - addressQueryResult = address; - addressQueryError = error; - resultsAvailable = true; - } - - boost::shared_ptr<DomainNameServiceQuery> createServiceQuery(const String& domain) { - boost::shared_ptr<DomainNameServiceQuery> result = resolver->createServiceQuery(domain); - result->onResult.connect(boost::bind(&DomainNameResolverTest::handleServiceQueryResult, this, _1)); - return result; - } - - void handleServiceQueryResult(const std::vector<DomainNameServiceQuery::Result>& result) { - serviceQueryResult = result; - resultsAvailable = true; - } - - void waitForResults() { - eventLoop->processEvents(); - int ticks = 0; - while (!resultsAvailable) { - ticks++; - if (ticks > 1000) { - CPPUNIT_ASSERT(false); - } - Swift::sleep(10); - eventLoop->processEvents(); - } - } - - private: - DummyEventLoop* eventLoop; - bool resultsAvailable; - HostAddress addressQueryResult; - boost::optional<DomainNameResolveError> addressQueryError; - std::vector<DomainNameServiceQuery::Result> serviceQueryResult; - PlatformDomainNameResolver* resolver; -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(DomainNameResolverTest); diff --git a/Swiften/QA/NetworkTest/SConscript b/Swiften/QA/NetworkTest/SConscript deleted file mode 100644 index 871df39..0000000 --- a/Swiften/QA/NetworkTest/SConscript +++ /dev/null @@ -1,18 +0,0 @@ -import os - -Import("env") - -if env["TEST"] : - myenv = env.Clone() - myenv.MergeFlags(myenv["CHECKER_FLAGS"]) - myenv.MergeFlags(myenv["SWIFTEN_FLAGS"]) - myenv.MergeFlags(myenv["CPPUNIT_FLAGS"]) - myenv.MergeFlags(myenv["BOOST_FLAGS"]) - myenv.MergeFlags(myenv["LIBIDN_FLAGS"]) - - tester = myenv.Program("NetworkTest", [ - "BoostConnectionServerTest.cpp", - "BoostConnectionTest.cpp", - "DomainNameResolverTest.cpp", - ]) - myenv.Test(tester, "system") diff --git a/Swiften/QA/SConscript b/Swiften/QA/SConscript deleted file mode 100644 index ede7b39..0000000 --- a/Swiften/QA/SConscript +++ /dev/null @@ -1,4 +0,0 @@ -SConscript([ - "NetworkTest/SConscript", - "ClientTest/SConscript", - ]) |