blob: 7b87faceda44737fb0dc2c1447ac136dd120764e [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
32 ofstream config;
33 config.open("unit-test-nlsr.conf");
34 config << CONFIG;
35 config.close();
36
37 const string CONFIG_FILE = "unit-test-nlsr.conf";
38
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