get rid of publisher and fetcher
modify SyncAppSocket API
modify SyncLogic API
Tweak SeqNo
diff --git a/test/test_app_socket.cc b/test/test_app_socket.cc
index 3e4394e..8a3f864 100644
--- a/test/test_app_socket.cc
+++ b/test/test_app_socket.cc
@@ -49,6 +49,19 @@
// cout << str1 << ", " << str2 << endl;
}
+ void fetchAll(vector<MissingDataInfo> &v, SyncAppSocket *socket) {
+ int n = v.size();
+ for (int i = 0; i < n; i++) {
+ SeqNo s = ++v[i].low;
+ for(; s <= v[i].high; ++s) {
+ socket->fetchString(v[i].prefix, s, bind(&TestSocketApp::set, this, _1, _2));
+ }
+ }
+ }
+
+ void pass(const string &prefix) {
+ }
+
string toString(){
map<string, string>::iterator it = data.begin();
string str = "\n";
@@ -76,18 +89,18 @@
string p1("/irl.cs.ucla.edu"), p2("/yakshi.org"), p3("/google.com");
_LOG_DEBUG ("s1");
- SyncAppSocket s1 (syncPrefix, bind(&TestSocketApp::set, &a1, _1, _2));
+ SyncAppSocket s1 (syncPrefix, bind(&TestSocketApp::fetchAll, &a1, _1, _2), bind(&TestSocketApp::pass, &a1, _1));
this_thread::sleep (posix_time::milliseconds (50));
_LOG_DEBUG ("s2");
- SyncAppSocket s2 (syncPrefix, bind(&TestSocketApp::set, &a2, _1, _2));
+ SyncAppSocket s2 (syncPrefix, bind(&TestSocketApp::fetchAll, &a2, _1, _2), bind(&TestSocketApp::pass, &a2, _1));
this_thread::sleep (posix_time::milliseconds (50));
- SyncAppSocket s3 (syncPrefix, bind(&TestSocketApp::set, &a3, _1, _2));
+ SyncAppSocket s3 (syncPrefix, bind(&TestSocketApp::fetchAll, &a3, _1, _2), bind(&TestSocketApp::pass, &a3, _1));
this_thread::sleep (posix_time::milliseconds (50));
// single source
string data0 = "Very funny Scotty, now beam down my clothes";
_LOG_DEBUG ("s1 publish");
- s1.publish (p1, 0, data0, 10);
+ s1.publishString (p1, 0, data0, 10);
this_thread::sleep (posix_time::milliseconds (120));
// from code logic, we won't be fetching our own data
@@ -100,9 +113,9 @@
string data2 = "Don't look conspicuous, it draws fire";
_LOG_DEBUG ("s1 publish");
- s1.publish (p1, 0, data1, 10);
+ s1.publishString (p1, 0, data1, 10);
_LOG_DEBUG ("s1 publish");
- s1.publish (p1, 0, data2, 10);
+ s1.publishString (p1, 0, data2, 10);
this_thread::sleep (posix_time::milliseconds (1000));
// from code logic, we won't be fetching our own data
@@ -116,12 +129,12 @@
string data4 = "I got a fortune cookie once that said 'You like Chinese food'";
string data5 = "Real men wear pink. Why? Because their wives make them";
_LOG_DEBUG ("s3 publish");
- s3.publish(p3, 0, data3, 10);
+ s3.publishString(p3, 0, data3, 10);
this_thread::sleep (posix_time::milliseconds (200));
// another single source, multiple data at once
- s2.publish(p2, 0, data4, 10);
- s2.publish(p2, 0, data5, 10);
+ s2.publishString(p2, 0, data4, 10);
+ s2.publishString(p2, 0, data5, 10);
this_thread::sleep (posix_time::milliseconds (1000));
// from code logic, we won't be fetching our own data
@@ -135,9 +148,9 @@
_LOG_DEBUG ("Simultaneous publishing");
string data6 = "Shakespeare says: 'Prose before hos.'";
string data7 = "Pick good people, talent never wears out";
- s1.publish(p1, 0, data6, 10);
+ s1.publishString(p1, 0, data6, 10);
// this_thread::sleep (posix_time::milliseconds (1000));
- s2.publish(p2, 0, data7, 10);
+ s2.publishString(p2, 0, data7, 10);
this_thread::sleep (posix_time::milliseconds (1500));
// from code logic, we won't be fetching our own data
diff --git a/test/test_ccnx_wrapper.cc b/test/test_ccnx_wrapper.cc
index 6934584..3db44ba 100644
--- a/test/test_ccnx_wrapper.cc
+++ b/test/test_ccnx_wrapper.cc
@@ -62,7 +62,7 @@
this_thread::sleep (posix_time::milliseconds (10));
string interest = "/ucla.edu/0";
- hb.sendInterest(interest, memberFunc);
+ hb.sendInterestForString(interest, memberFunc);
// give time for ccnd to react
sleep(1);
@@ -71,9 +71,9 @@
string name = "/ucla.edu/0";
string data = "random bits: !#$!@#$!";
- ha.publishData(name, data, 5);
+ ha.publishStringData(name, data, 5);
- hb.sendInterest(interest, memberFunc);
+ hb.sendInterestForString(interest, memberFunc);
// give time for ccnd to react
this_thread::sleep (posix_time::milliseconds (5));
diff --git a/test/test_data_fetch_and_publish.cc b/test/test_data_fetch_and_publish.cc
index 157ce7f..e75b274 100644
--- a/test/test_data_fetch_and_publish.cc
+++ b/test/test_data_fetch_and_publish.cc
@@ -20,6 +20,7 @@
* Alexander Afanasyev <alexander.afanasyev@ucla.edu>
*/
+/*
#include <boost/test/unit_test.hpp>
#include <boost/test/output_test_stream.hpp>
#include <map>
@@ -71,7 +72,7 @@
string str[5] = {"panda", "express", "tastes", "so", "good"};
for (int i = 0; i < 5; i++) {
- foo.set(interest + "/" + "0/" /*session*/ + seq[i], str[i]);
+ foo.set(interest + "/" + "0/" + seq[i], str[i]);
}
boost::function<void (string, string)> setFunc =
@@ -107,5 +108,6 @@
BOOST_CHECK_EQUAL(poo.toString(), bar.toString());
}
+*/
diff --git a/test/test_sync_logic.cc b/test/test_sync_logic.cc
index f6b6808..0d77cd0 100644
--- a/test/test_sync_logic.cc
+++ b/test/test_sync_logic.cc
@@ -43,7 +43,14 @@
: instance (_instance)
{
}
-
+
+ void wrapper (vector<MissingDataInfo> &v) {
+ int n = v.size();
+ for (int i = 0; i < n; i++) {
+ onUpdate (v[i].prefix, v[i].high, v[i].low);
+ }
+ }
+
void onUpdate (const string &p/*prefix*/, const SeqNo &seq/*newSeq*/, const SeqNo &oldSeq/*oldSeq*/)
{
m_map[p] = seq.getSeq ();
@@ -68,7 +75,7 @@
{
Handler h1 ("1");
- SyncLogic l1 ("/bcast", bind (&Handler::onUpdate, &h1, _1, _2, _3), bind (&Handler::onRemove, &h1, _1));
+ SyncLogic l1 ("/bcast", bind (&Handler::wrapper, &h1, _1), bind (&Handler::onRemove, &h1, _1));
l1.addLocalNames ("/one", 1, 2);
BOOST_CHECK_EQUAL (h1.m_map.size (), 0);
@@ -76,7 +83,7 @@
BOOST_CHECK_EQUAL (h1.m_map.size (), 0);
Handler h2 ("2");
- SyncLogic l2 ("/bcast", bind (&Handler::onUpdate, &h2, _1, _2, _3), bind (&Handler::onRemove, &h2, _1));
+ SyncLogic l2 ("/bcast", bind (&Handler::wrapper, &h2, _1), bind (&Handler::onRemove, &h2, _1));
sleep (1);
BOOST_CHECK_EQUAL (h1.m_map.size (), 0);