summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/FileTransfer/UnitTest')
-rw-r--r--Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp2
-rw-r--r--Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp2
-rw-r--r--Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp4
3 files changed, 4 insertions, 4 deletions
diff --git a/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp b/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp
index d12f99e..13b73bb 100644
--- a/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/IBBSendSessionTest.cpp
@@ -5,71 +5,71 @@
*/
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <vector>
#include <boost/bind.hpp>
#include <Swiften/Base/ByteArray.h>
#include <Swiften/FileTransfer/IBBSendSession.h>
#include <Swiften/FileTransfer/ByteArrayReadBytestream.h>
#include <Swiften/Queries/IQRouter.h>
#include <Swiften/Client/DummyStanzaChannel.h>
using namespace Swift;
class IBBSendSessionTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(IBBSendSessionTest);
CPPUNIT_TEST(testStart);
CPPUNIT_TEST(testStart_ResponseStartsSending);
CPPUNIT_TEST(testResponseContinuesSending);
CPPUNIT_TEST(testRespondToAllFinishes);
CPPUNIT_TEST(testErrorResponseFinishesWithError);
CPPUNIT_TEST(testStopDuringSessionCloses);
CPPUNIT_TEST(testStopAfterFinishedDoesNotClose);
CPPUNIT_TEST(testDataStreamPauseStopsSendingData);
CPPUNIT_TEST(testDataStreamResumeAfterPauseSendsData);
CPPUNIT_TEST(testDataStreamResumeBeforePauseDoesNotSendData);
CPPUNIT_TEST(testDataStreamResumeAfterResumeDoesNotSendData);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
stanzaChannel = new DummyStanzaChannel();
iqRouter = new IQRouter(stanzaChannel);
- bytestream = boost::shared_ptr<ByteArrayReadBytestream>(new ByteArrayReadBytestream(createByteArray("abcdefg")));
+ bytestream = boost::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg"));
finished = false;
}
void tearDown() {
delete iqRouter;
delete stanzaChannel;
}
void testStart() {
boost::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz");
testling->setBlockSize(1234);
testling->start();
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(stanzaChannel->sentStanzas.size()));
CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<IBB>(0, JID("foo@bar.com/baz"), IQ::Set));
IBB::ref ibb = stanzaChannel->sentStanzas[0]->getPayload<IBB>();
CPPUNIT_ASSERT_EQUAL(IBB::Open, ibb->getAction());
CPPUNIT_ASSERT_EQUAL(1234, ibb->getBlockSize());
CPPUNIT_ASSERT_EQUAL(std::string("myid"), ibb->getStreamID());
}
void testStart_ResponseStartsSending() {
boost::shared_ptr<IBBSendSession> testling = createSession("foo@bar.com/baz");
testling->setBlockSize(3);
testling->start();
stanzaChannel->onIQReceived(createIBBResult());
CPPUNIT_ASSERT_EQUAL(2, static_cast<int>(stanzaChannel->sentStanzas.size()));
CPPUNIT_ASSERT(stanzaChannel->isRequestAtIndex<IBB>(1, JID("foo@bar.com/baz"), IQ::Set));
IBB::ref ibb = stanzaChannel->sentStanzas[1]->getPayload<IBB>();
CPPUNIT_ASSERT_EQUAL(IBB::Data, ibb->getAction());
CPPUNIT_ASSERT(createByteArray("abc") == ibb->getData());
CPPUNIT_ASSERT_EQUAL(0, ibb->getSequenceNumber());
diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
index 527e0ca..bb0d9b6 100644
--- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamClientSessionTest.cpp
@@ -25,71 +25,71 @@
#include <Swiften/FileTransfer/ByteArrayReadBytestream.h>
#include <Swiften/FileTransfer/ByteArrayWriteBytestream.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamClientSession.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamRegistry.h>
#include <Swiften/JID/JID.h>
#include <Swiften/Network/DummyConnection.h>
#include <Swiften/Network/DummyTimerFactory.h>
#include <Swiften/StringCodecs/Hexify.h>
using namespace Swift;
boost::mt19937 randomGen;
class SOCKS5BytestreamClientSessionTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(SOCKS5BytestreamClientSessionTest);
CPPUNIT_TEST(testForSessionReady);
CPPUNIT_TEST(testErrorHandlingHello);
CPPUNIT_TEST(testErrorHandlingRequest);
CPPUNIT_TEST(testWriteBytestream);
CPPUNIT_TEST(testReadBytestream);
CPPUNIT_TEST_SUITE_END();
const HostAddressPort destinationAddressPort;
const std::string destination;
public:
SOCKS5BytestreamClientSessionTest() : destinationAddressPort(HostAddressPort(HostAddress("127.0.0.1"), 8888)),
destination(SOCKS5BytestreamRegistry::getHostname("foo", JID("requester@example.com/test"), JID("target@example.com/test"))), eventLoop(NULL), timerFactory(NULL) { }
void setUp() {
randomGen.seed(time(NULL));
eventLoop = new DummyEventLoop();
timerFactory = new DummyTimerFactory();
connection = boost::make_shared<MockeryConnection>(failingPorts, true, eventLoop);
//connection->onDataSent.connect(boost::bind(&SOCKS5BytestreamServerSessionTest::handleDataWritten, this, _1));
- //stream1 = boost::shared_ptr<ByteArrayReadBytestream>(new ByteArrayReadBytestream(createByteArray("abcdefg")));
+ //stream1 = boost::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg")));
// connection->onDataRead.connect(boost::bind(&SOCKS5BytestreamClientSessionTest::handleDataRead, this, _1));
}
void tearDown() {
//connection.reset();
delete timerFactory;
delete eventLoop;
}
void testForSessionReady() {
TestHelper helper;
connection->onDataSent.connect(boost::bind(&TestHelper::handleConnectionDataWritten, &helper, _1));
SOCKS5BytestreamClientSession::ref clientSession = boost::make_shared<SOCKS5BytestreamClientSession>(connection, destinationAddressPort, destination, timerFactory);
clientSession->onSessionReady.connect(boost::bind(&TestHelper::handleSessionReady, &helper, _1));
clientSession->start();
eventLoop->processEvents();
CPPUNIT_ASSERT(createByteArray("\x05\x01\x00", 3) == helper.unprocessedInput);
helper.unprocessedInput.clear();
serverRespondHelloOK();
eventLoop->processEvents();
CPPUNIT_ASSERT_EQUAL(createByteArray("\x05\x01\x00\x03", 4), createByteArray(&helper.unprocessedInput[0], 4));
CPPUNIT_ASSERT_EQUAL(createByteArray(destination.size()), createByteArray(helper.unprocessedInput[4]));
CPPUNIT_ASSERT_EQUAL(createByteArray(destination), createByteArray(&helper.unprocessedInput[5], destination.size()));
CPPUNIT_ASSERT_EQUAL(createByteArray("\x00", 1), createByteArray(&helper.unprocessedInput[5 + destination.size()], 1));
helper.unprocessedInput.clear();
serverRespondRequestOK();
eventLoop->processEvents();
CPPUNIT_ASSERT_EQUAL(true, helper.sessionReadyCalled);
CPPUNIT_ASSERT_EQUAL(false, helper.sessionReadyError);
}
diff --git a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp
index 4fe72c0..e6df862 100644
--- a/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp
+++ b/Swiften/FileTransfer/UnitTest/SOCKS5BytestreamServerSessionTest.cpp
@@ -3,73 +3,73 @@
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#include <Swiften/Base/ByteArray.h>
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <boost/bind.hpp>
#include <Swiften/Base/Concat.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamServerSession.h>
#include <Swiften/FileTransfer/ByteArrayReadBytestream.h>
#include <Swiften/FileTransfer/SOCKS5BytestreamRegistry.h>
#include <Swiften/Network/DummyConnection.h>
#include <Swiften/EventLoop/DummyEventLoop.h>
#include <Swiften/Base/StartStopper.h>
using namespace Swift;
class SOCKS5BytestreamServerSessionTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(SOCKS5BytestreamServerSessionTest);
CPPUNIT_TEST(testAuthenticate);
CPPUNIT_TEST(testAuthenticate_Chunked);
CPPUNIT_TEST(testRequest);
CPPUNIT_TEST(testRequest_UnknownBytestream);
CPPUNIT_TEST(testReceiveData);
CPPUNIT_TEST(testReceiveData_Chunked);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
receivedDataChunks = 0;
eventLoop = new DummyEventLoop();
bytestreams = new SOCKS5BytestreamRegistry();
- connection = boost::shared_ptr<DummyConnection>(new DummyConnection(eventLoop));
+ connection = boost::make_shared<DummyConnection>(eventLoop);
connection->onDataSent.connect(boost::bind(&SOCKS5BytestreamServerSessionTest::handleDataWritten, this, _1));
- stream1 = boost::shared_ptr<ByteArrayReadBytestream>(new ByteArrayReadBytestream(createByteArray("abcdefg")));
+ stream1 = boost::make_shared<ByteArrayReadBytestream>(createByteArray("abcdefg"));
}
void tearDown() {
connection.reset();
delete bytestreams;
delete eventLoop;
}
void testAuthenticate() {
boost::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession());
StartStopper<SOCKS5BytestreamServerSession> stopper(testling.get());
receive(createSafeByteArray("\x05\x02\x01\x02"));
CPPUNIT_ASSERT(createByteArray("\x05\x00", 2) == receivedData);
}
void testAuthenticate_Chunked() {
boost::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession());
StartStopper<SOCKS5BytestreamServerSession> stopper(testling.get());
receive(createSafeByteArray("\x05\x02\x01"));
CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(receivedData.size()));
receive(createSafeByteArray("\x01"));
CPPUNIT_ASSERT(createByteArray("\x05\x00", 2) == receivedData);
}
void testRequest() {
boost::shared_ptr<SOCKS5BytestreamServerSession> testling(createSession());
StartStopper<SOCKS5BytestreamServerSession> stopper(testling.get());
bytestreams->addReadBytestream("abcdef", stream1);
authenticate();
ByteArray hostname(createByteArray("abcdef"));