blob: 3adf0b402ccee02d95f1973a1e8371674b95d029 [file] [log] [blame]
Alexander Afanasyevb0c78ea2014-04-15 18:12:04 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Alexander Afanasyeve1e6f2a2014-04-25 11:28:12 -07003 * 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 Afanasyevb0c78ea2014-04-15 18:12:04 -070018 */
19
20#ifndef REPO_TESTS_DATASET_FIXTURES_HPP
21#define REPO_TESTS_DATASET_FIXTURES_HPP
22
Alexander Afanasyeve291caf2014-04-25 11:17:36 -070023#include <ndn-cxx/security/key-chain.hpp>
Wentao Shang91fb4f22014-05-20 10:55:22 -070024#include <vector>
25#include <boost/mpl/vector.hpp>
Alexander Afanasyevb0c78ea2014-04-15 18:12:04 -070026
27namespace repo {
28namespace tests {
29
30static inline ndn::shared_ptr<ndn::Data>
31createData(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
45class DatasetBase
46{
47public:
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;
53};
54
55
56template<size_t N>
57class BaseSmoketestFixture : public DatasetBase
58{
59public:
60 static const std::string&
61 getName()
62 {
63 static std::string name = "BaseSmoketest";
64 return name;
65 }
66
67 BaseSmoketestFixture()
68 {
69 ndn::Name baseName("/x/y/z/test/1");
70 for (size_t i = 0; i < N; i++) {
71 ndn::Name name(baseName);
72 name.appendSegment(i);
73 ndn::shared_ptr<Data> data = createData(name);
74 this->data.push_back(data);
75
76 this->interests.push_back(std::make_pair(Interest(name), data));
77 }
78 }
79};
80
81
82class BaseTestFixture : public DatasetBase
83{
84public:
85 static const std::string&
86 getName()
87 {
88 static std::string name = "BaseTest";
89 return name;
90 }
91
92 BaseTestFixture()
93 {
94 this->data.push_back(createData("/a"));
95 this->interests.push_back(std::make_pair(Interest("/a"), this->data.back()));
96
97 this->data.push_back(createData("/a/b"));
98 this->interests.push_back(std::make_pair(Interest("/a/b"), this->data.back()));
99
100 this->data.push_back(createData("/a/b/c"));
101 this->interests.push_back(std::make_pair(Interest("/a/b/c"), this->data.back()));
102
103 this->data.push_back(createData("/a/b/c/d"));
104 this->interests.push_back(std::make_pair(Interest("/a/b/c/d"), this->data.back()));
105 }
106};
107
108
109class FetchByPrefixTestFixture : public DatasetBase
110{
111public:
112 static const std::string&
113 getName()
114 {
115 static std::string name = "FetchByPrefix";
116 return name;
117 }
118
119 FetchByPrefixTestFixture()
120 {
121 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"));
122 this->interests.push_back(std::make_pair(Interest("/a"),
123 this->data.back()));
124 this->interests.push_back(std::make_pair(Interest("/a/b"),
125 this->data.back()));
126 this->interests.push_back(std::make_pair(Interest("/a/b/c"),
127 this->data.back()));
128 this->interests.push_back(std::make_pair(Interest("/a/b/c/d"),
129 this->data.back()));
130 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e"),
131 this->data.back()));
132 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f"),
133 this->data.back()));
134 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g"),
135 this->data.back()));
136 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h"),
137 this->data.back()));
138 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i"),
139 this->data.back()));
140 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j"),
141 this->data.back()));
142 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k"),
143 this->data.back()));
144 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l"),
145 this->data.back()));
146 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m"),
147 this->data.back()));
148 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n"),
149 this->data.back()));
150 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o"),
151 this->data.back()));
152 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p"),
153 this->data.back()));
154 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"),
155 this->data.back()));
156 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"),
157 this->data.back()));
158 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"),
159 this->data.back()));
160 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"),
161 this->data.back()));
162 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"),
163 this->data.back()));
164 this->interests.push_back(
165 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"),
166 this->data.back()));
167 this->interests.push_back(
168 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"),
169 this->data.back()));
170 this->interests.push_back(
171 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"),
172 this->data.back()));
173 this->interests.push_back(
174 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"),
175 this->data.back()));
176 this->interests.push_back(
177 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"),
178 this->data.back()));
179 }
180};
181
182
183class SelectorTestFixture : public DatasetBase
184{
185public:
186 static const std::string&
187 getName()
188 {
189 static std::string name = "SelectorTest";
190 return name;
191 }
192
193 SelectorTestFixture()
194 {
195 this->data.push_back(createData("/a/1"));
196 this->data.push_back(createData("/b/1"));
197 this->interests.push_back(std::make_pair(Interest()
198 .setName("/b")
199 .setSelectors(Selectors()
200 .setChildSelector(0)),
201 this->data.back()));
202
203 this->data.push_back(createData("/c/1"));
204 this->data.push_back(createData("/b/99"));
205 this->interests.push_back(std::make_pair(Interest()
206 .setName("/b")
207 .setSelectors(Selectors()
208 .setChildSelector(1)),
209 this->data.back()));
210 this->data.push_back(createData("/b/5"));
211 this->data.push_back(createData("/b/55"));
212 }
213};
214
215
216typedef boost::mpl::vector< BaseTestFixture,
217 FetchByPrefixTestFixture,
218 SelectorTestFixture,
219 BaseSmoketestFixture<1>,
220 BaseSmoketestFixture<100> > DatasetFixtures;
221
222} // namespace tests
223} // namespace repo
224
225#endif // REPO_TESTS_DATASET_FIXTURES_HPP