Merge test folder of test branch
[iotivity.git] / test / src / tc / rc / junit / src / org / iotivity / test / rc / tc / btc / RCResourceContainerTest.java
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 package org.iotivity.test.rc.tc.btc;
21
22 import java.util.HashMap;
23 import java.util.List;
24 import java.util.Map;
25
26 import static org.iotivity.test.rc.tc.helper.RCCommonUtilBTC.*;
27 import org.iotivity.test.rc.tc.helper.RCHelperBTC;
28
29 import org.iotivity.service.resourcecontainer.RcsBundleInfo;
30 import org.iotivity.service.resourcecontainer.RcsResourceContainer;
31 import org.iotivity.service.resourcecontainer.ResourceConfig;
32
33 import android.content.Context;
34 import android.test.InstrumentationTestCase;
35 import android.util.Log;
36
37 public class RCResourceContainerTest extends InstrumentationTestCase {
38         private RcsResourceContainer m_ResourceContainer;
39         private RCHelperBTC m_RCHelper;
40
41         private String bundlePath;
42         private String configFile;
43         private String emptyConfigFile;
44         private String sdCardPath;
45
46         public static final String s_INSERT_VERSION_INFO = "Version";
47         public static String[] resourceParam;
48
49         public static final int n_ZERO = 0;
50         public static final int n_MAX_WAIT = 2;
51         public static final int n_NEGATIVE_ONE = -1;
52
53         private static boolean isCopied = false;
54         private Context m_Context = null;
55
56         protected void setUp() throws Exception {
57                 super.setUp();
58
59                 m_Context = getInstrumentation().getTargetContext();
60
61                 m_RCHelper = RCHelperBTC.getInstance();
62
63                 isCopied = m_RCHelper.copyFilesToDevice(m_Context);
64
65                 sdCardPath = m_RCHelper.getFilesPath(m_Context);
66
67                 configFile = sdCardPath + RESOURCE_CONTAINER_CONFIG_XML;
68                 emptyConfigFile = sdCardPath + RESOURCE_CONTAINER_EMPTY_CONFIG_XML;
69                 bundlePath = sdCardPath + HUE_BUNDLE_JAR;
70
71                 if (!isCopied) {
72                         Log.d(TAG, "Can't copy the files from assets/lib folder");
73                 } else {
74                         Log.d(TAG, "Successfully copied files from assets/lib folder");
75                 }
76
77                 m_ResourceContainer = new RcsResourceContainer(m_Context);
78         }
79
80         protected void tearDown() throws Exception {
81                 super.tearDown();
82
83                 if (m_ResourceContainer != null) {
84                         m_ResourceContainer = null;
85                 }
86         }
87
88         /**
89          * @since 2015-10-26
90          * @see None
91          * @objective Test 'StartContainer' function with ResourceContainerConfig
92          * @target void startContainer(string configFile)
93          * @test_data ResourceContainerConfig
94          * @pre_condition Get container instance
95          * @procedure Perform StartContainer() API
96          * @post_condition None
97          * @expected Container can gather information from
98          *           ResourceContainerConfig.xml file.
99          **/
100         public void testStartContainer_SRC_P() {
101                 try {
102                         m_ResourceContainer.startContainer(configFile);
103                 } catch (Exception e) {
104                         fail("Can't start container because of the exception: "
105                                         + e.getLocalizedMessage());
106                 }
107         }
108
109         /**
110          * @since 2015-10-26
111          * @see None
112          * @objective Test 'StartContainer' function with empty string instead of
113          *            ResourceContainerConfig
114          * @target void startContainer(string configFile)
115          * @test_data None
116          * @pre_condition Get container instance
117          * @procedure Perform StartContainer() API
118          * @post_condition None
119          * @expected No crash occurs
120          **/
121         public void testStartContainer_ESV_N() {
122                 try {
123                         m_ResourceContainer.startContainer(EMPTY_STRING);
124
125                         fail("Successfully called startContainer with empty config file path");
126                 } catch (Exception e) {
127                 }
128         }
129
130         /**
131          * @since 2015-10-26
132          * @see StartContainer
133          * @objective Test 'StopContainer' function with StartContainer first
134          * @target void StopContainer(void)
135          * @test_data ResourceContainerConfig
136          * @pre_condition 1. Get container instance 2. Perform StartContainer() API
137          * @procedure Perform StopContainer() API
138          * @post_condition None
139          * @expected Container can stop container.
140          **/
141         public void testStopContainer_SRC_P() {
142                 try {
143                         m_ResourceContainer.startContainer(configFile);
144                         m_ResourceContainer.stopContainer();
145                 } catch (Exception e) {
146                         fail("Can't stop container because of the exception: "
147                                         + e.getLocalizedMessage());
148                 }
149         }
150
151         /**
152          * @since 2015-10-26
153          * @see None
154          * @objective Test 'StopContainer' function without StartContainer
155          * @target void StopContainer(void)
156          * @test_data None
157          * @pre_condition Get container instance
158          * @procedure Perform StopContainer() API
159          * @post_condition None
160          * @expected No crash occurs
161          **/
162         public void testStopContainer_ESV_N() {
163                 try {
164                         m_ResourceContainer.stopContainer();
165                 } catch (Exception e) {
166                         fail("Can't stop container because of the exception: "
167                                         + e.getLocalizedMessage());
168                 }
169         }
170
171         /**
172          * @since 2015-10-26
173          * @see StartContainer
174          * @objective Test 'listBundles' function with StartContainer first
175          * @target list<BundleInfo*> listBundles(void)
176          * @test_data ResourceContainerConfig
177          * @pre_condition 1. Get container instance 2. Perform StartContainer() API
178          *                with config file
179          * @procedure Perform listBundles() API
180          * @post_condition Stop container
181          * @expected Container can list up bundles.
182          **/
183         public void testListBundles_SRC_P() {
184                 m_ResourceContainer.startContainer(configFile);
185                 try {
186                         List<RcsBundleInfo> bundleList = m_ResourceContainer.listBundles();
187                 } catch (Exception e) {
188                         fail("ListBundles occurs  the exception: "
189                                         + e.getLocalizedMessage());
190                 }
191
192                 m_ResourceContainer.stopContainer();
193         }
194
195         /**
196          * @since 2015-10-26
197          * @see StartContainer
198          * @objective Test 'listBundles' function with StartContainer that have
199          *            empty config file
200          * @target list<BundleInfo*> listBundles(void)
201          * @test_data Empty Resource Config
202          * @pre_condition 1. Get container instance 2. Start container with valid
203          *                config file which has bundles
204          * @procedure Perform listBundles() API
205          * @post_condition Stop container
206          * @expected No crash occurs
207          **/
208         public void testListBundles_ESV_N() {
209                 m_ResourceContainer.startContainer(emptyConfigFile);
210
211                 try {
212                         List<RcsBundleInfo> bundleList = m_ResourceContainer.listBundles();
213
214                         if (bundleList.size() != n_ZERO) {
215                                 fail("Bundle size must be 0 but got " + bundleList.size());
216                         }
217                 } catch (Exception e) {
218                 }
219
220                 m_ResourceContainer.stopContainer();
221         }
222
223         /**
224          * @since 2015-10-27
225          * @see StartContainer
226          * @objective Test 'startBundle' function with StartContainer that have
227          *            valid Resource Config file
228          * @target void startBundle(string bundleId)
229          * @test_data ResourceContainerConfig
230          * @pre_condition 1. Get container instance 2. Perform StartContainer() API
231          * @procedure Perform startBundle() API
232          * @post_condition Stop container
233          * @expected Container can start bundle.
234          **/
235         public void testStartBundle_SRC_P() {
236                 try {
237                         m_ResourceContainer.startContainer(configFile);
238                         List<RcsBundleInfo> bundleList = m_ResourceContainer.listBundles();
239
240                         if (bundleList.size() >= n_ZERO) {
241                                 RcsBundleInfo bundleInfo = bundleList.get(n_ZERO);
242                                 m_ResourceContainer.startBundle(bundleInfo.getID());
243
244                                 m_RCHelper.waitInSecond(n_MAX_WAIT);
245
246                                 m_ResourceContainer.stopContainer();
247                         } else {
248                                 fail("Can't get bundle list");
249                         }
250                 } catch (Exception e) {
251                         fail("Got exception at StartBundle_P. Exception: "
252                                         + e.getLocalizedMessage());
253                 }
254         }
255
256         /**
257          * @since 2015-10-27
258          * @see None
259          * @objective Test 'startBundle' function with Empty String
260          * @target void startBundle(string bundleId)
261          * @test_data empty string
262          * @pre_condition Get container instance
263          * @procedure Perform startBundle() API
264          * @post_condition None
265          * @expected No crash occurs
266          **/
267         public void testStartBundle_ESV_N() {
268                 try {
269                         m_ResourceContainer.startBundle(EMPTY_STRING);
270                         fail("Successfully called startBundle with null bundleId");
271                 } catch (Exception e) {
272                 }
273         }
274
275         /**
276          * @since 2015-10-27
277          * @see StartContainer
278          * @see StartBundle
279          * @see Get bundle list
280          * @objective Test 'stopBundle' function with StartContainer and StartBundle
281          *            these have valid data
282          * @target void stopBundle(string bundleId)
283          * @test_data ResourceContainerConfig
284          * @pre_condition 1. Get container instance 2. Perform StartContainer() 3.
285          *                Get bundle list 4. StartBundle
286          * @procedure Perform stopBundle() API
287          * @post_condition StopContainer
288          * @expected Container can stop bundle
289          **/
290         public void testStopBundle_SRC_P() {
291                 try {
292                         m_ResourceContainer.startContainer(configFile);
293                         List<RcsBundleInfo> bundleList = m_ResourceContainer.listBundles();
294
295                         if (bundleList.size() >= n_ZERO) {
296                                 RcsBundleInfo bundleInfo = bundleList.get(n_ZERO);
297                                 m_ResourceContainer.startBundle(bundleInfo.getID());
298                                 m_RCHelper.waitInSecond(n_MAX_WAIT);
299                                 m_ResourceContainer.stopBundle(bundleInfo.getID());
300
301                                 m_ResourceContainer.stopContainer();
302                         } else {
303                                 fail("Can't get bundle list");
304                         }
305                 } catch (Exception e) {
306                         fail("Got exception at StopBundle_P. Exception: "
307                                         + e.getLocalizedMessage());
308                 }
309         }
310
311         /**
312          * @since 2015-10-27
313          * @see None
314          * @objective Test 'stopBundle' function with empty string
315          * @target void stopBundle(string bundleId)
316          * @test_data Empty string
317          * @pre_condition Get container instance
318          * @procedure Perform stopBundle() API
319          * @post_condition None
320          * @expected No crash occurs
321          **/
322         public void testStopBundle_ESV_N() {
323                 try {
324                         m_ResourceContainer.stopBundle(EMPTY_STRING);
325
326                         fail("Successfully called stopBundle with null bundleId");
327                 } catch (Exception e) {
328                 }
329         }
330
331         /**
332          * @since 2015-10-27
333          * @see None
334          * @objective Test 'addBundle' function with data and path
335          * @target void addBundle(String bundleId, String bundleUri, String
336          *         bundlePath, String activator, Map<String, String> params)
337          * @test_data Bundle information
338          * @pre_condition 1. Get container instance 2. Start Container 3. Initiate
339          *                param value
340          * @procedure Perform addBundle() API
341          * @post_condition None
342          * @expected Container should add bundle
343          **/
344         public void testAddBundle_SRC_P() {
345                 try {
346                         m_ResourceContainer.startContainer(configFile);
347                         Map<String, String> params = new HashMap<String, String>();
348                         params.put(s_INSERT_VERSION_INFO, HUE_BUNDLE_VERSION);
349
350                         m_ResourceContainer.addBundle(HUE_BUNDLE_ID, HUE_BUNDLE_URI,
351                                         bundlePath, HUE_BUNDLE_ACTIVATOR, params);
352                 } catch (Exception e) {
353                         fail("Exception occurred inside AddBundle_P. "
354                                         + e.getLocalizedMessage());
355                 }
356         }
357
358         /**
359          * @since 2015-10-27
360          * @see None
361          * @objective Test 'addBundle' function with empty string
362          * @target void addBundle(String bundleId, String bundleUri, String
363          *         bundlePath, String activator, Map<String, String> params)
364          * @test_data None
365          * @pre_condition Get container instance
366          * @procedure Perform addBundle() API
367          * @post_condition None
368          * @expected No crash occurs
369          **/
370         public void testAddBundle_ESV_N() {
371                 try {
372                         Map<String, String> params = new HashMap<String, String>();
373
374                         m_ResourceContainer.addBundle(EMPTY_STRING, EMPTY_STRING,
375                                         EMPTY_STRING, EMPTY_STRING, params);
376                 } catch (Exception e) {
377                         fail("Exception occurred inside AddBundle_N. "
378                                         + e.getLocalizedMessage());
379                 }
380         }
381
382         /**
383          * @since 2015-10-27
384          * @see None
385          * @objective Test 'removeBundle' function with valid data and path
386          * @target void removeBundle(string bundleId)
387          * @test_data Bundle Info
388          * @pre_condition 1. Get container instance 2. Add bundle
389          * @procedure Perform removeBundle() API
390          * @post_condition None
391          * @expected Container can remove bundle
392          **/
393         public void testRemoveBundle_SRC_P() {
394                 try {
395                         Map<String, String> params = new HashMap<String, String>();
396                         params.put(s_INSERT_VERSION_INFO, HUE_BUNDLE_VERSION);
397
398                         m_ResourceContainer.addBundle(HUE_BUNDLE_ID, HUE_BUNDLE_URI,
399                                         bundlePath, HUE_BUNDLE_ACTIVATOR, params);
400
401                         m_RCHelper.waitInSecond(n_MAX_WAIT);
402
403                         m_ResourceContainer.removeBundle(HUE_BUNDLE_ID);
404                 } catch (Exception e) {
405                         fail("Exception occurred inside RemoveBundle_P. "
406                                         + e.getLocalizedMessage());
407                 }
408         }
409
410         /**
411          * @since 2015-10-27
412          * @see None
413          * @objective Test 'removeBundle' function with empty bundleID
414          * @target void removeBundle(string bundleId)
415          * @test_data empty string
416          * @pre_condition Get container instance
417          * @procedure Perform removeBundle() API
418          * @post_condition None
419          * @expected No crash occurs
420          **/
421         public void testRemoveBundle_ESV_N() {
422                 try {
423                         m_ResourceContainer.removeBundle(EMPTY_STRING);
424                         fail("Successfully called removeBundle with empty bundleId");
425                 } catch (Exception e) {
426                 }
427         }
428
429         /**
430          * @since 2015-10-27
431          * @see None
432          * @objective Test 'addResourceConfig' function with valid resource data
433          * @target void addResourceConfig(string bundleId, string resourceUri,
434          *         std::map<string, string> params)
435          * @test_data Bundle information
436          * @pre_condition Get container instance
437          * @procedure Perform addResourceConfig() API
438          * @post_condition None
439          * @expected Container can add resource in resourceConfig
440          **/
441         public void testAddResourceConfig_SRC_P() {
442                 try {
443                         Map<String, String> params = new HashMap<String, String>();
444                         params.put(s_INSERT_VERSION_INFO, HUE_BUNDLE_VERSION);
445
446                         m_ResourceContainer.addResourceConfig(HUE_BUNDLE_ID,
447                                         HUE_BUNDLE_URI, params);
448                 } catch (Exception e) {
449                         fail("Exception occurred inside AddResourceConfig_P. "
450                                         + e.getLocalizedMessage());
451                 }
452         }
453
454         /**
455          * @since 2015-10-27
456          * @see None
457          * @objective Test 'addResourceConfig' function with empty string for
458          *            bundleId and resourceUri
459          * @target void addResourceConfig(string bundleId, string resourceUri,
460          *         std::map<string, string> params)
461          * @test_data None
462          * @pre_condition Get container instance
463          * @procedure Perform addResourceConfig() API
464          * @post_condition None
465          * @expected No crash occurs
466          **/
467         public void testAddResourceConfig_ESV_N() {
468                 try {
469                         Map<String, String> params = new HashMap<String, String>();
470
471                         m_ResourceContainer.addResourceConfig(EMPTY_STRING, EMPTY_STRING,
472                                         params);
473                         fail("Successfully called addResourceConfig with empty bundleId and resUri");
474                 } catch (Exception e) {
475                 }
476         }
477
478         /**
479          * @since 2015-10-27
480          * @see addResourceConfig
481          * @objective Test 'removeResourceConfig' function with BundleId & BundleUri
482          * @target void removeResourceConfig(string bundleId)
483          * @test_data BundleId & BundleUri
484          * @pre_condition 1. Get container instance 2. Add resource
485          * @procedure Perform removeResourceConfig() API
486          * @post_condition None
487          * @expected Container can remove resource in resourceConfig
488          **/
489         public void testRemoveResourceConfig_SRC_P() {
490                 try {
491                         Map<String, String> params = new HashMap<String, String>();
492                         params.put(s_INSERT_VERSION_INFO, HUE_BUNDLE_VERSION);
493
494                         m_ResourceContainer.addResourceConfig(HUE_BUNDLE_ID,
495                                         HUE_BUNDLE_URI, params);
496
497                         m_RCHelper.waitInSecond(n_MAX_WAIT);
498
499                         m_ResourceContainer.removeResourceConfig(HUE_BUNDLE_ID,
500                                         HUE_BUNDLE_URI);
501                 } catch (Exception e) {
502                         fail("Exception occurred inside RemoveResourceConfig_P. "
503                                         + e.getLocalizedMessage());
504                 }
505         }
506
507         /**
508          * @since 2015-10-27
509          * @see None
510          * @objective Test 'removeResourceConfig' function with empty string
511          * @target void removeResourceConfig(string bundleId)
512          * @test_data None
513          * @pre_condition Get container instance
514          * @procedure Perform removeResourceConfig() API
515          * @post_condition None
516          * @expected No crash occurs
517          **/
518         public void testRemoveResourceConfig_ESV_N() {
519                 try {
520                         m_ResourceContainer
521                                         .removeResourceConfig(EMPTY_STRING, EMPTY_STRING);
522
523                         fail("Successfully called removeResourceConfig with empty bundleId, resUri");
524                 } catch (Exception e) {
525                 }
526         }
527
528         /**
529          * @since 2015-10-27
530          * @see StartContainer
531          * @objective Test 'listBundleResources' function with StartContainer first
532          * @target list<string> listBundleResources(void)
533          * @test_data ResourceConfig File
534          * @pre_condition 1. Get container instance 2. Add bundle resource
535          * @procedure Perform listBundleResources() API
536          * @post_condition StopContainer
537          * @expected Container can remove resource in resourceConfig
538          **/
539         public void testListBundleResources_SRC_P() {
540                 m_ResourceContainer.startContainer(configFile);
541                 RcsBundleInfo bundleInfo = m_ResourceContainer.listBundles()
542                                 .get(n_ZERO);
543
544                 if (bundleInfo != null) {
545                         String bundleID = bundleInfo.getID();
546
547                         if (m_ResourceContainer.listBundleResources(bundleID).size() == n_ZERO) {
548                                 fail("bundle resource count is 0.");
549                         }
550                 } else {
551                         fail("Precondition failed. Bundle info is null");
552                 }
553
554                 m_ResourceContainer.stopContainer();
555         }
556
557         /**
558          * @since 2015-10-27
559          * @see StartContainer
560          * @objective Test 'listBundleResources' function with StartContainer that
561          *            have empty config file
562          * @target list<string> listBundleResources(void)
563          * @test_data emptyConfigFile
564          * @pre_condition Get container instance
565          * @procedure Perform listBundleResources() API
566          * @post_condition StopContainer
567          * @expected No crash occurs
568          **/
569         public void testListBundleResources_N() {
570                 m_ResourceContainer.startContainer(emptyConfigFile);
571
572                 if (m_ResourceContainer.listBundleResources(HUE_BUNDLE_ID).size() != n_ZERO) {
573                         fail("bundle resource count is 0");
574                 }
575
576                 m_ResourceContainer.stopContainer();
577         }
578
579         /**
580          * @since 2016-02-29
581          * @see Get Instance
582          * @objective Test 'StartContainer' function with NULL configFile
583          * @target void startContainer(string configFile)
584          * @test_data None
585          * @pre_condition Get container instance
586          * @procedure Perform StartContainer() API with NULL
587          * @post_condition None
588          * @expected Should not be crashed
589          **/
590         public void testStartContainer_NV_N() {
591                 try {
592                         m_ResourceContainer.startContainer(null);
593
594                         fail("Successfully called startContainer with null bundleId");
595                 } catch (Exception e) {
596                 }
597         }
598
599         /**
600          * @since 2016-02-29
601          * @see None
602          * @objective Test 'addBundle' function with NULL Resource BundleId
603          * @target void addBundle(String bundleId, String bundleUri, String
604          *         bundlePath, String activator, Map<String, String> params)
605          * @test_data None
606          * @pre_condition 1. Get container instance 2. Initiate param value as null
607          * @procedure Perform addBundle() API
608          * @post_condition None
609          * @expected Should not be crashed
610          **/
611         public void testAddBundle_BundleID_NV_N() {
612                 try {
613                         Map<String, String> params = new HashMap<String, String>();
614
615                         m_ResourceContainer.addBundle(null, HUE_BUNDLE_URI, bundlePath,
616                                         HUE_BUNDLE_ACTIVATOR, params);
617
618                         fail("Successfully called addBundle with null bundleId");
619                 } catch (Exception e) {
620                 }
621         }
622
623         /**
624          * @since 2016-02-29
625          * @see None
626          * @objective Test 'addBundle' function with NULL Resource URI
627          * @target void addBundle(String bundleId, String bundleUri, String
628          *         bundlePath, String activator, Map<String, String> params)
629          * @test_data None
630          * @pre_condition 1. Get container instance 2. Initiate param value as null
631          * @procedure Perform addBundle() API
632          * @post_condition None
633          * @expected Should not be crashed
634          **/
635         public void testAddBundle_BundleUri_NV_N() {
636                 try {
637                         Map<String, String> params = new HashMap<String, String>();
638
639                         m_ResourceContainer.addBundle(HUE_BUNDLE_ID, null, bundlePath,
640                                         HUE_BUNDLE_ACTIVATOR, params);
641
642                         fail("Successfully called addBundle with null Bundle Uri");
643                 } catch (Exception e) {
644                 }
645         }
646
647         /**
648          * @since 2016-02-29
649          * @see None
650          * @objective Test 'addBundle' function with NULL Resource BundlePath
651          * @target void addBundle(String bundleId, String bundleUri, String
652          *         bundlePath, String activator, Map<String, String> params)
653          * @test_data None
654          * @pre_condition 1. Get container instance 2. Initiate param value as null
655          * @procedure Perform addBundle() API
656          * @post_condition None
657          * @expected Should not be crashed
658          **/
659         public void testAddBundle_BundlePath_NV_N() {
660                 try {
661                         Map<String, String> params = new HashMap<String, String>();
662
663                         m_ResourceContainer.addBundle(HUE_BUNDLE_ID, HUE_BUNDLE_URI, null,
664                                         HUE_BUNDLE_ACTIVATOR, params);
665                         fail("Successfully called addBundle with null Bundle path");
666                 } catch (Exception e) {
667                 }
668         }
669
670         /**
671          * @since 2016-02-29
672          * @see None
673          * @objective Test 'addBundle' function with NULL resource Activator
674          * @target void addBundle(String bundleId, String bundleUri, String
675          *         bundlePath, String activator, Map<String, String> params)
676          * @test_data None
677          * @pre_condition 1. Get container instance 2. Initiate param value as null
678          * @procedure Perform addBundle() API
679          * @post_condition None
680          * @expected Should not be crashed
681          **/
682         public void testAddBundle_BundleActivator_NV_N() {
683                 try {
684                         Map<String, String> params = new HashMap<String, String>();
685
686                         m_ResourceContainer.addBundle(HUE_BUNDLE_ID, HUE_BUNDLE_URI,
687                                         bundlePath, null, params);
688                         fail("Successfully called addBundle with null activator");
689                 } catch (Exception e) {
690                 }
691         }
692
693         /**
694          * @since 2016-02-29
695          * @see None
696          * @objective Test 'removeBundle' function with NULL
697          * @target void removeBundle(string bundleId)
698          * @test_data None
699          * @pre_condition Get container instance
700          * @procedure Perform removeBundle() API with null
701          * @post_condition None
702          * @expected No crash occurs
703          **/
704         public void testRemoveBundle_NV_N() {
705                 try {
706                         m_ResourceContainer.removeBundle(null);
707                         fail("Successfully called removeBundle() with null.");
708                 } catch (Exception e) {
709                 }
710         }
711
712         /**
713          * @since 2016-02-29
714          * @see None
715          * @objective Test 'startBundle' function with NULL
716          * @target void startBundle(string bundleId)
717          * @test_data None
718          * @pre_condition Get container instance
719          * @procedure Perform startBundle() API with null
720          * @post_condition None
721          * @expected No crash occurs
722          **/
723         public void testStartBundle_NV_N() {
724                 try {
725                         m_ResourceContainer.startBundle(null);
726
727                         fail("Successfully called startBundle with null bundleId");
728                 } catch (Exception e) {
729                 }
730         }
731
732         /**
733          * @since 2016-02-29
734          * @see None
735          * @objective Test 'stopBundle' function with NULL
736          * @target void stopBundle(string bundleId)
737          * @test_data None
738          * @pre_condition Get container instance
739          * @procedure Perform stopBundle() API with null
740          * @post_condition None
741          * @expected No crash occurs
742          **/
743         public void testStopBundle_NV_N() {
744                 try {
745                         m_ResourceContainer.stopBundle(null);
746
747                         fail("Successfully called stopBundle with null bundleId");
748                 } catch (Exception e) {
749                 }
750         }
751
752         /**
753          * @since 2016-02-29
754          * @see None
755          * @objective Test 'addResourceConfig' function with NULL resource BundleId
756          * @target void addResourceConfig(string bundleId, string resourceUri,
757          *         std::map<string, string> params)
758          * @test_data Bundle information
759          * @pre_condition Get container instance
760          * @procedure Perform addResourceConfig() API
761          * @post_condition None
762          * @expected should not be crashed
763          **/
764         public void testAddResourceConfig_BundleId_NV_N() {
765                 try {
766                         Map<String, String> params = new HashMap<String, String>();
767
768                         m_ResourceContainer.addResourceConfig(null, HUE_BUNDLE_URI, params);
769
770                         fail("Successfully called addResourceConfig with null bundleId");
771                 } catch (Exception e) {
772                 }
773         }
774
775         /**
776          * @since 2016-02-29
777          * @see None
778          * @objective Test 'addResourceConfig' function with NULL resource BundleURI
779          * @target void addResourceConfig(string bundleId, string resourceUri,
780          *         std::map<string, string> params)
781          * @test_data Bundle information
782          * @pre_condition Get container instance
783          * @procedure Perform addResourceConfig() API with null
784          * @post_condition None
785          * @expected should not be crashed
786          **/
787         public void testAddResourceConfig_BundleUri_NV_N() {
788                 try {
789                         Map<String, String> params = new HashMap<String, String>();
790
791                         m_ResourceContainer.addResourceConfig(HUE_BUNDLE_ID, null, params);
792                         fail("Successfully called addResourceConfig with null resourceUri");
793                 } catch (Exception e) {
794                 }
795         }
796
797         /**
798          * @since 2016-02-29
799          * @see None
800          * @objective Test 'removeResourceConfig' function with NULL resource
801          *            BundleId
802          * @target void removeResourceConfig(string bundleId)
803          * @test_data None
804          * @pre_condition Get container instance
805          * @procedure Perform removeResourceConfig() API with null
806          * @post_condition None
807          * @expected No crash occurs
808          **/
809         public void testRemoveResourceConfig_BundleId_NV_N() {
810                 try {
811                         m_ResourceContainer.removeResourceConfig(null, HUE_BUNDLE_URI);
812                         fail("Successfully called removeResourceConfig with null bundleId");
813                 } catch (Exception e) {
814                 }
815         }
816
817         /**
818          * @since 2016-02-29
819          * @see None
820          * @objective Test 'removeResourceConfig' function with NULL resource
821          *            BundleURI
822          * @target void removeResourceConfig(string bundleId, string resourceUri)
823          * @test_data None
824          * @pre_condition Get container instance
825          * @procedure Perform removeResourceConfig() API with null
826          * @post_condition None
827          * @expected No crash occurs
828          **/
829         public void testRemoveResourceConfig_ResUri_NV_N() {
830                 try {
831                         m_ResourceContainer.removeResourceConfig(HUE_BUNDLE_ID, null);
832                         fail("Successfully called removeResourceConfig with null resUri");
833                 } catch (Exception e) {
834                 }
835         }
836
837         /**
838          * @since 2016-03-10
839          * @see StartContainer
840          * @see getbundleResource
841          * @objective Test 'registerResource' function with startContainer first and
842          *            valid BundleId
843          * @target public void registerResource(java.lang.String bundleId,
844          *         BundleResource resource)
845          * @test_data ConfigFile
846          * @pre_condition Start Container
847          * @procedure Perform registerResource() API with DISCOMFORT_BUNDLE_ID and
848          *            Bundle Resource instance
849          * @post_condition Stop Container
850          * @expected No Exception occurs
851          **/
852         public void testRegisterResource_SRC_P() {
853
854                 try {
855                         m_ResourceContainer.startContainer(configFile);
856                         m_ResourceContainer.registerResource(DI_BUNDLE_ID,
857                                         RCHelperBTC.getBundleResource(m_Context));
858                         m_ResourceContainer.stopContainer();
859                 } catch (Exception e) {
860                         fail("Can't  register resource of the exception: "
861                                         + e.getLocalizedMessage());
862                 }
863
864         }
865
866         /**
867          * @since 2016-03-10
868          * @see StartContainer
869          * @objective Test 'registerResource' function with empty resource BundleId
870          * @target public void registerResource(java.lang.String bundleId,
871          *         BundleResource resource)
872          * @test_data configFile
873          * @pre_condition Start Container
874          * @procedure Perform registerResource() API with DISCOMFORT_BUNDLE_ID = ""
875          * @post_condition Stop Container
876          * @expected Exception Should Occure
877          **/
878         public void testRegisterResourceBundleID_ESV_N() {
879                 try {
880                         m_ResourceContainer.startContainer(configFile);
881                         m_ResourceContainer.registerResource(EMPTY_STRING,
882                                         RCHelperBTC.getBundleResource(m_Context));
883
884                         fail("Should throw a Exception");
885                         m_ResourceContainer.stopContainer();
886                 } catch (Exception e) {
887                 }
888
889         }
890
891         /**
892          * @since 2016-03-10
893          * @see StartContainer
894          * @objective Test 'registerResource' function with NULL resource BundleId
895          * @target public void registerResource(java.lang.String bundleId,
896          *         BundleResource resource)
897          * @test_data configFile
898          * @pre_condition Start Container
899          * @procedure Perform registerResource() API with DISCOMFORT_BUNDLE_ID =
900          *            null
901          * @post_condition Stop Container
902          * @expected Exception Should Occure
903          **/
904         public void testRegisterResourceBundleID_NV_N() {
905                 try {
906                         m_ResourceContainer.startContainer(configFile);
907
908                         m_ResourceContainer.registerResource(null,
909                                         RCHelperBTC.getBundleResource(m_Context));
910
911                         fail("Should throw a Exception for registerResource() with null bundleId");
912                         m_ResourceContainer.stopContainer();
913                 } catch (Exception e) {
914                 }
915         }
916
917         /**
918          * @since 2016-03-10
919          * @see StartContainer
920          * @objective Test 'registerResource' function with NULL getBundleResource
921          * @target public void registerResource(java.lang.String bundleId,
922          *         BundleResource resource)
923          * @test_data ConfigFile
924          * @pre_condition Start Container
925          * @procedure Perform registerResource() API with BundleResource = null
926          * @post_condition Stop Container
927          * @expected Exception Should Occure
928          **/
929         public void testRegisterResourceBundleResource_NV_N() {
930                 try {
931                         m_ResourceContainer.startContainer(configFile);
932                         m_ResourceContainer.registerResource(DI_BUNDLE_ID, null);
933
934                         fail("Should throw a Exception");
935                         m_ResourceContainer.stopContainer();
936                 } catch (Exception e) {
937                 }
938
939         }
940
941         /**
942          * @since 2016-03-10
943          * @see StartContainer
944          * @see RegisterResource
945          * @objective Test 'unregisterResource' function with registerResource first
946          * @target public void unregisterResource(BundleResource resource)
947          * @test_data configFile
948          * @pre_condition 1.Start Container 2.Register Resource
949          * @procedure Perform unregisterResource() API with BundleResource
950          * @post_condition Stop Container
951          * @expected No Exception occurs
952          **/
953         public void testUnregisterResource_SRC_P() {
954                 try {
955                         m_ResourceContainer.startContainer(configFile);
956                         m_ResourceContainer.registerResource(DI_BUNDLE_ID,
957                                         RCHelperBTC.getBundleResource(m_Context));
958                         m_ResourceContainer.unregisterResource(RCHelperBTC
959                                         .getBundleResource(m_Context));
960                         m_ResourceContainer.stopContainer();
961                 } catch (Exception e) {
962                         fail("Can't  unregister resource of the exception: "
963                                         + e.getLocalizedMessage());
964                 }
965
966         }
967
968         /**
969          * @since 2016-03-10
970          * @see StartContainer
971          * @see Register Resource
972          * @objective Test 'unregisterResource' function with NULL
973          * @target public void unregisterResource(BundleResource resource)
974          * @test_data configFile
975          * @pre_condition 1. Start Container 2. Register Resource
976          * @procedure Perform unregisterResource() API with BundleResource = null
977          * @post_condition Stop Container
978          * @expected Exception should occure
979          **/
980         public void testUnregisterResourceBundleResource_NV_N() {
981                 try {
982                         m_ResourceContainer.startContainer(configFile);
983                         m_ResourceContainer.registerResource(DI_BUNDLE_ID,
984                                         RCHelperBTC.getBundleResource(m_Context));
985                         m_ResourceContainer.unregisterResource(null);
986
987                         fail("Should throw a Exception");
988                         m_ResourceContainer.stopContainer();
989                 } catch (Exception e) {
990                 }
991
992         }
993
994         /**
995          * @since 2016-03-10
996          * @see StartContainer
997          * @objective Test 'getConfiguredBundleResources' function with Resource
998          *            BundleId
999          * @target public void getConfiguredBundleResources(BundleResource resource)
1000          * @test_data configFile
1001          * @pre_condition Start Container
1002          * @procedure Perform getConfiguredBundleResources() API with
1003          *            DISCOMFORT_BUNDLE_ID
1004          * @post_condition Stop Container
1005          * @expected Return a List with Size > 0 and No Exception occurs
1006          **/
1007         public void testGetConfiguredBundleResources_SRC_P() {
1008                 try {
1009                         m_ResourceContainer.startContainer(configFile);
1010
1011                         List<ResourceConfig> resourceConfigList = m_ResourceContainer
1012                                         .getConfiguredBundleResources(DI_BUNDLE_ID);
1013                         Log.i(TAG, "Size of resource configuration list ="
1014                                         + resourceConfigList.size());
1015
1016                         if (resourceConfigList.size() <= n_ZERO) {
1017                                 fail("getConfiguredBundleResources returns a List Size = "
1018                                                 + resourceConfigList.size());
1019                         }
1020
1021                         for (int i = n_ZERO; i < resourceConfigList.size(); i++) {
1022                                 Log.i(TAG, "resourceConfigList - [" + i + "] "
1023                                                 + resourceConfigList.get(i));
1024                         }
1025
1026                         m_ResourceContainer.stopContainer();
1027
1028                 } catch (Exception e) {
1029                         fail("Can't  get configured bundle resources because of the exception: "
1030                                         + e.getLocalizedMessage());
1031                 }
1032         }
1033
1034         /**
1035          * @since 2016-03-10
1036          * @see StartContainer
1037          * @objective Test 'getConfiguredBundleResources' function with Resource
1038          *            empty BundleId [ESV]
1039          * @target public void getConfiguredBundleResources(BundleResource resource)
1040          * @test_data configFile
1041          * @pre_condition Start Container
1042          * @procedure Perform getConfiguredBundleResources() API with
1043          *            DISCOMFORT_BUNDLE_ID = ""
1044          * @post_condition Stop Container
1045          * @expected Expection should occurs
1046          **/
1047         public void testGetConfiguredBundleResourcesBudleID_ESV_N() {
1048                 try {
1049                         m_ResourceContainer.startContainer(configFile);
1050
1051                         List<ResourceConfig> resConfigList = m_ResourceContainer
1052                                         .getConfiguredBundleResources(EMPTY_STRING);
1053
1054                         if (resConfigList.size() > n_ZERO) {
1055                                 fail("getConfiguredBundleResources() returns ResourceConfig list while BundleId is empty");
1056                         }
1057
1058                         m_ResourceContainer.stopContainer();
1059                 } catch (Exception e) {
1060                         m_ResourceContainer.stopContainer();
1061                 }
1062         }
1063
1064         /**
1065          * @since 2016-03-10
1066          * @see StartContainer
1067          * @objective Test 'getConfiguredBundleResources' function with NULL
1068          *            Resource BundleId
1069          * @target public void getConfiguredBundleResources(BundleResource resource)
1070          * @test_data configFile
1071          * @pre_condition Start Container
1072          * @procedure Perform getConfiguredBundleResources() API with
1073          *            DISCOMFORT_BUNDLE_ID = null
1074          * @post_condition Stop Container
1075          * @expected Expection should occurs
1076          **/
1077         public void testGetConfiguredBundleResources_NV_N() {
1078                 try {
1079                         m_ResourceContainer.startContainer(configFile);
1080
1081                         List<ResourceConfig> resConfigList = m_ResourceContainer
1082                                         .getConfiguredBundleResources(null);
1083
1084                         if (resConfigList.size() > n_ZERO) {
1085                                 fail("getConfiguredBundleResources() returns ResourceConfig list while BundleId is null");
1086                         }
1087
1088                         m_ResourceContainer.stopContainer();
1089                 } catch (Exception e) {
1090                         m_ResourceContainer.stopContainer();
1091                 }
1092         }
1093
1094         /**
1095          * @since 2016-03-10
1096          * @see StartContainer
1097          * @objective Test 'getNumberOfConfiguredResources' function with valid
1098          *            Resource BundleId
1099          * @target public void getNumberOfConfiguredResources(BundleResource
1100          *         resource)
1101          * @test_data configFile
1102          * @pre_condition Start Container
1103          * @procedure Perform getNumberOfConfiguredResources() API with
1104          *            DISCOMFORT_BUNDLE_ID
1105          * @post_condition Stop Container
1106          * @expected Return ResourceCount > 0 and No Exception occurs
1107          **/
1108         public void testGetNumberOfConfiguredResources_SRC_P() {
1109                 try {
1110                         m_ResourceContainer.startContainer(configFile);
1111
1112                         int numberOfConfiguredResources = n_NEGATIVE_ONE;
1113                         numberOfConfiguredResources = m_ResourceContainer
1114                                         .getNumberOfConfiguredResources(DI_BUNDLE_ID);
1115
1116                         Log.i(TAG, "numberOfConfiguredResources  is "
1117                                         + numberOfConfiguredResources);
1118
1119                         if (numberOfConfiguredResources <= n_ZERO) {
1120                                 fail("numberOfConfiguredResources  is "
1121                                                 + numberOfConfiguredResources);
1122                         }
1123
1124                         m_ResourceContainer.stopContainer();
1125                 } catch (Exception e) {
1126                         fail("Can't  get number of configured bundle resources because of the exception: "
1127                                         + e.getLocalizedMessage());
1128                 }
1129
1130         }
1131
1132         /**
1133          * @since 2016-03-10
1134          * @see StartContainer
1135          * @objective Test 'getNumberOfConfiguredResources' function with Empty
1136          *            Resource BundleId
1137          * @target public void getNumberOfConfiguredResources(BundleResource
1138          *         resource)
1139          * @test_data configFile
1140          * @pre_condition Start Container
1141          * @procedure Perform getNumberOfConfiguredResources() API with
1142          *            DISCOMFORT_BUNDLE_ID = ""
1143          * @post_condition Stop Container
1144          * @expected Exception should occurs
1145          **/
1146         public void testGetNumberOfConfiguredResourcesBundleID_ESV_N() {
1147                 try {
1148                         m_ResourceContainer.startContainer(configFile);
1149
1150                         int confRestCount = m_ResourceContainer
1151                                         .getNumberOfConfiguredResources(EMPTY_STRING);
1152
1153                         if (confRestCount > n_ZERO) {
1154                                 fail("getNumberOfConfiguredResources() returns greater than zero when bundleId is empty");
1155                         }
1156
1157                         m_ResourceContainer.stopContainer();
1158                 } catch (Exception e) {
1159                         m_ResourceContainer.stopContainer();
1160                 }
1161         }
1162
1163         /**
1164          * @since 2016-03-10
1165          * @see StartContainer
1166          * @objective Test 'getNumberOfConfiguredResources' function with NULL
1167          *            Resource BundleId
1168          * @target public void getNumberOfConfiguredResources(BundleResource
1169          *         resource)
1170          * @test_data configFile
1171          * @pre_condition Start Container
1172          * @procedure Perform getNumberOfConfiguredResources() API with
1173          *            DISCOMFORT_BUNDLE_ID = null
1174          * @post_condition Stop Container
1175          * @expected Exception should occurs
1176          **/
1177         public void testGetNumberOfConfiguredResourcesBundleID_NV_N() {
1178                 try {
1179                         m_ResourceContainer.startContainer(configFile);
1180
1181                         int confRestCount = m_ResourceContainer
1182                                         .getNumberOfConfiguredResources(null);
1183
1184                         if (confRestCount > n_ZERO) {
1185                                 fail("getNumberOfConfiguredResources() returns greater than zero when bundleId is null");
1186                         }
1187
1188                         m_ResourceContainer.stopContainer();
1189                 } catch (Exception e) {
1190                         m_ResourceContainer.stopContainer();
1191                 }
1192         }
1193
1194         /**
1195          * @since 2016-03-10
1196          * @see StartContainer
1197          * @objective Test 'getConfiguredResourceParams' function with postively
1198          *            valid Resource BundleId
1199          * @target public void getConfiguredResourceParams(BundleResource resource,
1200          *         int redID)
1201          * @test_data configFile
1202          * @pre_condition Start Container
1203          * @procedure Perform getNumberOfConfiguredResources() API with
1204          *            DISCOMFORT_BUNDLE_ID and resId = 0
1205          * @post_condition Stop Container
1206          * @expected Return a Strign Array Length > 0 and No Exception occurs
1207          **/
1208         public void testGetConfiguredResourceParams_SRC_P() {
1209                 try {
1210                         m_ResourceContainer.startContainer(configFile);
1211
1212                         resourceParam = m_ResourceContainer.getConfiguredResourceParams(
1213                                         DI_BUNDLE_ID, n_ZERO);
1214
1215                         if (resourceParam.length <= n_ZERO) {
1216                                 fail("getConfiguredResourceParams returns a string array Size"
1217                                                 + resourceParam.length);
1218                         }
1219
1220                         for (int i = n_ZERO; i < resourceParam.length; i++) {
1221                                 Log.i(TAG, "resourceParam - [" + i + "] = " + resourceParam[i]);
1222                         }
1223
1224                         m_ResourceContainer.stopContainer();
1225                 } catch (Exception e) {
1226                         fail("Can't  get configured resource parameters because of the exception: "
1227                                         + e.getLocalizedMessage());
1228                 }
1229         }
1230
1231         /**
1232          * @since 2016-03-10
1233          * @see StartContainer
1234          * @objective Test 'getConfiguredResourceParams' function negatively with
1235          *            negative redId
1236          * @target public void getConfiguredResourceParams(BundleResource resource,
1237          *         int redID)
1238          * @test_data ConfigFile
1239          * @pre_condition Start Container
1240          * @procedure Perform getNumberOfConfiguredResources() API with
1241          *            DISCOMFORT_BUNDLE_ID and resId = -1
1242          * @post_condition Stop Container
1243          * @expected Should handle the Exception
1244          **/
1245         public void testGetConfiguredResourceParams_LOBV_N() {
1246                 try {
1247                         m_ResourceContainer.startContainer(configFile);
1248
1249                         resourceParam = m_ResourceContainer.getConfiguredResourceParams(
1250                                         DI_BUNDLE_ID, n_NEGATIVE_ONE);
1251
1252                         if (resourceParam.length <= n_ZERO) {
1253                                 fail("getConfiguredResourceParams returns a string array Size"
1254                                                 + resourceParam.length);
1255                         }
1256
1257                         for (int i = n_ZERO; i < resourceParam.length; i++) {
1258                                 Log.i(TAG, "resourceParam - [" + i + "] = " + resourceParam[i]);
1259                         }
1260
1261                         m_ResourceContainer.stopContainer();
1262                 } catch (Exception e) {
1263                 }
1264         }
1265
1266         /**
1267          * @since 2016-03-10
1268          * @see StartContainer
1269          * @objective Test 'getConfiguredResourceParams' function empty Resource
1270          *            BundleId
1271          * @target public void getConfiguredResourceParams(BundleResource resource,
1272          *         int redID)
1273          * @test_data configFile
1274          * @pre_condition Start Container
1275          * @procedure Perform getNumberOfConfiguredResources() API with
1276          *            DISCOMFORT_BUNDLE_ID = ""
1277          * @post_condition Stop Container
1278          * @expected Should handle the Exception
1279          **/
1280         public void testGetConfiguredResourceParamsBundleID_ESV_N() {
1281                 try {
1282                         m_ResourceContainer.startContainer(configFile);
1283
1284                         resourceParam = m_ResourceContainer.getConfiguredResourceParams(
1285                                         EMPTY_STRING, n_ZERO);
1286
1287                         if (resourceParam.length < n_ZERO) {
1288                                 fail("getConfiguredResourceParams returns a string array Size"
1289                                                 + resourceParam.length);
1290                         }
1291
1292                         m_ResourceContainer.stopContainer();
1293                 } catch (Exception e) {
1294                         m_ResourceContainer.stopContainer();
1295                 }
1296
1297         }
1298
1299         /**
1300          * @since 2016-03-10
1301          * @see StartContainer
1302          * @objective Test 'getConfiguredResourceParams' function with NULL Resource
1303          *            BundleId
1304          * @target public void getConfiguredResourceParams(BundleResource resource,
1305          *         int redID)
1306          * @test_data configFile
1307          * @pre_condition Start Container
1308          * @procedure Perform getNumberOfConfiguredResources() API with
1309          *            DISCOMFORT_BUNDLE_ID = null
1310          * @post_condition Stop Container
1311          * @expected Should handle the Exception
1312          **/
1313         public void testGetConfiguredResourceParamsBundleID_NV_N() {
1314                 try {
1315                         m_ResourceContainer.startContainer(configFile);
1316
1317                         m_ResourceContainer.getConfiguredResourceParams(null, n_ZERO);
1318
1319                         resourceParam = m_ResourceContainer.getConfiguredResourceParams(
1320                                         null, n_ZERO);
1321
1322                         if (resourceParam.length < n_ZERO) {
1323                                 fail("getConfiguredResourceParams returns a string array Size "
1324                                                 + resourceParam.length);
1325                         }
1326
1327                         m_ResourceContainer.stopContainer();
1328                 } catch (Exception e) {
1329                         m_ResourceContainer.stopContainer();
1330                 }
1331         }
1332 }