Avoid deprecated Boost.Asio interfaces
Change-Id: I7041c89ea9147e08c8b6226b84a6d17dddeed0e1
diff --git a/tests/integrated/command-fixture.cpp b/tests/integrated/command-fixture.cpp
deleted file mode 100644
index 28990e3..0000000
--- a/tests/integrated/command-fixture.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2014-2022, Regents of the University of California.
- *
- * This file is part of NDN repo-ng (Next generation of NDN repository).
- * See AUTHORS.md for complete list of repo-ng authors and contributors.
- *
- * repo-ng is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * repo-ng is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * repo-ng, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "command-fixture.hpp"
-
-namespace repo::tests {
-
-CommandFixture::CommandFixture()
- : scheduler(repoFace.getIoService())
- , keyChain(m_keyChain)
- , dispatcher(repoFace, keyChain)
- , validator(repoFace)
-{
- this->addIdentity("/ndn/test/repo");
- this->saveIdentityCertificate("/ndn/test/repo", "tests/integrated/insert-delete-test.cert");
- validator.load("tests/integrated/insert-delete-validator-config.conf");
-}
-
-} // namespace repo::tests
diff --git a/tests/integrated/command-fixture.hpp b/tests/integrated/command-fixture.hpp
index 6d4aa44..507a9f1 100644
--- a/tests/integrated/command-fixture.hpp
+++ b/tests/integrated/command-fixture.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California.
+ * Copyright (c) 2014-2023, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
@@ -30,15 +30,19 @@
class CommandFixture : public virtual IdentityManagementFixture
{
protected:
- CommandFixture();
+ CommandFixture()
+ {
+ addIdentity("/ndn/test/repo");
+ saveIdentityCertificate("/ndn/test/repo", "tests/integrated/insert-delete-test.cert");
+ validator.load("tests/integrated/insert-delete-validator-config.conf");
+ }
protected:
Face repoFace;
- Scheduler scheduler;
- ndn::KeyChain& keyChain;
- ndn::mgmt::Dispatcher dispatcher;
+ Scheduler scheduler{repoFace.getIoContext()};
+ ndn::mgmt::Dispatcher dispatcher{repoFace, m_keyChain};
/// \todo #4091 switch to ValidatorPolicyConf and load insert-delete-validator-config.conf
- ndn::security::ValidatorConfig validator;
+ ndn::security::ValidatorConfig validator{repoFace};
};
} // namespace repo::tests
diff --git a/tests/integrated/test-basic-command-insert-delete.cpp b/tests/integrated/test-basic-command-insert-delete.cpp
index 0f868eb..f1a9110 100644
--- a/tests/integrated/test-basic-command-insert-delete.cpp
+++ b/tests/integrated/test-basic-command-insert-delete.cpp
@@ -50,9 +50,9 @@
Fixture()
: writeHandle(repoFace, *handle, dispatcher, scheduler, validator)
, deleteHandle(repoFace, *handle, dispatcher, scheduler, validator)
- , insertFace(repoFace.getIoService())
- , deleteFace(repoFace.getIoService())
- , signer(keyChain)
+ , insertFace(repoFace.getIoContext())
+ , deleteFace(repoFace.getIoContext())
+ , signer(m_keyChain)
{
Name cmdPrefix("/repo/command");
repoFace.registerPrefix(cmdPrefix, nullptr,
@@ -114,11 +114,11 @@
void
Fixture<T>::onInsertInterest(const Interest& interest)
{
- Data data(Name(interest.getName()));
+ Data data(interest.getName());
data.setContent(CONTENT);
- data.setFreshnessPeriod(0_ms);
- keyChain.sign(data);
+ m_keyChain.sign(data);
insertFace.put(data);
+
auto eventIt = insertEvents.find(interest.getName());
if (eventIt != insertEvents.end()) {
eventIt->second.cancel();
diff --git a/tests/integrated/test-basic-interest-read.cpp b/tests/integrated/test-basic-interest-read.cpp
index 81ceb98..c2b6a17 100644
--- a/tests/integrated/test-basic-interest-read.cpp
+++ b/tests/integrated/test-basic-interest-read.cpp
@@ -38,15 +38,15 @@
{
public:
BasicInterestReadFixture()
- : scheduler(repoFace.getIoService())
+ : scheduler(repoFace.getIoContext())
, readHandle(repoFace, *handle, 0)
- , readFace(repoFace.getIoService())
+ , readFace(repoFace.getIoContext())
{
}
~BasicInterestReadFixture()
{
- repoFace.getIoService().stop();
+ repoFace.getIoContext().stop();
}
void
diff --git a/tests/unit/read-handle.t.cpp b/tests/unit/read-handle.t.cpp
index 9d36b18..553f651 100644
--- a/tests/unit/read-handle.t.cpp
+++ b/tests/unit/read-handle.t.cpp
@@ -44,7 +44,7 @@
public:
Fixture()
: face({true, true})
- , scheduler(face.getIoService())
+ , scheduler(face.getIoContext())
, subsetLength(1)
, dataPrefix("/ndn/test/prefix")
, identity("/ndn/test/identity")
diff --git a/tests/unit/tcp-bulk-insert-handle.cpp b/tests/unit/tcp-bulk-insert-handle.cpp
index 9c0398b..e227167 100644
--- a/tests/unit/tcp-bulk-insert-handle.cpp
+++ b/tests/unit/tcp-bulk-insert-handle.cpp
@@ -18,10 +18,11 @@
*/
#include "handles/tcp-bulk-insert-handle.hpp"
-#include "storage/sqlite-storage.hpp"
+
#include "../repo-storage-fixture.hpp"
#include "../dataset-fixtures.hpp"
+#include <boost/asio/ip/tcp.hpp>
#include <boost/test/unit_test.hpp>
namespace repo::tests {
@@ -34,28 +35,21 @@
void
start(const std::string& host, const std::string& port)
{
- using namespace boost::asio;
-
- ip::tcp::resolver resolver(ioCtx);
- ip::tcp::resolver::query query(host, port);
-
- ip::tcp::resolver::iterator endpoint = resolver.resolve(query);
- ip::tcp::resolver::iterator end;
-
- if (endpoint == end)
+ boost::asio::ip::tcp::resolver resolver(ioCtx);
+ boost::system::error_code ec;
+ auto results = resolver.resolve(host, port, ec);
+ if (ec) {
BOOST_FAIL("Cannot resolve [" + host + ":" + port + "]");
+ }
- ip::tcp::endpoint serverEndpoint = *endpoint;
-
- socket.async_connect(serverEndpoint,
- std::bind(&TcpClient::onSuccessfullConnect, this, _1));
+ socket.async_connect(*results.begin(), std::bind(&TcpClient::handleConnect, this, _1));
}
virtual void
- onSuccessfullConnect(const boost::system::error_code& error)
+ handleConnect(const boost::system::error_code& error)
{
if (error) {
- BOOST_FAIL("TCP connection aborted");
+ BOOST_FAIL("TCP connection failed");
}
}
@@ -78,9 +72,9 @@
}
void
- onSuccessfullConnect(const boost::system::error_code& error) override
+ handleConnect(const boost::system::error_code& error) override
{
- TcpClient::onSuccessfullConnect(error);
+ TcpClient::handleConnect(error);
// This value may need to be adjusted if some dataset exceeds 100k
socket.set_option(boost::asio::socket_base::send_buffer_size(100000));