blob: 9554aeafa592e303d379ccf93afcb4b7b302e5ef [file] [log] [blame]
Weiqi Shif0330d52014-07-09 10:54:27 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
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/>.
18 */
19
20#include "storage/repo-storage.hpp"
21#include "storage/sqlite-storage.hpp"
22#include "../dataset-fixtures.hpp"
23#include "../repo-storage-fixture.hpp"
24
25#include <boost/test/unit_test.hpp>
26#include <iostream>
27#include <string.h>
28
29namespace repo {
30namespace tests {
31
32BOOST_AUTO_TEST_SUITE(RepoStorage)
Alexander Afanasyevb7e8a812014-07-23 01:36:47 -070033
Weiqi Shif0330d52014-07-09 10:54:27 -070034template<class Dataset>
35class Fixture : public Dataset, public RepoStorageFixture
36{
37};
38
Alexander Afanasyevd3e9da12014-11-12 11:31:31 -080039// // Combine CommonDatasets with ComplexSelectorDataset
40// typedef boost::mpl::push_back<CommonDatasets,
41// ComplexSelectorsDataset>::type Datasets;
Alexander Afanasyevb7e8a812014-07-23 01:36:47 -070042
Alexander Afanasyevd3e9da12014-11-12 11:31:31 -080043// BOOST_FIXTURE_TEST_CASE_TEMPLATE(Bulk, T, Datasets, Fixture<T>)
44BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES(Bulk, 7)
45BOOST_FIXTURE_TEST_CASE(Bulk, Fixture<ComplexSelectorsDataset>)
Weiqi Shif0330d52014-07-09 10:54:27 -070046{
Alexander Afanasyevd3e9da12014-11-12 11:31:31 -080047 typedef ComplexSelectorsDataset T;
Alexander Afanasyevb7e8a812014-07-23 01:36:47 -070048 BOOST_TEST_MESSAGE(T::getName());
49
50 // Insert data into repo
Weiqi Shif0330d52014-07-09 10:54:27 -070051 for (typename T::DataContainer::iterator i = this->data.begin();
Alexander Afanasyevb7e8a812014-07-23 01:36:47 -070052 i != this->data.end(); ++i)
Weiqi Shif0330d52014-07-09 10:54:27 -070053 {
54 BOOST_CHECK_EQUAL(this->handle->insertData(**i), true);
55 }
Alexander Afanasyevb7e8a812014-07-23 01:36:47 -070056
57 // check size directly with the storage (repo doesn't have interface yet)
58 BOOST_CHECK_EQUAL(this->store->size(), this->data.size());
59
60 // Read
Weiqi Shif0330d52014-07-09 10:54:27 -070061 for (typename T::InterestContainer::iterator i = this->interests.begin();
Alexander Afanasyevb7e8a812014-07-23 01:36:47 -070062 i != this->interests.end(); ++i)
Weiqi Shif0330d52014-07-09 10:54:27 -070063 {
64 shared_ptr<ndn::Data> dataTest = this->handle->readData(i->first);
65 BOOST_CHECK_EQUAL(*this->handle->readData(i->first), *i->second);
Weiqi Shif0330d52014-07-09 10:54:27 -070066 }
Alexander Afanasyevb7e8a812014-07-23 01:36:47 -070067
68 // Remove items
69 for (typename T::RemovalsContainer::iterator i = this->removals.begin();
70 i != this->removals.end(); ++i)
Weiqi Shif0330d52014-07-09 10:54:27 -070071 {
Alexander Afanasyevb7e8a812014-07-23 01:36:47 -070072 size_t nRemoved = 0;
73 BOOST_REQUIRE_NO_THROW(nRemoved = this->handle->deleteData(i->first));
74 BOOST_CHECK_EQUAL(nRemoved, i->second);
Weiqi Shif0330d52014-07-09 10:54:27 -070075 }
Weiqi Shif0330d52014-07-09 10:54:27 -070076}
77
78BOOST_AUTO_TEST_SUITE_END()
79
80} // namespace tests
81} // namespace repo