blob: fcd0361ca807dd410521332daefb6a6325b0db24 [file] [log] [blame]
Junxiao Shibc19b372014-03-23 16:59:25 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07003 * Copyright (c) 2013-2014, Regents of the University of California.
4 * All rights reserved.
5 *
6 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
7 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
8 *
9 * This file licensed under New BSD License. See COPYING for detailed information about
10 * ndn-cxx library copyright, permissions, and redistribution restrictions.
Junxiao Shibc19b372014-03-23 16:59:25 -070011 */
12
13#include "management/nfd-control-parameters.hpp"
Junxiao Shibc19b372014-03-23 16:59:25 -070014
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -070015#include "boost-test.hpp"
Junxiao Shibc19b372014-03-23 16:59:25 -070016
17namespace ndn {
18namespace nfd {
19
Alexander Afanasyevd1b5c412014-03-27 15:03:51 -070020BOOST_AUTO_TEST_SUITE(ManagementTestNfdControlParameters)
Junxiao Shibc19b372014-03-23 16:59:25 -070021
22BOOST_AUTO_TEST_CASE(FaceOptions)
23{
24 ControlParameters parameters;
25 parameters.setUri("tcp4://192.0.2.1:6363");
26
27 Block wire = parameters.wireEncode();
28
29 ControlParameters decoded(wire);
30 BOOST_CHECK_EQUAL(decoded.getUri(), "tcp4://192.0.2.1:6363");
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070031
Junxiao Shibc19b372014-03-23 16:59:25 -070032 BOOST_CHECK_EQUAL(decoded.hasName(), false);
33 BOOST_CHECK_EQUAL(decoded.hasFaceId(), false);
34 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070035 BOOST_CHECK_EQUAL(decoded.hasOrigin(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070036 BOOST_CHECK_EQUAL(decoded.hasCost(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070037 BOOST_CHECK_EQUAL(decoded.hasFlags(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070038 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070039 BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070040}
41
42BOOST_AUTO_TEST_CASE(FaceLocalControlOptions)
43{
44 ControlParameters parameters;
45 parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID);
46
47 Block wire = parameters.wireEncode();
48
49 ControlParameters decoded(wire);
50 BOOST_CHECK_EQUAL(decoded.getLocalControlFeature(), LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070051
Junxiao Shibc19b372014-03-23 16:59:25 -070052 BOOST_CHECK_EQUAL(decoded.hasName(), false);
53 BOOST_CHECK_EQUAL(decoded.hasFaceId(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070054 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070055 BOOST_CHECK_EQUAL(decoded.hasOrigin(), false);
56 BOOST_CHECK_EQUAL(decoded.hasCost(), false);
57 BOOST_CHECK_EQUAL(decoded.hasFlags(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070058 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070059 BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070060}
61
62BOOST_AUTO_TEST_CASE(FibOptions)
63{
64 ControlParameters parameters;
65 parameters.setName("ndn:/example")
66 .setFaceId(4)
67 .setCost(555);
68
69 Block wire = parameters.wireEncode();
70
71 ControlParameters decoded(wire);
72 BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/example"));
73 BOOST_CHECK_EQUAL(decoded.getFaceId(), 4);
74 BOOST_CHECK_EQUAL(decoded.getCost(), 555);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070075
Junxiao Shibc19b372014-03-23 16:59:25 -070076 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070077 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
78 BOOST_CHECK_EQUAL(decoded.hasOrigin(), false);
79 BOOST_CHECK_EQUAL(decoded.hasFlags(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070080 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070081 BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070082}
83
84BOOST_AUTO_TEST_CASE(StrategyChoiceOptions)
85{
86 ControlParameters parameters;
87 parameters.setName("ndn:/")
88 .setStrategy("ndn:/strategy/A");
89
90 Block wire = parameters.wireEncode();
91
92 ControlParameters decoded(wire);
93 BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/"));
94 BOOST_CHECK_EQUAL(decoded.getStrategy(), Name("ndn:/strategy/A"));
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070095
Junxiao Shibc19b372014-03-23 16:59:25 -070096 BOOST_CHECK_EQUAL(decoded.hasFaceId(), false);
97 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
98 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070099 BOOST_CHECK_EQUAL(decoded.hasOrigin(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -0700100 BOOST_CHECK_EQUAL(decoded.hasCost(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -0700101 BOOST_CHECK_EQUAL(decoded.hasFlags(), false);
102 BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false);
103}
104
105BOOST_AUTO_TEST_CASE(RibOptions)
106{
107 ControlParameters parameters;
108 parameters.setName("ndn:/example")
109 .setFaceId(4)
110 .setOrigin(128)
111 .setCost(6)
112 .setFlags(0x01)
113 .setExpirationPeriod(time::milliseconds(1800000));
114
115 Block wire = parameters.wireEncode();
116
117 ControlParameters decoded(wire);
118 BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/example"));
119 BOOST_CHECK_EQUAL(decoded.getFaceId(), 4);
120 BOOST_CHECK_EQUAL(decoded.getOrigin(), 128);
121 BOOST_CHECK_EQUAL(decoded.getCost(), 6);
122 BOOST_CHECK_EQUAL(decoded.getFlags(), 0x01);
123 BOOST_CHECK_EQUAL(decoded.getExpirationPeriod(), time::milliseconds(1800000));
124
125 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
126 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
127 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -0700128}
129
130BOOST_AUTO_TEST_SUITE_END()
131
132} // namespace nfd
133} // namespace ndn