Merge Resource Directory into the master
[platform/upstream/iotivity.git] / resource / unittests / OCResourceTest.cpp
1 //******************************************************************
2 //
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21
22 #include <OCPlatform.h>
23 #include <OCApi.h>
24 #include <gtest/gtest.h>
25 #include <string>
26 #include <map>
27
28 static char gLongHostAddress[] = "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111:5000";
29
30 namespace OCResourceTest
31 {
32     using namespace OC;
33     // Callbacks
34     void onObserve(const HeaderOptions, const OCRepresentation&, const int&, const int&)
35     {
36     }
37
38     void onGetPut(const HeaderOptions&, const OCRepresentation& , const int eCode)
39     {
40         EXPECT_EQ(eCode, OC_STACK_OK);
41     }
42
43     void foundResource(std::shared_ptr<OCResource> )
44     {
45     }
46
47     void deleteResponse(const HeaderOptions&, const int)
48     {
49     }
50
51     //Helper method
52     OCResource::Ptr ConstructResourceObject(std::string host, std::string uri)
53     {
54         OCConnectivityType connectivityType = CT_DEFAULT;
55         std::vector<std::string> types = {"intel.rpost"};
56         std::vector<std::string> ifaces = {DEFAULT_INTERFACE};
57
58         auto ret = OCPlatform::constructResourceObject(host, uri,
59                 connectivityType, false, types, ifaces);
60
61         if(!ret)
62         {
63             ADD_FAILURE() << "ConstructResourceObject result was null";
64             throw std::runtime_error("ConstructResourceObject result was null");
65         }
66
67         return ret;
68     }
69
70      //Get Test
71     TEST(ConstructResourceTest, ConstructResourceObject)
72     {
73         EXPECT_ANY_THROW(ConstructResourceObject(std::string(""), std::string("")));
74     }
75
76     TEST(ConstructResourceTest, ConstructResourceObjectWithoutCoapScheme)
77     {
78         EXPECT_ANY_THROW(ConstructResourceObject("//192.168.1.2:5000", "/resource"));
79     }
80
81     TEST(ConstructResourceTest, ConstructResourceObjectWithoutPortNumber)
82     {
83         EXPECT_ANY_THROW(ConstructResourceObject("coap://192.168.1.2", "/resource"));
84     }
85
86     TEST(ConstructResourceTest, ConstructResourceObjectWithLongHostAddress)
87     {
88         EXPECT_ANY_THROW(ConstructResourceObject(gLongHostAddress, "/resource"));
89     }
90
91     TEST(ConstructResourceTest, ConstructResourceObjectInvalidHost)
92     {
93         EXPECT_ANY_THROW(ConstructResourceObject("192.168.1.2:5000", "/resource"));
94     }
95
96     TEST(ConstructResourceTest, ConstructResourceObjectInvalidHost2)
97     {
98         EXPECT_ANY_THROW(ConstructResourceObject("coap://:5000", "/resource"));
99     }
100
101     TEST(ConstructResourceTest, ConstructResourceObjectInvalidUri)
102     {
103         EXPECT_ANY_THROW(ConstructResourceObject("coap://192.168.1.2:5000", "/"));
104     }
105
106     TEST(ConstructResourceTest, ConstructResourceObjectInvalidUri2)
107     {
108         EXPECT_ANY_THROW(ConstructResourceObject("coap://192.168.1.2:5000", "resource"));
109     }
110
111     TEST(ResourceGetTest, DISABLED_ResourceGetForValidUri)
112     {
113         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
114         EXPECT_TRUE(resource != NULL);
115         EXPECT_EQ(OC_STACK_OK, resource->get(OC::QueryParamsMap(), &onGetPut));
116
117     }
118
119     TEST(ResourceGetTest, DISABLED_ResourceGetForBadUri)
120     {
121         OCResource::Ptr resource = ConstructResourceObject("", "coap://192.168.1.2:5000");
122         EXPECT_TRUE(resource != NULL);
123         EXPECT_THROW(resource->get(OC::QueryParamsMap(), &onGetPut), OC::OCException);
124     }
125
126     TEST(ResourceGetTest, DISABLED_ResourceGetWithHighQos)
127     {
128         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
129         EXPECT_TRUE(resource != NULL);
130         EXPECT_EQ(OC_STACK_OK,
131                 resource->get(OC::QueryParamsMap(), &onGetPut, QualityOfService::HighQos));
132     }
133
134     TEST(ResourceGetTest, DISABLED_ResourceGetWithLowQos)
135     {
136         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
137         EXPECT_TRUE(resource != NULL);
138         EXPECT_EQ(OC_STACK_OK,
139                 resource->get(OC::QueryParamsMap(), &onGetPut, QualityOfService::LowQos));
140     }
141
142     TEST(ResourceGetTest, DISABLED_ResourceGetWithMidQos)
143     {
144         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
145         EXPECT_TRUE(resource != NULL);
146         EXPECT_EQ(OC_STACK_OK,
147                 resource->get(OC::QueryParamsMap(), &onGetPut, QualityOfService::MidQos));
148     }
149
150     TEST(ResourceGetTest, DISABLED_ResourceGetWithNaQos)
151     {
152         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
153         EXPECT_TRUE(resource != NULL);
154         EXPECT_EQ(OC_STACK_OK,
155                 resource->get(OC::QueryParamsMap(), &onGetPut, QualityOfService::NaQos));
156     }
157
158     TEST(ResourceGetTest, DISABLED_ResourceGetWithRTIFNaQos)
159     {
160         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
161         EXPECT_TRUE(resource != NULL);
162         EXPECT_EQ(OC_STACK_OK,
163                 resource->get("", DEFAULT_INTERFACE, QueryParamsMap(), &onGetPut,
164                         QualityOfService::NaQos));
165     }
166
167     TEST(ResourceGetTest, DISABLED_ResourceGetWithNullResourceType)
168     {
169         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
170         EXPECT_TRUE(resource != NULL);
171         EXPECT_ANY_THROW(
172                 resource->get(nullptr, DEFAULT_INTERFACE, QueryParamsMap(), &onGetPut,
173                         QualityOfService::NaQos));
174     }
175
176
177     TEST(ResourceGetTest, DISABLED_ResourceGetWithNullResourceInterface)
178     {
179         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
180         EXPECT_TRUE(resource != NULL);
181         EXPECT_ANY_THROW(
182                 resource->get("", nullptr, QueryParamsMap(), &onGetPut, QualityOfService::NaQos));
183     }
184
185     TEST(ResourceGetTest, DISABLED_ResourceGetWithTypeAndInterface)
186     {
187         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
188         EXPECT_TRUE(resource != NULL);
189         EXPECT_EQ(OC_STACK_OK, resource->get("", DEFAULT_INTERFACE, QueryParamsMap(), &onGetPut));
190     }
191
192     //Post Test
193     TEST(ResourcePostTest, DISABLED_ResourcePostValidConfiguration)
194     {
195         OCRepresentation rep;
196         QueryParamsMap query = {};
197         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
198         EXPECT_TRUE(resource != NULL);
199         EXPECT_EQ(OC_STACK_OK, resource->post(rep, query, &onGetPut));
200     }
201
202     TEST(ResourcePostTest, DISABLED_ResourcePostWithNaQos)
203     {
204         OCRepresentation rep;
205         QueryParamsMap query = {};
206         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
207         EXPECT_TRUE(resource != NULL);
208         EXPECT_EQ(OC_STACK_OK, resource->post(rep, query, &onGetPut, QualityOfService::NaQos));
209     }
210
211     TEST(ResourcePostTest, DISABLED_ResourcePostWithMidQos)
212     {
213         OCRepresentation rep;
214         QueryParamsMap query = {};
215         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
216         EXPECT_TRUE(resource != NULL);
217         EXPECT_EQ(OC_STACK_OK, resource->post(rep, query, &onGetPut, QualityOfService::MidQos));
218     }
219
220     TEST(ResourcePostTest, DISABLED_ResourcePostWithLowQos)
221     {
222         OCRepresentation rep;
223         QueryParamsMap query = {};
224         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
225         EXPECT_TRUE(resource != NULL);
226         EXPECT_EQ(OC_STACK_OK, resource->post(rep, query, &onGetPut, QualityOfService::LowQos));
227     }
228
229     TEST(ResourcePostTest, DISABLED_ResourcePostWithHighQos)
230     {
231         OCRepresentation rep;
232         QueryParamsMap query = {};
233         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
234         EXPECT_TRUE(resource != NULL);
235         EXPECT_EQ(OC_STACK_OK, resource->post(rep, query, &onGetPut, QualityOfService::HighQos));
236     }
237
238     //Put Test
239     TEST(ResourcePutTest, DISABLED_ResourcePutForValid)
240     {
241         OCRepresentation rep;
242         QueryParamsMap query = {};
243         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
244         EXPECT_TRUE(resource != NULL);
245         EXPECT_EQ(OC_STACK_OK, resource->put(rep, query, &onGetPut));
246     }
247
248     TEST(ResourcePutTest, DISABLED_ResourcePutWithNaQos)
249     {
250         OCRepresentation rep;
251         QueryParamsMap query = {};
252         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
253         EXPECT_TRUE(resource != NULL);
254         EXPECT_EQ(OC_STACK_OK, resource->put(rep, query, &onGetPut, QualityOfService::NaQos));
255     }
256
257     TEST(ResourcePutTest, DISABLED_ResourcePutWithLowQos)
258     {
259         OCRepresentation rep;
260         QueryParamsMap query = {};
261         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
262         EXPECT_TRUE(resource != NULL);
263         EXPECT_EQ(OC_STACK_OK, resource->put(rep, query, &onGetPut, QualityOfService::LowQos));
264     }
265
266     TEST(ResourcePutTest, DISABLED_ResourcePutWithMidQos)
267     {
268         OCRepresentation rep;
269         QueryParamsMap query = {};
270         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
271         EXPECT_TRUE(resource != NULL);
272         EXPECT_EQ(OC_STACK_OK, resource->put(rep, query, &onGetPut, QualityOfService::MidQos));
273     }
274
275     TEST(ResourcePutTest, DISABLED_ResourcePutWithHighQos)
276     {
277         OCRepresentation rep;
278         QueryParamsMap query = {};
279         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
280         EXPECT_TRUE(resource != NULL);
281         EXPECT_EQ(OC_STACK_OK, resource->put(rep, query, &onGetPut, QualityOfService::HighQos));
282     }
283
284     TEST(ResourcePutTest, DISABLED_ResourcePutWithTypeAndInterface)
285     {
286         OCRepresentation rep;
287         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
288         EXPECT_TRUE(resource != NULL);
289         EXPECT_EQ(OC_STACK_OK,
290                 resource->put("", DEFAULT_INTERFACE, rep, QueryParamsMap(), &onGetPut));
291     }
292
293     TEST(ResourcePutTest, DISABLED_ResourcePutWithNullType)
294     {
295         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
296         EXPECT_TRUE(resource != NULL);
297         OCRepresentation rep;
298         EXPECT_ANY_THROW(
299                 resource->put(nullptr, DEFAULT_INTERFACE, rep, QueryParamsMap(), &onGetPut));
300         HeaderOptions headerOptions;
301         onGetPut(headerOptions, rep, OC_STACK_OK);
302     }
303
304     TEST(ResourcePutTest, DISABLED_ResourcePutWithNullInterface)
305     {
306         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
307         EXPECT_TRUE(resource != NULL);
308         OCRepresentation rep;
309         EXPECT_ANY_THROW(resource->put("", nullptr, rep, QueryParamsMap(), &onGetPut));
310     }
311
312     // Observer Test
313     TEST(ResourceObserveTest, DISABLED_ResourceObserveValidUri)
314     {
315         OCResource::Ptr resource =
316                 ConstructResourceObject("coap://192.168.1.2:5000", "/Observe");
317         EXPECT_TRUE(resource != NULL);
318         QueryParamsMap query = {};
319         EXPECT_EQ(OC_STACK_OK, resource->observe(ObserveType::ObserveAll, query, &onObserve));
320     }
321
322     TEST(ResourceObserveTest, DISABLED_ResourceObserveLoQos)
323     {
324         QueryParamsMap query = {};
325         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/Observe");
326         EXPECT_TRUE(resource != NULL);
327         EXPECT_EQ(OC_STACK_OK,
328                 resource->observe(ObserveType::ObserveAll, query, &onObserve,
329                         QualityOfService::LowQos));
330     }
331
332     TEST(ResourceObserveTest, DISABLED_ResourceObserveNaQos)
333     {
334         QueryParamsMap query = {};
335         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/Observe");
336         EXPECT_TRUE(resource != NULL);
337         EXPECT_EQ(OC_STACK_OK,
338                 resource->observe(ObserveType::ObserveAll, query, &onObserve,
339                         QualityOfService::NaQos));
340     }
341
342     TEST(ResourceObserveTest, DISABLED_ResourceObserveMidQos)
343     {
344         QueryParamsMap query = {};
345         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/Observe");
346         EXPECT_TRUE(resource != NULL);
347         EXPECT_EQ(OC_STACK_OK,
348                 resource->observe(ObserveType::ObserveAll, query, &onObserve,
349                         QualityOfService::MidQos));
350     }
351
352     TEST(ResourceObserveTest, DISABLED_ResourceObserveHighQos)
353     {
354         QueryParamsMap query = {};
355         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/Observe");
356         EXPECT_TRUE(resource != NULL);
357         EXPECT_EQ(OC_STACK_OK,
358                 resource->observe(ObserveType::ObserveAll, query, &onObserve,
359                         QualityOfService::HighQos));
360     }
361
362     TEST(ResourceObserveTest, DISABLED_ResourceCancelObserveValidUri)
363     {
364         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
365         EXPECT_TRUE(resource != NULL);
366         QueryParamsMap query = {};
367         EXPECT_EQ(OC_STACK_OK, resource->observe(ObserveType::ObserveAll, query, &onObserve));
368         EXPECT_EQ(OC_STACK_OK, resource->cancelObserve());
369     }
370
371     TEST(ResourceObserveTest, DISABLED_ResourceCancelObserveWithNaQos)
372     {
373         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
374         EXPECT_TRUE(resource != NULL);
375         QueryParamsMap query = {};
376         EXPECT_EQ(OC_STACK_OK,
377                 resource->observe(ObserveType::ObserveAll, query, &onObserve,
378                         QualityOfService::NaQos));
379         EXPECT_EQ(OC_STACK_OK, resource->cancelObserve(QualityOfService::NaQos));
380     }
381
382     TEST(ResourceObserveTest, DISABLED_ResourceCancelObserveWithLowQos)
383     {
384         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
385         EXPECT_TRUE(resource != NULL);
386         QueryParamsMap query = {};
387         EXPECT_EQ(OC_STACK_OK,
388                 resource->observe(ObserveType::ObserveAll, query, &onObserve,
389                         QualityOfService::LowQos));
390         EXPECT_EQ(OC_STACK_OK, resource->cancelObserve(QualityOfService::LowQos));
391     }
392
393     TEST(ResourceObserveTest, DISABLED_ResourceCancelObserveWithMidQos)
394     {
395         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
396         EXPECT_TRUE(resource != NULL);
397             QueryParamsMap query = {};
398         EXPECT_EQ(OC_STACK_OK,
399                 resource->observe(ObserveType::ObserveAll, query, &onObserve,
400                         QualityOfService::MidQos));
401         EXPECT_EQ(OC_STACK_OK, resource->cancelObserve(QualityOfService::MidQos));
402     }
403
404     TEST(ResourceObserveTest, DISABLED_ResourceCancelObserveWithHighQos)
405     {
406         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
407         EXPECT_TRUE(resource != NULL);
408             QueryParamsMap query = {};
409         EXPECT_EQ(OC_STACK_OK,
410                 resource->observe(ObserveType::ObserveAll, query, &onObserve,
411                         QualityOfService::HighQos));
412         EXPECT_EQ(OC_STACK_OK, resource->cancelObserve(QualityOfService::HighQos));
413     }
414
415     //DeleteResource
416     TEST(DeleteResourceTest, DISABLED_DeleteResourceValidUri)
417     {
418         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
419         EXPECT_TRUE(resource != NULL);
420         EXPECT_EQ(OC_STACK_OK, resource->deleteResource(&deleteResponse));
421     }
422
423     TEST(DeleteResourceTest, DISABLED_DeleteResourceWithLowQos)
424     {
425         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
426         EXPECT_TRUE(resource != NULL);
427         EXPECT_EQ(OC_STACK_OK,
428                 resource->deleteResource(&deleteResponse, QualityOfService::LowQos));
429     }
430
431     TEST(DeleteResourceTest, DISABLED_DeleteResourceWithMidQos)
432     {
433         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
434         EXPECT_TRUE(resource != NULL);
435         EXPECT_EQ(OC_STACK_OK,
436                 resource->deleteResource(&deleteResponse, QualityOfService::MidQos));
437     }
438
439     TEST(DeleteResourceTest, DISABLED_DeleteResourceWithHighQos)
440     {
441         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
442         EXPECT_TRUE(resource != NULL);
443         EXPECT_EQ(OC_STACK_OK,
444                 resource->deleteResource(&deleteResponse, QualityOfService::HighQos));
445     }
446     TEST(DeleteResourceTest, DISABLED_DeleteResourceWithNaQos)
447     {
448         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
449         EXPECT_TRUE(resource != NULL);
450         EXPECT_EQ(OC_STACK_OK, resource->deleteResource(&deleteResponse, QualityOfService::NaQos));
451     }
452
453     //GetResourceInterfaces Test
454     TEST(GetResourceInterfacesTest, GetResourceInterfaces)
455     {
456         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
457         EXPECT_TRUE(resource != NULL);
458         EXPECT_TRUE(resource->getResourceInterfaces().front() == DEFAULT_INTERFACE);
459     }
460
461     //GetResourceTypes Test
462     TEST(GetResourceTypesTest, GetResourceTypes)
463     {
464         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
465         EXPECT_TRUE(resource != NULL);
466         EXPECT_TRUE(resource->getResourceTypes().front() == "intel.rpost");
467     }
468
469     // Host Test
470     TEST(HostTest, Host)
471     {
472         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
473         EXPECT_TRUE(resource != NULL);
474         EXPECT_TRUE(resource->host() == "coap://192.168.1.2:5000");
475     }
476
477     //Uri Test
478     TEST(UriTest, Uri)
479     {
480         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
481         EXPECT_TRUE(resource != NULL);
482         EXPECT_TRUE(resource->uri() == "/resource");
483     }
484
485     //ConnectivityType Test
486     TEST(ConnectivityTypeTest, ConnectivityType)
487     {
488         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
489         EXPECT_TRUE(resource != NULL);
490         EXPECT_TRUE(resource->connectivityType() == CT_DEFAULT);
491     }
492
493     //IsObservable Test
494     TEST(IsObservableTest, isObservable)
495     {
496         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
497         EXPECT_TRUE(resource != NULL);
498         EXPECT_FALSE(resource->isObservable());
499     }
500
501     //SID Test
502     TEST(SidTest, sid)
503     {
504         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
505         EXPECT_TRUE(resource != NULL);
506         EXPECT_TRUE(resource->sid() == "");
507     }
508
509     //UniqueIdentifier Test
510     TEST(UniqueIdentifierTest, uniqueIdentifier)
511     {
512         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
513         EXPECT_TRUE(resource != NULL);
514         std::ostringstream ss;
515         ss << resource->uniqueIdentifier();
516         EXPECT_TRUE(ss.str() == "/resource");
517     }
518
519     // HeaderOptions Test
520     TEST(HeaderOptionsTest, SetHeaderOptionsValidInput)
521     {
522         const uint16_t API_VERSION = 2048;
523         const uint16_t TOKEN = 3000;
524         HeaderOptions headerOptions;
525         HeaderOption::OCHeaderOption apiVersion(API_VERSION, "v.1.0");
526         HeaderOption::OCHeaderOption clientToken(TOKEN, "21ae43gf");
527         headerOptions.push_back(apiVersion);
528         headerOptions.push_back(clientToken);
529
530         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
531         EXPECT_TRUE(resource != NULL);
532         EXPECT_NO_THROW(resource->setHeaderOptions(headerOptions));
533         EXPECT_NO_THROW(resource->unsetHeaderOptions());
534     }
535
536     TEST(HeaderOptionsTest, SetHeaderOptionsEmptyInput)
537     {
538         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
539         EXPECT_TRUE(resource != NULL);
540         HeaderOptions headerOptions;
541         EXPECT_NO_THROW(resource->setHeaderOptions(headerOptions));
542         EXPECT_NO_THROW(resource->unsetHeaderOptions());
543     }
544 }
545