#include "ccnx-tunnel.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(CcnxTunnelTests)

class DummyTunnel : public CcnxTunnel
{
public:
  DummyTunnel();
  virtual ~DummyTunnel() {}

  virtual Name
  queryRoutableName(const Name &name);

  void
  overridePrefix();

};

DummyTunnel::DummyTunnel() : CcnxTunnel()
{
  m_localPrefix = Name("/local");
}

void
DummyTunnel::overridePrefix()
{
  CcnxWrapper::setInterestFilter(m_localPrefix, bind(&DummyTunnel::handleTunneledInterest, this, _1));
}

Name
DummyTunnel::queryRoutableName (const Name &name)
{
  return Name("/local") + name;
}

CcnxWrapperPtr t1(new DummyTunnel());
CcnxWrapperPtr t2(new DummyTunnel());
CcnxWrapperPtr c1(new CcnxWrapper());

DummyTunnel t3;

// global data callback counter;
int g_dc_i = 0;
int g_dc_o = 0;
int g_ic = 0;

void innerCallback(const Name &name, const Bytes &content)
{
  g_dc_i ++;
  string str((const char *)&content[0], content.size());
  BOOST_CHECK_EQUAL(name, str);
}

void outerCallback(const Name &name, const Bytes &content)
{
  g_dc_o ++;
}

void interestCallback(const Name &name)
{
  string strName = name.toString();
  t3.publishData(name, (const unsigned char *)strName.c_str(), strName.size(), 5);
  g_ic++;
}

BOOST_AUTO_TEST_CASE (CcnxTunnelTest)
{
  // test publish
  string inner = "/hello";

  g_dc_o = 0;
  t1->publishData(Name(inner), (const unsigned char *)inner.c_str(), inner.size(), 5);
  usleep(100000);

  c1->sendInterest(Name("/local/hello"), Closure(bind(outerCallback, _1, _2)));
  usleep(100000);
  // it is indeed published as /local/hello
  BOOST_CHECK_EQUAL(g_dc_o, 1);

  g_dc_i = 0;
  t2->sendInterest(Name(inner), Closure(bind(innerCallback, _1, _2)));
  usleep(100000);
  BOOST_CHECK_EQUAL(g_dc_i, 1);
}

BOOST_AUTO_TEST_CASE (CcnxTunnelRegister)
{

  g_ic = 0;
  g_dc_i = 0;
  t3.overridePrefix();
  t3.setInterestFilter(Name("/t3"), bind(interestCallback, _1));
  usleep(100000);
  Closure innerClosure (bind(innerCallback, _1, _2));
  t1->sendInterest(Name("/t3/hello"), innerClosure);
  usleep(100000);
  BOOST_CHECK_EQUAL(g_dc_i, 1);
  BOOST_CHECK_EQUAL(g_ic, 1);

  t3.clearInterestFilter(Name("/t3"));
  usleep(100000);
  t1->sendInterest(Name("/t3/hello-there"), innerClosure);
  usleep(100000);
  BOOST_CHECK_EQUAL(g_dc_i, 1);
  BOOST_CHECK_EQUAL(g_ic, 1);

}


BOOST_AUTO_TEST_SUITE_END()
