modified setHost() in OCResource for ipv6 with scope ID
[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     //ConstructResourceObject Test
71     TEST(ConstructResourceTest, ConstructResourceObjectWithValidHost)
72     {
73         EXPECT_NO_THROW(ConstructResourceObject("coap://192.168.1.2:5000", "/resource"));
74     }
75
76     TEST(ConstructResourceTest, ConstructResourceObjectWithValidHost2)
77     {
78         EXPECT_NO_THROW(ConstructResourceObject("coap://[ffff::ffff]:5000", "/resource"));
79     }
80
81     TEST(ConstructResourceTest, ConstructResourceObjectWithValidHost3)
82     {
83         EXPECT_NO_THROW(ConstructResourceObject("coap://[ffff::ffff%eth0]:5000", "/resource"));
84     }
85
86     TEST(ConstructResourceTest, ConstructResourceObject)
87     {
88         EXPECT_ANY_THROW(ConstructResourceObject(std::string(""), std::string("")));
89     }
90
91     TEST(ConstructResourceTest, ConstructResourceObjectWithoutCoapScheme)
92     {
93         EXPECT_ANY_THROW(ConstructResourceObject("//192.168.1.2:5000", "/resource"));
94     }
95
96     TEST(ConstructResourceTest, ConstructResourceObjectWithoutPortNumber)
97     {
98         EXPECT_ANY_THROW(ConstructResourceObject("coap://192.168.1.2", "/resource"));
99     }
100
101     TEST(ConstructResourceTest, ConstructResourceObjectWithoutPortNumber2)
102     {
103         EXPECT_ANY_THROW(ConstructResourceObject("coap://192.168.1.2:", "/resource"));
104     }
105
106     TEST(ConstructResourceTest, ConstructResourceObjectWithLongHostAddress)
107     {
108         EXPECT_ANY_THROW(ConstructResourceObject(gLongHostAddress, "/resource"));
109     }
110
111     TEST(ConstructResourceTest, ConstructResourceObjectInvalidHost)
112     {
113         EXPECT_ANY_THROW(ConstructResourceObject("192.168.1.2:5000", "/resource"));
114     }
115
116     TEST(ConstructResourceTest, ConstructResourceObjectInvalidHost2)
117     {
118         EXPECT_ANY_THROW(ConstructResourceObject("coap://:5000", "/resource"));
119     }
120
121     TEST(ConstructResourceTest, ConstructResourceObjectInvalidHost3)
122     {
123         EXPECT_ANY_THROW(ConstructResourceObject("coap://[ffff:::ffff]:5000", "/resource"));
124     }
125
126     TEST(ConstructResourceTest, ConstructResourceObjectInvalidUri)
127     {
128         EXPECT_ANY_THROW(ConstructResourceObject("coap://192.168.1.2:5000", "/"));
129     }
130
131     TEST(ConstructResourceTest, ConstructResourceObjectInvalidUri2)
132     {
133         EXPECT_ANY_THROW(ConstructResourceObject("coap://192.168.1.2:5000", "resource"));
134     }
135
136     //Get Test
137     TEST(ResourceGetTest, DISABLED_ResourceGetForValidUri)
138     {
139         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
140         EXPECT_TRUE(resource != NULL);
141         EXPECT_EQ(OC_STACK_OK, resource->get(OC::QueryParamsMap(), &onGetPut));
142
143     }
144
145     TEST(ResourceGetTest, DISABLED_ResourceGetForBadUri)
146     {
147         OCResource::Ptr resource = ConstructResourceObject("", "coap://192.168.1.2:5000");
148         EXPECT_TRUE(resource != NULL);
149         EXPECT_THROW(resource->get(OC::QueryParamsMap(), &onGetPut), OC::OCException);
150     }
151
152     TEST(ResourceGetTest, DISABLED_ResourceGetWithHighQos)
153     {
154         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
155         EXPECT_TRUE(resource != NULL);
156         EXPECT_EQ(OC_STACK_OK,
157                 resource->get(OC::QueryParamsMap(), &onGetPut, QualityOfService::HighQos));
158     }
159
160     TEST(ResourceGetTest, DISABLED_ResourceGetWithLowQos)
161     {
162         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
163         EXPECT_TRUE(resource != NULL);
164         EXPECT_EQ(OC_STACK_OK,
165                 resource->get(OC::QueryParamsMap(), &onGetPut, QualityOfService::LowQos));
166     }
167
168     TEST(ResourceGetTest, DISABLED_ResourceGetWithMidQos)
169     {
170         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
171         EXPECT_TRUE(resource != NULL);
172         EXPECT_EQ(OC_STACK_OK,
173                 resource->get(OC::QueryParamsMap(), &onGetPut, QualityOfService::MidQos));
174     }
175
176     TEST(ResourceGetTest, DISABLED_ResourceGetWithNaQos)
177     {
178         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
179         EXPECT_TRUE(resource != NULL);
180         EXPECT_EQ(OC_STACK_OK,
181                 resource->get(OC::QueryParamsMap(), &onGetPut, QualityOfService::NaQos));
182     }
183
184     TEST(ResourceGetTest, DISABLED_ResourceGetWithRTIFNaQos)
185     {
186         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
187         EXPECT_TRUE(resource != NULL);
188         EXPECT_EQ(OC_STACK_OK,
189                 resource->get("", DEFAULT_INTERFACE, QueryParamsMap(), &onGetPut,
190                         QualityOfService::NaQos));
191     }
192
193     TEST(ResourceGetTest, DISABLED_ResourceGetWithNullResourceType)
194     {
195         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
196         EXPECT_TRUE(resource != NULL);
197         EXPECT_ANY_THROW(
198                 resource->get(nullptr, DEFAULT_INTERFACE, QueryParamsMap(), &onGetPut,
199                         QualityOfService::NaQos));
200     }
201
202
203     TEST(ResourceGetTest, DISABLED_ResourceGetWithNullResourceInterface)
204     {
205         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
206         EXPECT_TRUE(resource != NULL);
207         EXPECT_ANY_THROW(
208                 resource->get("", nullptr, QueryParamsMap(), &onGetPut, QualityOfService::NaQos));
209     }
210
211     TEST(ResourceGetTest, DISABLED_ResourceGetWithTypeAndInterface)
212     {
213         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
214         EXPECT_TRUE(resource != NULL);
215         EXPECT_EQ(OC_STACK_OK, resource->get("", DEFAULT_INTERFACE, QueryParamsMap(), &onGetPut));
216     }
217
218     //Post Test
219     TEST(ResourcePostTest, DISABLED_ResourcePostValidConfiguration)
220     {
221         OCRepresentation rep;
222         QueryParamsMap query = {};
223         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
224         EXPECT_TRUE(resource != NULL);
225         EXPECT_EQ(OC_STACK_OK, resource->post(rep, query, &onGetPut));
226     }
227
228     TEST(ResourcePostTest, DISABLED_ResourcePostWithNaQos)
229     {
230         OCRepresentation rep;
231         QueryParamsMap query = {};
232         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
233         EXPECT_TRUE(resource != NULL);
234         EXPECT_EQ(OC_STACK_OK, resource->post(rep, query, &onGetPut, QualityOfService::NaQos));
235     }
236
237     TEST(ResourcePostTest, DISABLED_ResourcePostWithMidQos)
238     {
239         OCRepresentation rep;
240         QueryParamsMap query = {};
241         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
242         EXPECT_TRUE(resource != NULL);
243         EXPECT_EQ(OC_STACK_OK, resource->post(rep, query, &onGetPut, QualityOfService::MidQos));
244     }
245
246     TEST(ResourcePostTest, DISABLED_ResourcePostWithLowQos)
247     {
248         OCRepresentation rep;
249         QueryParamsMap query = {};
250         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
251         EXPECT_TRUE(resource != NULL);
252         EXPECT_EQ(OC_STACK_OK, resource->post(rep, query, &onGetPut, QualityOfService::LowQos));
253     }
254
255     TEST(ResourcePostTest, DISABLED_ResourcePostWithHighQos)
256     {
257         OCRepresentation rep;
258         QueryParamsMap query = {};
259         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
260         EXPECT_TRUE(resource != NULL);
261         EXPECT_EQ(OC_STACK_OK, resource->post(rep, query, &onGetPut, QualityOfService::HighQos));
262     }
263
264     //Put Test
265     TEST(ResourcePutTest, DISABLED_ResourcePutForValid)
266     {
267         OCRepresentation rep;
268         QueryParamsMap query = {};
269         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
270         EXPECT_TRUE(resource != NULL);
271         EXPECT_EQ(OC_STACK_OK, resource->put(rep, query, &onGetPut));
272     }
273
274     TEST(ResourcePutTest, DISABLED_ResourcePutWithNaQos)
275     {
276         OCRepresentation rep;
277         QueryParamsMap query = {};
278         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
279         EXPECT_TRUE(resource != NULL);
280         EXPECT_EQ(OC_STACK_OK, resource->put(rep, query, &onGetPut, QualityOfService::NaQos));
281     }
282
283     TEST(ResourcePutTest, DISABLED_ResourcePutWithLowQos)
284     {
285         OCRepresentation rep;
286         QueryParamsMap query = {};
287         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
288         EXPECT_TRUE(resource != NULL);
289         EXPECT_EQ(OC_STACK_OK, resource->put(rep, query, &onGetPut, QualityOfService::LowQos));
290     }
291
292     TEST(ResourcePutTest, DISABLED_ResourcePutWithMidQos)
293     {
294         OCRepresentation rep;
295         QueryParamsMap query = {};
296         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
297         EXPECT_TRUE(resource != NULL);
298         EXPECT_EQ(OC_STACK_OK, resource->put(rep, query, &onGetPut, QualityOfService::MidQos));
299     }
300
301     TEST(ResourcePutTest, DISABLED_ResourcePutWithHighQos)
302     {
303         OCRepresentation rep;
304         QueryParamsMap query = {};
305         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
306         EXPECT_TRUE(resource != NULL);
307         EXPECT_EQ(OC_STACK_OK, resource->put(rep, query, &onGetPut, QualityOfService::HighQos));
308     }
309
310     TEST(ResourcePutTest, DISABLED_ResourcePutWithTypeAndInterface)
311     {
312         OCRepresentation rep;
313         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
314         EXPECT_TRUE(resource != NULL);
315         EXPECT_EQ(OC_STACK_OK,
316                 resource->put("", DEFAULT_INTERFACE, rep, QueryParamsMap(), &onGetPut));
317     }
318
319     TEST(ResourcePutTest, DISABLED_ResourcePutWithNullType)
320     {
321         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
322         EXPECT_TRUE(resource != NULL);
323         OCRepresentation rep;
324         EXPECT_ANY_THROW(
325                 resource->put(nullptr, DEFAULT_INTERFACE, rep, QueryParamsMap(), &onGetPut));
326         HeaderOptions headerOptions;
327         onGetPut(headerOptions, rep, OC_STACK_OK);
328     }
329
330     TEST(ResourcePutTest, DISABLED_ResourcePutWithNullInterface)
331     {
332         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
333         EXPECT_TRUE(resource != NULL);
334         OCRepresentation rep;
335         EXPECT_ANY_THROW(resource->put("", nullptr, rep, QueryParamsMap(), &onGetPut));
336     }
337
338     // Observer Test
339     TEST(ResourceObserveTest, DISABLED_ResourceObserveValidUri)
340     {
341         OCResource::Ptr resource =
342                 ConstructResourceObject("coap://192.168.1.2:5000", "/Observe");
343         EXPECT_TRUE(resource != NULL);
344         QueryParamsMap query = {};
345         EXPECT_EQ(OC_STACK_OK, resource->observe(ObserveType::ObserveAll, query, &onObserve));
346     }
347
348     TEST(ResourceObserveTest, DISABLED_ResourceObserveLoQos)
349     {
350         QueryParamsMap query = {};
351         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/Observe");
352         EXPECT_TRUE(resource != NULL);
353         EXPECT_EQ(OC_STACK_OK,
354                 resource->observe(ObserveType::ObserveAll, query, &onObserve,
355                         QualityOfService::LowQos));
356     }
357
358     TEST(ResourceObserveTest, DISABLED_ResourceObserveNaQos)
359     {
360         QueryParamsMap query = {};
361         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/Observe");
362         EXPECT_TRUE(resource != NULL);
363         EXPECT_EQ(OC_STACK_OK,
364                 resource->observe(ObserveType::ObserveAll, query, &onObserve,
365                         QualityOfService::NaQos));
366     }
367
368     TEST(ResourceObserveTest, DISABLED_ResourceObserveMidQos)
369     {
370         QueryParamsMap query = {};
371         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/Observe");
372         EXPECT_TRUE(resource != NULL);
373         EXPECT_EQ(OC_STACK_OK,
374                 resource->observe(ObserveType::ObserveAll, query, &onObserve,
375                         QualityOfService::MidQos));
376     }
377
378     TEST(ResourceObserveTest, DISABLED_ResourceObserveHighQos)
379     {
380         QueryParamsMap query = {};
381         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/Observe");
382         EXPECT_TRUE(resource != NULL);
383         EXPECT_EQ(OC_STACK_OK,
384                 resource->observe(ObserveType::ObserveAll, query, &onObserve,
385                         QualityOfService::HighQos));
386     }
387
388     TEST(ResourceObserveTest, DISABLED_ResourceCancelObserveValidUri)
389     {
390         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
391         EXPECT_TRUE(resource != NULL);
392         QueryParamsMap query = {};
393         EXPECT_EQ(OC_STACK_OK, resource->observe(ObserveType::ObserveAll, query, &onObserve));
394         EXPECT_EQ(OC_STACK_OK, resource->cancelObserve());
395     }
396
397     TEST(ResourceObserveTest, DISABLED_ResourceCancelObserveWithNaQos)
398     {
399         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
400         EXPECT_TRUE(resource != NULL);
401         QueryParamsMap query = {};
402         EXPECT_EQ(OC_STACK_OK,
403                 resource->observe(ObserveType::ObserveAll, query, &onObserve,
404                         QualityOfService::NaQos));
405         EXPECT_EQ(OC_STACK_OK, resource->cancelObserve(QualityOfService::NaQos));
406     }
407
408     TEST(ResourceObserveTest, DISABLED_ResourceCancelObserveWithLowQos)
409     {
410         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
411         EXPECT_TRUE(resource != NULL);
412         QueryParamsMap query = {};
413         EXPECT_EQ(OC_STACK_OK,
414                 resource->observe(ObserveType::ObserveAll, query, &onObserve,
415                         QualityOfService::LowQos));
416         EXPECT_EQ(OC_STACK_OK, resource->cancelObserve(QualityOfService::LowQos));
417     }
418
419     TEST(ResourceObserveTest, DISABLED_ResourceCancelObserveWithMidQos)
420     {
421         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
422         EXPECT_TRUE(resource != NULL);
423             QueryParamsMap query = {};
424         EXPECT_EQ(OC_STACK_OK,
425                 resource->observe(ObserveType::ObserveAll, query, &onObserve,
426                         QualityOfService::MidQos));
427         EXPECT_EQ(OC_STACK_OK, resource->cancelObserve(QualityOfService::MidQos));
428     }
429
430     TEST(ResourceObserveTest, DISABLED_ResourceCancelObserveWithHighQos)
431     {
432         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
433         EXPECT_TRUE(resource != NULL);
434             QueryParamsMap query = {};
435         EXPECT_EQ(OC_STACK_OK,
436                 resource->observe(ObserveType::ObserveAll, query, &onObserve,
437                         QualityOfService::HighQos));
438         EXPECT_EQ(OC_STACK_OK, resource->cancelObserve(QualityOfService::HighQos));
439     }
440
441     //DeleteResource
442     TEST(DeleteResourceTest, DISABLED_DeleteResourceValidUri)
443     {
444         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
445         EXPECT_TRUE(resource != NULL);
446         EXPECT_EQ(OC_STACK_OK, resource->deleteResource(&deleteResponse));
447     }
448
449     TEST(DeleteResourceTest, DISABLED_DeleteResourceWithLowQos)
450     {
451         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
452         EXPECT_TRUE(resource != NULL);
453         EXPECT_EQ(OC_STACK_OK,
454                 resource->deleteResource(&deleteResponse, QualityOfService::LowQos));
455     }
456
457     TEST(DeleteResourceTest, DISABLED_DeleteResourceWithMidQos)
458     {
459         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
460         EXPECT_TRUE(resource != NULL);
461         EXPECT_EQ(OC_STACK_OK,
462                 resource->deleteResource(&deleteResponse, QualityOfService::MidQos));
463     }
464
465     TEST(DeleteResourceTest, DISABLED_DeleteResourceWithHighQos)
466     {
467         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
468         EXPECT_TRUE(resource != NULL);
469         EXPECT_EQ(OC_STACK_OK,
470                 resource->deleteResource(&deleteResponse, QualityOfService::HighQos));
471     }
472     TEST(DeleteResourceTest, DISABLED_DeleteResourceWithNaQos)
473     {
474         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
475         EXPECT_TRUE(resource != NULL);
476         EXPECT_EQ(OC_STACK_OK, resource->deleteResource(&deleteResponse, QualityOfService::NaQos));
477     }
478
479     //GetResourceInterfaces Test
480     TEST(GetResourceInterfacesTest, GetResourceInterfaces)
481     {
482         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
483         EXPECT_TRUE(resource != NULL);
484         EXPECT_TRUE(resource->getResourceInterfaces().front() == DEFAULT_INTERFACE);
485     }
486
487     //GetResourceTypes Test
488     TEST(GetResourceTypesTest, GetResourceTypes)
489     {
490         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
491         EXPECT_TRUE(resource != NULL);
492         EXPECT_TRUE(resource->getResourceTypes().front() == "intel.rpost");
493     }
494
495     // Host Test
496     TEST(HostTest, Host)
497     {
498         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
499         EXPECT_TRUE(resource != NULL);
500         EXPECT_TRUE(resource->host() == "coap://192.168.1.2:5000");
501     }
502
503     //Uri Test
504     TEST(UriTest, Uri)
505     {
506         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
507         EXPECT_TRUE(resource != NULL);
508         EXPECT_TRUE(resource->uri() == "/resource");
509     }
510
511     //ConnectivityType Test
512     TEST(ConnectivityTypeTest, ConnectivityType)
513     {
514         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
515         EXPECT_TRUE(resource != NULL);
516         EXPECT_TRUE(resource->connectivityType() == CT_DEFAULT);
517     }
518
519     //IsObservable Test
520     TEST(IsObservableTest, isObservable)
521     {
522         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
523         EXPECT_TRUE(resource != NULL);
524         EXPECT_FALSE(resource->isObservable());
525     }
526
527     //SID Test
528     TEST(SidTest, sid)
529     {
530         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
531         EXPECT_TRUE(resource != NULL);
532         EXPECT_TRUE(resource->sid() == "");
533     }
534
535     //UniqueIdentifier Test
536     TEST(UniqueIdentifierTest, uniqueIdentifier)
537     {
538         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
539         EXPECT_TRUE(resource != NULL);
540         std::ostringstream ss;
541         ss << resource->uniqueIdentifier();
542         EXPECT_TRUE(ss.str() == "/resource");
543     }
544
545     // HeaderOptions Test
546     TEST(HeaderOptionsTest, SetHeaderOptionsValidInput)
547     {
548         const uint16_t API_VERSION = 2048;
549         const uint16_t TOKEN = 3000;
550         HeaderOptions headerOptions;
551         HeaderOption::OCHeaderOption apiVersion(API_VERSION, "v.1.0");
552         HeaderOption::OCHeaderOption clientToken(TOKEN, "21ae43gf");
553         headerOptions.push_back(apiVersion);
554         headerOptions.push_back(clientToken);
555
556         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
557         EXPECT_TRUE(resource != NULL);
558         EXPECT_NO_THROW(resource->setHeaderOptions(headerOptions));
559         EXPECT_NO_THROW(resource->unsetHeaderOptions());
560     }
561
562     TEST(HeaderOptionsTest, SetHeaderOptionsEmptyInput)
563     {
564         OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
565         EXPECT_TRUE(resource != NULL);
566         HeaderOptions headerOptions;
567         EXPECT_NO_THROW(resource->setHeaderOptions(headerOptions));
568         EXPECT_NO_THROW(resource->unsetHeaderOptions());
569     }
570 }
571