api-changes: Use ndn-cpp-dev

Change-Id: I4540e601106598d51601e59e5fe9524a9080a572
diff --git a/test/endorse-certificate-test.cc b/test/endorse-certificate-test.cc
deleted file mode 100644
index 23075e3..0000000
--- a/test/endorse-certificate-test.cc
+++ /dev/null
@@ -1,115 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/**
- * Copyright (C) 2013 Regents of the University of California.
- * @author: Yingdi Yu <yingdi@cs.ucla.edu>
- * See COPYING for copyright and distribution information.
- */
-
-#if __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wreorder"
-#pragma clang diagnostic ignored "-Wtautological-compare"
-#pragma clang diagnostic ignored "-Wunused-variable"
-#pragma clang diagnostic ignored "-Wunused-function"
-#elif __GNUC__
-#pragma GCC diagnostic ignored "-Wreorder"
-#pragma GCC diagnostic ignored "-Wunused-variable"
-#pragma GCC diagnostic ignored "-Wunused-function"
-#endif
-
-#include <boost/test/unit_test.hpp>
-
-#include <iostream>
-#include <iomanip>
-#include <cryptopp/base64.h>
-#include <ndn-cpp/security/key-chain.hpp>
-#include "endorse-certificate.h"
-
-using namespace ndn;
-using namespace ndn::ptr_lib;
-using namespace std;
-
-BOOST_AUTO_TEST_SUITE(EndorseCertificateTests)
-
-const string aliceCert("BIICqgOyEIUBbIk+NUYUb6QYOBmPyWrhj9WiEKgoAzXAjQ+gz6iAmeX4srvcH3dQ\
-a/Y1H4Vf/LmNrXUsqbEJn1tmGoxGoQlkMtuKZ9K9X40R2SbH8d01IOIHILodRdG3\
-KXlsXS13vBkuGB8RwhMCh3RCBc6K10LQ87TkkpLdYpIjS8n2stQn2HgiHPsIUGyE\
-yLXqJ8ght2ZLVUYzHcpW4D0asckiQGXJuFmkGnbQVNHEBuirY8R1Zak6uDopoZi1\
-xvFCH6UkUXBzh3FhXrk/GA5Y6sZTKTDqo1fwz6GRubyhPq1+nHOM7ud5k4DoC6zI\
-Xstlhi5LSrCInSBItBaSNd2RPO3dbp0QAADy+p1uZG4A+sV1Y2xhLmVkdQD6nUtF\
-WQD6rWFsaWNlAPr1a3NrLTEzODI5MzQyMDEA+r1JRC1DRVJUAPrN/f/////ea6GX\
-AAABogPiAoX4UXq6YdztiNp79l71bcPBOBnRKOJBPKxDZTeC3YrfSgACurUFJt5r\
-oZgAAeIB6vL6nW5kbgD6xXVjbGEuZWR1APqdS0VZAPr1ZHNrLTEzODI5MzQyMDAA\
-+r1JRC1DRVJUAAAAAAABmhfdMIIBdzAiGA8yMDEzMTAyODAwMDAwMFoYDzIwMzMx\
-MDI4MDAwMDAwWjArMCkGA1UEKRMiL25kbi91Y2xhLmVkdS9hbGljZS9rc2stMTM4\
-MjkzNDIwMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJ9b5S6MJIDz\
-EyYDYL6/1PeeM1ZIr9lyDJojyLBa/nxvCkTykdeUEIEsQb0+B5UDcyS9iGZRlBUf\
-CXOjRlnbo5BtD0IWw2aR048RT3pDh2U+dsOsJQMdPwTAaegwv+BEBvWVX+A93xya\
-qoYQcJF56q6ktvxfFj5c4G6vuuuf8ZSGbIeesXy1P5wYdSu1ceTL8mnawR0+Nj2D\
-VG71gn1A9NiIBKKQcT0rUgxo3NOaPHBUdQP67qLdfBOj0HrktGndVDxD5pWbnxKU\
-V3zd/aD1DJuP826RJ8b/7eftdIF7/8gVRN5fz3wbjFtNzAE5RLmXP+ik8MhnHMx+\
-B2QkdwR+8gcCAwEAAQAA");
-
-KeyChain keyChain;
-
-BOOST_AUTO_TEST_CASE(ProfileDataEncodeDecode)
-{
-  string decoded;
-  CryptoPP::StringSource ss(reinterpret_cast<const unsigned char *>(aliceCert.c_str()), 
-                            aliceCert.size(), 
-                            true,
-                            new CryptoPP::Base64Decoder(new CryptoPP::StringSink(decoded)));
-  Data data;
-  data.wireDecode(Block(decoded.c_str(), decoded.size()));
-  IdentityCertificate identityCertificate(data);
-  
-  Profile profile(identityCertificate);
-  ProfileData profileData(profile);
-
-  Name certificateName = keyChain.getDefaultCertificateName();
-  keyChain.sign(profileData, certificateName);
-
-  const Block& profileDataBlock = profileData.wireEncode();
-  Data decodedProfileData;
-  
-  decodedProfileData.wireDecode(profileDataBlock);
-  ProfileData decodedProfile(decodedProfileData);
-  BOOST_CHECK_EQUAL(decodedProfile.getProfile().getProfileEntry("IDENTITY"), string("/ndn/ucla.edu/alice"));
-  BOOST_CHECK_EQUAL(decodedProfile.getProfile().getProfileEntry("name"), string("/ndn/ucla.edu/alice/ksk-1382934201"));
-}
-
-BOOST_AUTO_TEST_CASE(EndorseCertifiicateEncodeDecode)
-{
-  string decoded;
-  CryptoPP::StringSource ss(reinterpret_cast<const unsigned char *>(aliceCert.c_str()), 
-                            aliceCert.size(), 
-                            true,
-                            new CryptoPP::Base64Decoder(new CryptoPP::StringSink(decoded)));
-  Data data;
-  data.wireDecode(Block(decoded.c_str(), decoded.size()));
-  IdentityCertificate identityCertificate(data);
-
-  Profile profile(identityCertificate);
-  ProfileData profileData(profile);
-  
-  Name certificateName = keyChain.getDefaultCertificateName();
-  keyChain.sign(profileData, certificateName);
-
-  EndorseCertificate endorseCertificate(identityCertificate, profileData);
-
-  keyChain.sign(endorseCertificate, certificateName);
-  
-  const Block& endorseDataBlock = endorseCertificate.wireEncode();
-
-  Data decodedEndorseData;
-
-  decodedEndorseData.wireDecode(endorseDataBlock);
-  EndorseCertificate decodedEndorse(decodedEndorseData);
-  BOOST_CHECK_EQUAL(decodedEndorse.getProfileData().getProfile().getProfileEntry("IDENTITY"), string("/ndn/ucla.edu/alice"));
-  BOOST_CHECK_EQUAL(decodedEndorse.getProfileData().getProfile().getProfileEntry("name"), string("/ndn/ucla.edu/alice/ksk-1382934201"));
-}
-
-
-
-BOOST_AUTO_TEST_SUITE_END()
-
diff --git a/test/main.cc b/test/main.cc
new file mode 100644
index 0000000..6b0a14a
--- /dev/null
+++ b/test/main.cc
@@ -0,0 +1,13 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2013, Regents of the University of California
+ *
+ * BSD license, See the LICENSE file for more information
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ */
+
+#define BOOST_TEST_MAIN 1
+#define BOOST_TEST_DYN_LINK 1
+
+#include <boost/test/unit_test.hpp>
diff --git a/test/profile-test.cc b/test/profile-test.cc
deleted file mode 100644
index b50f024..0000000
--- a/test/profile-test.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/**
- * Copyright (C) 2013 Regents of the University of California.
- * @author: Yingdi Yu <yingdi@cs.ucla.edu>
- * See COPYING for copyright and distribution information.
- */
-
-#include <profile.h>
-
-#define BOOST_TEST_MODULE ChronoChat
-#include <boost/test/unit_test.hpp>
-
-using namespace ndn;
-using namespace std;
-
-BOOST_AUTO_TEST_SUITE(ProfileTests)
-
-BOOST_AUTO_TEST_CASE(WriteRead)
-{
-  Name identity("/ndn/ucla/yingdi");
-  Profile profile(identity);
-  profile.setProfileEntry(string("name"), string("Yingdi Yu"));
-  profile.setProfileEntry(string("school"), string("UCLA"));
-
-  string encoded;
-  profile.encode(&encoded);
-
-  ptr_lib::shared_ptr<Profile> decodedProfile = Profile::decode(encoded);
-  
-  BOOST_CHECK_EQUAL(decodedProfile->getIdentityName().toUri(), string("/ndn/ucla/yingdi"));
-  BOOST_CHECK_EQUAL(decodedProfile->getProfileEntry(string("name")), string("Yingdi Yu"));
-  BOOST_CHECK_EQUAL(decodedProfile->getProfileEntry(string("school")), string("UCLA"));
-}
-
-BOOST_AUTO_TEST_SUITE_END()
diff --git a/test/test-endorse-certificate.cc b/test/test-endorse-certificate.cc
new file mode 100644
index 0000000..14dda41
--- /dev/null
+++ b/test/test-endorse-certificate.cc
@@ -0,0 +1,93 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/**
+ * Copyright (C) 2013 Regents of the University of California.
+ * @author: Yingdi Yu <yingdi@cs.ucla.edu>
+ * See COPYING for copyright and distribution information.
+ */
+
+#if __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wtautological-compare"
+#pragma clang diagnostic ignored "-Wunused-function"
+#elif __GNUC__
+#pragma GCC diagnostic ignored "-Wunused-function"
+#endif
+
+#include <boost/test/unit_test.hpp>
+
+#include <cryptopp/base64.h>
+#include <ndn-cpp-dev/security/key-chain.hpp>
+#include <ndn-cpp-dev/util/time.hpp>
+#include "endorse-certificate.h"
+
+using namespace ndn;
+using namespace std;
+using namespace chronos;
+
+BOOST_AUTO_TEST_SUITE(TestEndorseCertificate)
+
+const string testCert("Av0DgANRBBdFbmRvcnNlQ2VydGlmaWNhdGVUZXN0cwQMRW5jb2RlRGVjb2RlBANL\
+RVkEEWtzay0xMzkxNzM0NzY0MzE2BAdJRC1DRVJUBAf9AUQJ9fu/EAMUAQIR/QHP\
+MIIByzAiGA8yMDE0MDEwMTAwMDAwMFoYDzIwMTUwMTAxMDAwMDAwWjB/MCwGA1UE\
+KRMlL0VuZG9yc2VDZXJ0aWZpY2F0ZVRlc3RzL0VuY29kZURlY29kZTASBgkqhkiG\
+9w0BCQETBWFAYi5jMAoGA1UECxMDbmRuMA4GA1UEARMHdWNsYSBjczATBgNVBAMT\
+DGh0dHA6Ly9hLmIuYzAKBgNVBFATA25kbjCCASIwDQYJKoZIhvcNAQEBBQADggEP\
+ADCCAQoCggEBALX3RJhGUUQp+i6nJRMWgCbCxxrpmSOGlUfLNAFQh/zizdFdpG0O\
++fjI82ilUzOsi4KnCBxpEez+tEMFzRTOFaLYj6bGQhTKhMsDb/d5mtjjKRBE69+R\
+H4IC9rUsD+pD/qh4lEZwoxz74DmsbAL4sCXyNLOTJFAokKpD5GB5/enwkMyC8425\
+seQXCZw/rlhpeIZkh19ULOvq4GXPk6fVPW/HsnReNa2J8toQepoh5nk1KAZjc/ed\
+GdegTAn4rBUH65chfoztBMli7sE9BJMkVf0OHSXTbRGqGSR/u0uOs+F69QisS+du\
+xyEZJFqJGOv7ZROo9C6cRZFpCJH+pjLen00CAwEAARJPFgEBF0oDSAQXRW5kb3Jz\
+ZUNlcnRpZmljYXRlVGVzdHMEDEVuY29kZURlY29kZQQDS0VZBBFrc2stMTM5MTcz\
+NDc2NDMxNgQHSUQtQ0VSVBP9AQBOUc/C6yrGQ9A3FYlwklNz9WrK7FhvkMmynugY\
+Ejasc6rVeMgigCIwgLau+bnIbO0rfMLSGdrvB/XSiWFzZSt1fQj/uJ29he+tIBf+\
+B5tP0MJL5hFNtSxgHgMCXkSRl9cC356GPpEcG+vMCoYMQLILukXfTwhP8qUB/hoy\
+5/1OxXMUAFnU2EoX90DJYvpVlD6nZt04okLVBUpNJSODEzFJrNbgpapzkb4djGol\
+6uRDV8iGhMfFtCmf+ZtcXyr49uBF2npqwgz01lTnXAB6jExD+EQ9rxospGkMgKVz\
+camQA/xj3G2PdPylszVO6qfv2clQxr9atW2Vt1BeI1ZtFbd/");
+
+KeyChain keyChain;
+
+BOOST_AUTO_TEST_CASE(EncodeDecode)
+{
+  string decoded;
+  CryptoPP::StringSource ss(reinterpret_cast<const uint8_t*>(testCert.c_str()), 
+                            testCert.size(), true,
+                            new CryptoPP::Base64Decoder(new CryptoPP::StringSink(decoded)));
+  Data data;
+  data.wireDecode(Block(decoded.c_str(), decoded.size()));
+  IdentityCertificate identityCertificate(data);
+
+  Profile profile(identityCertificate);
+  vector<string> endorseList;
+  endorseList.push_back("email");
+  endorseList.push_back("homepage");
+
+  EndorseCertificate endorseCertificate(identityCertificate, profile, endorseList);
+
+  KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keyChain;
+  Name signingIdentity("/EndorseCertificateTests/EncodeDecode/"+boost::lexical_cast<string>(time::now()));
+  keyChain.createIdentity(signingIdentity);
+
+  keyChain.signByIdentity(endorseCertificate, signingIdentity);
+  
+  const Block& endorseDataBlock = endorseCertificate.wireEncode();
+
+  Data decodedEndorseData;
+
+  decodedEndorseData.wireDecode(endorseDataBlock);
+  EndorseCertificate decodedEndorse(decodedEndorseData);
+  BOOST_CHECK_EQUAL(decodedEndorse.getProfile().get("IDENTITY"), "/EndorseCertificateTests/EncodeDecode");
+  BOOST_CHECK_EQUAL(decodedEndorse.getProfile().get("name"), "/EndorseCertificateTests/EncodeDecode");
+  BOOST_CHECK_EQUAL(decodedEndorse.getProfile().get("homepage"), "http://a.b.c");
+  BOOST_CHECK_EQUAL(decodedEndorse.getEndorseList().size(), 2);
+  BOOST_CHECK_EQUAL(decodedEndorse.getEndorseList().at(0), "email");
+  BOOST_CHECK_EQUAL(decodedEndorse.getEndorseList().at(1), "homepage");
+
+  keyChain.deleteIdentity(signingIdentity);
+}
+
+
+
+BOOST_AUTO_TEST_SUITE_END()
+
diff --git a/test/test-profile.cc b/test/test-profile.cc
new file mode 100644
index 0000000..56b7d4b
--- /dev/null
+++ b/test/test-profile.cc
@@ -0,0 +1,73 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
+/**
+ * Copyright (C) 2013 Regents of the University of California.
+ * @author: Yingdi Yu <yingdi@cs.ucla.edu>
+ * See COPYING for copyright and distribution information.
+ */
+
+#include <boost/test/unit_test.hpp>
+
+#include "profile-data.h"
+#include <ndn-cpp-dev/security/key-chain.hpp>
+#include <ndn-cpp-dev/util/time.hpp>
+
+using namespace ndn;
+using namespace std;
+using namespace chronos;
+
+BOOST_AUTO_TEST_SUITE(TestProfile)
+
+BOOST_AUTO_TEST_CASE(EncodeDecodeProfile)
+{
+  Name identity("/ndn/ucla/yingdi");
+  Profile profile(identity);
+  profile["name"] = "Yingdi Yu";
+  profile["school"] = "UCLA";
+
+  OBufferStream os;
+  profile.encode(os);
+
+  shared_ptr<Buffer> encoded = os.buf();
+  
+  boost::iostreams::stream
+    <boost::iostreams::array_source> is (reinterpret_cast<const char*>(encoded->buf ()), encoded->size ());
+
+  Profile decodedProfile; 
+  decodedProfile.decode(is);
+  
+  BOOST_CHECK_EQUAL(decodedProfile.getIdentityName().toUri(), string("/ndn/ucla/yingdi"));
+  BOOST_CHECK_EQUAL(decodedProfile["name"], string("Yingdi Yu"));
+  BOOST_CHECK_EQUAL(decodedProfile["school"], string("UCLA"));
+}
+
+BOOST_AUTO_TEST_CASE(EncodeDecodeProfileData)
+{
+  Name identity("/ndn/ucla/yingdi");
+  Profile profile(identity);
+  profile["name"] = "Yingdi Yu";
+  profile["school"] = "UCLA";
+
+  ProfileData profileData(profile);
+  
+  KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keyChain;
+  Name signingIdentity("/EncodeDecodeProfile/EncodeDecodeProfileData");
+  keyChain.createIdentity(signingIdentity);
+  keyChain.signByIdentity(profileData, signingIdentity);
+
+  Block encodedBlock = profileData.wireEncode();
+
+  Data decodedData;
+  decodedData.wireDecode(encodedBlock);
+  
+  ProfileData decodedProfileData(decodedData);
+  Profile decodedProfile = decodedProfileData.getProfile();
+
+  BOOST_CHECK_EQUAL(profileData.getIdentityName(), string("/ndn/ucla/yingdi"));
+  BOOST_CHECK_EQUAL(decodedProfile["name"], string("Yingdi Yu"));
+  BOOST_CHECK_EQUAL(decodedProfile["school"], string("UCLA"));
+  
+  keyChain.deleteIdentity(signingIdentity);
+}
+
+
+BOOST_AUTO_TEST_SUITE_END()