blob: 737e89e78fbe04a1d77c7dfcd8532851c8182417 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Junxiao Shibc19b372014-03-23 16:59:25 -07002/**
Alexander Afanasyevc169a812014-05-20 20:37:29 -04003 * Copyright (c) 2013-2014 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
Junxiao Shibc19b372014-03-23 16:59:25 -070020 */
21
22#include "management/nfd-control-parameters.hpp"
Junxiao Shibc19b372014-03-23 16:59:25 -070023
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070024#include "boost-test.hpp"
Junxiao Shibc19b372014-03-23 16:59:25 -070025
26namespace ndn {
27namespace nfd {
28
Alexander Afanasyevd1b5c412014-03-27 15:03:51 -070029BOOST_AUTO_TEST_SUITE(ManagementTestNfdControlParameters)
Junxiao Shibc19b372014-03-23 16:59:25 -070030
31BOOST_AUTO_TEST_CASE(FaceOptions)
32{
33 ControlParameters parameters;
34 parameters.setUri("tcp4://192.0.2.1:6363");
35
36 Block wire = parameters.wireEncode();
37
38 ControlParameters decoded(wire);
39 BOOST_CHECK_EQUAL(decoded.getUri(), "tcp4://192.0.2.1:6363");
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070040
Junxiao Shibc19b372014-03-23 16:59:25 -070041 BOOST_CHECK_EQUAL(decoded.hasName(), false);
42 BOOST_CHECK_EQUAL(decoded.hasFaceId(), false);
43 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070044 BOOST_CHECK_EQUAL(decoded.hasOrigin(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070045 BOOST_CHECK_EQUAL(decoded.hasCost(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070046 BOOST_CHECK_EQUAL(decoded.hasFlags(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070047 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070048 BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070049}
50
51BOOST_AUTO_TEST_CASE(FaceLocalControlOptions)
52{
53 ControlParameters parameters;
54 parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID);
55
56 Block wire = parameters.wireEncode();
57
58 ControlParameters decoded(wire);
59 BOOST_CHECK_EQUAL(decoded.getLocalControlFeature(), LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070060
Junxiao Shibc19b372014-03-23 16:59:25 -070061 BOOST_CHECK_EQUAL(decoded.hasName(), false);
62 BOOST_CHECK_EQUAL(decoded.hasFaceId(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070063 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070064 BOOST_CHECK_EQUAL(decoded.hasOrigin(), false);
65 BOOST_CHECK_EQUAL(decoded.hasCost(), false);
66 BOOST_CHECK_EQUAL(decoded.hasFlags(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070067 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070068 BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070069}
70
71BOOST_AUTO_TEST_CASE(FibOptions)
72{
73 ControlParameters parameters;
74 parameters.setName("ndn:/example")
75 .setFaceId(4)
76 .setCost(555);
77
78 Block wire = parameters.wireEncode();
79
80 ControlParameters decoded(wire);
81 BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/example"));
82 BOOST_CHECK_EQUAL(decoded.getFaceId(), 4);
83 BOOST_CHECK_EQUAL(decoded.getCost(), 555);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070084
Junxiao Shibc19b372014-03-23 16:59:25 -070085 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070086 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
87 BOOST_CHECK_EQUAL(decoded.hasOrigin(), false);
88 BOOST_CHECK_EQUAL(decoded.hasFlags(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070089 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070090 BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070091}
92
93BOOST_AUTO_TEST_CASE(StrategyChoiceOptions)
94{
95 ControlParameters parameters;
96 parameters.setName("ndn:/")
97 .setStrategy("ndn:/strategy/A");
98
99 Block wire = parameters.wireEncode();
100
101 ControlParameters decoded(wire);
102 BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/"));
103 BOOST_CHECK_EQUAL(decoded.getStrategy(), Name("ndn:/strategy/A"));
Junxiao Shi5f6c74f2014-04-18 16:29:44 -0700104
Junxiao Shibc19b372014-03-23 16:59:25 -0700105 BOOST_CHECK_EQUAL(decoded.hasFaceId(), false);
106 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
107 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -0700108 BOOST_CHECK_EQUAL(decoded.hasOrigin(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -0700109 BOOST_CHECK_EQUAL(decoded.hasCost(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -0700110 BOOST_CHECK_EQUAL(decoded.hasFlags(), false);
111 BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false);
112}
113
114BOOST_AUTO_TEST_CASE(RibOptions)
115{
116 ControlParameters parameters;
117 parameters.setName("ndn:/example")
118 .setFaceId(4)
119 .setOrigin(128)
120 .setCost(6)
121 .setFlags(0x01)
122 .setExpirationPeriod(time::milliseconds(1800000));
123
124 Block wire = parameters.wireEncode();
125
126 ControlParameters decoded(wire);
127 BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/example"));
128 BOOST_CHECK_EQUAL(decoded.getFaceId(), 4);
129 BOOST_CHECK_EQUAL(decoded.getOrigin(), 128);
130 BOOST_CHECK_EQUAL(decoded.getCost(), 6);
131 BOOST_CHECK_EQUAL(decoded.getFlags(), 0x01);
132 BOOST_CHECK_EQUAL(decoded.getExpirationPeriod(), time::milliseconds(1800000));
133
134 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
135 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
136 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -0700137}
138
139BOOST_AUTO_TEST_SUITE_END()
140
141} // namespace nfd
142} // namespace ndn