diff options
author | Remko Tronçon <git@el-tramo.be> | 2010-04-07 19:26:45 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2010-04-07 19:26:45 (GMT) |
commit | 7ad73a099f4e3e55cbafd004df3eb8d4007efb20 (patch) | |
tree | bc9b6317cdd53e209223b2b28d5286165d474d97 /Swiften/Network/UnitTest | |
parent | 39e4547f396b6a21ec4ceb2f28c003c4011229a7 (diff) | |
parent | 2086abd85c97ee4e03f6d7b266076c6607012243 (diff) | |
download | swift-contrib-7ad73a099f4e3e55cbafd004df3eb8d4007efb20.zip swift-contrib-7ad73a099f4e3e55cbafd004df3eb8d4007efb20.tar.bz2 |
Merge branch 'case-305'
Diffstat (limited to 'Swiften/Network/UnitTest')
-rw-r--r-- | Swiften/Network/UnitTest/ConnectorTest.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/Swiften/Network/UnitTest/ConnectorTest.cpp b/Swiften/Network/UnitTest/ConnectorTest.cpp index 663011c..2a2ab41 100644 --- a/Swiften/Network/UnitTest/ConnectorTest.cpp +++ b/Swiften/Network/UnitTest/ConnectorTest.cpp @@ -18,6 +18,7 @@ using namespace Swift; class ConnectorTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(ConnectorTest); CPPUNIT_TEST(testConnect); + CPPUNIT_TEST(testConnect_FirstAddressHostFails); CPPUNIT_TEST(testConnect_NoSRVHost); CPPUNIT_TEST(testConnect_NoHosts); CPPUNIT_TEST(testConnect_FirstSRVHostFails); @@ -73,6 +74,24 @@ class ConnectorTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(host3 == *(connections[0]->hostAddressPort)); } + void testConnect_FirstAddressHostFails() { + std::auto_ptr<Connector> testling(createConnector()); + + HostAddress address1("1.1.1.1"); + HostAddress address2("2.2.2.2"); + resolver->addXMPPClientService("foo.com", "host-foo.com", 1234); + resolver->addAddress("host-foo.com", address1); + resolver->addAddress("host-foo.com", address2); + connectionFactory->failingPorts.push_back(HostAddressPort(address1, 1234)); + + testling->start(); + eventLoop->processEvents(); + + CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(connections.size())); + CPPUNIT_ASSERT(connections[0]); + CPPUNIT_ASSERT(HostAddressPort(address2, 1234) == *(connections[0]->hostAddressPort)); + } + void testConnect_NoHosts() { std::auto_ptr<Connector> testling(createConnector()); @@ -207,7 +226,8 @@ class ConnectorTest : public CppUnit::TestFixture { void connect(const HostAddressPort& address) { hostAddressPort = address; if (isResponsive) { - MainEventLoop::postEvent(boost::bind(boost::ref(onConnectFinished), std::find(failingPorts.begin(), failingPorts.end(), address) != failingPorts.end())); + bool fail = std::find(failingPorts.begin(), failingPorts.end(), address) != failingPorts.end(); + MainEventLoop::postEvent(boost::bind(boost::ref(onConnectFinished), fail)); } } |