From d6c35d1d27126165d9f73b324fbb1052b1ff21d4 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Fri, 7 Dec 2012 21:03:51 +0000
Subject: Add more steps to the BOSH unit tests for resource binding.

Change-Id: I6c3dfe548b1e0a4ccba0dd834447e5fa40e397d6

diff --git a/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp b/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp
index 7a2f0e6..23f1a3c 100644
--- a/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp
+++ b/Swiften/Network/UnitTest/BOSHConnectionPoolTest.cpp
@@ -274,6 +274,24 @@ class BOSHConnectionPoolTest : public CppUnit::TestFixture {
 			eventLoop->processEvents();
 			CPPUNIT_ASSERT_EQUAL(st(3), boshDataWritten.size());
 			CPPUNIT_ASSERT_EQUAL(st(1), connectionFactory->connections.size());
+
+			testling->restartStream();
+			eventLoop->processEvents();
+			CPPUNIT_ASSERT_EQUAL(st(4), boshDataWritten.size());
+			CPPUNIT_ASSERT_EQUAL(st(1), connectionFactory->connections.size());
+
+			response = "<body xmpp:version='1.0' xmlns:stream='http://etherx.jabber.org/streams' xmlns:xmpp='urn:xmpp:xbosh' inactivity='60' wait='60' polling='5' secure='true' hold='1' from='prosody.doomsong.co.uk' ver='1.6' sid='743da605-4c2e-4de1-afac-ac040dd4a940' requests='2' xmlns='http://jabber.org/protocol/httpbind'><stream:features><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><required/></bind><session xmlns='urn:ietf:params:xml:ns:xmpp-session'><optional/></session><sm xmlns='urn:xmpp:sm:2'><optional/></sm></stream:features></body>";
+			readResponse(response, connectionFactory->connections[0]);
+			eventLoop->processEvents();
+			CPPUNIT_ASSERT_EQUAL(st(5), boshDataWritten.size()); /* Now we've authed (restarted) we should be keeping one query in flight so the server can reply to us at any time it wants. */
+			CPPUNIT_ASSERT_EQUAL(st(1), connectionFactory->connections.size());
+
+			send = "<body rid='2821988967416214' sid='cf663f6b94279d4f' xmlns='http://jabber.org/protocol/httpbind'><iq id='session-bind' type='set'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>d5a9744036cd20a0</resource></bind></iq></body>";
+			testling->write(createSafeByteArray(send));
+			eventLoop->processEvents();
+			CPPUNIT_ASSERT_EQUAL(st(6), boshDataWritten.size());
+			CPPUNIT_ASSERT_EQUAL(st(2), connectionFactory->connections.size()); /* and as it keeps one in flight, it's needed to open a second to send these data */
+
 		}
 
 		void testWrite_Empty() {
-- 
cgit v0.10.2-6-g49f6