Merge test folder of test branch
[iotivity.git] / test / src / tc / re / gtest / src / btc / RERepresentationTest.cpp
1 //******************************************************************
2 //
3 // Copyright 2016 Samsung Electronics 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 #include <string>
22 #include "gtest/gtest.h"
23 #include "REHelper.h"
24
25 class RERepresentationTest_btc: public ::testing::Test
26 {
27     virtual void SetUp()
28     {
29         CommonUtil::launchApp(RE_SERVER_APP);
30         CommonUtil::waitInSecond(CALLBACK_WAIT_MAX);
31     }
32
33     virtual void TearDown()
34     {
35         CommonUtil::killApp(RE_SERVER_APP);
36         CommonUtil::waitInSecond(CALLBACK_WAIT_MAX);
37     }
38 };
39
40 /**
41  * @since 2016-03-11
42  * @see RCSResourceObject, RCRemoteResourceObject
43  * @see RCSResourceObject, RCRemoteResourceObject
44  * @objective Test RCSRepresentation() in a positive basic way
45  * @target RCSRepresentation(const std::string& uri, const std::vector< std::string >& interfaces,
46  const std::vector< std::string >& resourceTypes);
47  * @test_data uriString = "uri";
48  * @pre_condition None
49  * @procedure Perform RCSRepresentation() API
50  * @post_condition None
51  * @expected The API should not generate any exception
52  **/
53 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
54 TEST_F(RERepresentationTest_btc, RCSRepresentationWithData_SRC_P)
55 {
56
57     std::string uriString = "uri";
58     std::vector < std::string > interfaces;
59     std::vector < std::string > resourceTypes;
60
61     try
62     {
63         RCSRepresentation representation(uriString, interfaces, resourceTypes);
64     }
65     catch (exception& e)
66     {
67         SET_FAILURE(
68                 "exception occurred inside RCSRepresentationWithData_SRC_P: "
69                         + std::string(e.what()));
70     }
71 }
72 #endif
73
74 /**
75  * @since 2016-03-11
76  * @see RCSResourceObject, RCRemoteResourceObject
77  * @objective Test RCSRepresentation() With Data ResourceAttributes in a positive basic way
78  * @target RCSRepresentation(const std::string& uri, const std::vector< std::string >& interfaces,
79  const std::vector< std::string >& resourceTypes,
80  const RCSResourceAttributes& attrs);
81  * @test_data uriString = "uri";
82  * @pre_condition None
83  * @procedure Perform RCSRepresentation() With Data ResourceAttributes
84  * @post_condition None
85  * @expected The API should not generate any exception
86  **/
87 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
88 TEST_F(RERepresentationTest_btc, RCSRepresentationWithDataResourceAttributes_SRC_P)
89 {
90
91     std::string uriString = "uri";
92     std::vector < std::string > interfaces;
93     std::vector < std::string > resourceTypes;
94     RCSResourceAttributes resourceAttributes;
95     try
96     {
97         RCSRepresentation representation(uriString, interfaces, resourceTypes, resourceAttributes);
98     }
99     catch (exception& e)
100     {
101         SET_FAILURE(
102                 "exception occurred inside RCSRepresentationWithDataResourceAttributes_SRC_P: "
103                         + std::string(e.what()));
104     }
105 }
106 #endif
107
108 /**
109  * @since 2016-03-10
110  * @see RCSResourceObject, RCRemoteResourceObject
111  * @objective Test getUri() in a positive basic way
112  * @target std::string getUri() const;
113  * @test_data None
114  * @pre_condition None
115  * @procedure Perform getUri() API
116  * @post_condition None
117  * @expected The API should not generate any exception
118  **/
119 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
120 TEST_F(RERepresentationTest_btc, RCSRepresentationGetUri_SRC_P)
121 {
122     RCSRepresentation representation;
123     try
124     {
125         representation.getUri();
126     }
127     catch (exception& e)
128     {
129         SET_FAILURE(
130                 "exception occurred inside RCSRepresentationGetUri_SRC_P: "
131                         + std::string(e.what()));
132     }
133 }
134 #endif
135
136 /**
137  * @since 2016-03-10
138  * @see RCSResourceObject, RCRemoteResourceObject
139  * @objective Test setUri() in a positive basic way
140  * @target  void setUri(std::string uri)
141  * @test_data uri = "uri";
142  * @pre_condition None
143  * @procedure Perform setUri() API
144  * @post_condition None
145  * @expected The API should not generate any exception
146  **/
147 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
148 TEST_F(RERepresentationTest_btc, RCSRepresentationSetUri_SRC_P)
149 {
150     RCSRepresentation representation;
151     std::string uri = "uri";
152     try
153     {
154         representation.setUri(uri);
155     }
156     catch (exception& e)
157     {
158         SET_FAILURE(
159                 "exception occurred inside RCSRepresentationSetUri_SRC_P: "
160                         + std::string(e.what()));
161     }
162 }
163 #endif
164
165 /**
166  * @since 2016-03-11
167  * @see RCSResourceObject, RCRemoteResourceObject
168  * @objective Test setUri() API with empty uri
169  * @target  void setUri(std::string uri)
170  * @test_data uri = "";
171  * @pre_condition None
172  * @procedure Perform setUri() with empty value
173  * @post_condition None
174  * @expected The API should throw exception
175  **/
176 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
177 TEST_F(RERepresentationTest_btc, RCSRepresentationSetUri_ESV_N)
178 {
179     RCSRepresentation representation;
180     std::string emptyString = "";
181     try
182     {
183         representation.setUri(emptyString);
184     }
185     catch (exception& e)
186     {
187         SET_FAILURE(
188                 "exception occurred inside RCSRepresentationSetUri_ESV_N: "
189                         + std::string(e.what()));
190     }
191 }
192 #endif
193
194 /**
195  * @since 2016-03-10
196  * @see RCSResourceObject, RCRemoteResourceObject
197  * @objective Test addInterface() API in a positive basic way
198  * @target void addInterface(std::string interface)
199  * @test_data interface = "interface";
200  * @pre_condition None
201  * @procedure Perform addInterface() API
202  * @post_condition None
203  * @expected The API should not generate any exception
204  **/
205 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
206 TEST_F(RERepresentationTest_btc, RCSRepresentationAddInterface_SRC_P)
207 {
208     RCSRepresentation representation;
209     std::string interface = "interface";
210     try
211     {
212         representation.addInterface(interface);
213     }
214     catch (exception& e)
215     {
216         SET_FAILURE(
217                 "exception occurred inside RCSRepresentationAddInterface_SRC_P: "
218                         + std::string(e.what()));
219     }
220 }
221 #endif
222
223 /**
224  * @since 2016-03-11
225  * @see RCSResourceObject, RCRemoteResourceObject
226  * @objective Test addInterface() with empty interface
227  * @target void addInterface(std::string interface)
228  * @test_data interface = "";
229  * @pre_condition None
230  * @procedure perform addInterface() API with empty value
231  * @post_condition None
232  * @expected The API Should not crash
233  **/
234 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
235 TEST_F(RERepresentationTest_btc, RCSRepresentationAddInterface_ESV_N)
236 {
237     RCSRepresentation representation;
238     std::string emptyInterface = "";
239     try
240     {
241         representation.addInterface(emptyInterface);
242     }
243     catch (exception& e)
244     {
245         SET_FAILURE(
246                 "exception occurred inside RCSRepresentationAddInterface_ESV_N: "
247                         + std::string(e.what()));
248     }
249 }
250 #endif
251
252 /**
253  * @since 2016-03-10
254  * @see RCSResourceObject, RCRemoteResourceObject
255  * @objective Test getInterfaces() with positive basic way
256  * @target const std::vector< std::string >& getInterfaces() const;
257  * @test_data None
258  * @pre_condition None
259  * @procedure Perform getInterfaces() API
260  * @post_condition None
261  * @expected The API should not generate any exception
262  **/
263 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
264 TEST_F(RERepresentationTest_btc, RCSRepresentationGetInterfaces_SRC_P)
265 {
266     RCSRepresentation representation;
267     try
268     {
269         std::vector < std::string > interfaces = representation.getInterfaces();
270     }
271     catch (exception& e)
272     {
273         SET_FAILURE(
274                 "exception occurred inside RCSRepresentationGetInterfaces_SRC_P: "
275                         + std::string(e.what()));
276     }
277 }
278 #endif
279
280 /**
281  * @since 2016-03-10
282  * @see RCSResourceObject, RCRemoteResourceObject
283  * @objective Test clearInterfaces() with positive basic way
284  * @target  void clearInterfaces();
285  * @test_data None
286  * @pre_condition None
287  * @procedure perform clearInterfaces() API
288  * @post_condition None
289  * @expected The API should not generate any exception
290  **/
291 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
292 TEST_F(RERepresentationTest_btc, RCSRepresentationClearInterfaces_SRC_P)
293 {
294     RCSRepresentation representation;
295     try
296     {
297         representation.clearInterfaces();
298     }
299     catch (exception& e)
300     {
301         SET_FAILURE(
302                 "exception occurred inside RCSRepresentationClearInterfaces_SRC_P: "
303                         + std::string(e.what()));
304     }
305 }
306 #endif
307
308 /**
309  * @since 2016-03-10
310  * @see RCSResourceObject, RCRemoteResourceObject
311  * @objective Test getResourceTypes() in a positive basic way
312  * @target  const std::vector< std::string >& getResourceTypes() const;
313  * @test_data None
314  * @pre_condition None
315  * @procedure Perform getResourceTypes() API
316  * @post_condition None
317  * @expected The API should not generate any exception
318  **/
319 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
320 TEST_F(RERepresentationTest_btc, RCSRepresentationGetResourceTypes_SRC_P)
321 {
322     RCSRepresentation representation;
323     try
324     {
325         std::vector < std::string > interfaces = representation.getResourceTypes();
326     }
327     catch (exception& e)
328     {
329         SET_FAILURE(
330                 "exception occurred inside RCSRepresentationGetResourceTypes_SRC_P: "
331                         + std::string(e.what()));
332     }
333 }
334 #endif
335
336 /**
337  * @since 2016-03-10
338  * @see RCSResourceObject, RCRemoteResourceObject
339  * @objective Test addResourceType() with positive basic way
340  * @target  void addResourceType(std::string resourceType);
341  * @test_data resourceType = "resourceType";
342  * @pre_condition None
343  * @procedure Perform addResourceType() API
344  * @post_condition None
345  * @expected The API should not generate any exception
346  **/
347 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
348 TEST_F(RERepresentationTest_btc, RCSRepresentationAddResourceTypes_SRC_P)
349 {
350     RCSRepresentation representation;
351     std::string resourceType = "resourceType";
352     try
353     {
354         representation.addResourceType(resourceType);
355     }
356     catch (exception& e)
357     {
358         SET_FAILURE(
359                 "exception occurred inside RCSRepresentationAddResourceTypes_SRC_P: "
360                         + std::string(e.what()));
361     }
362 }
363 #endif
364
365 /**
366  * @since 2016-03-10
367  * @see RCSResourceObject, RCRemoteResourceObject
368  * @objective Test addResourceType() with empty resourceType
369  * @target  void addResourceType(std::string resourceType);
370  * @test_data resourceType = "";
371  * @pre_condition None
372  * @procedure Perform addResourceType() API with empty value
373  * @post_condition None
374  * @expected The API Should not crash
375  **/
376 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
377 TEST_F(RERepresentationTest_btc, RCSRepresentationAddResourceTypes_ESV_N)
378 {
379     RCSRepresentation representation;
380     std::string resourceType = "";
381     try
382     {
383         representation.addResourceType(resourceType);
384     }
385     catch (exception& e)
386     {
387         SET_FAILURE(
388                 "exception occurred inside RCSRepresentationAddResourceTypes_ESV_N: "
389                         + std::string(e.what()));
390     }
391 }
392 #endif
393
394 /**
395  * @since 2016-03-10
396  * @see RCSResourceObject, RCRemoteResourceObject
397  * @objective Test clearResourceTypes() with positive basic way
398  * @target  void clearResourceTypes();
399  * @test_data None
400  * @pre_condition None
401  * @procedure Perform clearResourceTypes() API
402  * @post_condition None
403  * @expected The API should not generate any exception
404  **/
405 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
406 TEST_F(RERepresentationTest_btc, RCSRepresentationClearResourceTypes_SRC_P)
407 {
408     RCSRepresentation representation;
409
410     try
411     {
412         representation.clearResourceTypes();
413     }
414     catch (exception& e)
415     {
416         SET_FAILURE(
417                 "exception occurred inside RCSRepresentationClearResourceTypes_SRC_P: "
418                         + std::string(e.what()));
419     }
420 }
421 #endif
422
423 /**
424  * @since 2016-03-10
425  * @see RCSResourceObject, RCRemoteResourceObject
426  * @objective Test getAttributes() in a positive basic way
427  * @target  const RCSResourceAttributes& getAttributes() const
428  * @test_data None
429  * @pre_condition None
430  * @procedure Perform getAttributes() API
431  * @post_condition None
432  * @expected The API should not generate any exception
433  **/
434 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
435 TEST_F(RERepresentationTest_btc, RCSRepresentationGetAttributes_SRC_P)
436 {
437     RCSRepresentation representation;
438
439     try
440     {
441         RCSResourceAttributes attributes = representation.getAttributes();
442     }
443     catch (exception& e)
444     {
445         SET_FAILURE(
446                 "exception occurred inside RCSRepresentationGetAttributes_SRC_P: "
447                         + std::string(e.what()));
448     }
449 }
450 #endif
451
452 /**
453  * @since 2016-03-11
454  * @see RCSResourceObject, RCRemoteResourceObject
455  * @objective Test setAttributes() with positive basic way
456  * @target  void setAttributes(const RCSResourceAttributes& attrs);
457  * @test_data None
458  * @pre_condition None
459  * @procedure Perform setAttributes() API with Resource Attributes
460  * @post_condition None
461  * @expected The API should not generate any exception
462  **/
463 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
464 TEST_F(RERepresentationTest_btc, RCSRepresentationSetAttributes_SRC_P)
465 {
466     RCSResourceAttributes resourceAttributes;
467     RCSRepresentation representation;
468
469     try
470     {
471         representation.setAttributes(resourceAttributes);
472     }
473     catch (exception& e)
474     {
475         SET_FAILURE(
476                 "exception occurred inside RCSRepresentationSetAttributes_SRC_P: "
477                         + std::string(e.what()));
478     }
479 }
480 #endif
481
482 /**
483  * @since 2016-03-11
484  * @see RCSResourceObject, RCRemoteResourceObject
485  * @objective Test getChildren() with positive basic way
486  * @target  const std::vector< RCSRepresentation >& getChildren() const;
487  * @test_data None
488  * @pre_condition None
489  * @procedure Perform getChildren() API
490  * @post_condition None
491  * @expected The API should not generate any exception
492  **/
493 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
494 TEST_F(RERepresentationTest_btc, RCSRepresentationGetChildren_SRC_P)
495 {
496     RCSRepresentation representation;
497     std::vector< RCSRepresentation > representationVector;
498
499     try
500     {
501         representationVector = representation.getChildren();
502     }
503     catch (exception& e)
504     {
505         SET_FAILURE(
506                 "exception occurred inside RCSRepresentationGetChildren_SRC_P: "
507                         + std::string(e.what()));
508     }
509 }
510 #endif
511
512 /**
513  * @since 2016-03-11
514  * @see RCSResourceObject, RCRemoteResourceObject
515  * @objective Test addChild() in a positive basic way
516  * @target  void addChild(RCSRepresentation child);
517  * @test_data None
518  * @pre_condition None
519  * @procedure Perform addChild() API
520  * @post_condition None
521  * @expected The API should not generate any exception
522  **/
523 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
524 TEST_F(RERepresentationTest_btc, RCSRepresentationAddChild_SRC_P)
525 {
526     RCSRepresentation representation;
527     RCSRepresentation child;
528
529     try
530     {
531         representation.addChild(child);
532     }
533     catch (exception& e)
534     {
535         SET_FAILURE(
536                 "exception occurred inside RCSRepresentationAddChild_SRC_P: "
537                         + std::string(e.what()));
538     }
539 }
540 #endif
541
542 /**
543  * @since 2016-03-11
544  * @see RCSResourceObject, RCRemoteResourceObject
545  * @objective Test setChildren() with positive basic way
546  * @target  void setChildren(std::vector< RCSRepresentation > children);
547  * @test_data None
548  * @pre_condition None
549  * @procedure Perform setChildren() API
550  * @post_condition None
551  * @expected The API should not generate any exception
552  **/
553 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
554 TEST_F(RERepresentationTest_btc, RCSRepresentationSetChildren_SRC_P)
555 {
556     RCSRepresentation representation;
557     std::vector< RCSRepresentation > children;
558
559     try
560     {
561         representation.setChildren(children);
562     }
563     catch (exception& e)
564     {
565         SET_FAILURE(
566                 "exception occurred inside RCSRepresentationSetChildren_SRC_P : "
567                         + std::string(e.what()));
568     }
569 }
570 #endif
571
572 /**
573  * @since 2016-03-11
574  * @see RCSResourceObject, RCRemoteResourceObject
575  * @objective Test clearChildren() with positive basic way
576  * @target  void clearChildren();
577  * @test_data None
578  * @pre_condition None
579  * @procedure Perform clearChildren() API
580  * @post_condition None
581  * @expected The API should not generate any exception
582  **/
583 #if defined(__LINUX__) || defined(__TIZEN__) || defined(__WINDOWS__)
584 TEST_F(RERepresentationTest_btc, RCSRepresentationClearChildren_SRC_P)
585 {
586     RCSRepresentation representation;
587
588     try
589     {
590         representation.clearChildren();
591     }
592     catch (exception& e)
593     {
594         SET_FAILURE(
595                 "exception occurred inside RCSRepresentationClearChildren_SRC_P: "
596                         + std::string(e.what()));
597     }
598 }
599 #endif