summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2012-03-20 00:05:55 (GMT)
committerRemko Tronçon <git@el-tramo.be>2012-03-20 19:13:43 (GMT)
commit3d6694b0c698fff63d11f8bb4aa995c1df882315 (patch)
treea46ccace647f23a65100cf69c951345aa6dea7ab /Swiften/Client/UnitTest/ClientSessionTest.cpp
parent3d27d98ccc232ae7bfacfd5a3f85f44b6c2e9cc9 (diff)
downloadswift-contrib-3d6694b0c698fff63d11f8bb4aa995c1df882315.zip
swift-contrib-3d6694b0c698fff63d11f8bb4aa995c1df882315.tar.bz2
boost::shared_ptr<?>(new ?(...)) -> boost::make_shared<?>(...) transformation where possible.
License: This patch is BSD-licensed, see http://www.opensource.org/licenses/bsd-license.php
Diffstat (limited to 'Swiften/Client/UnitTest/ClientSessionTest.cpp')
-rw-r--r--Swiften/Client/UnitTest/ClientSessionTest.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/Swiften/Client/UnitTest/ClientSessionTest.cpp b/Swiften/Client/UnitTest/ClientSessionTest.cpp
index 22db8fc..a6d5a3a 100644
--- a/Swiften/Client/UnitTest/ClientSessionTest.cpp
+++ b/Swiften/Client/UnitTest/ClientSessionTest.cpp
@@ -34,71 +34,71 @@
using namespace Swift;
class ClientSessionTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(ClientSessionTest);
CPPUNIT_TEST(testStart_Error);
CPPUNIT_TEST(testStart_StreamError);
CPPUNIT_TEST(testStartTLS);
CPPUNIT_TEST(testStartTLS_ServerError);
CPPUNIT_TEST(testStartTLS_ConnectError);
CPPUNIT_TEST(testStartTLS_InvalidIdentity);
CPPUNIT_TEST(testStart_StreamFeaturesWithoutResourceBindingFails);
CPPUNIT_TEST(testAuthenticate);
CPPUNIT_TEST(testAuthenticate_Unauthorized);
CPPUNIT_TEST(testAuthenticate_NoValidAuthMechanisms);
CPPUNIT_TEST(testAuthenticate_PLAINOverNonTLS);
CPPUNIT_TEST(testAuthenticate_RequireTLS);
CPPUNIT_TEST(testStreamManagement);
CPPUNIT_TEST(testStreamManagement_Failed);
CPPUNIT_TEST(testFinishAcksStanzas);
/*
CPPUNIT_TEST(testResourceBind);
CPPUNIT_TEST(testResourceBind_ChangeResource);
CPPUNIT_TEST(testResourceBind_EmptyResource);
CPPUNIT_TEST(testResourceBind_Error);
CPPUNIT_TEST(testSessionStart);
CPPUNIT_TEST(testSessionStart_Error);
CPPUNIT_TEST(testSessionStart_AfterResourceBind);
CPPUNIT_TEST(testWhitespacePing);
CPPUNIT_TEST(testReceiveElementAfterSessionStarted);
CPPUNIT_TEST(testSendElement);
*/
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {
- server = boost::shared_ptr<MockSessionStream>(new MockSessionStream());
+ server = boost::make_shared<MockSessionStream>();
sessionFinishedReceived = false;
needCredentials = false;
blindCertificateTrustChecker = new BlindCertificateTrustChecker();
}
void tearDown() {
delete blindCertificateTrustChecker;
}
void testStart_Error() {
boost::shared_ptr<ClientSession> session(createSession());
session->start();
server->breakConnection();
CPPUNIT_ASSERT_EQUAL(ClientSession::Finished, session->getState());
CPPUNIT_ASSERT(sessionFinishedReceived);
CPPUNIT_ASSERT(sessionFinishedError);
}
void testStart_StreamError() {
boost::shared_ptr<ClientSession> session(createSession());
session->start();
server->sendStreamStart();
server->sendStreamError();
CPPUNIT_ASSERT_EQUAL(ClientSession::Finished, session->getState());
CPPUNIT_ASSERT(sessionFinishedReceived);
CPPUNIT_ASSERT(sessionFinishedError);
}
void testStartTLS() {
boost::shared_ptr<ClientSession> session(createSession());
session->setCertificateTrustChecker(blindCertificateTrustChecker);
session->start();
server->receiveStreamStart();
@@ -388,147 +388,147 @@ class ClientSessionTest : public CppUnit::TestFixture {
}
virtual bool isTLSEncrypted() {
return tlsEncrypted;
}
virtual ByteArray getTLSFinishMessage() const {
return ByteArray();
}
virtual Certificate::ref getPeerCertificate() const {
return Certificate::ref(new SimpleCertificate());
}
virtual boost::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const {
return boost::shared_ptr<CertificateVerificationError>();
}
virtual bool supportsZLibCompression() {
return true;
}
virtual void addZLibCompression() {
compressed = true;
}
virtual void setWhitespacePingEnabled(bool enabled) {
whitespacePingEnabled = enabled;
}
virtual void resetXMPPParser() {
resetCount++;
}
void breakConnection() {
- onClosed(boost::shared_ptr<SessionStream::Error>(new SessionStream::Error(SessionStream::Error::ConnectionReadError)));
+ onClosed(boost::make_shared<SessionStream::Error>(SessionStream::Error::ConnectionReadError));
}
void breakTLS() {
- onClosed(boost::shared_ptr<SessionStream::Error>(new SessionStream::Error(SessionStream::Error::TLSError)));
+ onClosed(boost::make_shared<SessionStream::Error>(SessionStream::Error::TLSError));
}
void sendStreamStart() {
ProtocolHeader header;
header.setTo("foo.com");
return onStreamStartReceived(header);
}
void sendStreamFeaturesWithStartTLS() {
boost::shared_ptr<StreamFeatures> streamFeatures(new StreamFeatures());
streamFeatures->setHasStartTLS();
onElementReceived(streamFeatures);
}
void sendStreamError() {
onElementReceived(boost::make_shared<StreamError>());
}
void sendTLSProceed() {
- onElementReceived(boost::shared_ptr<TLSProceed>(new TLSProceed()));
+ onElementReceived(boost::make_shared<TLSProceed>());
}
void sendTLSFailure() {
- onElementReceived(boost::shared_ptr<StartTLSFailure>(new StartTLSFailure()));
+ onElementReceived(boost::make_shared<StartTLSFailure>());
}
void sendStreamFeaturesWithMultipleAuthentication() {
boost::shared_ptr<StreamFeatures> streamFeatures(new StreamFeatures());
streamFeatures->addAuthenticationMechanism("PLAIN");
streamFeatures->addAuthenticationMechanism("DIGEST-MD5");
streamFeatures->addAuthenticationMechanism("SCRAM-SHA1");
onElementReceived(streamFeatures);
}
void sendStreamFeaturesWithPLAINAuthentication() {
boost::shared_ptr<StreamFeatures> streamFeatures(new StreamFeatures());
streamFeatures->addAuthenticationMechanism("PLAIN");
onElementReceived(streamFeatures);
}
void sendStreamFeaturesWithUnknownAuthentication() {
boost::shared_ptr<StreamFeatures> streamFeatures(new StreamFeatures());
streamFeatures->addAuthenticationMechanism("UNKNOWN");
onElementReceived(streamFeatures);
}
void sendStreamFeaturesWithBindAndStreamManagement() {
boost::shared_ptr<StreamFeatures> streamFeatures(new StreamFeatures());
streamFeatures->setHasResourceBind();
streamFeatures->setHasStreamManagement();
onElementReceived(streamFeatures);
}
void sendEmptyStreamFeatures() {
onElementReceived(boost::make_shared<StreamFeatures>());
}
void sendAuthSuccess() {
- onElementReceived(boost::shared_ptr<AuthSuccess>(new AuthSuccess()));
+ onElementReceived(boost::make_shared<AuthSuccess>());
}
void sendAuthFailure() {
- onElementReceived(boost::shared_ptr<AuthFailure>(new AuthFailure()));
+ onElementReceived(boost::make_shared<AuthFailure>());
}
void sendStreamManagementEnabled() {
- onElementReceived(boost::shared_ptr<StreamManagementEnabled>(new StreamManagementEnabled()));
+ onElementReceived(boost::make_shared<StreamManagementEnabled>());
}
void sendStreamManagementFailed() {
- onElementReceived(boost::shared_ptr<StreamManagementFailed>(new StreamManagementFailed()));
+ onElementReceived(boost::make_shared<StreamManagementFailed>());
}
void sendBindResult() {
boost::shared_ptr<ResourceBind> resourceBind(new ResourceBind());
resourceBind->setJID(JID("foo@bar.com/bla"));
boost::shared_ptr<IQ> iq = IQ::createResult(JID("foo@bar.com"), bindID, resourceBind);
onElementReceived(iq);
}
void sendMessage() {
boost::shared_ptr<Message> message = boost::make_shared<Message>();
message->setTo(JID("foo@bar.com/bla"));
onElementReceived(message);
}
void receiveStreamStart() {
Event event = popEvent();
CPPUNIT_ASSERT(event.header);
}
void receiveStartTLS() {
Event event = popEvent();
CPPUNIT_ASSERT(event.element);
CPPUNIT_ASSERT(boost::dynamic_pointer_cast<StartTLSRequest>(event.element));
}
void receiveAuthRequest(const std::string& mech) {
Event event = popEvent();
CPPUNIT_ASSERT(event.element);
boost::shared_ptr<AuthRequest> request(boost::dynamic_pointer_cast<AuthRequest>(event.element));
CPPUNIT_ASSERT(request);
CPPUNIT_ASSERT_EQUAL(mech, request->getMechanism());
}
void receiveStreamManagementEnable() {
@@ -723,52 +723,52 @@ CPPUNIT_TEST_SUITE_REGISTRATION(ClientSessionTest);
boost::shared_ptr<MockSession> session(createSession("me@foo.com/Bar"));
session->onSessionStarted.connect(boost::bind(&ClientSessionTest::setSessionStarted, this));
getMockServer()->expectStreamStart();
getMockServer()->sendStreamStart();
getMockServer()->sendStreamFeaturesWithResourceBindAndSession();
getMockServer()->expectResourceBind("Bar", "session-bind");
getMockServer()->sendResourceBindResponse("me@foo.com/Bar", "session-bind");
getMockServer()->expectSessionStart("session-start");
getMockServer()->sendSessionStartResponse("session-start");
session->startSession();
processEvents();
CPPUNIT_ASSERT_EQUAL(ClientSession::SessionStarted, session->getState());
CPPUNIT_ASSERT(sessionStarted_);
}
void testWhitespacePing() {
boost::shared_ptr<MockSession> session(createSession("me@foo.com/Bar"));
getMockServer()->expectStreamStart();
getMockServer()->sendStreamStart();
getMockServer()->sendStreamFeatures();
session->startSession();
processEvents();
CPPUNIT_ASSERT(session->getWhitespacePingLayer());
}
void testReceiveElementAfterSessionStarted() {
boost::shared_ptr<MockSession> session(createSession("me@foo.com/Bar"));
getMockServer()->expectStreamStart();
getMockServer()->sendStreamStart();
getMockServer()->sendStreamFeatures();
session->startSession();
processEvents();
getMockServer()->expectMessage();
- session->sendElement(boost::shared_ptr<Message>(new Message()));
+ session->sendElement(boost::make_shared<Message>()));
}
void testSendElement() {
boost::shared_ptr<MockSession> session(createSession("me@foo.com/Bar"));
session->onElementReceived.connect(boost::bind(&ClientSessionTest::addReceivedElement, this, _1));
getMockServer()->expectStreamStart();
getMockServer()->sendStreamStart();
getMockServer()->sendStreamFeatures();
getMockServer()->sendMessage();
session->startSession();
processEvents();
CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(receivedElements_.size()));
CPPUNIT_ASSERT(boost::dynamic_pointer_cast<Message>(receivedElements_[0]));
}
#endif