diff options
author | Henning Baldersheim <balder@oath.com> | 2018-10-04 22:05:19 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-10-04 22:05:19 +0200 |
commit | 0bdd3c5fa4326ed4106b9aee0585d57c7193bd97 (patch) | |
tree | 2b519cf259eb30ab28d85fc560a589457f54ed17 /documentapi | |
parent | 3f2b1a9230fbab12f2e8b5afcf1e0ad72f3d872a (diff) |
Remove the costly and unnecessary setSlobrokId interface.
Diffstat (limited to 'documentapi')
-rw-r--r-- | documentapi/src/tests/policyfactory/policyfactory.cpp | 16 | ||||
-rw-r--r-- | documentapi/src/tests/routablefactory/routablefactory.cpp | 16 |
2 files changed, 16 insertions, 16 deletions
diff --git a/documentapi/src/tests/policyfactory/policyfactory.cpp b/documentapi/src/tests/policyfactory/policyfactory.cpp index ef8c461ad02..41905183928 100644 --- a/documentapi/src/tests/policyfactory/policyfactory.cpp +++ b/documentapi/src/tests/policyfactory/policyfactory.cpp @@ -54,13 +54,13 @@ public: mbus::IRoutingPolicy::UP MyFactory::createPolicy(const string ¶m) const { - return mbus::IRoutingPolicy::UP(new MyPolicy(param)); + return std::make_unique<MyPolicy>(param); } mbus::Message::UP createMessage() { - mbus::Message::UP ret(new RemoveDocumentMessage(document::DocumentId("doc:scheme:"))); + auto ret = std::make_unique<RemoveDocumentMessage>(document::DocumentId("doc:scheme:")); ret->getTrace().setLevel(9); return ret; } @@ -82,27 +82,27 @@ Test::Main() mbus::Slobrok slobrok; LoadTypeSet loadTypes; mbus::TestServer - srv(mbus::MessageBusParams().addProtocol(mbus::IProtocol::SP(new DocumentProtocol(loadTypes, repo))), - mbus::RPCNetworkParams().setSlobrokConfig(slobrok.config())); + srv(mbus::MessageBusParams().addProtocol(std::make_shared<DocumentProtocol>(loadTypes, repo)), + mbus::RPCNetworkParams(slobrok.config())); mbus::Receptor handler; mbus::SourceSession::UP src = srv.mb.createSourceSession(mbus::SourceSessionParams().setReplyHandler(handler)); mbus::Route route = mbus::Route::parse("[MyPolicy]"); ASSERT_TRUE(src->send(createMessage(), route).isAccepted()); mbus::Reply::UP reply = static_cast<mbus::Receptor&>(src->getReplyHandler()).getReply(600); - ASSERT_TRUE(reply.get() != NULL); + ASSERT_TRUE(reply); fprintf(stderr, "%s", reply->getTrace().toString().c_str()); EXPECT_EQUAL(1u, reply->getNumErrors()); EXPECT_EQUAL((uint32_t)mbus::ErrorCode::UNKNOWN_POLICY, reply->getError(0).getCode()); mbus::IProtocol * obj = srv.mb.getProtocol(DocumentProtocol::NAME); DocumentProtocol * protocol = dynamic_cast<DocumentProtocol*>(obj); - ASSERT_TRUE(protocol != NULL); - protocol->putRoutingPolicyFactory("MyPolicy", IRoutingPolicyFactory::SP(new MyFactory())); + ASSERT_TRUE(protocol != nullptr); + protocol->putRoutingPolicyFactory("MyPolicy", std::make_shared<MyFactory>()); ASSERT_TRUE(src->send(createMessage(), route).isAccepted()); reply = static_cast<mbus::Receptor&>(src->getReplyHandler()).getReply(600); - ASSERT_TRUE(reply.get() != NULL); + ASSERT_TRUE(reply); fprintf(stderr, "%s", reply->getTrace().toString().c_str()); EXPECT_EQUAL(1u, reply->getNumErrors()); EXPECT_EQUAL((uint32_t)DocumentProtocol::ERROR_POLICY_FAILURE, reply->getError(0).getCode()); diff --git a/documentapi/src/tests/routablefactory/routablefactory.cpp b/documentapi/src/tests/routablefactory/routablefactory.cpp index 63d37de8c65..13ebd45fdc6 100644 --- a/documentapi/src/tests/routablefactory/routablefactory.cpp +++ b/documentapi/src/tests/routablefactory/routablefactory.cpp @@ -114,32 +114,32 @@ public: TEST_APPHOOK(Test); TestData::TestData() : - _repo(new DocumentTypeRepo), + _repo(std::make_shared<DocumentTypeRepo>()), _slobrok(), _loadTypes(), - _srcProtocol(new DocumentProtocol(_loadTypes, _repo)), + _srcProtocol(std::make_shared<DocumentProtocol>(_loadTypes, _repo)), _srcServer(mbus::MessageBusParams().addProtocol(_srcProtocol), - mbus::RPCNetworkParams().setSlobrokConfig(_slobrok.config())), + mbus::RPCNetworkParams(_slobrok.config())), _srcSession(), _srcHandler(), - _dstProtocol(new DocumentProtocol(_loadTypes, _repo)), + _dstProtocol(std::make_shared<DocumentProtocol>(_loadTypes, _repo)), _dstServer(mbus::MessageBusParams().addProtocol(_dstProtocol), - mbus::RPCNetworkParams().setIdentity(mbus::Identity("dst")).setSlobrokConfig(_slobrok.config())), + mbus::RPCNetworkParams(_slobrok.config()).setIdentity(mbus::Identity("dst"))), _dstSession(), _dstHandler() { } -TestData::~TestData() {} +TestData::~TestData() = default; bool TestData::start() { _srcSession = _srcServer.mb.createSourceSession(mbus::SourceSessionParams().setReplyHandler(_srcHandler)); - if (_srcSession.get() == NULL) { + if ( ! _srcSession) { return false; } _dstSession = _dstServer.mb.createDestinationSession(mbus::DestinationSessionParams().setName("session").setMessageHandler(_dstHandler)); - if (_dstSession.get() == NULL) { + if ( ! _dstSession) { return false; } if (!_srcServer.waitSlobrok("dst/session", 1u)) { |