Avoid deprecated ndn-cxx functions

Change-Id: Ib9220786a724327b89dcc328c8f34a5c8fe1fdd9
diff --git a/tests/key-chain-fixture.cpp b/tests/key-chain-fixture.cpp
index c374fa3..c1abcf8 100644
--- a/tests/key-chain-fixture.cpp
+++ b/tests/key-chain-fixture.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2020 Regents of the University of California.
+ * Copyright (c) 2013-2022 Regents of the University of California.
  *
  * This file is part of NDNS (Named Data Networking Domain Name Service).
  * See AUTHORS.md for complete list of NDNS authors and contributors.
@@ -55,7 +55,7 @@
   cert.setFreshnessPeriod(1_h);
 
   // set content
-  cert.setContent(key.getPublicKey().data(), key.getPublicKey().size());
+  cert.setContent(key.getPublicKey());
 
   // set signature info
   ndn::SignatureInfo info;
diff --git a/tests/unit/daemon/name-server.t.cpp b/tests/unit/daemon/name-server.t.cpp
index 8ca796d..a0ec0f5 100644
--- a/tests/unit/daemon/name-server.t.cpp
+++ b/tests/unit/daemon/name-server.t.cpp
@@ -177,13 +177,12 @@
   str = "ns2.ndnsim.net";
   re.addRr(makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size()));
 
-  shared_ptr<Data> data = re.toData();
+  auto data = re.toData();
   m_keyChain.sign(*data, security::signingByCertificate(m_cert));
 
   Query q(Name(zone), ndns::label::NDNS_ITERATIVE_QUERY);
-  const Block& block = data->wireEncode();
   Name name;
-  name.append(block);
+  name.append(ndn::tlv::GenericNameComponent, data->wireEncode());
 
   q.setRrLabel(name);
   q.setRrType(label::NDNS_UPDATE_LABEL);
@@ -228,13 +227,12 @@
   str = "ns2.ndnsim.net";
   re.addRr(makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size()));
 
-  shared_ptr<Data> data = re.toData();
+  auto data = re.toData();
   m_keyChain.sign(*data, security::signingByCertificate(m_cert));
 
   Query q(Name(zone), ndns::label::NDNS_ITERATIVE_QUERY);
-  const Block& block = data->wireEncode();
   Name name;
-  name.append(block);
+  name.append(ndn::tlv::GenericNameComponent, data->wireEncode());
 
   q.setRrLabel(name);
   q.setRrType(label::NDNS_UPDATE_LABEL);
@@ -279,7 +277,7 @@
   dskCert.setName(dskCertName);
   dskCert.setContentType(ndn::tlv::ContentType_Key);
   dskCert.setFreshnessPeriod(time::hours(1));
-  dskCert.setContent(dsk.getPublicKey().data(), dsk.getPublicKey().size());
+  dskCert.setContent(dsk.getPublicKey());
   SignatureInfo info;
   info.setValidityPeriod(security::ValidityPeriod(time::system_clock::now(),
                                                   time::system_clock::now() + time::days(365)));
@@ -313,13 +311,12 @@
   str = "ns2.ndnsim.net";
   re.addRr(makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size()));
 
-  shared_ptr<Data> data = re.toData();
+  auto data = re.toData();
   m_keyChain.sign(*data, security::signingByCertificate(dskCert));
 
   Query q(Name(zone), ndns::label::NDNS_ITERATIVE_QUERY);
-  const Block& block = data->wireEncode();
   Name name;
-  name.append(block);
+  name.append(ndn::tlv::GenericNameComponent, data->wireEncode());
 
   q.setRrLabel(name);
   q.setRrType(label::NDNS_UPDATE_LABEL);
@@ -353,11 +350,8 @@
 
     validatorFace.onSendInterest.connect([this] (const Interest& interest) {
       NDNS_LOG_TRACE("validatorFace get Interest: " << interest.getName());
-
-      shared_ptr<const Interest> i = interest.shared_from_this();
-      io.post([i, this] {
-          face.receive(*i);
-        });
+      auto i = interest.shared_from_this();
+      io.post([i, this] { face.receive(*i); });
     });
   }
 
@@ -391,13 +385,12 @@
   str = "ns2.ndnsim.net";
   re.addRr(makeBinaryBlock(ndns::tlv::RrData, str.c_str(), str.size()));
 
-  shared_ptr<Data> data = re.toData();
+  auto data = re.toData();
   m_keyChain.sign(*data, security::signingByCertificate(m_cert));
 
   Query q(Name(zone), ndns::label::NDNS_ITERATIVE_QUERY);
-  const Block& block = data->wireEncode();
   Name name;
-  name.append(block);
+  name.append(ndn::tlv::GenericNameComponent, data->wireEncode());
 
   q.setRrLabel(name);
   q.setRrType(label::NDNS_UPDATE_LABEL);
@@ -426,7 +419,7 @@
       block.parse();
       int ret = -1;
       BOOST_CHECK_EQUAL(block.type(), ndns::tlv::RrData);
-      Block::element_const_iterator val = block.elements_begin();
+      auto val = block.elements_begin();
       BOOST_CHECK_EQUAL(val->type(), ndns::tlv::UpdateReturnCode); // the first must be return code
       ret = readNonNegativeInteger(*val);
       BOOST_CHECK_EQUAL(ret, 0);
diff --git a/tests/unit/mgmt/management-tool.t.cpp b/tests/unit/mgmt/management-tool.t.cpp
index db2eaa0..97282d1 100644
--- a/tests/unit/mgmt/management-tool.t.cpp
+++ b/tests/unit/mgmt/management-tool.t.cpp
@@ -201,7 +201,6 @@
       }
     }
     NDN_THROW(Error("Certificate not found in keyChain"));
-    return rtn;
   }
 
   Certificate
@@ -1038,7 +1037,7 @@
   using security::transform::streamSink;
   using security::transform::bufferSource;
 
-  bufferSource(rrset1.getData().wire(), rrset1.getData().size()) >> base64Encode() >> streamSink(os);
+  bufferSource(rrset1.getData()) >> base64Encode() >> streamSink(os);
 
   std::string expectedValue = os.str();