Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Alexander Afanasyev | e1e6f2a | 2014-04-25 11:28:12 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014, Regents of the University of California. |
| 4 | * |
| 5 | * This file is part of NDN repo-ng (Next generation of NDN repository). |
| 6 | * See AUTHORS.md for complete list of repo-ng authors and contributors. |
| 7 | * |
| 8 | * repo-ng is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * repo-ng is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * repo-ng, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | #ifndef REPO_TESTS_DATASET_FIXTURES_HPP |
| 21 | #define REPO_TESTS_DATASET_FIXTURES_HPP |
| 22 | |
Alexander Afanasyev | e291caf | 2014-04-25 11:17:36 -0700 | [diff] [blame] | 23 | #include <ndn-cxx/security/key-chain.hpp> |
Wentao Shang | 91fb4f2 | 2014-05-20 10:55:22 -0700 | [diff] [blame] | 24 | #include <vector> |
| 25 | #include <boost/mpl/vector.hpp> |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 26 | |
| 27 | namespace repo { |
| 28 | namespace tests { |
| 29 | |
| 30 | static inline ndn::shared_ptr<ndn::Data> |
| 31 | createData(const ndn::Name& name) |
| 32 | { |
| 33 | static ndn::KeyChain keyChain; |
| 34 | static std::vector<uint8_t> content(1500, '-'); |
| 35 | |
| 36 | ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>(); |
| 37 | data->setName(name); |
| 38 | data->setContent(&content[0], content.size()); |
| 39 | keyChain.sign(*data); |
| 40 | |
| 41 | return data; |
| 42 | } |
| 43 | |
| 44 | |
| 45 | class DatasetBase |
| 46 | { |
| 47 | public: |
| 48 | typedef std::list<ndn::shared_ptr<ndn::Data> > DataContainer; |
| 49 | DataContainer data; |
| 50 | |
| 51 | typedef std::list<std::pair<ndn::Interest, ndn::shared_ptr<ndn::Data> > > InterestContainer; |
| 52 | InterestContainer interests; |
Shuo Chen | 9a43f16 | 2014-07-01 13:43:54 +0800 | [diff] [blame] | 53 | |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 54 | typedef std::list<std::pair<ndn::Interest, int > > InterestIdContainer; |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 55 | InterestIdContainer interestsSelectors, interestDeleteCount; |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 56 | |
| 57 | typedef std::list<std::pair<int, ndn::shared_ptr<ndn::Data> > > IdContainer; |
| 58 | IdContainer ids, insert; |
Shuo Chen | 9a43f16 | 2014-07-01 13:43:54 +0800 | [diff] [blame] | 59 | |
| 60 | struct DataSetNameCompare |
| 61 | { |
| 62 | bool operator()(const ndn::Name& a, const ndn::Name& b) const |
| 63 | { |
| 64 | return a < b; |
| 65 | } |
| 66 | }; |
| 67 | |
| 68 | struct DataSetDataCompare |
| 69 | { |
| 70 | bool operator()(const Data& a, const Data& b) const |
| 71 | { |
| 72 | return a.getName() < b.getName(); |
| 73 | } |
| 74 | }; |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | |
| 78 | template<size_t N> |
| 79 | class BaseSmoketestFixture : public DatasetBase |
| 80 | { |
| 81 | public: |
| 82 | static const std::string& |
| 83 | getName() |
| 84 | { |
| 85 | static std::string name = "BaseSmoketest"; |
| 86 | return name; |
| 87 | } |
| 88 | |
| 89 | BaseSmoketestFixture() |
| 90 | { |
| 91 | ndn::Name baseName("/x/y/z/test/1"); |
| 92 | for (size_t i = 0; i < N; i++) { |
| 93 | ndn::Name name(baseName); |
| 94 | name.appendSegment(i); |
| 95 | ndn::shared_ptr<Data> data = createData(name); |
| 96 | this->data.push_back(data); |
| 97 | |
| 98 | this->interests.push_back(std::make_pair(Interest(name), data)); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 99 | this->ids.push_back(std::make_pair(i+1, data)); |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 100 | } |
| 101 | } |
| 102 | }; |
| 103 | |
| 104 | |
| 105 | class BaseTestFixture : public DatasetBase |
| 106 | { |
| 107 | public: |
| 108 | static const std::string& |
| 109 | getName() |
| 110 | { |
| 111 | static std::string name = "BaseTest"; |
| 112 | return name; |
| 113 | } |
| 114 | |
| 115 | BaseTestFixture() |
| 116 | { |
| 117 | this->data.push_back(createData("/a")); |
| 118 | this->interests.push_back(std::make_pair(Interest("/a"), this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 119 | this->ids.push_back(std::make_pair(1, this->data.back())); |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 120 | |
| 121 | this->data.push_back(createData("/a/b")); |
| 122 | this->interests.push_back(std::make_pair(Interest("/a/b"), this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 123 | this->ids.push_back(std::make_pair(2, this->data.back())); |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 124 | |
| 125 | this->data.push_back(createData("/a/b/c")); |
| 126 | this->interests.push_back(std::make_pair(Interest("/a/b/c"), this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 127 | this->ids.push_back(std::make_pair(3, this->data.back())); |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 128 | |
| 129 | this->data.push_back(createData("/a/b/c/d")); |
| 130 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d"), this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 131 | this->ids.push_back(std::make_pair(4, this->data.back())); |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 132 | } |
| 133 | }; |
| 134 | |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 135 | //Fetch by prefix is useless due to the database is fetched by id |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 136 | class FetchByPrefixTestFixture : public DatasetBase |
| 137 | { |
| 138 | public: |
| 139 | static const std::string& |
| 140 | getName() |
| 141 | { |
| 142 | static std::string name = "FetchByPrefix"; |
| 143 | return name; |
| 144 | } |
| 145 | |
| 146 | FetchByPrefixTestFixture() |
| 147 | { |
| 148 | this->data.push_back(createData("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z")); |
| 149 | this->interests.push_back(std::make_pair(Interest("/a"), |
| 150 | this->data.back())); |
| 151 | this->interests.push_back(std::make_pair(Interest("/a/b"), |
| 152 | this->data.back())); |
| 153 | this->interests.push_back(std::make_pair(Interest("/a/b/c"), |
| 154 | this->data.back())); |
| 155 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d"), |
| 156 | this->data.back())); |
| 157 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e"), |
| 158 | this->data.back())); |
| 159 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f"), |
| 160 | this->data.back())); |
| 161 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g"), |
| 162 | this->data.back())); |
| 163 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h"), |
| 164 | this->data.back())); |
| 165 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i"), |
| 166 | this->data.back())); |
| 167 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j"), |
| 168 | this->data.back())); |
| 169 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k"), |
| 170 | this->data.back())); |
| 171 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l"), |
| 172 | this->data.back())); |
| 173 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m"), |
| 174 | this->data.back())); |
| 175 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n"), |
| 176 | this->data.back())); |
| 177 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o"), |
| 178 | this->data.back())); |
| 179 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p"), |
| 180 | this->data.back())); |
| 181 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q"), |
| 182 | this->data.back())); |
| 183 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r"), |
| 184 | this->data.back())); |
| 185 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s"), |
| 186 | this->data.back())); |
| 187 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t"), |
| 188 | this->data.back())); |
| 189 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u"), |
| 190 | this->data.back())); |
| 191 | this->interests.push_back( |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 192 | std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v"), |
| 193 | this->data.back())); |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 194 | this->interests.push_back( |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 195 | std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w"), |
| 196 | this->data.back())); |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 197 | this->interests.push_back( |
| 198 | std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x"), |
| 199 | this->data.back())); |
| 200 | this->interests.push_back( |
| 201 | std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y"), |
| 202 | this->data.back())); |
| 203 | this->interests.push_back( |
| 204 | std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z"), |
| 205 | this->data.back())); |
| 206 | } |
| 207 | }; |
| 208 | |
| 209 | |
| 210 | class SelectorTestFixture : public DatasetBase |
| 211 | { |
| 212 | public: |
| 213 | static const std::string& |
| 214 | getName() |
| 215 | { |
| 216 | static std::string name = "SelectorTest"; |
| 217 | return name; |
| 218 | } |
| 219 | |
| 220 | SelectorTestFixture() |
| 221 | { |
| 222 | this->data.push_back(createData("/a/1")); |
| 223 | this->data.push_back(createData("/b/1")); |
| 224 | this->interests.push_back(std::make_pair(Interest() |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 225 | .setName("/b") |
| 226 | .setSelectors(Selectors() |
| 227 | .setChildSelector(0)), |
| 228 | this->data.back())); |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 229 | |
| 230 | this->data.push_back(createData("/c/1")); |
| 231 | this->data.push_back(createData("/b/99")); |
| 232 | this->interests.push_back(std::make_pair(Interest() |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 233 | .setName("/b") |
| 234 | .setSelectors(Selectors() |
| 235 | .setChildSelector(1)), |
| 236 | this->data.back())); |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 237 | this->data.push_back(createData("/b/5")); |
| 238 | this->data.push_back(createData("/b/55")); |
| 239 | } |
| 240 | }; |
| 241 | |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 242 | class IndexTestFixture : public DatasetBase |
| 243 | { |
| 244 | public: |
| 245 | static const std::string& |
| 246 | getName() |
| 247 | { |
| 248 | static std::string name = "IndexTest"; |
| 249 | return name; |
| 250 | } |
| 251 | |
| 252 | IndexTestFixture() |
| 253 | { |
| 254 | this->data.push_back(createData("/a/b/c")); |
| 255 | this->interests.push_back(std::make_pair(Interest("/a/b/c"), this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 256 | this->ids.push_back(std::make_pair(1, this->data.back())); |
| 257 | this->insert.push_back(std::make_pair(1, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 258 | |
| 259 | this->data.push_back(createData("/a/b/d/1")); |
| 260 | this->interests.push_back(std::make_pair(Interest("/a/b/d"), this->data.back())); |
| 261 | this->interests.push_back(std::make_pair(Interest("/a/b/d/1"), this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 262 | this->ids.push_back(std::make_pair(2, this->data.back())); |
| 263 | this->ids.push_back(std::make_pair(2, this->data.back())); |
| 264 | this->insert.push_back(std::make_pair(2, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 265 | |
| 266 | this->data.push_back(createData("/a/b/d/2")); |
| 267 | this->interests.push_back(std::make_pair(Interest("/a/b/d/2"), this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 268 | this->ids.push_back(std::make_pair(3, this->data.back())); |
| 269 | this->insert.push_back(std::make_pair(3, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 270 | |
| 271 | this->data.push_back(createData("/a/b/d/3")); |
| 272 | this->interests.push_back(std::make_pair(Interest("/a/b/d/3"), this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 273 | this->ids.push_back(std::make_pair(4, this->data.back())); |
| 274 | this->insert.push_back(std::make_pair(4, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 275 | |
| 276 | this->data.push_back(createData("/a/b/d/4/I")); |
| 277 | this->interests.push_back(std::make_pair(Interest("/a/b/d/4/I"), this->data.back())); |
| 278 | this->interests.push_back(std::make_pair(Interest("/a/b/d/4"), this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 279 | this->ids.push_back(std::make_pair(5, this->data.back())); |
| 280 | this->ids.push_back(std::make_pair(5, this->data.back())); |
| 281 | this->insert.push_back(std::make_pair(5, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 282 | |
| 283 | this->data.push_back(createData("/a/b/d/4")); |
| 284 | // this->ids.push_back(std::make_pair(7, this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 285 | this->insert.push_back(std::make_pair(6, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 286 | |
| 287 | this->data.push_back(createData("/a/b/d")); |
| 288 | // this->ids.push_back(std::make_pair(8, this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 289 | this->insert.push_back(std::make_pair(7, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 290 | |
| 291 | this->data.push_back(createData("/a/b/e/1")); |
| 292 | this->interests.push_back(std::make_pair(Interest("/a/b/e"), this->data.back())); |
| 293 | this->interests.push_back(std::make_pair(Interest("/a/b/e/1"), this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 294 | this->ids.push_back(std::make_pair(8, this->data.back())); |
| 295 | this->ids.push_back(std::make_pair(8, this->data.back())); |
| 296 | this->insert.push_back(std::make_pair(8, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 297 | |
| 298 | Selectors selector_keylocator; |
| 299 | ndn::SignatureSha256WithRsa rsaSignature(this->data.back()->getSignature()); |
| 300 | |
| 301 | this->data.push_back(createData("/a/b/e")); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 302 | this->ids.push_back(std::make_pair(9, this->data.back())); |
| 303 | this->insert.push_back(std::make_pair(9, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 304 | |
| 305 | Selectors selector; |
| 306 | selector.setMinSuffixComponents(3); |
| 307 | this->interestsSelectors.push_back(std::make_pair(Interest("/a/b/d").setSelectors(selector), |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 308 | 5)); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 309 | |
| 310 | selector.setMinSuffixComponents(-1); |
| 311 | selector.setChildSelector(0); |
| 312 | this->interestsSelectors.push_back(std::make_pair(Interest("/a/b/d").setSelectors(selector), |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 313 | 2)); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 314 | |
| 315 | selector.setMinSuffixComponents(2); |
| 316 | this->interestsSelectors.push_back(std::make_pair(Interest("/a/b/d").setSelectors(selector), |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 317 | 2)); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 318 | |
| 319 | selector.setChildSelector(1); |
| 320 | this->interestsSelectors.push_back(std::make_pair(Interest("/a/b/d").setSelectors(selector), |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 321 | 6)); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 322 | |
| 323 | selector.setChildSelector(-1); |
| 324 | selector.setMaxSuffixComponents(2); |
| 325 | this->interestsSelectors.push_back(std::make_pair(Interest("/a/b").setSelectors(selector), |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 326 | 1)); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 327 | |
| 328 | ndn::name::Component from("3"); |
| 329 | ndn::name::Component to("4"); |
| 330 | Exclude exclude; |
| 331 | exclude.excludeRange(from, to); |
| 332 | selector.setChildSelector(1); |
| 333 | selector.setExclude(exclude); |
| 334 | this->interestsSelectors.push_back(std::make_pair(Interest("/a/b/d").setSelectors(selector), |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 335 | 3)); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 336 | |
| 337 | |
| 338 | KeyLocator keylocate = rsaSignature.getKeyLocator(); |
| 339 | // std::cout<<"keylocator from data = "<<keylocate.wireEncode()<<std::endl; |
| 340 | selector_keylocator.setPublisherPublicKeyLocator(keylocate); |
| 341 | this->interestsSelectors.push_back(std::make_pair |
| 342 | (Interest("/a/b/e").setSelectors(selector_keylocator), 9)); |
| 343 | } |
| 344 | }; |
| 345 | |
| 346 | class ChildSelectorTestFixture : public DatasetBase |
| 347 | { |
| 348 | public: |
| 349 | static const std::string& |
| 350 | getName() |
| 351 | { |
| 352 | static std::string name = "storage"; |
| 353 | return name; |
| 354 | } |
| 355 | |
| 356 | ChildSelectorTestFixture() |
| 357 | { |
| 358 | this->data.push_back(createData("/a/b/1")); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 359 | this->insert.push_back(std::make_pair(1, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 360 | this->data.push_back(createData("/a/c/1")); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 361 | this->insert.push_back(std::make_pair(2, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 362 | |
| 363 | this->data.push_back(createData("/a/c/2")); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 364 | this->insert.push_back(std::make_pair(3, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 365 | |
| 366 | this->data.push_back(createData("/b")); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 367 | this->insert.push_back(std::make_pair(4, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 368 | |
| 369 | Selectors selector; |
| 370 | selector.setChildSelector(1); |
| 371 | this->interestsSelectors.push_back(std::make_pair(Interest("/a").setSelectors(selector), |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 372 | 2)); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 373 | } |
| 374 | }; |
| 375 | |
| 376 | class StorageFixture : public DatasetBase |
| 377 | { |
| 378 | public: |
| 379 | static const std::string& |
| 380 | getName() |
| 381 | { |
| 382 | static std::string name = "storage"; |
| 383 | return name; |
| 384 | } |
| 385 | |
| 386 | StorageFixture() |
| 387 | { |
| 388 | this->data.push_back(createData("/a/b/c")); |
| 389 | this->interests.push_back(std::make_pair(Interest("/a/b/c"), this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 390 | this->ids.push_back(std::make_pair(1, this->data.back())); |
| 391 | this->insert.push_back(std::make_pair(1, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 392 | |
| 393 | this->data.push_back(createData("/a/b/d/1")); |
| 394 | this->interests.push_back(std::make_pair(Interest("/a/b/d/1"), this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 395 | this->ids.push_back(std::make_pair(2, this->data.back())); |
| 396 | this->insert.push_back(std::make_pair(2, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 397 | |
| 398 | this->data.push_back(createData("/a/b/d/2")); |
| 399 | this->interests.push_back(std::make_pair(Interest("/a/b/d/2"), this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 400 | this->ids.push_back(std::make_pair(3, this->data.back())); |
| 401 | this->insert.push_back(std::make_pair(3, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 402 | |
| 403 | this->data.push_back(createData("/a/b/d/3")); |
| 404 | this->interests.push_back(std::make_pair(Interest("/a/b/d/3"), this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 405 | this->ids.push_back(std::make_pair(4, this->data.back())); |
| 406 | this->insert.push_back(std::make_pair(4, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 407 | |
| 408 | this->data.push_back(createData("/a/b/d/4")); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 409 | this->ids.push_back(std::make_pair(5, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 410 | this->interests.push_back(std::make_pair(Interest("/a/b/d/4"), this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 411 | this->insert.push_back(std::make_pair(5, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 412 | |
| 413 | this->data.push_back(createData("/a/b/e/1")); |
| 414 | this->interests.push_back(std::make_pair(Interest("/a/b/e/1"), this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 415 | this->ids.push_back(std::make_pair(6, this->data.back())); |
| 416 | this->insert.push_back(std::make_pair(6, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 417 | |
| 418 | Selectors selector_keylocator; |
| 419 | ndn::SignatureSha256WithRsa rsaSignature(this->data.back()->getSignature()); |
| 420 | |
| 421 | this->data.push_back(createData("/a/b/e/2")); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 422 | this->ids.push_back(std::make_pair(7, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 423 | this->interests.push_back(std::make_pair(Interest("/a/b/e/2"), this->data.back())); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 424 | this->insert.push_back(std::make_pair(7, this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 425 | |
| 426 | Selectors selector; |
| 427 | selector.setChildSelector(0); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 428 | this->interestsSelectors.push_back(std::make_pair |
| 429 | (Interest("/a/b/d").setSelectors(selector), 2)); |
| 430 | this->interestDeleteCount.push_back(std::make_pair |
| 431 | (Interest("/a/b/d").setSelectors(selector), 4)); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 432 | |
| 433 | |
| 434 | selector.setChildSelector(1); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 435 | this->interestsSelectors.push_back(std::make_pair |
| 436 | (Interest("/a/b/d").setSelectors(selector), 5)); |
| 437 | this->interestDeleteCount.push_back(std::make_pair |
| 438 | (Interest("/a/b/d").setSelectors(selector), 0)); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 439 | |
| 440 | selector.setChildSelector(-1); |
| 441 | selector.setMaxSuffixComponents(2); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 442 | this->interestsSelectors.push_back(std::make_pair |
| 443 | (Interest("/a/b").setSelectors(selector), 1)); |
| 444 | this->interestDeleteCount.push_back(std::make_pair |
| 445 | (Interest("/a/b").setSelectors(selector), 1)); |
| 446 | |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 447 | ndn::name::Component from("3"); |
| 448 | ndn::name::Component to("4"); |
| 449 | Exclude exclude; |
| 450 | exclude.excludeRange(from, to); |
| 451 | selector.setChildSelector(1); |
| 452 | selector.setExclude(exclude); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 453 | this->interestsSelectors.push_back(std::make_pair |
| 454 | (Interest("/a/b/d").setSelectors(selector), 3)); |
| 455 | this->interestDeleteCount.push_back(std::make_pair |
| 456 | (Interest("/a/b/d").setSelectors(selector), 0)); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 457 | |
| 458 | |
| 459 | KeyLocator keylocate = rsaSignature.getKeyLocator(); |
| 460 | selector_keylocator.setPublisherPublicKeyLocator(keylocate); |
| 461 | this->interestsSelectors.push_back(std::make_pair |
| 462 | (Interest("/a/b/e").setSelectors(selector_keylocator), |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame^] | 463 | 6)); |
| 464 | this->interestDeleteCount |
| 465 | .push_back(std::make_pair(Interest("/a/b/e") |
| 466 | .setSelectors(selector_keylocator), 2)); |
| 467 | |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 468 | } |
| 469 | }; |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 470 | |
| 471 | typedef boost::mpl::vector< BaseTestFixture, |
| 472 | FetchByPrefixTestFixture, |
| 473 | SelectorTestFixture, |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 474 | BaseSmoketestFixture<10> > DatasetFixtures; |
| 475 | |
| 476 | typedef boost::mpl::vector< BaseTestFixture, |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 477 | BaseSmoketestFixture<10> > DatasetFixtures_Sqlite; |
| 478 | |
| 479 | typedef boost::mpl::vector<IndexTestFixture> DatasetFixtures_Index; |
| 480 | typedef boost::mpl::vector<StorageFixture> DatasetFixtures_Storage; |
| 481 | typedef boost::mpl::vector<ChildSelectorTestFixture> DatasetFixtures_Selector; |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 482 | |
| 483 | } // namespace tests |
| 484 | } // namespace repo |
| 485 | |
| 486 | #endif // REPO_TESTS_DATASET_FIXTURES_HPP |