blob: a786ec98ca69e5ff9c3d53a62d6ffa956d39d7cf [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 **/
akmhoque157b0a42014-05-13 00:26:37 -050023#include <fstream>
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050024#include "conf-file-processor.hpp"
25#include "nlsr.hpp"
26#include <boost/test/unit_test.hpp>
27
28namespace nlsr {
29
30namespace test {
31
32BOOST_AUTO_TEST_SUITE(TestConfFileProcessor)
33
34BOOST_AUTO_TEST_CASE(ConfFileProcessorSample)
35{
36 Nlsr nlsr1;
37
38 const std::string CONFIG =
akmhoque157b0a42014-05-13 00:26:37 -050039 "general\n"
40 "{\n"
41 " network /ndn/\n"
42 " site /memphis.edu/\n"
43 " router /cs/pollux/\n"
44 " lsa-refresh-time 1800\n"
45 " log-level INFO\n"
46 "}\n\n"
47 "neighbors\n"
48 "{\n"
49 " hello-retries 3\n"
50 " hello-time-out 1\n"
51 " hello-interval 60\n\n"
52 " neighbor\n"
53 " {\n"
54 " name /ndn/memphis.edu/cs/castor\n"
55 " face-id 15\n"
56 " link-cost 20\n"
57 " }\n\n"
58 " neighbor\n"
59 " {\n"
60 " name /ndn/memphis.edu/cs/mira\n"
61 " face-id 17\n"
62 " link-cost 30\n"
63 " }\n"
64 "}\n\n"
65 "hyperbolic\n"
66 "{\n"
67 "state off\n"
68 "radius 123.456\n"
69 "angle 1.45\n"
70 "}\n\n"
71 "fib\n"
72 "{\n"
73 " max-faces-per-prefix 3\n"
74 "}\n\n"
75 "advertising\n"
76 "{\n"
77 "prefix /ndn/edu/memphis/cs/netlab\n"
78 "prefix /ndn/edu/memphis/sports/basketball\n"
79 "}\n";
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050080
akmhoquefdbddb12014-05-02 18:35:19 -050081 std::ofstream config;
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050082 config.open("unit-test-nlsr.conf");
83 config << CONFIG;
84 config.close();
85
akmhoquefdbddb12014-05-02 18:35:19 -050086 const std::string CONFIG_FILE = "unit-test-nlsr.conf";
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050087
88 ConfFileProcessor cfp1(nlsr1, CONFIG_FILE);
89
90 cfp1.processConfFile();
91
akmhoque157b0a42014-05-13 00:26:37 -050092 BOOST_CHECK(nlsr1.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/mira"));
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050093 BOOST_CHECK_EQUAL(
akmhoque157b0a42014-05-13 00:26:37 -050094 nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/mira").getName(),
95 "/ndn/memphis.edu/cs/mira");
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050096 BOOST_CHECK_EQUAL(
akmhoque157b0a42014-05-13 00:26:37 -050097 nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/mira").getLinkCost(),
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050098 30);
99
100 BOOST_CHECK_EQUAL(nlsr1.getNamePrefixList().getSize(), 2);
101
102 remove("unit-test-nlsr.conf");
103}
104
105BOOST_AUTO_TEST_SUITE_END()
106
107} //namespace test
108} //namespace nlsr