blob: 1f6e6d4832acda69866ca555505d8f7111eefb5e [file] [log] [blame]
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -05001/**
2 * Copyright (C) 2014 Regents of the University of Memphis.
3 * See COPYING for copyright and distribution information.
4 */
5
6#include "lsdb.hpp"
7#include "nlsr.hpp"
8#include "lsa.hpp"
9#include "name-prefix-list.hpp"
10#include <boost/test/unit_test.hpp>
akmhoquec7a79b22014-05-26 08:06:19 -050011#include <ndn-cxx/util/time.hpp>
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050012
13namespace nlsr {
14
15namespace test {
16
17BOOST_AUTO_TEST_SUITE(TestLsdb)
18
19BOOST_AUTO_TEST_CASE(LsdbRemoveAndExists)
20{
21 Nlsr nlsr1;
akmhoquec7a79b22014-05-26 08:06:19 -050022 ndn::time::system_clock::TimePoint testTimePoint = ndn::time::system_clock::now();
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050023 NamePrefixList npl1;
24
akmhoquefdbddb12014-05-02 18:35:19 -050025 std::string s1 = "name1";
26 std::string s2 = "name2";
27 std::string router1 = "router1/1";
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050028
29 npl1.insert(s1);
30 npl1.insert(s2);
31
akmhoque157b0a42014-05-13 00:26:37 -050032//For NameLsa lsType is name.
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050033//12 is seqNo, randomly generated.
34//1800 is the default life time.
akmhoquec7a79b22014-05-26 08:06:19 -050035 NameLsa nlsa1("router1", std::string("name"), 12, testTimePoint, npl1);
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050036
akmhoque31d1d4b2014-05-05 22:08:14 -050037 Lsdb lsdb1(nlsr1);
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050038
akmhoque31d1d4b2014-05-05 22:08:14 -050039 lsdb1.installNameLsa(nlsa1);
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050040
akmhoque31d1d4b2014-05-05 22:08:14 -050041 BOOST_CHECK(lsdb1.doesLsaExist("router1/1", std::string("name")));
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050042
akmhoque31d1d4b2014-05-05 22:08:14 -050043 lsdb1.removeNameLsa(router1);
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050044
akmhoque31d1d4b2014-05-05 22:08:14 -050045 BOOST_CHECK_EQUAL(lsdb1.doesLsaExist("router1/1", std::string("name")), false);
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050046}
47
48BOOST_AUTO_TEST_SUITE_END()
49
50} //namespace test
51} //namespace nlsr