blob: b404ab286355b7e43974390bb1516f97d29f9296 [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>
Alexander Afanasyevb0c78ea2014-04-15 18:12:04 -070024
25namespace repo {
26namespace tests {
27
28static inline ndn::shared_ptr<ndn::Data>
29createData(const ndn::Name& name)
30{
31 static ndn::KeyChain keyChain;
32 static std::vector<uint8_t> content(1500, '-');
33
34 ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>();
35 data->setName(name);
36 data->setContent(&content[0], content.size());
37 keyChain.sign(*data);
38
39 return data;
40}
41
42
43class DatasetBase
44{
45public:
46 typedef std::list<ndn::shared_ptr<ndn::Data> > DataContainer;
47 DataContainer data;
48
49 typedef std::list<std::pair<ndn::Interest, ndn::shared_ptr<ndn::Data> > > InterestContainer;
50 InterestContainer interests;
51};
52
53
54template<size_t N>
55class BaseSmoketestFixture : public DatasetBase
56{
57public:
58 static const std::string&
59 getName()
60 {
61 static std::string name = "BaseSmoketest";
62 return name;
63 }
64
65 BaseSmoketestFixture()
66 {
67 ndn::Name baseName("/x/y/z/test/1");
68 for (size_t i = 0; i < N; i++) {
69 ndn::Name name(baseName);
70 name.appendSegment(i);
71 ndn::shared_ptr<Data> data = createData(name);
72 this->data.push_back(data);
73
74 this->interests.push_back(std::make_pair(Interest(name), data));
75 }
76 }
77};
78
79
80class BaseTestFixture : public DatasetBase
81{
82public:
83 static const std::string&
84 getName()
85 {
86 static std::string name = "BaseTest";
87 return name;
88 }
89
90 BaseTestFixture()
91 {
92 this->data.push_back(createData("/a"));
93 this->interests.push_back(std::make_pair(Interest("/a"), this->data.back()));
94
95 this->data.push_back(createData("/a/b"));
96 this->interests.push_back(std::make_pair(Interest("/a/b"), this->data.back()));
97
98 this->data.push_back(createData("/a/b/c"));
99 this->interests.push_back(std::make_pair(Interest("/a/b/c"), this->data.back()));
100
101 this->data.push_back(createData("/a/b/c/d"));
102 this->interests.push_back(std::make_pair(Interest("/a/b/c/d"), this->data.back()));
103 }
104};
105
106
107class FetchByPrefixTestFixture : public DatasetBase
108{
109public:
110 static const std::string&
111 getName()
112 {
113 static std::string name = "FetchByPrefix";
114 return name;
115 }
116
117 FetchByPrefixTestFixture()
118 {
119 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"));
120 this->interests.push_back(std::make_pair(Interest("/a"),
121 this->data.back()));
122 this->interests.push_back(std::make_pair(Interest("/a/b"),
123 this->data.back()));
124 this->interests.push_back(std::make_pair(Interest("/a/b/c"),
125 this->data.back()));
126 this->interests.push_back(std::make_pair(Interest("/a/b/c/d"),
127 this->data.back()));
128 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e"),
129 this->data.back()));
130 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f"),
131 this->data.back()));
132 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g"),
133 this->data.back()));
134 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h"),
135 this->data.back()));
136 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i"),
137 this->data.back()));
138 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j"),
139 this->data.back()));
140 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k"),
141 this->data.back()));
142 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l"),
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/m"),
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/n"),
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/o"),
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/p"),
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/q"),
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/r"),
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/s"),
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/t"),
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/u"),
161 this->data.back()));
162 this->interests.push_back(
163 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"),
164 this->data.back()));
165 this->interests.push_back(
166 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"),
167 this->data.back()));
168 this->interests.push_back(
169 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"),
170 this->data.back()));
171 this->interests.push_back(
172 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"),
173 this->data.back()));
174 this->interests.push_back(
175 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"),
176 this->data.back()));
177 }
178};
179
180
181class SelectorTestFixture : public DatasetBase
182{
183public:
184 static const std::string&
185 getName()
186 {
187 static std::string name = "SelectorTest";
188 return name;
189 }
190
191 SelectorTestFixture()
192 {
193 this->data.push_back(createData("/a/1"));
194 this->data.push_back(createData("/b/1"));
195 this->interests.push_back(std::make_pair(Interest()
196 .setName("/b")
197 .setSelectors(Selectors()
198 .setChildSelector(0)),
199 this->data.back()));
200
201 this->data.push_back(createData("/c/1"));
202 this->data.push_back(createData("/b/99"));
203 this->interests.push_back(std::make_pair(Interest()
204 .setName("/b")
205 .setSelectors(Selectors()
206 .setChildSelector(1)),
207 this->data.back()));
208 this->data.push_back(createData("/b/5"));
209 this->data.push_back(createData("/b/55"));
210 }
211};
212
213
214typedef boost::mpl::vector< BaseTestFixture,
215 FetchByPrefixTestFixture,
216 SelectorTestFixture,
217 BaseSmoketestFixture<1>,
218 BaseSmoketestFixture<100> > DatasetFixtures;
219
220} // namespace tests
221} // namespace repo
222
223#endif // REPO_TESTS_DATASET_FIXTURES_HPP