add hacks to allow publishing unsigned data
This is mainly to reduce the computing overhead when serving
content object from database
Change-Id: I15dd03a496b21ab38bb1f00027eedada5282a743
diff --git a/test/test-ccnx-wrapper.cc b/test/test-ccnx-wrapper.cc
index 2b99dd3..def7876 100644
--- a/test/test-ccnx-wrapper.cc
+++ b/test/test-ccnx-wrapper.cc
@@ -55,6 +55,7 @@
void dataCallback(const Name &name, Ccnx::PcoPtr pco)
{
+ cout << " in data callback" << endl;
BytesPtr content = pco->contentPtr ();
string msg(reinterpret_cast<const char *> (head (*content)), content->size());
g_dataCallback_counter ++;
@@ -67,11 +68,36 @@
g_timeout_counter ++;
}
+void
+setup()
+{
+ if (!c1)
+ {
+ c1 = make_shared<CcnxWrapper> ();
+ }
+ if (!c2)
+ {
+ c2 = make_shared<CcnxWrapper> ();
+ }
+}
+
+void
+teardown()
+{
+ if (c1)
+ {
+ c1.reset();
+ }
+ if (c2)
+ {
+ c2.reset();
+ }
+}
+
+
BOOST_AUTO_TEST_CASE (BlaCcnxWrapperTest)
{
- c1 = make_shared<CcnxWrapper> ();
- c2 = make_shared<CcnxWrapper> ();
-
+ setup();
Name prefix1("/c1");
Name prefix2("/c2");
@@ -89,11 +115,14 @@
// reset
g_dataCallback_counter = 0;
g_timeout_counter = 0;
+
+ teardown();
}
BOOST_AUTO_TEST_CASE (CcnxWrapperSelector)
{
+ setup();
Closure closure (bind(dataCallback, _1, _2), bind(timeout, _1, _2, _3));
Selectors selectors;
@@ -120,6 +149,7 @@
g_dataCallback_counter = 0;
g_timeout_counter = 0;
+ teardown();
}
@@ -132,6 +162,7 @@
BOOST_AUTO_TEST_CASE (TestTimeout)
{
+ setup();
g_dataCallback_counter = 0;
g_timeout_counter = 0;
Closure closure (bind(dataCallback, _1, _2), bind(reexpress, _1, _2, _3));
@@ -146,37 +177,50 @@
usleep(1000);
BOOST_CHECK_EQUAL(g_dataCallback_counter, 1);
BOOST_CHECK_EQUAL(g_timeout_counter, 3);
+ teardown();
}
-BOOST_AUTO_TEST_CASE(Cleanup)
+BOOST_AUTO_TEST_CASE (TestUnsigned)
{
- c1.reset ();
- c2.reset ();
+ setup();
+ string n1 = "/xxxxxx/unsigned/01";
+ Closure closure (bind(dataCallback, _1, _2), bind(timeout, _1, _2, _3));
+
+ g_dataCallback_counter = 0;
+ c1->sendInterest(Name(n1), closure);
+ usleep(1000);
+ c2->publishUnsignedData(Name(n1), (const unsigned char *)n1.c_str(), n1.size(), 1);
+ usleep(1000);
+ BOOST_CHECK_EQUAL(g_dataCallback_counter, 1);
+ teardown();
}
-// BOOST_AUTO_TEST_CASE (CcnxWrapperSigningTest)
-// {
-// Bytes data;
-// data.resize(1024);
-// for (int i = 0; i < 1024; i++)
-// {
-// data[i] = 'm';
-// }
-// Name name("/signingtest");
+ BOOST_AUTO_TEST_CASE (CcnxWrapperUnsigningTest)
+ {
+ setup();
+ Bytes data;
+ data.resize(1024);
+ for (int i = 0; i < 1024; i++)
+ {
+ data[i] = 'm';
+ }
-// posix_time::ptime start = posix_time::second_clock::local_time();
-// for (uint64_t i = 0; i < 10000; i++)
-// {
-// Name n = name;
-// n.appendComp(i);
-// c1->publishData(n, data, 10);
-// }
-// posix_time::ptime end = posix_time::second_clock::local_time();
+ Name name("/unsigningtest");
-// posix_time::time_duration duration = end - start;
+ posix_time::ptime start = posix_time::second_clock::local_time();
+ for (uint64_t i = 0; i < 100000; i++)
+ {
+ Name n = name;
+ n.appendComp(i);
+ c1->publishUnsignedData(n, data, 10);
+ }
+ posix_time::ptime end = posix_time::second_clock::local_time();
-// cout << "Publishing 10000 1K size content objects costs " <<duration.total_milliseconds() << " milliseconds" << endl;
-// cout << "Average time to publish one content object is " << (double) duration.total_milliseconds() / 10000.0 << " milliseconds" << endl;
-// }
+ posix_time::time_duration duration = end - start;
+
+ cout << "Publishing 100000 1K size content objects costs " <<duration.total_milliseconds() << " milliseconds" << endl;
+ cout << "Average time to publish one content object is " << (double) duration.total_milliseconds() / 100000.0 << " milliseconds" << endl;
+ teardown();
+ }
BOOST_AUTO_TEST_SUITE_END()