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