Merge remote-tracking branch 'origin/master'
diff --git a/include/ccnx-name.h b/include/ccnx-name.h
index 59e34a5..7c5447b 100644
--- a/include/ccnx-name.h
+++ b/include/ccnx-name.h
@@ -71,10 +71,10 @@
   operator=(const Name &other);
 
   bool
-  operator==(const string &str);
+  operator==(const string &str) const;
 
   bool
-  operator!=(const string &str);
+  operator!=(const string &str) const;
 
   friend Name
   operator+(const Name &n1, const Name &n2);
diff --git a/src/ccnx-name.cpp b/src/ccnx-name.cpp
index ce5f270..748410f 100644
--- a/src/ccnx-name.cpp
+++ b/src/ccnx-name.cpp
@@ -37,8 +37,15 @@
 {
   stringstream ss(name);
   string compStr;
+  bool first = true;
   while(getline(ss, compStr, '/'))
   {
+    // discard the first empty comp before the first '/'
+    if (first)
+    {
+      first = false;
+      continue;
+    }
     Bytes comp(compStr.begin(), compStr.end());
     m_comps.push_back(comp);
   }
@@ -74,13 +81,13 @@
   return *this;
 }
 bool
-Name::operator==(const string &str)
+Name::operator==(const string &str) const
 {
   return this->toString() == str;
 }
 
 bool
-Name::operator!=(const string &str)
+Name::operator!=(const string &str) const
 {
   return !(*this == str);
 }
diff --git a/src/ccnx-wrapper.cpp b/src/ccnx-wrapper.cpp
index ac65cba..78e9ac7 100644
--- a/src/ccnx-wrapper.cpp
+++ b/src/ccnx-wrapper.cpp
@@ -49,10 +49,10 @@
 CcnxWrapper::connectCcnd()
 {
   UniqueRecLock(m_mutex);
-  if (m_handle != 0) {
-    ccn_disconnect (m_handle);
-    ccn_destroy (&m_handle);
-  }
+  //if (m_handle != 0) {
+    //ccn_disconnect (m_handle);
+    //ccn_destroy (&m_handle);
+  //}
 
   m_handle = ccn_create ();
   if (ccn_connect(m_handle, NULL) < 0)
@@ -61,14 +61,14 @@
   }
   m_connected = true;
 
-  if (!m_registeredInterests.empty())
-  {
-    for (map<Name, InterestCallback>::const_iterator it = m_registeredInterests.begin(); it != m_registeredInterests.end(); ++it)
-    {
+  //if (!m_registeredInterests.empty())
+  //{
+   // for (map<Name, InterestCallback>::const_iterator it = m_registeredInterests.begin(); it != m_registeredInterests.end(); ++it)
+    //{
       // clearInterestFilter(it->first);
-      setInterestFilter(it->first, it->second);
-    }
-  }
+     // setInterestFilter(it->first, it->second);
+    //}
+  //}
 }
 
 CcnxWrapper::~CcnxWrapper()
diff --git a/test/test-ccnx-name.cc b/test/test-ccnx-name.cc
index abab747..5084246 100644
--- a/test/test-ccnx-name.cc
+++ b/test/test-ccnx-name.cc
@@ -2,8 +2,6 @@
 #include "ccnx-name.h"
 
 #define BOOST_TEST_MAIN 1
-// #define BOOST_TEST_DYN_LINK
-// #define BOOST_TEST_Module Main
 
 #include <boost/test/unit_test.hpp>
 
@@ -18,11 +16,27 @@
   Name empty = Name();
   Name root = Name("/");
   BOOST_CHECK_EQUAL(empty, root);
+  BOOST_CHECK_EQUAL(empty, "/");
+  BOOST_CHECK_EQUAL(root.size(), 0);
+  empty.appendComp("hello");
+  empty.appendComp("world");
+  BOOST_CHECK_EQUAL(empty.size(), 2);
+  BOOST_CHECK_EQUAL(empty.toString(), "/hello/world");
+  empty = empty + root;
+  BOOST_CHECK_EQUAL(empty.toString(), "/hello/world");
+  BOOST_CHECK_EQUAL(empty.getCompAsString(0), "hello");
+  BOOST_CHECK_EQUAL(empty.getPartialName(1, 1), Name("/world"));
+  Name name("/hello/world");
+  BOOST_CHECK_EQUAL(empty, name);
+  BOOST_CHECK_EQUAL(name, Name("/hello") + Name("/world"));
+
+  // Charbuf related stuff will be checked in other place
 }
 
 BOOST_AUTO_TEST_CASE (SelectorsTest)
 {
-  int i = 0;
+  Selectors s;
+  BOOST_CHECK(s.isEmpty());
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/test/test-ccnx-wrapper.cc b/test/test-ccnx-wrapper.cc
new file mode 100644
index 0000000..4fe58d7
--- /dev/null
+++ b/test/test-ccnx-wrapper.cc
@@ -0,0 +1,60 @@
+#include "ccnx-wrapper.h"
+#include "ccnx-closure.h"
+#include "ccnx-name.h"
+#include "ccnx-pco.h"
+#include <unistd.h>
+
+#include <boost/test/unit_test.hpp>
+
+
+using namespace Ccnx;
+using namespace std;
+using namespace boost;
+
+BOOST_AUTO_TEST_SUITE(CcnxWrapperTests)
+
+CcnxWrapperPtr c1(new CcnxWrapper());
+CcnxWrapperPtr c2(new CcnxWrapper());
+
+void publish1(const Name &name)
+{
+  string content = name.toString();
+  c1->publishData(name, (const unsigned char*)content.c_str(), content.size(), 5);
+}
+
+void publish2(const Name &name)
+{
+  string content = name.toString();
+  c2->publishData(name, (const unsigned char*)content.c_str(), content.size(), 5);
+}
+
+void dataCallback(const Name &name, const Bytes &content)
+{
+  string msg((const char*)&content[0], content.size());
+  BOOST_CHECK_EQUAL(name, msg);
+}
+
+Closure::TimeoutCallbackReturnValue timeout(const Name &name)
+{
+  cout << "Timeout: "<< name;
+  return Closure::RESULT_OK;
+}
+
+BOOST_AUTO_TEST_CASE (CcnxWrapperTest)
+{
+  Name prefix1("/c1");
+  Name prefix2("/c2");
+
+  c1->setInterestFilter(prefix1, bind(publish1, _1));
+  c2->setInterestFilter(prefix2, bind(publish2, _1));
+
+  Closure *closure = new Closure(1, bind(dataCallback, _1, _2), bind(timeout, _1));
+
+  c1->sendInterest(Name("/c2/hi"), closure);
+  usleep(100000);
+  c2->sendInterest(Name("/c1/hi"), closure);
+  sleep(100000);
+  delete closure;
+}
+
+BOOST_AUTO_TEST_SUITE_END()