blob: 576b87f5a03008b4cd0286261a223cb50ee5ebef [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 */
akmhoque157b0a42014-05-13 00:26:37 -05005#include <fstream>
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -05006#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 =
akmhoque157b0a42014-05-13 00:26:37 -050021 "general\n"
22 "{\n"
23 " network /ndn/\n"
24 " site /memphis.edu/\n"
25 " router /cs/pollux/\n"
26 " lsa-refresh-time 1800\n"
27 " log-level INFO\n"
28 "}\n\n"
29 "neighbors\n"
30 "{\n"
31 " hello-retries 3\n"
32 " hello-time-out 1\n"
33 " hello-interval 60\n\n"
34 " neighbor\n"
35 " {\n"
36 " name /ndn/memphis.edu/cs/castor\n"
37 " face-id 15\n"
38 " link-cost 20\n"
39 " }\n\n"
40 " neighbor\n"
41 " {\n"
42 " name /ndn/memphis.edu/cs/mira\n"
43 " face-id 17\n"
44 " link-cost 30\n"
45 " }\n"
46 "}\n\n"
47 "hyperbolic\n"
48 "{\n"
49 "state off\n"
50 "radius 123.456\n"
51 "angle 1.45\n"
52 "}\n\n"
53 "fib\n"
54 "{\n"
55 " max-faces-per-prefix 3\n"
56 "}\n\n"
57 "advertising\n"
58 "{\n"
59 "prefix /ndn/edu/memphis/cs/netlab\n"
60 "prefix /ndn/edu/memphis/sports/basketball\n"
61 "}\n";
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050062
akmhoquefdbddb12014-05-02 18:35:19 -050063 std::ofstream config;
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050064 config.open("unit-test-nlsr.conf");
65 config << CONFIG;
66 config.close();
67
akmhoquefdbddb12014-05-02 18:35:19 -050068 const std::string CONFIG_FILE = "unit-test-nlsr.conf";
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050069
70 ConfFileProcessor cfp1(nlsr1, CONFIG_FILE);
71
72 cfp1.processConfFile();
73
akmhoque157b0a42014-05-13 00:26:37 -050074 BOOST_CHECK(nlsr1.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/mira"));
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050075 BOOST_CHECK_EQUAL(
akmhoque157b0a42014-05-13 00:26:37 -050076 nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/mira").getName(),
77 "/ndn/memphis.edu/cs/mira");
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050078 BOOST_CHECK_EQUAL(
akmhoque157b0a42014-05-13 00:26:37 -050079 nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/mira").getLinkCost(),
Ashlesh Gawandeeb582eb2014-05-01 14:25:20 -050080 30);
81
82 BOOST_CHECK_EQUAL(nlsr1.getNamePrefixList().getSize(), 2);
83
84 remove("unit-test-nlsr.conf");
85}
86
87BOOST_AUTO_TEST_SUITE_END()
88
89} //namespace test
90} //namespace nlsr