blob: 84493d25fa540bcdcb4faeca1ce731580e839732 [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -05002/**
akmhoque3d06e792014-05-27 16:23:20 -05003 * Copyright (c) 2014 University of Memphis,
4 * Regents of the University of California
5 *
6 * This file is part of NLSR (Named-data Link State Routing).
7 * See AUTHORS.md for complete list of NLSR authors and contributors.
8 *
9 * NLSR is free software: you can redistribute it and/or modify it under the terms
10 * of the GNU General Public License as published by the Free Software Foundation,
11 * either version 3 of the License, or (at your option) any later version.
12 *
13 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * \author Ashlesh Gawande <agawande@memphis.edu>
21 *
22 **/
Vince Lehman7c603292014-09-11 17:48:16 -050023
24#include "test-common.hpp"
25
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050026#include "lsdb.hpp"
27#include "nlsr.hpp"
28#include "lsa.hpp"
29#include "name-prefix-list.hpp"
30#include <boost/test/unit_test.hpp>
akmhoquec7a79b22014-05-26 08:06:19 -050031#include <ndn-cxx/util/time.hpp>
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050032
33namespace nlsr {
34
35namespace test {
36
Vince Lehman7c603292014-09-11 17:48:16 -050037BOOST_FIXTURE_TEST_SUITE(TestLsdb, BaseFixture)
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050038
39BOOST_AUTO_TEST_CASE(LsdbRemoveAndExists)
40{
Vince Lehmanf99b87f2014-08-26 15:54:27 -050041 INIT_LOGGERS("/tmp", "DEBUG");
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -070042
Vince Lehman7c603292014-09-11 17:48:16 -050043 Nlsr nlsr1(g_ioService, g_scheduler);
akmhoquec7a79b22014-05-26 08:06:19 -050044 ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050045 NamePrefixList npl1;
46
akmhoquefdbddb12014-05-02 18:35:19 -050047 std::string s1 = "name1";
48 std::string s2 = "name2";
49 std::string router1 = "router1/1";
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050050
51 npl1.insert(s1);
52 npl1.insert(s2);
53
akmhoque157b0a42014-05-13 00:26:37 -050054//For NameLsa lsType is name.
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050055//12 is seqNo, randomly generated.
56//1800 is the default life time.
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -070057 NameLsa nlsa1(ndn::Name("/router1/1"), std::string("name"), 12, testTimePoint, npl1);
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050058
Vince Lehman7c603292014-09-11 17:48:16 -050059 Lsdb lsdb1(nlsr1, g_scheduler);
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050060
akmhoque31d1d4b2014-05-05 22:08:14 -050061 lsdb1.installNameLsa(nlsa1);
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -070062 lsdb1.writeNameLsdbLog();
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050063
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -070064 BOOST_CHECK(lsdb1.doesLsaExist(ndn::Name("/router1/1/name"), std::string("name")));
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050065
akmhoque31d1d4b2014-05-05 22:08:14 -050066 lsdb1.removeNameLsa(router1);
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050067
Alexander Afanasyev411ee4b2014-08-16 23:17:03 -070068 BOOST_CHECK_EQUAL(lsdb1.doesLsaExist(ndn::Name("/router1/1"), std::string("name")), false);
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050069}
70
71BOOST_AUTO_TEST_SUITE_END()
72
73} //namespace test
74} //namespace nlsr