Unit tests for android extension of resource contianer
[platform/upstream/iotivity.git] / service / resource-container / examples / android / RCSampleServerApp / app / src / androidTest / java / org / iotivity / service / sample / container / ResourceContainerTest.java
1 /******************************************************************
2  *
3  * Copyright 2015 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 package org.iotivity.service.sample.container;
22
23 import android.test.InstrumentationTestCase;
24 import android.util.Log;
25
26 import org.iotivity.service.resourcecontainer.RcsResourceContainer;
27
28 import java.util.HashMap;
29
30 public class ResourceContainerTest extends InstrumentationTestCase {
31     private RcsResourceContainer resourceContainerInstance;
32     private final String sdCardDir =
33             "/data/local/tmp/org.iotivity.service.sample.resourcecontainer.test/files/";
34
35     @Override
36     public void setUp(){
37         resourceContainerInstance = new RcsResourceContainer(getInstrumentation().getContext());
38     }
39
40     public void testStartContainer() {
41         resourceContainerInstance.startContainer("");
42         assertTrue(resourceContainerInstance.listBundles().size() == 0);
43         resourceContainerInstance.stopContainer();
44     }
45
46     public void testAddConfig(){
47         resourceContainerInstance.startContainer("");
48         //resourceContainerInstance.addBundle("");
49         assertTrue(resourceContainerInstance.listBundles().size() == 0);
50         resourceContainerInstance.stopContainer();
51     }
52
53     public void testStartBundle(){
54         resourceContainerInstance.startBundle("not.existing");
55         assertEquals(0, resourceContainerInstance.listBundles().size());
56     }
57
58     public void testStopBundle(){
59         resourceContainerInstance.startBundle("not.existing");
60         assertEquals(0, resourceContainerInstance.listBundles().size());
61     }
62
63     public void testAddBundle(){
64         resourceContainerInstance.startContainer(
65                 "");
66
67         resourceContainerInstance.addBundle("oic.bundle.test", "",
68                 sdCardDir + "libSoftSensorBundle.so",
69                 "disensor", new HashMap<String, String>());
70         resourceContainerInstance.startBundle("oic.bundle.test");
71         resourceContainerInstance.stopContainer();
72     }
73 }