blob: 8ec3a4ebc20f5712df74ca0765ed5b5bfad0e84c [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 "conf-file-processor.hpp"
7#include "nlsr.hpp"
8#include <boost/test/unit_test.hpp>
9
10namespace nlsr {
11
12namespace test {
13
14BOOST_AUTO_TEST_SUITE(TestConfFileProcessor)
15
16BOOST_AUTO_TEST_CASE(ConfFileProcessorSample)
17{
18 Nlsr nlsr1;
19
20 const std::string CONFIG =
21 "network ndn\n"
22 "site-name memphis.edu\n"
23 "router-name cs/macbook\n\n"
24 "ndnneighbor /ndn/memphis.edu/cs/maia 7\n"
25 "link-cost /ndn/memphis.edu/cs/maia 30\n"
26 "ndnneighbor /ndn/memphis.edu/cs/pollux 10\n"
27 "link-cost /ndn/memphis.edu/cs/pollux 25\n\n"
28 "ndnname /ndn/memphis.edu/cs/macbook/name1\n"
29 "ndnname /ndn/memphis.edu/cs/macbook/name2\n\n\n"
30 ;
31
akmhoquefdbddb12014-05-02 18:35:19 -050032 std::ofstream config;
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050033 config.open("unit-test-nlsr.conf");
34 config << CONFIG;
35 config.close();
36
akmhoquefdbddb12014-05-02 18:35:19 -050037 const std::string CONFIG_FILE = "unit-test-nlsr.conf";
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050038
39 ConfFileProcessor cfp1(nlsr1, CONFIG_FILE);
40
41 cfp1.processConfFile();
42
43 BOOST_CHECK(nlsr1.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/maia"));
44 BOOST_CHECK_EQUAL(
45 nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/maia").getName(),
46 "/ndn/memphis.edu/cs/maia");
47 BOOST_CHECK_EQUAL(
48 nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/maia").getLinkCost(),
49 30);
50
51 BOOST_CHECK_EQUAL(nlsr1.getNamePrefixList().getSize(), 2);
52
53 remove("unit-test-nlsr.conf");
54}
55
56BOOST_AUTO_TEST_SUITE_END()
57
58} //namespace test
59} //namespace nlsr