face: reserved FaceIds and NullFace

refs #1620, #1622

Change-Id: I315ae262c7e0813a64b69d3e7d67de61b7b88c55
diff --git a/tests/daemon/face/null.cpp b/tests/daemon/face/null.cpp
new file mode 100644
index 0000000..db90410
--- /dev/null
+++ b/tests/daemon/face/null.cpp
@@ -0,0 +1,51 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014,  Regents of the University of California,
+ *                      Arizona Board of Regents,
+ *                      Colorado State University,
+ *                      University Pierre & Marie Curie, Sorbonne University,
+ *                      Washington University in St. Louis,
+ *                      Beijing Institute of Technology,
+ *                      The University of Memphis
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "face/null-face.hpp"
+
+#include "tests/test-common.hpp"
+
+namespace nfd {
+namespace tests {
+
+BOOST_FIXTURE_TEST_SUITE(FaceNull, BaseFixture)
+
+BOOST_AUTO_TEST_CASE(Send)
+{
+  shared_ptr<NullFace> face = make_shared<NullFace>();
+
+  shared_ptr<Interest> interest = makeInterest("/A");
+  BOOST_CHECK_NO_THROW(face->sendInterest(*interest));
+
+  shared_ptr<Data> data = makeData("/B");
+  BOOST_CHECK_NO_THROW(face->sendData(*data));
+
+  BOOST_CHECK_NO_THROW(face->close());
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace tests
+} // namespace nfd
diff --git a/tests/daemon/fw/face-table.cpp b/tests/daemon/fw/face-table.cpp
index 3f49525..0dd8432 100644
--- a/tests/daemon/fw/face-table.cpp
+++ b/tests/daemon/fw/face-table.cpp
@@ -1,11 +1,12 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014  Regents of the University of California,
- *                     Arizona Board of Regents,
- *                     Colorado State University,
- *                     University Pierre & Marie Curie, Sorbonne University,
- *                     Washington University in St. Louis,
- *                     Beijing Institute of Technology
+ * Copyright (c) 2014,  Regents of the University of California,
+ *                      Arizona Board of Regents,
+ *                      Colorado State University,
+ *                      University Pierre & Marie Curie, Sorbonne University,
+ *                      Washington University in St. Louis,
+ *                      Beijing Institute of Technology,
+ *                      The University of Memphis
  *
  * This file is part of NFD (Named Data Networking Forwarding Daemon).
  * See AUTHORS.md for complete list of NFD authors and contributors.
@@ -20,7 +21,7 @@
  *
  * You should have received a copy of the GNU General Public License along with
  * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- **/
+ */
 
 #include "fw/face-table.hpp"
 #include "fw/forwarder.hpp"
@@ -61,6 +62,8 @@
   BOOST_CHECK_NE(face1->getId(), INVALID_FACEID);
   BOOST_CHECK_NE(face2->getId(), INVALID_FACEID);
   BOOST_CHECK_NE(face1->getId(), face2->getId());
+  BOOST_CHECK_GT(face1->getId(), FACEID_RESERVED_MAX);
+  BOOST_CHECK_GT(face2->getId(), FACEID_RESERVED_MAX);
 
   FaceId oldId1 = face1->getId();
   faceTable.add(face1);
@@ -79,6 +82,18 @@
   BOOST_CHECK_EQUAL(onRemoveHistory[0], onAddHistory[0]);
 }
 
+BOOST_AUTO_TEST_CASE(AddReserved)
+{
+  Forwarder forwarder;
+  FaceTable& faceTable = forwarder.getFaceTable();
+
+  shared_ptr<Face> face1 = make_shared<DummyFace>();
+  BOOST_CHECK_EQUAL(face1->getId(), INVALID_FACEID);
+
+  faceTable.addReserved(face1, 5);
+  BOOST_CHECK_EQUAL(face1->getId(), 5);
+}
+
 BOOST_AUTO_TEST_CASE(Enumerate)
 {
   Forwarder forwarder;
diff --git a/tests/daemon/mgmt/face-manager.cpp b/tests/daemon/mgmt/face-manager.cpp
index 92ec987..602db76 100644
--- a/tests/daemon/mgmt/face-manager.cpp
+++ b/tests/daemon/mgmt/face-manager.cpp
@@ -1587,13 +1587,13 @@
 
   ControlParameters resultParameters;
   resultParameters.setUri("dummy://");
-  resultParameters.setFaceId(1);
+  resultParameters.setFaceId(FACEID_RESERVED_MAX + 1);
 
   shared_ptr<DummyFace> dummy(make_shared<DummyFace>());
 
   ndn::nfd::FaceEventNotification expectedFaceEvent;
   expectedFaceEvent.setKind(ndn::nfd::FACE_EVENT_CREATED)
-                   .setFaceId(1)
+                   .setFaceId(FACEID_RESERVED_MAX + 1)
                    .setRemoteUri(dummy->getRemoteUri().toString())
                    .setLocalUri(dummy->getLocalUri().toString())
                    .setFlags(0);