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 | |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 30 | |
| 31 | class DatasetBase |
| 32 | { |
| 33 | public: |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 34 | class Error : public std::runtime_error |
| 35 | { |
| 36 | public: |
| 37 | explicit |
| 38 | Error(const std::string& what) |
| 39 | : std::runtime_error(what) |
| 40 | { |
| 41 | } |
| 42 | }; |
| 43 | |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 44 | typedef std::list<ndn::shared_ptr<ndn::Data> > DataContainer; |
| 45 | DataContainer data; |
| 46 | |
| 47 | typedef std::list<std::pair<ndn::Interest, ndn::shared_ptr<ndn::Data> > > InterestContainer; |
| 48 | InterestContainer interests; |
Shuo Chen | 9a43f16 | 2014-07-01 13:43:54 +0800 | [diff] [blame] | 49 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 50 | typedef std::list<std::pair<ndn::Interest, size_t > > RemovalsContainer; |
| 51 | RemovalsContainer removals; |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 52 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 53 | protected: |
| 54 | ndn::shared_ptr<ndn::Data> |
| 55 | createData(const ndn::Name& name) |
Shuo Chen | 9a43f16 | 2014-07-01 13:43:54 +0800 | [diff] [blame] | 56 | { |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 57 | if (map.count(name) > 0) |
| 58 | return map[name]; |
Shuo Chen | 9a43f16 | 2014-07-01 13:43:54 +0800 | [diff] [blame] | 59 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 60 | static ndn::KeyChain keyChain; |
| 61 | static std::vector<uint8_t> content(1500, '-'); |
| 62 | |
| 63 | ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>(); |
| 64 | data->setName(name); |
| 65 | data->setContent(&content[0], content.size()); |
| 66 | keyChain.sign(*data); |
| 67 | |
| 68 | map.insert(std::make_pair(name, data)); |
| 69 | return data; |
| 70 | } |
| 71 | |
| 72 | ndn::shared_ptr<ndn::Data> |
| 73 | getData(const ndn::Name& name) |
Shuo Chen | 9a43f16 | 2014-07-01 13:43:54 +0800 | [diff] [blame] | 74 | { |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 75 | if (map.count(name) > 0) |
| 76 | return map[name]; |
| 77 | else |
| 78 | throw Error("Data with name " + name.toUri() + " is not found"); |
| 79 | } |
| 80 | |
| 81 | private: |
| 82 | std::map<Name, shared_ptr<Data> > map; |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | |
| 86 | template<size_t N> |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 87 | class SamePrefixDataset : public DatasetBase |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 88 | { |
| 89 | public: |
| 90 | static const std::string& |
| 91 | getName() |
| 92 | { |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 93 | static std::string name = "SamePrefixDataset"; |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 94 | return name; |
| 95 | } |
| 96 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 97 | SamePrefixDataset() |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 98 | { |
| 99 | ndn::Name baseName("/x/y/z/test/1"); |
| 100 | for (size_t i = 0; i < N; i++) { |
| 101 | ndn::Name name(baseName); |
| 102 | name.appendSegment(i); |
| 103 | ndn::shared_ptr<Data> data = createData(name); |
| 104 | this->data.push_back(data); |
| 105 | |
| 106 | this->interests.push_back(std::make_pair(Interest(name), data)); |
| 107 | } |
| 108 | } |
| 109 | }; |
| 110 | |
| 111 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 112 | class BasicDataset : public DatasetBase |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 113 | { |
| 114 | public: |
| 115 | static const std::string& |
| 116 | getName() |
| 117 | { |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 118 | static std::string name = "BasicDataset"; |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 119 | return name; |
| 120 | } |
| 121 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 122 | BasicDataset() |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 123 | { |
| 124 | this->data.push_back(createData("/a")); |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 125 | this->data.push_back(createData("/a/b")); |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 126 | this->data.push_back(createData("/a/b/c")); |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 127 | this->data.push_back(createData("/a/b/c/d")); |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 128 | |
Alexander Afanasyev | 595b2bd | 2014-12-14 12:55:36 -0800 | [diff] [blame] | 129 | this->interests.push_back(std::make_pair(Interest("/a"), getData("/a"))); |
| 130 | this->interests.push_back(std::make_pair(Interest("/a/b"), getData("/a/b"))); |
| 131 | this->interests.push_back(std::make_pair(Interest("/a/b/c"), getData("/a/b/c"))); |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 132 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d"), getData("/a/b/c/d"))); |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 133 | } |
| 134 | }; |
| 135 | |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 136 | //Fetch by prefix is useless due to the database is fetched by id |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 137 | class FetchByPrefixDataset : public DatasetBase |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 138 | { |
| 139 | public: |
| 140 | static const std::string& |
| 141 | getName() |
| 142 | { |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 143 | static std::string name = "FetchByPrefixDataset"; |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 144 | return name; |
| 145 | } |
| 146 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 147 | FetchByPrefixDataset() |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 148 | { |
| 149 | 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")); |
| 150 | this->interests.push_back(std::make_pair(Interest("/a"), |
| 151 | this->data.back())); |
| 152 | this->interests.push_back(std::make_pair(Interest("/a/b"), |
| 153 | this->data.back())); |
| 154 | this->interests.push_back(std::make_pair(Interest("/a/b/c"), |
| 155 | this->data.back())); |
| 156 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d"), |
| 157 | this->data.back())); |
| 158 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e"), |
| 159 | this->data.back())); |
| 160 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f"), |
| 161 | this->data.back())); |
| 162 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g"), |
| 163 | this->data.back())); |
| 164 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h"), |
| 165 | this->data.back())); |
| 166 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i"), |
| 167 | this->data.back())); |
| 168 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j"), |
| 169 | this->data.back())); |
| 170 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k"), |
| 171 | this->data.back())); |
| 172 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l"), |
| 173 | this->data.back())); |
| 174 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m"), |
| 175 | this->data.back())); |
| 176 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n"), |
| 177 | this->data.back())); |
| 178 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o"), |
| 179 | this->data.back())); |
| 180 | this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p"), |
| 181 | this->data.back())); |
| 182 | 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"), |
| 183 | this->data.back())); |
| 184 | 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"), |
| 185 | this->data.back())); |
| 186 | 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"), |
| 187 | this->data.back())); |
| 188 | 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"), |
| 189 | this->data.back())); |
| 190 | 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"), |
| 191 | this->data.back())); |
| 192 | this->interests.push_back( |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 193 | 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"), |
| 194 | this->data.back())); |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 195 | this->interests.push_back( |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 196 | 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"), |
| 197 | this->data.back())); |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 198 | this->interests.push_back( |
| 199 | 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"), |
| 200 | this->data.back())); |
| 201 | this->interests.push_back( |
| 202 | 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"), |
| 203 | this->data.back())); |
| 204 | this->interests.push_back( |
| 205 | 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"), |
| 206 | this->data.back())); |
| 207 | } |
| 208 | }; |
| 209 | |
| 210 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 211 | class BasicChildSelectorDataset : public DatasetBase |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 212 | { |
| 213 | public: |
| 214 | static const std::string& |
| 215 | getName() |
| 216 | { |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 217 | static std::string name = "BasicChildSelectorDataset"; |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 218 | return name; |
| 219 | } |
| 220 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 221 | BasicChildSelectorDataset() |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 222 | { |
| 223 | this->data.push_back(createData("/a/1")); |
| 224 | this->data.push_back(createData("/b/1")); |
| 225 | this->interests.push_back(std::make_pair(Interest() |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 226 | .setName("/b") |
| 227 | .setSelectors(Selectors() |
| 228 | .setChildSelector(0)), |
| 229 | this->data.back())); |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 230 | |
| 231 | this->data.push_back(createData("/c/1")); |
| 232 | this->data.push_back(createData("/b/99")); |
| 233 | this->interests.push_back(std::make_pair(Interest() |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 234 | .setName("/b") |
| 235 | .setSelectors(Selectors() |
| 236 | .setChildSelector(1)), |
| 237 | this->data.back())); |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 238 | this->data.push_back(createData("/b/5")); |
| 239 | this->data.push_back(createData("/b/55")); |
| 240 | } |
| 241 | }; |
| 242 | |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 243 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 244 | class ExtendedChildSelectorDataset : public DatasetBase |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 245 | { |
| 246 | public: |
| 247 | static const std::string& |
| 248 | getName() |
| 249 | { |
| 250 | static std::string name = "storage"; |
| 251 | return name; |
| 252 | } |
| 253 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 254 | ExtendedChildSelectorDataset() |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 255 | { |
| 256 | this->data.push_back(createData("/a/b/1")); |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 257 | |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 258 | this->data.push_back(createData("/a/c/1")); |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 259 | this->interests.push_back(std::make_pair(Interest("/a") |
| 260 | .setSelectors(Selectors() |
| 261 | .setChildSelector(1)), |
| 262 | this->data.back())); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 263 | |
| 264 | this->data.push_back(createData("/a/c/2")); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 265 | |
| 266 | this->data.push_back(createData("/b")); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 267 | } |
| 268 | }; |
| 269 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 270 | |
| 271 | class ComplexSelectorsDataset : public DatasetBase |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 272 | { |
| 273 | public: |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 274 | static const std::string& |
| 275 | getName() |
| 276 | { |
| 277 | static std::string name = "ComplexSelectorsDataset"; |
| 278 | return name; |
| 279 | } |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 280 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 281 | std::map<std::string, shared_ptr<Data> > map; |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 282 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 283 | void |
| 284 | addData(const std::string& name) |
| 285 | { |
| 286 | } |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 287 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 288 | ComplexSelectorsDataset() |
| 289 | { |
| 290 | // Dataset |
| 291 | this->data.push_back(createData("/a/b/c")); |
| 292 | this->data.push_back(createData("/a/b/d/1")); |
| 293 | this->data.push_back(createData("/a/b/d/2")); |
| 294 | this->data.push_back(createData("/a/b/d/3")); |
| 295 | this->data.push_back(createData("/a/b/d/4/I")); |
| 296 | this->data.push_back(createData("/a/b/d/4")); |
| 297 | this->data.push_back(createData("/a/b/d")); |
| 298 | this->data.push_back(createData("/a/b/e/1")); |
| 299 | this->data.push_back(createData("/a/b/e")); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 300 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 301 | // Basic selects |
| 302 | this->interests.push_back(std::make_pair(Interest("/a/b/c"), this->getData("/a/b/c"))); |
Alexander Afanasyev | 595b2bd | 2014-12-14 12:55:36 -0800 | [diff] [blame] | 303 | this->interests.push_back(std::make_pair(Interest("/a/b/d"), this->getData("/a/b/d"))); |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 304 | this->interests.push_back(std::make_pair(Interest("/a/b/d/1"), this->getData("/a/b/d/1"))); |
| 305 | this->interests.push_back(std::make_pair(Interest("/a/b/d/2"), this->getData("/a/b/d/2"))); |
| 306 | this->interests.push_back(std::make_pair(Interest("/a/b/d/3"), this->getData("/a/b/d/3"))); |
| 307 | this->interests.push_back(std::make_pair(Interest("/a/b/d/4/I"), this->getData("/a/b/d/4/I"))); |
Alexander Afanasyev | 595b2bd | 2014-12-14 12:55:36 -0800 | [diff] [blame] | 308 | this->interests.push_back(std::make_pair(Interest("/a/b/d/4"), this->getData("/a/b/d/4"))); |
| 309 | this->interests.push_back(std::make_pair(Interest("/a/b/e"), this->getData("/a/b/e"))); |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 310 | this->interests.push_back(std::make_pair(Interest("/a/b/e/1"), this->getData("/a/b/e/1"))); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 311 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 312 | // Complex selects |
| 313 | this->interests.push_back(std::make_pair(Interest("/a/b") |
| 314 | .setSelectors(Selectors() |
| 315 | .setMinSuffixComponents(2) |
| 316 | .setMaxSuffixComponents(2)), |
| 317 | this->getData("/a/b/c"))); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 318 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 319 | this->interests.push_back(std::make_pair(Interest("/a/b/d") |
| 320 | .setSelectors(Selectors() |
| 321 | .setMinSuffixComponents(-1) |
| 322 | .setChildSelector(0)), |
Alexander Afanasyev | 595b2bd | 2014-12-14 12:55:36 -0800 | [diff] [blame] | 323 | this->getData("/a/b/d"))); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 324 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 325 | this->interests.push_back(std::make_pair(Interest("/a/b/d") |
| 326 | .setSelectors(Selectors() |
| 327 | .setMinSuffixComponents(2) |
| 328 | .setChildSelector(0)), |
| 329 | this->getData("/a/b/d/1"))); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 330 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 331 | this->interests.push_back(std::make_pair( |
| 332 | Interest("/a/b/d") |
| 333 | .setSelectors(Selectors() |
| 334 | .setChildSelector(1) |
| 335 | .setMaxSuffixComponents(2) |
| 336 | .setMinSuffixComponents(2) |
| 337 | .setExclude(Exclude() |
| 338 | .excludeRange(ndn::name::Component("3"), |
| 339 | ndn::name::Component("4")))), |
| 340 | this->getData("/a/b/d/2"))); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 341 | |
| 342 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 343 | this->interests.push_back(std::make_pair(Interest("/a/b/d") |
| 344 | .setSelectors(Selectors().setMinSuffixComponents(3)), |
| 345 | this->getData("/a/b/d/4/I"))); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 346 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 347 | // According to selector definition, RightMost for the next level and LeftMost for the next-next level |
| 348 | this->interests.push_back(std::make_pair(Interest("/a/b/d") |
| 349 | .setSelectors(Selectors() |
| 350 | .setMinSuffixComponents(2) |
| 351 | .setChildSelector(1)), |
Alexander Afanasyev | 595b2bd | 2014-12-14 12:55:36 -0800 | [diff] [blame] | 352 | this->getData("/a/b/d/4"))); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame] | 353 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 354 | // because of the digest component, /a/b/d will be to the right of /a/b/d/4 |
| 355 | this->interests.push_back(std::make_pair(Interest("/a/b/d") |
| 356 | .setSelectors(Selectors() |
| 357 | .setChildSelector(1)), |
Alexander Afanasyev | 595b2bd | 2014-12-14 12:55:36 -0800 | [diff] [blame] | 358 | this->getData("/a/b/d/4"))); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 359 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 360 | // Alex: this interest doesn't make sense, as all Data packets will have the same selector |
| 361 | this->interests.push_back(std::make_pair(Interest("/a/b/e") |
| 362 | .setSelectors(Selectors() |
| 363 | .setPublisherPublicKeyLocator( |
| 364 | this->data.back() |
| 365 | ->getSignature().getKeyLocator())), |
Alexander Afanasyev | 595b2bd | 2014-12-14 12:55:36 -0800 | [diff] [blame] | 366 | this->getData("/a/b/e"))); |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 367 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 368 | // Removals |
| 369 | this->removals.push_back(std::make_pair(Interest("/a/b/d/2"), 1)); |
Weiqi Shi | f0330d5 | 2014-07-09 10:54:27 -0700 | [diff] [blame] | 370 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 371 | this->removals.push_back(std::make_pair( |
| 372 | Interest("/a/b/d") |
| 373 | .setSelectors(Selectors() |
| 374 | .setMaxSuffixComponents(2) |
| 375 | .setMinSuffixComponents(2) |
| 376 | .setExclude(Exclude() |
| 377 | .excludeOne(ndn::name::Component("3")))), |
| 378 | 2)); |
| 379 | } |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 380 | }; |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 381 | |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 382 | |
Alexander Afanasyev | b7e8a81 | 2014-07-23 01:36:47 -0700 | [diff] [blame] | 383 | typedef boost::mpl::vector< BasicDataset, |
| 384 | FetchByPrefixDataset, |
| 385 | BasicChildSelectorDataset, |
| 386 | ExtendedChildSelectorDataset, |
| 387 | SamePrefixDataset<10>, |
| 388 | SamePrefixDataset<100> > CommonDatasets; |
Weiqi Shi | 28a90fb | 2014-07-09 10:28:55 -0700 | [diff] [blame] | 389 | |
Alexander Afanasyev | b0c78ea | 2014-04-15 18:12:04 -0700 | [diff] [blame] | 390 | |
| 391 | } // namespace tests |
| 392 | } // namespace repo |
| 393 | |
| 394 | #endif // REPO_TESTS_DATASET_FIXTURES_HPP |