Added test-get-async
diff --git a/Makefile.am b/Makefile.am
index 98f5be3..19e2ed8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,7 +11,7 @@
lib_LIBRARIES = libndn-c.a libndn-cpp.a
-bin_PROGRAMS = bin/test-encode-decode-Interest bin/test-encode-decode-ContentObject
+bin_PROGRAMS = bin/test-encode-decode-Interest bin/test-encode-decode-ContentObject bin/test-get-async
libndn_c_a_SOURCES = \
config.h \
@@ -53,4 +53,7 @@
bin_test_encode_decode_ContentObject_SOURCES = tests/test-encode-decode-ContentObject.cpp
bin_test_encode_decode_ContentObject_LDADD = libndn-c.a libndn-cpp.a
+bin_test_get_async_SOURCES = tests/test-get-async.cpp
+bin_test_get_async_LDADD = libndn-c.a libndn-cpp.a
+
dist_noinst_SCRIPTS = autogen.sh
diff --git a/Makefile.in b/Makefile.in
index 0c245ab..89789e7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -86,7 +86,8 @@
$(dist_noinst_SCRIPTS) depcomp COPYING ar-lib compile \
config.guess config.sub install-sh missing ltmain.sh
bin_PROGRAMS = bin/test-encode-decode-Interest$(EXEEXT) \
- bin/test-encode-decode-ContentObject$(EXEEXT)
+ bin/test-encode-decode-ContentObject$(EXEEXT) \
+ bin/test-get-async$(EXEEXT)
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.ac
@@ -169,6 +170,9 @@
bin_test_encode_decode_Interest_OBJECTS = \
$(am_bin_test_encode_decode_Interest_OBJECTS)
bin_test_encode_decode_Interest_DEPENDENCIES = libndn-c.a libndn-cpp.a
+am_bin_test_get_async_OBJECTS = tests/test-get-async.$(OBJEXT)
+bin_test_get_async_OBJECTS = $(am_bin_test_get_async_OBJECTS)
+bin_test_get_async_DEPENDENCIES = libndn-c.a libndn-cpp.a
SCRIPTS = $(dist_noinst_SCRIPTS)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@@ -213,10 +217,12 @@
am__v_CXXLD_1 =
SOURCES = $(libndn_c_a_SOURCES) $(libndn_cpp_a_SOURCES) \
$(bin_test_encode_decode_ContentObject_SOURCES) \
- $(bin_test_encode_decode_Interest_SOURCES)
+ $(bin_test_encode_decode_Interest_SOURCES) \
+ $(bin_test_get_async_SOURCES)
DIST_SOURCES = $(libndn_c_a_SOURCES) $(libndn_cpp_a_SOURCES) \
$(bin_test_encode_decode_ContentObject_SOURCES) \
- $(bin_test_encode_decode_Interest_SOURCES)
+ $(bin_test_encode_decode_Interest_SOURCES) \
+ $(bin_test_get_async_SOURCES)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -442,6 +448,8 @@
bin_test_encode_decode_Interest_LDADD = libndn-c.a libndn-cpp.a
bin_test_encode_decode_ContentObject_SOURCES = tests/test-encode-decode-ContentObject.cpp
bin_test_encode_decode_ContentObject_LDADD = libndn-c.a libndn-cpp.a
+bin_test_get_async_SOURCES = tests/test-get-async.cpp
+bin_test_get_async_LDADD = libndn-c.a libndn-cpp.a
dist_noinst_SCRIPTS = autogen.sh
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
@@ -686,6 +694,12 @@
bin/test-encode-decode-Interest$(EXEEXT): $(bin_test_encode_decode_Interest_OBJECTS) $(bin_test_encode_decode_Interest_DEPENDENCIES) $(EXTRA_bin_test_encode_decode_Interest_DEPENDENCIES) bin/$(am__dirstamp)
@rm -f bin/test-encode-decode-Interest$(EXEEXT)
$(AM_V_CXXLD)$(CXXLINK) $(bin_test_encode_decode_Interest_OBJECTS) $(bin_test_encode_decode_Interest_LDADD) $(LIBS)
+tests/test-get-async.$(OBJEXT): tests/$(am__dirstamp) \
+ tests/$(DEPDIR)/$(am__dirstamp)
+
+bin/test-get-async$(EXEEXT): $(bin_test_get_async_OBJECTS) $(bin_test_get_async_DEPENDENCIES) $(EXTRA_bin_test_get_async_DEPENDENCIES) bin/$(am__dirstamp)
+ @rm -f bin/test-get-async$(EXEEXT)
+ $(AM_V_CXXLD)$(CXXLINK) $(bin_test_get_async_OBJECTS) $(bin_test_get_async_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
@@ -720,6 +734,7 @@
@AMDEP_TRUE@@am__include@ @am__quote@ndn-cpp/encoding/$(DEPDIR)/WireFormat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/test-encode-decode-ContentObject.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/test-encode-decode-Interest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@tests/$(DEPDIR)/test-get-async.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
diff --git a/tests/test-encode-decode-Interest.cpp b/tests/test-encode-decode-Interest.cpp
index bba7596..d715c85 100644
--- a/tests/test-encode-decode-Interest.cpp
+++ b/tests/test-encode-decode-Interest.cpp
@@ -7,7 +7,6 @@
#include <sstream>
#include <iostream>
#include <ndn-cpp/Interest.hpp>
-#include <ndn-cpp/c/network/TcpTransport.h>
using namespace std;
using namespace ndn;
@@ -38,36 +37,17 @@
{
try {
Interest interest;
-#if 0
interest.decode(Interest1, sizeof(Interest1));
cout << "Interest name " << interest.getName().to_uri() << endl;
cout << "Interest minSuffixComponents " << interest.getMinSuffixComponents() << endl;
cout << "Interest publisherPublicKeyDigest length " << interest.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() << endl;
cout << "Interest excludeEntryCount " << interest.getExclude().getEntryCount() << endl;
cout << "InterestLifetimeMilliseconds " << interest.getInterestLifetimeMilliseconds() << endl;
-#endif
vector<unsigned char> encoding;
interest.encode(encoding);
cout << "Interest encoding length " << encoding.size() << " vs. sizeof(Interest1) " << sizeof(Interest1) << endl;
- struct ndn_TcpTransport transport;
- ndn_TcpTransport_init(&transport);
- ndn_Error error;
- if (error = ndn_TcpTransport_connect(&transport, (char *)"E.hub.ndn.ucla.edu", 9695))
- return error;
- if (error = ndn_TcpTransport_send(&transport, &encoding[0], encoding.size()))
- return error;
-
- unsigned char buffer[1000];
- unsigned int nBytes;
- if (error = ndn_TcpTransport_receive(&transport, buffer, sizeof(buffer), &nBytes))
- return error;
-
- for (int i = 0; i < nBytes; ++i)
- printf("%02X ", (unsigned int)buffer[i]);
-
-#if 0
Interest reDecodedInterest;
reDecodedInterest.decode(encoding);
cout << "Re-decoded Interest name " << reDecodedInterest.getName().to_uri() << endl;
@@ -75,7 +55,6 @@
cout << "Re-decoded Interest publisherPublicKeyDigest length " << reDecodedInterest.getPublisherPublicKeyDigest().getPublisherPublicKeyDigest().size() << endl;
cout << "Re-decoded Interest excludeEntryCount " << reDecodedInterest.getExclude().getEntryCount() << endl;
cout << "Re-decoded InterestLifetimeMilliseconds " << reDecodedInterest.getInterestLifetimeMilliseconds() << endl;
-#endif
} catch (exception &e) {
cout << "exception: " << e.what() << endl;
}
diff --git a/tests/test-get-async.cpp b/tests/test-get-async.cpp
new file mode 100644
index 0000000..a185386
--- /dev/null
+++ b/tests/test-get-async.cpp
@@ -0,0 +1,49 @@
+/**
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+#include <cstdlib>
+#include <sstream>
+#include <iostream>
+#include <ndn-cpp/Interest.hpp>
+#include <ndn-cpp/ContentObject.hpp>
+#include <ndn-cpp/c/network/TcpTransport.h>
+
+using namespace std;
+using namespace ndn;
+int main(int argc, char** argv)
+{
+ try {
+ Interest interest;
+ interest.getName() = Name("/ndn/ucla.edu/apps/ndn-js-test/hello.txt/level2/%FD%05%0B%16%7D%95%0E");
+ vector<unsigned char> encoding;
+ interest.encode(encoding);
+
+ struct ndn_TcpTransport transport;
+ ndn_TcpTransport_init(&transport);
+ ndn_Error error;
+ if (error = ndn_TcpTransport_connect(&transport, (char *)"E.hub.ndn.ucla.edu", 9695))
+ return error;
+ if (error = ndn_TcpTransport_send(&transport, &encoding[0], encoding.size()))
+ return error;
+
+ unsigned char buffer[8000];
+ unsigned int nBytes;
+ while (1) {
+ if (error = ndn_TcpTransport_receive(&transport, buffer, sizeof(buffer), &nBytes))
+ return error;
+ if (buffer[0] == 0x04)
+ break;
+ }
+
+ for (int i = 0; i < nBytes; ++i)
+ printf("%02X ", (unsigned int)buffer[i]);
+
+ ContentObject contentObject;
+ contentObject.decode(buffer, nBytes);
+ } catch (exception &e) {
+ cout << "exception: " << e.what() << endl;
+ }
+ return 0;
+}