util: Add helper method to load/save object from/to file.

Change-Id: I7417bbf85865e15c02e5dec170265bcdd3f2bae4
diff --git a/tests/util/test-io.cpp b/tests/util/test-io.cpp
new file mode 100644
index 0000000..acbdc38
--- /dev/null
+++ b/tests/util/test-io.cpp
@@ -0,0 +1,36 @@
+/**
+ * Copyright (C) 2013 Regents of the University of California.
+ * See COPYING for copyright and distribution information.
+ */
+
+#include <boost/test/unit_test.hpp>
+
+#include "util/io.hpp"
+#include "security/key-chain.hpp"
+
+namespace ndn {
+
+BOOST_AUTO_TEST_SUITE(TestIO)
+
+BOOST_AUTO_TEST_CASE (Basic)
+{
+  KeyChainImpl<SecPublicInfoSqlite3, SecTpmFile> keychain;
+
+  Name identity("/TestIO/Basic/" + boost::lexical_cast<std::string>(time::now()));
+  Name certName;
+  BOOST_REQUIRE_NO_THROW(certName = keychain.createIdentity(identity));
+  shared_ptr<IdentityCertificate> idCert;
+  BOOST_REQUIRE_NO_THROW(idCert = keychain.getCertificate(certName));
+
+  std::string file("/tmp/TestIO-Basic");
+  io::save(*idCert, file);
+  shared_ptr<IdentityCertificate> readCert = io::load<IdentityCertificate>(file);
+
+  BOOST_CHECK(static_cast<bool>(readCert));
+  BOOST_CHECK(idCert->getName() == readCert->getName());
+  keychain.deleteIdentity(identity);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace ndn