1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 #include <OCPlatform.h>
24 #include <gtest/gtest.h>
28 static char gLongHostAddress[] = "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111:5000";
30 namespace OCResourceTest
34 void onObserve(const HeaderOptions, const OCRepresentation&, const int&, const int&)
38 void onGetPut(const HeaderOptions&, const OCRepresentation& , const int eCode)
40 EXPECT_EQ(eCode, OC_STACK_OK);
43 void foundResource(std::shared_ptr<OCResource> )
47 void deleteResponse(const HeaderOptions&, const int)
52 OCResource::Ptr ConstructResourceObject(std::string host, std::string uri)
54 OCConnectivityType connectivityType = CT_DEFAULT;
55 std::vector<std::string> types = {"intel.rpost"};
56 std::vector<std::string> ifaces = {DEFAULT_INTERFACE};
58 auto ret = OCPlatform::constructResourceObject(host, uri,
59 connectivityType, false, types, ifaces);
63 ADD_FAILURE() << "ConstructResourceObject result was null";
64 throw std::runtime_error("ConstructResourceObject result was null");
70 //ConstructResourceObject Test
71 TEST(ConstructResourceTest, ConstructResourceObjectWithValidHost)
73 EXPECT_NO_THROW(ConstructResourceObject("coap://192.168.1.2:5000", "/resource"));
76 TEST(ConstructResourceTest, ConstructResourceObjectWithValidHost2)
78 EXPECT_NO_THROW(ConstructResourceObject("coap://[ffff::ffff]:5000", "/resource"));
81 TEST(ConstructResourceTest, ConstructResourceObjectWithValidHost3)
83 EXPECT_NO_THROW(ConstructResourceObject("coap://[ffff::ffff%25eth0]:5000", "/resource"));
86 TEST(ConstructResourceTest, ConstructResourceObject)
88 EXPECT_ANY_THROW(ConstructResourceObject(std::string(""), std::string("")));
91 TEST(ConstructResourceTest, ConstructResourceObjectWithoutCoapScheme)
93 EXPECT_ANY_THROW(ConstructResourceObject("//192.168.1.2:5000", "/resource"));
96 TEST(ConstructResourceTest, ConstructResourceObjectWithoutPortNumber)
98 EXPECT_ANY_THROW(ConstructResourceObject("coap://192.168.1.2", "/resource"));
101 TEST(ConstructResourceTest, ConstructResourceObjectWithoutPortNumber2)
103 EXPECT_ANY_THROW(ConstructResourceObject("coap://192.168.1.2:", "/resource"));
106 TEST(ConstructResourceTest, ConstructResourceObjectWithLongHostAddress)
108 EXPECT_ANY_THROW(ConstructResourceObject(gLongHostAddress, "/resource"));
111 TEST(ConstructResourceTest, ConstructResourceObjectInvalidHost)
113 EXPECT_ANY_THROW(ConstructResourceObject("192.168.1.2:5000", "/resource"));
116 TEST(ConstructResourceTest, ConstructResourceObjectInvalidHost2)
118 EXPECT_ANY_THROW(ConstructResourceObject("coap://:5000", "/resource"));
121 TEST(ConstructResourceTest, ConstructResourceObjectInvalidHost3)
123 EXPECT_ANY_THROW(ConstructResourceObject("coap://[ffff:::ffff]:5000", "/resource"));
126 TEST(ConstructResourceTest, ConstructResourceObjectInvalidHost4)
128 EXPECT_ANY_THROW(ConstructResourceObject("coap://[ffff::ffff%eth0]:5000", "/resource"));
131 TEST(ConstructResourceTest, ConstructResourceObjectInvalidUri)
133 EXPECT_ANY_THROW(ConstructResourceObject("coap://192.168.1.2:5000", "/"));
136 TEST(ConstructResourceTest, ConstructResourceObjectInvalidUri2)
138 EXPECT_ANY_THROW(ConstructResourceObject("coap://192.168.1.2:5000", "resource"));
142 TEST(ResourceGetTest, DISABLED_ResourceGetForValidUri)
144 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
145 EXPECT_TRUE(resource != NULL);
146 EXPECT_EQ(OC_STACK_OK, resource->get(OC::QueryParamsMap(), &onGetPut));
150 TEST(ResourceGetTest, DISABLED_ResourceGetForBadUri)
152 OCResource::Ptr resource = ConstructResourceObject("", "coap://192.168.1.2:5000");
153 EXPECT_TRUE(resource != NULL);
154 EXPECT_THROW(resource->get(OC::QueryParamsMap(), &onGetPut), OC::OCException);
157 TEST(ResourceGetTest, DISABLED_ResourceGetWithHighQos)
159 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
160 EXPECT_TRUE(resource != NULL);
161 EXPECT_EQ(OC_STACK_OK,
162 resource->get(OC::QueryParamsMap(), &onGetPut, QualityOfService::HighQos));
165 TEST(ResourceGetTest, DISABLED_ResourceGetWithLowQos)
167 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
168 EXPECT_TRUE(resource != NULL);
169 EXPECT_EQ(OC_STACK_OK,
170 resource->get(OC::QueryParamsMap(), &onGetPut, QualityOfService::LowQos));
173 TEST(ResourceGetTest, DISABLED_ResourceGetWithMidQos)
175 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
176 EXPECT_TRUE(resource != NULL);
177 EXPECT_EQ(OC_STACK_OK,
178 resource->get(OC::QueryParamsMap(), &onGetPut, QualityOfService::MidQos));
181 TEST(ResourceGetTest, DISABLED_ResourceGetWithNaQos)
183 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
184 EXPECT_TRUE(resource != NULL);
185 EXPECT_EQ(OC_STACK_OK,
186 resource->get(OC::QueryParamsMap(), &onGetPut, QualityOfService::NaQos));
189 TEST(ResourceGetTest, DISABLED_ResourceGetWithRTIFNaQos)
191 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
192 EXPECT_TRUE(resource != NULL);
193 EXPECT_EQ(OC_STACK_OK,
194 resource->get("", DEFAULT_INTERFACE, QueryParamsMap(), &onGetPut,
195 QualityOfService::NaQos));
198 TEST(ResourceGetTest, DISABLED_ResourceGetWithNullResourceType)
200 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
201 EXPECT_TRUE(resource != NULL);
203 resource->get(nullptr, DEFAULT_INTERFACE, QueryParamsMap(), &onGetPut,
204 QualityOfService::NaQos));
208 TEST(ResourceGetTest, DISABLED_ResourceGetWithNullResourceInterface)
210 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
211 EXPECT_TRUE(resource != NULL);
213 resource->get("", nullptr, QueryParamsMap(), &onGetPut, QualityOfService::NaQos));
216 TEST(ResourceGetTest, DISABLED_ResourceGetWithTypeAndInterface)
218 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
219 EXPECT_TRUE(resource != NULL);
220 EXPECT_EQ(OC_STACK_OK, resource->get("", DEFAULT_INTERFACE, QueryParamsMap(), &onGetPut));
224 TEST(ResourcePostTest, DISABLED_ResourcePostValidConfiguration)
226 OCRepresentation rep;
227 QueryParamsMap query = {};
228 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
229 EXPECT_TRUE(resource != NULL);
230 EXPECT_EQ(OC_STACK_OK, resource->post(rep, query, &onGetPut));
233 TEST(ResourcePostTest, DISABLED_ResourcePostWithNaQos)
235 OCRepresentation rep;
236 QueryParamsMap query = {};
237 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
238 EXPECT_TRUE(resource != NULL);
239 EXPECT_EQ(OC_STACK_OK, resource->post(rep, query, &onGetPut, QualityOfService::NaQos));
242 TEST(ResourcePostTest, DISABLED_ResourcePostWithMidQos)
244 OCRepresentation rep;
245 QueryParamsMap query = {};
246 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
247 EXPECT_TRUE(resource != NULL);
248 EXPECT_EQ(OC_STACK_OK, resource->post(rep, query, &onGetPut, QualityOfService::MidQos));
251 TEST(ResourcePostTest, DISABLED_ResourcePostWithLowQos)
253 OCRepresentation rep;
254 QueryParamsMap query = {};
255 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
256 EXPECT_TRUE(resource != NULL);
257 EXPECT_EQ(OC_STACK_OK, resource->post(rep, query, &onGetPut, QualityOfService::LowQos));
260 TEST(ResourcePostTest, DISABLED_ResourcePostWithHighQos)
262 OCRepresentation rep;
263 QueryParamsMap query = {};
264 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
265 EXPECT_TRUE(resource != NULL);
266 EXPECT_EQ(OC_STACK_OK, resource->post(rep, query, &onGetPut, QualityOfService::HighQos));
270 TEST(ResourcePutTest, DISABLED_ResourcePutForValid)
272 OCRepresentation rep;
273 QueryParamsMap query = {};
274 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
275 EXPECT_TRUE(resource != NULL);
276 EXPECT_EQ(OC_STACK_OK, resource->put(rep, query, &onGetPut));
279 TEST(ResourcePutTest, DISABLED_ResourcePutWithNaQos)
281 OCRepresentation rep;
282 QueryParamsMap query = {};
283 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
284 EXPECT_TRUE(resource != NULL);
285 EXPECT_EQ(OC_STACK_OK, resource->put(rep, query, &onGetPut, QualityOfService::NaQos));
288 TEST(ResourcePutTest, DISABLED_ResourcePutWithLowQos)
290 OCRepresentation rep;
291 QueryParamsMap query = {};
292 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
293 EXPECT_TRUE(resource != NULL);
294 EXPECT_EQ(OC_STACK_OK, resource->put(rep, query, &onGetPut, QualityOfService::LowQos));
297 TEST(ResourcePutTest, DISABLED_ResourcePutWithMidQos)
299 OCRepresentation rep;
300 QueryParamsMap query = {};
301 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
302 EXPECT_TRUE(resource != NULL);
303 EXPECT_EQ(OC_STACK_OK, resource->put(rep, query, &onGetPut, QualityOfService::MidQos));
306 TEST(ResourcePutTest, DISABLED_ResourcePutWithHighQos)
308 OCRepresentation rep;
309 QueryParamsMap query = {};
310 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
311 EXPECT_TRUE(resource != NULL);
312 EXPECT_EQ(OC_STACK_OK, resource->put(rep, query, &onGetPut, QualityOfService::HighQos));
315 TEST(ResourcePutTest, DISABLED_ResourcePutWithTypeAndInterface)
317 OCRepresentation rep;
318 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
319 EXPECT_TRUE(resource != NULL);
320 EXPECT_EQ(OC_STACK_OK,
321 resource->put("", DEFAULT_INTERFACE, rep, QueryParamsMap(), &onGetPut));
324 TEST(ResourcePutTest, DISABLED_ResourcePutWithNullType)
326 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
327 EXPECT_TRUE(resource != NULL);
328 OCRepresentation rep;
330 resource->put(nullptr, DEFAULT_INTERFACE, rep, QueryParamsMap(), &onGetPut));
331 HeaderOptions headerOptions;
332 onGetPut(headerOptions, rep, OC_STACK_OK);
335 TEST(ResourcePutTest, DISABLED_ResourcePutWithNullInterface)
337 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
338 EXPECT_TRUE(resource != NULL);
339 OCRepresentation rep;
340 EXPECT_ANY_THROW(resource->put("", nullptr, rep, QueryParamsMap(), &onGetPut));
344 TEST(ResourceObserveTest, DISABLED_ResourceObserveValidUri)
346 OCResource::Ptr resource =
347 ConstructResourceObject("coap://192.168.1.2:5000", "/Observe");
348 EXPECT_TRUE(resource != NULL);
349 QueryParamsMap query = {};
350 EXPECT_EQ(OC_STACK_OK, resource->observe(ObserveType::ObserveAll, query, &onObserve));
353 TEST(ResourceObserveTest, DISABLED_ResourceObserveLoQos)
355 QueryParamsMap query = {};
356 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/Observe");
357 EXPECT_TRUE(resource != NULL);
358 EXPECT_EQ(OC_STACK_OK,
359 resource->observe(ObserveType::ObserveAll, query, &onObserve,
360 QualityOfService::LowQos));
363 TEST(ResourceObserveTest, DISABLED_ResourceObserveNaQos)
365 QueryParamsMap query = {};
366 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/Observe");
367 EXPECT_TRUE(resource != NULL);
368 EXPECT_EQ(OC_STACK_OK,
369 resource->observe(ObserveType::ObserveAll, query, &onObserve,
370 QualityOfService::NaQos));
373 TEST(ResourceObserveTest, DISABLED_ResourceObserveMidQos)
375 QueryParamsMap query = {};
376 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/Observe");
377 EXPECT_TRUE(resource != NULL);
378 EXPECT_EQ(OC_STACK_OK,
379 resource->observe(ObserveType::ObserveAll, query, &onObserve,
380 QualityOfService::MidQos));
383 TEST(ResourceObserveTest, DISABLED_ResourceObserveHighQos)
385 QueryParamsMap query = {};
386 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/Observe");
387 EXPECT_TRUE(resource != NULL);
388 EXPECT_EQ(OC_STACK_OK,
389 resource->observe(ObserveType::ObserveAll, query, &onObserve,
390 QualityOfService::HighQos));
393 TEST(ResourceObserveTest, DISABLED_ResourceCancelObserveValidUri)
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, resource->observe(ObserveType::ObserveAll, query, &onObserve));
399 EXPECT_EQ(OC_STACK_OK, resource->cancelObserve());
402 TEST(ResourceObserveTest, DISABLED_ResourceCancelObserveWithNaQos)
404 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
405 EXPECT_TRUE(resource != NULL);
406 QueryParamsMap query = {};
407 EXPECT_EQ(OC_STACK_OK,
408 resource->observe(ObserveType::ObserveAll, query, &onObserve,
409 QualityOfService::NaQos));
410 EXPECT_EQ(OC_STACK_OK, resource->cancelObserve(QualityOfService::NaQos));
413 TEST(ResourceObserveTest, DISABLED_ResourceCancelObserveWithLowQos)
415 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
416 EXPECT_TRUE(resource != NULL);
417 QueryParamsMap query = {};
418 EXPECT_EQ(OC_STACK_OK,
419 resource->observe(ObserveType::ObserveAll, query, &onObserve,
420 QualityOfService::LowQos));
421 EXPECT_EQ(OC_STACK_OK, resource->cancelObserve(QualityOfService::LowQos));
424 TEST(ResourceObserveTest, DISABLED_ResourceCancelObserveWithMidQos)
426 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
427 EXPECT_TRUE(resource != NULL);
428 QueryParamsMap query = {};
429 EXPECT_EQ(OC_STACK_OK,
430 resource->observe(ObserveType::ObserveAll, query, &onObserve,
431 QualityOfService::MidQos));
432 EXPECT_EQ(OC_STACK_OK, resource->cancelObserve(QualityOfService::MidQos));
435 TEST(ResourceObserveTest, DISABLED_ResourceCancelObserveWithHighQos)
437 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
438 EXPECT_TRUE(resource != NULL);
439 QueryParamsMap query = {};
440 EXPECT_EQ(OC_STACK_OK,
441 resource->observe(ObserveType::ObserveAll, query, &onObserve,
442 QualityOfService::HighQos));
443 EXPECT_EQ(OC_STACK_OK, resource->cancelObserve(QualityOfService::HighQos));
447 TEST(DeleteResourceTest, DISABLED_DeleteResourceValidUri)
449 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
450 EXPECT_TRUE(resource != NULL);
451 EXPECT_EQ(OC_STACK_OK, resource->deleteResource(&deleteResponse));
454 TEST(DeleteResourceTest, DISABLED_DeleteResourceWithLowQos)
456 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
457 EXPECT_TRUE(resource != NULL);
458 EXPECT_EQ(OC_STACK_OK,
459 resource->deleteResource(&deleteResponse, QualityOfService::LowQos));
462 TEST(DeleteResourceTest, DISABLED_DeleteResourceWithMidQos)
464 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
465 EXPECT_TRUE(resource != NULL);
466 EXPECT_EQ(OC_STACK_OK,
467 resource->deleteResource(&deleteResponse, QualityOfService::MidQos));
470 TEST(DeleteResourceTest, DISABLED_DeleteResourceWithHighQos)
472 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
473 EXPECT_TRUE(resource != NULL);
474 EXPECT_EQ(OC_STACK_OK,
475 resource->deleteResource(&deleteResponse, QualityOfService::HighQos));
477 TEST(DeleteResourceTest, DISABLED_DeleteResourceWithNaQos)
479 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
480 EXPECT_TRUE(resource != NULL);
481 EXPECT_EQ(OC_STACK_OK, resource->deleteResource(&deleteResponse, QualityOfService::NaQos));
484 //GetResourceInterfaces Test
485 TEST(GetResourceInterfacesTest, GetResourceInterfaces)
487 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
488 EXPECT_TRUE(resource != NULL);
489 EXPECT_TRUE(resource->getResourceInterfaces().front() == DEFAULT_INTERFACE);
492 //GetResourceTypes Test
493 TEST(GetResourceTypesTest, GetResourceTypes)
495 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
496 EXPECT_TRUE(resource != NULL);
497 EXPECT_TRUE(resource->getResourceTypes().front() == "intel.rpost");
503 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
504 EXPECT_TRUE(resource != NULL);
505 EXPECT_TRUE(resource->host() == "coap://192.168.1.2:5000");
508 TEST(HostTest, Host2)
510 OCResource::Ptr resource = ConstructResourceObject("coap://[ffff::ffff%25eth0]:5000", "/resource");
511 EXPECT_TRUE(resource != NULL);
512 EXPECT_TRUE(resource->host() == "coap://[ffff::ffff%25eth0]:5000");
516 TEST(HostsTest, EmptyHosts)
518 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
519 EXPECT_TRUE(resource != NULL);
520 EXPECT_TRUE(resource->getAllHosts().empty());
524 TEST(SetHostTest, SetHost)
526 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
527 EXPECT_TRUE(resource != NULL);
528 EXPECT_TRUE(resource->host() == "coap://192.168.1.2:5000");
529 EXPECT_TRUE(resource->setHost("coap://192.168.1.1:5000") == "coap://192.168.1.1:5000");
533 TEST(SetHostTest, SetHost2)
535 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
536 EXPECT_TRUE(resource != NULL);
537 EXPECT_TRUE(resource->host() == "coap://192.168.1.2:5000");
538 EXPECT_TRUE(resource->setHost("coap://[3731:54:65fe:2::a7]:32787") ==
539 "coap://[3731:54:65fe:2::a7]:32787");
543 TEST(SetHostTest, SetHost3)
545 OCResource::Ptr resource = ConstructResourceObject("coap://[3731:54:65fe:2::a7]:32787", "/resource");
546 EXPECT_TRUE(resource != NULL);
547 EXPECT_TRUE(resource->host() == "coap://[3731:54:65fe:2::a7]:32787");
548 EXPECT_TRUE(resource->setHost("coap://192.168.1.2:5000") == "coap://192.168.1.2:5000");
554 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
555 EXPECT_TRUE(resource != NULL);
556 EXPECT_TRUE(resource->uri() == "/resource");
559 //ConnectivityType Test
560 TEST(ConnectivityTypeTest, ConnectivityTypeIpv4)
562 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
563 EXPECT_TRUE(resource != NULL);
564 EXPECT_TRUE(resource->connectivityType() == (CT_ADAPTER_IP | CT_IP_USE_V4));
567 //ConnectivityType Test
568 TEST(ConnectivityTypeTest, ConnectivityTypeIpv6)
570 OCResource::Ptr resource = ConstructResourceObject("coap://[fe80::52b7:c3ff:fead:dc0d%25eth0]:5000", "/resource");
571 EXPECT_TRUE(resource != NULL);
572 EXPECT_TRUE(resource->connectivityType() == (CT_ADAPTER_IP | CT_IP_USE_V6));
576 TEST(IsObservableTest, isObservable)
578 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
579 EXPECT_TRUE(resource != NULL);
580 EXPECT_FALSE(resource->isObservable());
586 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
587 EXPECT_TRUE(resource != NULL);
588 EXPECT_TRUE(resource->sid() == "");
591 //UniqueIdentifier Test
592 TEST(UniqueIdentifierTest, uniqueIdentifier)
594 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
595 EXPECT_TRUE(resource != NULL);
596 std::ostringstream ss;
597 ss << resource->uniqueIdentifier();
598 EXPECT_TRUE(ss.str() == "/resource");
601 // HeaderOptions Test
602 TEST(HeaderOptionsTest, SetHeaderOptionsValidInput)
604 const uint16_t API_VERSION = 2048;
605 const uint16_t TOKEN = 3000;
606 HeaderOptions headerOptions;
607 HeaderOption::OCHeaderOption apiVersion(API_VERSION, "v.1.0");
608 HeaderOption::OCHeaderOption clientToken(TOKEN, "21ae43gf");
609 headerOptions.push_back(apiVersion);
610 headerOptions.push_back(clientToken);
612 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
613 EXPECT_TRUE(resource != NULL);
614 EXPECT_NO_THROW(resource->setHeaderOptions(headerOptions));
615 EXPECT_NO_THROW(resource->unsetHeaderOptions());
618 TEST(HeaderOptionsTest, SetHeaderOptionsEmptyInput)
620 OCResource::Ptr resource = ConstructResourceObject("coap://192.168.1.2:5000", "/resource");
621 EXPECT_TRUE(resource != NULL);
622 HeaderOptions headerOptions;
623 EXPECT_NO_THROW(resource->setHeaderOptions(headerOptions));
624 EXPECT_NO_THROW(resource->unsetHeaderOptions());