Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Copyright (C) 2014 Regents of the University of Memphis. |
| 3 | * See COPYING for copyright and distribution information. |
| 4 | */ |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 5 | #include <fstream> |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 6 | #include "conf-file-processor.hpp" |
| 7 | #include "nlsr.hpp" |
| 8 | #include <boost/test/unit_test.hpp> |
| 9 | |
| 10 | namespace nlsr { |
| 11 | |
| 12 | namespace test { |
| 13 | |
| 14 | BOOST_AUTO_TEST_SUITE(TestConfFileProcessor) |
| 15 | |
| 16 | BOOST_AUTO_TEST_CASE(ConfFileProcessorSample) |
| 17 | { |
| 18 | Nlsr nlsr1; |
| 19 | |
| 20 | const std::string CONFIG = |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 21 | "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 Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 62 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 63 | std::ofstream config; |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 64 | config.open("unit-test-nlsr.conf"); |
| 65 | config << CONFIG; |
| 66 | config.close(); |
| 67 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 68 | const std::string CONFIG_FILE = "unit-test-nlsr.conf"; |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 69 | |
| 70 | ConfFileProcessor cfp1(nlsr1, CONFIG_FILE); |
| 71 | |
| 72 | cfp1.processConfFile(); |
| 73 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 74 | BOOST_CHECK(nlsr1.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/mira")); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 75 | BOOST_CHECK_EQUAL( |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 76 | nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/mira").getName(), |
| 77 | "/ndn/memphis.edu/cs/mira"); |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 78 | BOOST_CHECK_EQUAL( |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame^] | 79 | nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/mira").getLinkCost(), |
Ashlesh Gawande | eb582eb | 2014-05-01 14:25:20 -0500 | [diff] [blame] | 80 | 30); |
| 81 | |
| 82 | BOOST_CHECK_EQUAL(nlsr1.getNamePrefixList().getSize(), 2); |
| 83 | |
| 84 | remove("unit-test-nlsr.conf"); |
| 85 | } |
| 86 | |
| 87 | BOOST_AUTO_TEST_SUITE_END() |
| 88 | |
| 89 | } //namespace test |
| 90 | } //namespace nlsr |