blob: 53751cd5410e6697644f26778dd34dd5206da907 [file] [log] [blame]
Junxiao Shibc19b372014-03-23 16:59:25 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/**
3 * Copyright (C) 2013 Regents of the University of California.
4 * See COPYING for copyright and distribution information.
5 */
6
7#include "management/nfd-control-parameters.hpp"
Junxiao Shibc19b372014-03-23 16:59:25 -07008
Alexander Afanasyevb1db7c62014-04-03 14:57:25 -07009#include "boost-test.hpp"
Junxiao Shibc19b372014-03-23 16:59:25 -070010
11namespace ndn {
12namespace nfd {
13
Alexander Afanasyevd1b5c412014-03-27 15:03:51 -070014BOOST_AUTO_TEST_SUITE(ManagementTestNfdControlParameters)
Junxiao Shibc19b372014-03-23 16:59:25 -070015
16BOOST_AUTO_TEST_CASE(FaceOptions)
17{
18 ControlParameters parameters;
19 parameters.setUri("tcp4://192.0.2.1:6363");
20
21 Block wire = parameters.wireEncode();
22
23 ControlParameters decoded(wire);
24 BOOST_CHECK_EQUAL(decoded.getUri(), "tcp4://192.0.2.1:6363");
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070025
Junxiao Shibc19b372014-03-23 16:59:25 -070026 BOOST_CHECK_EQUAL(decoded.hasName(), false);
27 BOOST_CHECK_EQUAL(decoded.hasFaceId(), false);
28 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070029 BOOST_CHECK_EQUAL(decoded.hasOrigin(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070030 BOOST_CHECK_EQUAL(decoded.hasCost(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070031 BOOST_CHECK_EQUAL(decoded.hasFlags(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070032 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070033 BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070034}
35
36BOOST_AUTO_TEST_CASE(FaceLocalControlOptions)
37{
38 ControlParameters parameters;
39 parameters.setLocalControlFeature(LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID);
40
41 Block wire = parameters.wireEncode();
42
43 ControlParameters decoded(wire);
44 BOOST_CHECK_EQUAL(decoded.getLocalControlFeature(), LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070045
Junxiao Shibc19b372014-03-23 16:59:25 -070046 BOOST_CHECK_EQUAL(decoded.hasName(), false);
47 BOOST_CHECK_EQUAL(decoded.hasFaceId(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070048 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070049 BOOST_CHECK_EQUAL(decoded.hasOrigin(), false);
50 BOOST_CHECK_EQUAL(decoded.hasCost(), false);
51 BOOST_CHECK_EQUAL(decoded.hasFlags(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070052 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070053 BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070054}
55
56BOOST_AUTO_TEST_CASE(FibOptions)
57{
58 ControlParameters parameters;
59 parameters.setName("ndn:/example")
60 .setFaceId(4)
61 .setCost(555);
62
63 Block wire = parameters.wireEncode();
64
65 ControlParameters decoded(wire);
66 BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/example"));
67 BOOST_CHECK_EQUAL(decoded.getFaceId(), 4);
68 BOOST_CHECK_EQUAL(decoded.getCost(), 555);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070069
Junxiao Shibc19b372014-03-23 16:59:25 -070070 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070071 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
72 BOOST_CHECK_EQUAL(decoded.hasOrigin(), false);
73 BOOST_CHECK_EQUAL(decoded.hasFlags(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070074 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070075 BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070076}
77
78BOOST_AUTO_TEST_CASE(StrategyChoiceOptions)
79{
80 ControlParameters parameters;
81 parameters.setName("ndn:/")
82 .setStrategy("ndn:/strategy/A");
83
84 Block wire = parameters.wireEncode();
85
86 ControlParameters decoded(wire);
87 BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/"));
88 BOOST_CHECK_EQUAL(decoded.getStrategy(), Name("ndn:/strategy/A"));
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070089
Junxiao Shibc19b372014-03-23 16:59:25 -070090 BOOST_CHECK_EQUAL(decoded.hasFaceId(), false);
91 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
92 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070093 BOOST_CHECK_EQUAL(decoded.hasOrigin(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -070094 BOOST_CHECK_EQUAL(decoded.hasCost(), false);
Junxiao Shi5f6c74f2014-04-18 16:29:44 -070095 BOOST_CHECK_EQUAL(decoded.hasFlags(), false);
96 BOOST_CHECK_EQUAL(decoded.hasExpirationPeriod(), false);
97}
98
99BOOST_AUTO_TEST_CASE(RibOptions)
100{
101 ControlParameters parameters;
102 parameters.setName("ndn:/example")
103 .setFaceId(4)
104 .setOrigin(128)
105 .setCost(6)
106 .setFlags(0x01)
107 .setExpirationPeriod(time::milliseconds(1800000));
108
109 Block wire = parameters.wireEncode();
110
111 ControlParameters decoded(wire);
112 BOOST_CHECK_EQUAL(decoded.getName(), Name("ndn:/example"));
113 BOOST_CHECK_EQUAL(decoded.getFaceId(), 4);
114 BOOST_CHECK_EQUAL(decoded.getOrigin(), 128);
115 BOOST_CHECK_EQUAL(decoded.getCost(), 6);
116 BOOST_CHECK_EQUAL(decoded.getFlags(), 0x01);
117 BOOST_CHECK_EQUAL(decoded.getExpirationPeriod(), time::milliseconds(1800000));
118
119 BOOST_CHECK_EQUAL(decoded.hasUri(), false);
120 BOOST_CHECK_EQUAL(decoded.hasLocalControlFeature(), false);
121 BOOST_CHECK_EQUAL(decoded.hasStrategy(), false);
Junxiao Shibc19b372014-03-23 16:59:25 -0700122}
123
124BOOST_AUTO_TEST_SUITE_END()
125
126} // namespace nfd
127} // namespace ndn