Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2013-2016, Regents of the University of California. |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 4 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame] | 5 | * This file is part of ChronoShare, a decentralized file sharing application over NDN. |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 6 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame] | 7 | * ChronoShare is free software: you can redistribute it and/or modify it under the terms |
| 8 | * of the GNU General Public License as published by the Free Software Foundation, either |
| 9 | * version 3 of the License, or (at your option) any later version. |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 10 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame] | 11 | * ChronoShare is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU General Public License for more details. |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 14 | * |
Alexander Afanasyev | fa2f662 | 2016-12-25 12:28:00 -0800 | [diff] [blame] | 15 | * You should have received copies of the GNU General Public License along with |
| 16 | * ChronoShare, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
| 18 | * See AUTHORS.md for complete list of ChronoShare authors and contributors. |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 19 | */ |
| 20 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 21 | #include "ccnx-wrapper.hpp" |
Alexander Afanasyev | f4cde4e | 2016-12-25 13:42:57 -0800 | [diff] [blame] | 22 | #include "fetch-manager.hpp" |
| 23 | #include "fetcher.hpp" |
Alexander Afanasyev | f4cde4e | 2016-12-25 13:42:57 -0800 | [diff] [blame] | 24 | #include "logging.hpp" |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 25 | #include <boost/make_shared.hpp> |
| 26 | #include <boost/test/unit_test.hpp> |
Alexander Afanasyev | 1d1cc83 | 2013-02-05 20:03:36 -0800 | [diff] [blame] | 27 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 28 | INIT_LOGGER("Test.FetchManager"); |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 29 | |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame] | 30 | using namespace Ndnx; |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 31 | using namespace std; |
| 32 | using namespace boost; |
| 33 | |
| 34 | BOOST_AUTO_TEST_SUITE(TestFetchManager) |
| 35 | |
| 36 | struct FetcherTestData |
| 37 | { |
Zhenkai Zhu | 3d1beca | 2013-01-23 14:55:32 -0800 | [diff] [blame] | 38 | set<uint64_t> recvData; |
| 39 | set<uint64_t> recvContent; |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 40 | |
| 41 | set<Name> differentNames; |
| 42 | set<Name> segmentNames; |
| 43 | |
| 44 | bool m_done; |
| 45 | bool m_failed; |
| 46 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 47 | FetcherTestData() |
| 48 | : m_done(false) |
| 49 | , m_failed(false) |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 50 | { |
| 51 | } |
| 52 | |
| 53 | void |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 54 | onData(const Ccnx::Name& deviceName, const Ccnx::Name& basename, uint64_t seqno, Ccnx::PcoPtr pco) |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 55 | { |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 56 | _LOG_TRACE("onData: " << seqno); |
Alexander Afanasyev | 1d1cc83 | 2013-02-05 20:03:36 -0800 | [diff] [blame] | 57 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 58 | recvData.insert(seqno); |
| 59 | differentNames.insert(basename); |
Zhenkai Zhu | 3d1beca | 2013-01-23 14:55:32 -0800 | [diff] [blame] | 60 | Name name = basename; |
| 61 | name.appendComp(seqno); |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 62 | segmentNames.insert(name); |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 63 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 64 | BytesPtr data = pco->contentPtr(); |
Alexander Afanasyev | f278db3 | 2013-01-21 14:41:01 -0800 | [diff] [blame] | 65 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 66 | if (data->size() == sizeof(int)) { |
| 67 | recvContent.insert(*reinterpret_cast<const int*>(head(*data))); |
| 68 | } |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 69 | |
Alexander Afanasyev | 650ba28 | 2013-01-20 20:14:06 -0800 | [diff] [blame] | 70 | // cout << "<<< " << basename << ", " << name << ", " << seqno << endl; |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | void |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 74 | finish(const Ccnx::Name& deviceName, const Ccnx::Name& baseName) |
Zhenkai Zhu | 3d1beca | 2013-01-23 14:55:32 -0800 | [diff] [blame] | 75 | { |
| 76 | } |
| 77 | |
| 78 | void |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 79 | onComplete(Fetcher& fetcher) |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 80 | { |
| 81 | m_done = true; |
| 82 | // cout << "Done" << endl; |
| 83 | } |
| 84 | |
| 85 | void |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 86 | onFail(Fetcher& fetcher) |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 87 | { |
| 88 | m_failed = true; |
| 89 | // cout << "Failed" << endl; |
| 90 | } |
| 91 | }; |
| 92 | |
Yingdi Yu | f0b3de3 | 2013-07-11 12:59:00 -0700 | [diff] [blame] | 93 | void run() |
| 94 | { |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame] | 95 | NdnxWrapperPtr ndnx = make_shared<NdnxWrapper> (); |
Yingdi Yu | f0b3de3 | 2013-07-11 12:59:00 -0700 | [diff] [blame] | 96 | |
| 97 | Name baseName ("/base"); |
| 98 | Name deviceName ("/device"); |
| 99 | |
| 100 | for (int i = 0; i < 10; i++) |
| 101 | { |
| 102 | usleep(100000); |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame] | 103 | ndnx->publishData (Name (baseName)(i), reinterpret_cast<const unsigned char*> (&i), sizeof(int), 30); |
Yingdi Yu | f0b3de3 | 2013-07-11 12:59:00 -0700 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | for (int i = 11; i < 50; i++) |
| 107 | { |
| 108 | usleep(100000); |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame] | 109 | ndnx->publishData (Name (baseName)(i), reinterpret_cast<const unsigned char*> (&i), sizeof(int), 30); |
Yingdi Yu | f0b3de3 | 2013-07-11 12:59:00 -0700 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | } |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 113 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 114 | BOOST_AUTO_TEST_CASE(TestFetcher) |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 115 | { |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 116 | INIT_LOGGERS(); |
Alexander Afanasyev | 1d1cc83 | 2013-02-05 20:03:36 -0800 | [diff] [blame] | 117 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 118 | CcnxWrapperPtr ccnx = make_shared<CcnxWrapper>(); |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 119 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 120 | Name baseName("/base"); |
| 121 | Name deviceName("/device"); |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 122 | /* publish seqnos: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, <gap 5>, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, <gap 1>, 26 */ |
| 123 | // this will allow us to test our pipeline of 6 |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 124 | for (int i = 0; i < 10; i++) { |
| 125 | ccnx->publishData(Name(baseName)(i), reinterpret_cast<const unsigned char*>(&i), sizeof(int), 30); |
| 126 | } |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 127 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 128 | for (int i = 15; i < 25; i++) { |
| 129 | ccnx->publishData(Name(baseName)(i), reinterpret_cast<const unsigned char*>(&i), sizeof(int), 30); |
| 130 | } |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 131 | |
| 132 | int oneMore = 26; |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 133 | ccnx->publishData(Name(baseName)(oneMore), reinterpret_cast<const unsigned char*>(&oneMore), |
| 134 | sizeof(int), 30); |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 135 | |
| 136 | FetcherTestData data; |
Zhenkai Zhu | ab9215c | 2013-01-28 23:42:28 -0800 | [diff] [blame] | 137 | ExecutorPtr executor = make_shared<Executor>(1); |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 138 | executor->start(); |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 139 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 140 | Fetcher fetcher(ccnx, executor, bind(&FetcherTestData::onData, &data, _1, _2, _3, _4), |
| 141 | bind(&FetcherTestData::finish, &data, _1, _2), |
| 142 | bind(&FetcherTestData::onComplete, &data, _1), |
| 143 | bind(&FetcherTestData::onFail, &data, _1), deviceName, Name("/base"), 0, 26, |
| 144 | boost::posix_time::seconds(5)); // this time is not precise |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 145 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 146 | BOOST_CHECK_EQUAL(fetcher.IsActive(), false); |
| 147 | fetcher.RestartPipeline(); |
| 148 | BOOST_CHECK_EQUAL(fetcher.IsActive(), true); |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 149 | |
Alexander Afanasyev | 650ba28 | 2013-01-20 20:14:06 -0800 | [diff] [blame] | 150 | usleep(7000000); |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 151 | BOOST_CHECK_EQUAL(data.m_failed, true); |
| 152 | BOOST_CHECK_EQUAL(data.differentNames.size(), 1); |
| 153 | BOOST_CHECK_EQUAL(data.segmentNames.size(), 20); |
| 154 | BOOST_CHECK_EQUAL(data.recvData.size(), 20); |
| 155 | BOOST_CHECK_EQUAL(data.recvContent.size(), 20); |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 156 | |
Alexander Afanasyev | 650ba28 | 2013-01-20 20:14:06 -0800 | [diff] [blame] | 157 | { |
| 158 | ostringstream recvData; |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 159 | for (set<uint64_t>::iterator i = data.recvData.begin(); i != data.recvData.end(); i++) |
Alexander Afanasyev | 650ba28 | 2013-01-20 20:14:06 -0800 | [diff] [blame] | 160 | recvData << *i << ", "; |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 161 | |
Alexander Afanasyev | 650ba28 | 2013-01-20 20:14:06 -0800 | [diff] [blame] | 162 | ostringstream recvContent; |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 163 | for (set<uint64_t>::iterator i = data.recvContent.begin(); i != data.recvContent.end(); i++) |
Alexander Afanasyev | 650ba28 | 2013-01-20 20:14:06 -0800 | [diff] [blame] | 164 | recvContent << *i << ", "; |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 165 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 166 | BOOST_CHECK_EQUAL(recvData.str(), |
| 167 | "0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, "); |
| 168 | BOOST_CHECK_EQUAL(recvData.str(), recvContent.str()); |
Alexander Afanasyev | 650ba28 | 2013-01-20 20:14:06 -0800 | [diff] [blame] | 169 | } |
| 170 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 171 | BOOST_CHECK_EQUAL(fetcher.IsActive(), false); |
| 172 | fetcher.RestartPipeline(); |
| 173 | BOOST_CHECK_EQUAL(fetcher.IsActive(), true); |
Alexander Afanasyev | 650ba28 | 2013-01-20 20:14:06 -0800 | [diff] [blame] | 174 | |
| 175 | usleep(7000000); |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 176 | BOOST_CHECK_EQUAL(data.m_failed, true); |
Alexander Afanasyev | 650ba28 | 2013-01-20 20:14:06 -0800 | [diff] [blame] | 177 | |
| 178 | // publishing missing pieces |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 179 | for (int i = 0; i < 27; i++) { |
| 180 | ccnx->publishData(Name(baseName)(i), reinterpret_cast<const unsigned char*>(&i), sizeof(int), 1); |
| 181 | } |
| 182 | BOOST_CHECK_EQUAL(fetcher.IsActive(), false); |
| 183 | fetcher.RestartPipeline(); |
| 184 | BOOST_CHECK_EQUAL(fetcher.IsActive(), true); |
Alexander Afanasyev | 650ba28 | 2013-01-20 20:14:06 -0800 | [diff] [blame] | 185 | |
| 186 | usleep(1000000); |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 187 | BOOST_CHECK_EQUAL(data.m_done, true); |
Alexander Afanasyev | 650ba28 | 2013-01-20 20:14:06 -0800 | [diff] [blame] | 188 | |
| 189 | { |
| 190 | ostringstream recvData; |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 191 | for (set<uint64_t>::iterator i = data.recvData.begin(); i != data.recvData.end(); i++) |
Alexander Afanasyev | 650ba28 | 2013-01-20 20:14:06 -0800 | [diff] [blame] | 192 | recvData << *i << ", "; |
| 193 | |
| 194 | ostringstream recvContent; |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 195 | for (set<uint64_t>::iterator i = data.recvContent.begin(); i != data.recvContent.end(); i++) |
Alexander Afanasyev | 650ba28 | 2013-01-20 20:14:06 -0800 | [diff] [blame] | 196 | recvContent << *i << ", "; |
| 197 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 198 | BOOST_CHECK_EQUAL(recvData.str(), |
| 199 | "0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, "); |
| 200 | BOOST_CHECK_EQUAL(recvData.str(), recvContent.str()); |
Alexander Afanasyev | 650ba28 | 2013-01-20 20:14:06 -0800 | [diff] [blame] | 201 | } |
Alexander Afanasyev | 1d1cc83 | 2013-02-05 20:03:36 -0800 | [diff] [blame] | 202 | |
Alexander Afanasyev | eda3b7a | 2016-12-25 11:26:40 -0800 | [diff] [blame] | 203 | executor->shutdown(); |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 204 | } |
| 205 | |
Yingdi Yu | 57f667b | 2013-07-11 10:37:59 -0700 | [diff] [blame] | 206 | |
| 207 | BOOST_AUTO_TEST_CASE (TestFetcher2) |
| 208 | { |
| 209 | INIT_LOGGERS (); |
| 210 | |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame] | 211 | NdnxWrapperPtr ndnx = make_shared<NdnxWrapper> (); |
Yingdi Yu | 57f667b | 2013-07-11 10:37:59 -0700 | [diff] [blame] | 212 | |
| 213 | Name baseName ("/base"); |
| 214 | Name deviceName ("/device"); |
Yingdi Yu | 57f667b | 2013-07-11 10:37:59 -0700 | [diff] [blame] | 215 | |
Yingdi Yu | f0b3de3 | 2013-07-11 12:59:00 -0700 | [diff] [blame] | 216 | thread publishThread(run); |
Yingdi Yu | 57f667b | 2013-07-11 10:37:59 -0700 | [diff] [blame] | 217 | |
| 218 | FetcherTestData data; |
| 219 | ExecutorPtr executor = make_shared<Executor>(1); |
| 220 | executor->start (); |
| 221 | |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame] | 222 | Fetcher fetcher (ndnx, |
Yingdi Yu | 57f667b | 2013-07-11 10:37:59 -0700 | [diff] [blame] | 223 | executor, |
| 224 | bind (&FetcherTestData::onData, &data, _1, _2, _3, _4), |
| 225 | bind (&FetcherTestData::finish, &data, _1, _2), |
| 226 | bind (&FetcherTestData::onComplete, &data, _1), |
| 227 | bind (&FetcherTestData::onFail, &data, _1), |
Yingdi Yu | f0b3de3 | 2013-07-11 12:59:00 -0700 | [diff] [blame] | 228 | deviceName, baseName, 0, 49, |
Yingdi Yu | 57f667b | 2013-07-11 10:37:59 -0700 | [diff] [blame] | 229 | boost::posix_time::seconds (5)); // this time is not precise |
| 230 | |
| 231 | BOOST_CHECK_EQUAL (fetcher.IsActive (), false); |
| 232 | fetcher.RestartPipeline (); |
| 233 | BOOST_CHECK_EQUAL (fetcher.IsActive (), true); |
| 234 | |
Yingdi Yu | f0b3de3 | 2013-07-11 12:59:00 -0700 | [diff] [blame] | 235 | usleep(20000000); |
Yingdi Yu | 57f667b | 2013-07-11 10:37:59 -0700 | [diff] [blame] | 236 | BOOST_CHECK_EQUAL (data.m_failed, true); |
| 237 | |
| 238 | executor->shutdown (); |
| 239 | } |
| 240 | |
| 241 | |
| 242 | |
Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame] | 243 | // BOOST_AUTO_TEST_CASE (NdnxWrapperSelector) |
Alexander Afanasyev | 21a166e | 2013-01-20 16:04:41 -0800 | [diff] [blame] | 244 | // { |
| 245 | |
| 246 | // Closure closure (bind(dataCallback, _1, _2), bind(timeout, _1)); |
| 247 | |
| 248 | // Selectors selectors; |
| 249 | // selectors.interestLifetime(1); |
| 250 | |
| 251 | // string n1 = "/random/01"; |
| 252 | // c1->sendInterest(Name(n1), closure, selectors); |
| 253 | // sleep(2); |
| 254 | // c2->publishData(Name(n1), (const unsigned char *)n1.c_str(), n1.size(), 4); |
| 255 | // usleep(100000); |
| 256 | // BOOST_CHECK_EQUAL(g_timeout_counter, 1); |
| 257 | // BOOST_CHECK_EQUAL(g_dataCallback_counter, 0); |
| 258 | |
| 259 | // string n2 = "/random/02"; |
| 260 | // selectors.interestLifetime(2); |
| 261 | // c1->sendInterest(Name(n2), closure, selectors); |
| 262 | // sleep(1); |
| 263 | // c2->publishData(Name(n2), (const unsigned char *)n2.c_str(), n2.size(), 4); |
| 264 | // usleep(100000); |
| 265 | // BOOST_CHECK_EQUAL(g_timeout_counter, 1); |
| 266 | // BOOST_CHECK_EQUAL(g_dataCallback_counter, 1); |
| 267 | |
| 268 | // // reset |
| 269 | // g_dataCallback_counter = 0; |
| 270 | // g_timeout_counter = 0; |
| 271 | // } |
| 272 | |
| 273 | BOOST_AUTO_TEST_SUITE_END() |