Unit tests for android extension of resource contianer
authorMarkus Jung <markus.jung@samsung.com>
Tue, 2 Feb 2016 00:48:36 +0000 (09:48 +0900)
committerUze Choi <uzchoi@samsung.com>
Tue, 2 Feb 2016 10:35:18 +0000 (10:35 +0000)
Added simple unit tests that have to be executed manually.

Change-Id: I03759a8c8ba865a26488508899991e24686df64b
Signed-off-by: Markus Jung <markus.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/4909
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/resource-container/examples/android/RCSampleServerApp/app/src/androidTest/assets/lib/ResourceContainerConfig.xml [new file with mode: 0755]
service/resource-container/examples/android/RCSampleServerApp/app/src/androidTest/java/org/iotivity/service/sample/container/ResourceContainerTest.java [new file with mode: 0755]

diff --git a/service/resource-container/examples/android/RCSampleServerApp/app/src/androidTest/assets/lib/ResourceContainerConfig.xml b/service/resource-container/examples/android/RCSampleServerApp/app/src/androidTest/assets/lib/ResourceContainerConfig.xml
new file mode 100755 (executable)
index 0000000..4c52d93
--- /dev/null
@@ -0,0 +1,105 @@
+<container>
+    <bundle>
+        <id>oic.bundle.discomfortIndexSensor</id>
+        <path>/data/local/tmp/org.iotivity.service.sample.resourcecontainer.test/files/libSoftSensorBundle.so</path>
+        <activator>disensor</activator>
+        <version>1.0.0</version>
+        <resources>
+            <resourceInfo>
+                <name>DiscomfortIndexSensor1</name>
+                <resourceType>oic.r.sensor</resourceType>
+                <outputs>
+                    <output>
+                        <name>discomfortIndex</name>
+                        <type>int</type>
+                    </output>
+                    <output>
+                        <name>humidity</name>
+                        <type>double</type>
+                    </output>
+                    <output>
+                        <name>temperature</name>
+                        <type>double</type>
+                    </output>
+                </outputs>
+                <inputs>
+                    <input>
+                        <name>humidity</name>
+                        <type>double</type>
+                        <resourceType>oic.r.humidity</resourceType>
+                    </input>
+                    <input>
+                        <name>temperature</name>
+                        <type>double</type>
+                        <resourceType>oic.r.temperature</resourceType>
+                    </input>
+                </inputs>
+            </resourceInfo>
+        </resources>
+    </bundle>
+    <!--
+    <bundle>
+        <id>oic.android.sample</id>
+        <path>org.iotivity.service.sample.androidbundle.apk</path>
+        <activator>org.iotivity.service.sample.androidbundle.SampleActivator</activator>
+        <version>1.0.0</version>
+        <resources>
+           <resourceInfo>
+                <name>LightResource1</name>
+                <resourceType>oic.r.light</resourceType>
+                <resourceUri>/android/light/1</resourceUri>
+            </resourceInfo>
+            <resourceInfo>
+                 <name>LightIntensity1</name>
+                 <resourceType>oic.r.lightintensity</resourceType>
+                 <resourceUri>/android/lightintensity/1</resourceUri>
+            </resourceInfo>
+            <resourceInfo>
+                <name>Humidity1</name>
+                <resogitkurceType>oic.r.humidity</resogitkurceType>
+                <resourceUri>/android/humidity/1</resourceUri>
+            </resourceInfo>
+            <resourceInfo>
+                <name>Tepmerature1</name>
+                <resourceType>oic.r.temperature</resourceType>
+                <resourceUri>/android/temperature/1</resourceUri>
+            </resourceInfo>
+            <resourceInfo>
+                <name>Gyroscope1</name>
+                <resourceType>oic.r.gyroscope</resourceType>
+                <resourceUri>/android/gyroscope/1</resourceUri>
+            </resourceInfo>
+            <resourceInfo>
+                <name>DiscomfortIndexSensor1</name>
+                <resourceType>oic.r.discomfortindex</resourceType>
+                <resourceUri>/android/discomfortindex/1</resourceUri>
+                <outputs>
+                    <output>
+                        <name>discomfortIndex</name>
+                        <type>int</type>
+                    </output>
+                    <output>
+                        <name>humidity</name>
+                        <type>double</type>
+                    </output>
+                    <output>
+                        <name>temperature</name>
+                        <type>double</type>
+                    </output>
+                </outputs>
+                <inputs>
+                    <input>
+                        <name>humidity</name>
+                        <type>double</type>
+                        <resourceType>oic.r.humidity</resourceType>
+                    </input>
+                    <input>
+                        <name>temperature</name>
+                        <type>double</type>
+                        <resourceType>oic.r.temperature</resourceType>
+                    </input>
+                </inputs>
+            </resourceInfo>
+        </resources>
+    </bundle>-->
+</container>
\ No newline at end of file
diff --git a/service/resource-container/examples/android/RCSampleServerApp/app/src/androidTest/java/org/iotivity/service/sample/container/ResourceContainerTest.java b/service/resource-container/examples/android/RCSampleServerApp/app/src/androidTest/java/org/iotivity/service/sample/container/ResourceContainerTest.java
new file mode 100755 (executable)
index 0000000..53e4113
--- /dev/null
@@ -0,0 +1,73 @@
+/******************************************************************
+ *
+ * Copyright 2015 Samsung Electronics All Rights Reserved.
+ *
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************/
+
+package org.iotivity.service.sample.container;
+
+import android.test.InstrumentationTestCase;
+import android.util.Log;
+
+import org.iotivity.service.resourcecontainer.RcsResourceContainer;
+
+import java.util.HashMap;
+
+public class ResourceContainerTest extends InstrumentationTestCase {
+    private RcsResourceContainer resourceContainerInstance;
+    private final String sdCardDir =
+            "/data/local/tmp/org.iotivity.service.sample.resourcecontainer.test/files/";
+
+    @Override
+    public void setUp(){
+        resourceContainerInstance = new RcsResourceContainer(getInstrumentation().getContext());
+    }
+
+    public void testStartContainer() {
+        resourceContainerInstance.startContainer("");
+        assertTrue(resourceContainerInstance.listBundles().size() == 0);
+        resourceContainerInstance.stopContainer();
+    }
+
+    public void testAddConfig(){
+        resourceContainerInstance.startContainer("");
+        //resourceContainerInstance.addBundle("");
+        assertTrue(resourceContainerInstance.listBundles().size() == 0);
+        resourceContainerInstance.stopContainer();
+    }
+
+    public void testStartBundle(){
+        resourceContainerInstance.startBundle("not.existing");
+        assertEquals(0, resourceContainerInstance.listBundles().size());
+    }
+
+    public void testStopBundle(){
+        resourceContainerInstance.startBundle("not.existing");
+        assertEquals(0, resourceContainerInstance.listBundles().size());
+    }
+
+    public void testAddBundle(){
+        resourceContainerInstance.startContainer(
+                "");
+
+        resourceContainerInstance.addBundle("oic.bundle.test", "",
+                sdCardDir + "libSoftSensorBundle.so",
+                "disensor", new HashMap<String, String>());
+        resourceContainerInstance.startBundle("oic.bundle.test");
+        resourceContainerInstance.stopContainer();
+    }
+}
\ No newline at end of file