JUnit test cases for updated APIs.
authorHarish Kumara Marappa <h.marappa@samsung.com>
Fri, 30 Oct 2015 04:12:51 +0000 (09:42 +0530)
committerMadan Lanka <lanka.madan@samsung.com>
Fri, 30 Oct 2015 08:27:35 +0000 (08:27 +0000)
Implemented JUnit test cases for testing updated APIs of SimulatorManager,
SimulatorSingleResource, SimulatorCollectionResource, SimulatorRemoteResource,
SimulatorResourceModel classes.

Change-Id: Idefeefd909ece3daffebbdd23e31e59e355914fe
Signed-off-by: Harish Kumara Marappa <h.marappa@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3981
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
29 files changed:
service/simulator/unittests/SimulatorTest/ramls/oic.r.light-error.json [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/ramls/oic.r.light.json [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/ramls/oic.r.light.raml [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/client/test/SimulatorRemoteResourceTest.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/GetListener.java [deleted file]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/ListenerObject.java [deleted file]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/ObserveListener.java [deleted file]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/ObserveListenerObject.java [deleted file]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/PostListener.java [deleted file]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/PutListener.java [deleted file]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/SimulatorRemoteResourceTest.java [deleted file]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/VerifyListener.java [deleted file]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/VerifyListenerObject.java [deleted file]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/server/test/SimulatorCollectionResourceTest.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/server/test/SimulatorResourceTest.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/server/test/SimulatorSingleResourceTest.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/AutomationListener.java [deleted file]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/Observer.java [deleted file]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/ObserverObject.java [deleted file]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/SimlatorResourceServerTest.java [deleted file]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/AttributeValueTest.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/ExceptionType.java [moved from service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/SimulatorRemoteResourceObject.java with 55% similarity]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/FindResourceListener.java [deleted file]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/ResourceModelChangeListener.java [deleted file]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/ResourceModelObject.java [deleted file]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/SimulatorManagerTest.java
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/SimulatorResourceModelTest.java
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/utils/ObjectHolder.java [moved from service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/AutomationObject.java with 52% similarity]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/utils/SampleSingleResource.java [new file with mode: 0644]

diff --git a/service/simulator/unittests/SimulatorTest/ramls/oic.r.light-error.json b/service/simulator/unittests/SimulatorTest/ramls/oic.r.light-error.json
new file mode 100644 (file)
index 0000000..a6d1ce8
--- /dev/null
@@ -0,0 +1,34 @@
+{
+  "id": "http://openinterconnect.org/schemas/oic.r.light-error#",
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "title": "OIC Light",
+  "$ref": "#/definitions/oic.r.light",
+  "definitions": {
+    "oic.r.light": {
+      "type": "object",
+      "properties": {
+               "rt": {
+          "type": "string",
+          "description": "Description about resource type",
+          "default": "oic.r.light"
+        },
+               "if": {
+          "type": "string",
+          "description": "Interface supported",
+          "default": "oic.if.baseline"
+        },
+        "n": {
+          "type": "string",
+          "description": "Readonly, Human friendly name",
+                 "default": "OIC Light Error"
+        },
+        "intensity":  {
+          "type": "integer",
+          "description": "ReadOnly, Comma separated min,max values for intensity on this device",
+          "default": "10,20"
+        }
+      }
+    }
+  },
+   "required": ["rt","if"]
+}
diff --git a/service/simulator/unittests/SimulatorTest/ramls/oic.r.light.json b/service/simulator/unittests/SimulatorTest/ramls/oic.r.light.json
new file mode 100644 (file)
index 0000000..f6aad80
--- /dev/null
@@ -0,0 +1,42 @@
+{
+  "id": "http://openinterconnect.org/schemas/oic.r.light#",
+  "$schema": "http://json-schema.org/schema#",
+  "title": "OIC Light",
+  "$ref": "#/definitions/oic.r.light",
+  "definitions": {
+    "oic.r.light": {
+      "type": "object",
+      "properties": {
+               "rt": {
+          "type": "string",
+          "description": "Description about resource type",
+          "default": "oic.r.light"
+        },
+               "if": {
+          "type": "string",
+          "description": "Interface supported",
+          "default": "oic.if.baseline"
+        },
+        "n": {
+          "type": "string",
+          "description": "Readonly, Human friendly name",
+                 "default": "OIC Light"
+        },
+               "power": {
+                 "type": "boolean",
+                 "description": "Light status",
+                 "default": false,
+                 "enum": [true,false]
+               },
+               "intensity": {
+                 "type": "integer",
+                 "description": "brightness of the light",
+                 "default": 10,
+                 "minimum": 10,
+          "maximum": 20
+               }
+               }
+         }
+       },      
+  "required": [ "rt","if","power" ]
+}
\ No newline at end of file
diff --git a/service/simulator/unittests/SimulatorTest/ramls/oic.r.light.raml b/service/simulator/unittests/SimulatorTest/ramls/oic.r.light.raml
new file mode 100644 (file)
index 0000000..1988343
--- /dev/null
@@ -0,0 +1,133 @@
+#%RAML 0.8
+title: OICLight
+version: v1.0-20150910
+schemas:
+  - OICLight:         !include oic.r.light.json
+    OICLightError:    !include oic.r.light-error.json
+traits:
+  - interface:
+      queryParameters:
+        if:
+          enum: ["oic.if.a"]
+
+/oic/r/light:
+  description: |
+    Resource to be exposed by any OIC Device that can act as Light.
+  displayName: OIC Light
+  is: [ interface ] # valid for all methods
+
+  get:
+    responses:
+      200:
+        body:
+          application/json:
+            schema:  |
+              {
+                  "id": "http://openinterconnect.org/schemas/oic.r.light#",
+                  "$schema": "http://json-schema.org/schema#",
+                  "title": "OIC Light",
+                  "$ref": "#/definitions/oic.r.light",
+                  "definitions": {
+                  "oic.r.light": {
+                  "type": "object",
+                  "properties": {
+                      "rt": {
+                      "type": "string",
+                      "description": "Description about resource type",
+                      "default": "oic.r.light"
+                  },
+                  "if": {
+                      "type": "string",
+                      "description": "Interface supported",
+                      "default": "oic.if.baseline"
+                  },
+                  "n": {
+                      "type": "string",
+                      "description": "Readonly, Human friendly name",
+                      "default": "OIC Light"
+                  },
+                  "power": {
+                      "type": "boolean",
+                      "description": "Light status",
+                      "default": false,
+                      "enum": [true,false]
+                  },
+                  "intensity": {
+                      "type": "integer",
+                      "description": "brightness of the light",
+                      "default": 10,
+                      "minimum": 10,
+                      "maximum": 20
+                  }
+                  }
+                  }
+                },     
+                "required": [ "rt","if","power" ]
+              }
+  post:
+    body:
+      application/json:
+        schema: OICLight
+    responses:
+      200:
+        body:
+          application/json:
+            schema: OICLight
+      403:
+        description: |
+          This response is generated by the OIC Server when the client sends:
+            An update with an out of range property value for intensity.
+          The server responds with the range property illustrating the error.
+        body:
+          application/json:
+            schema: OICLightError
+  put:
+    body:
+      application/json:
+        schema: OICLight
+    responses:
+      200:
+        body:
+          application/json:
+            schema: OICLight
+      403:
+        description: |
+          This response is generated by the OIC Server when the client sends:
+            An update with an out of range property value for intensity.
+          The server responds with the range property illustrating the error.
+        body:
+          application/json:
+            schema:  |
+              {
+                  "id": "http://openinterconnect.org/schemas/oic.r.light-error#",
+                  "$schema": "http://json-schema.org/draft-04/schema#",
+                  "title": "OIC Light",
+                  "$ref": "#/definitions/oic.r.light",
+                  "definitions": {
+                  "oic.r.light": {
+                  "type": "object",
+                  "properties": {
+                      "rt": {
+                          "type": "string",
+                          "description": "Description about resource type",
+                          "default": "oic.r.light"
+                      },
+                      "if": {
+                          "type": "string",
+                          "description": "Interface supported",
+                          "default": "oic.if.baseline"
+                      },
+                      "n": {
+                          "type": "string",
+                          "description": "Readonly, Human friendly name",
+                          "default": "OIC Light Error"
+                      },
+                      "intensity":  {
+                          "type": "integer",
+                          "description": "ReadOnly, Comma separated min,max values for intensity on this device",
+                          "default": "10,20"
+                      }
+                    }
+                  }
+                }
+              }
\ No newline at end of file
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/client/test/SimulatorRemoteResourceTest.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/client/test/SimulatorRemoteResourceTest.java
new file mode 100644 (file)
index 0000000..0687158
--- /dev/null
@@ -0,0 +1,1148 @@
+/*
+ * 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.oic.simulator.client.test;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.oic.simulator.AttributeValue;
+import org.oic.simulator.InvalidArgsException;
+import org.oic.simulator.SimulatorException;
+import org.oic.simulator.SimulatorManager;
+import org.oic.simulator.SimulatorResourceAttribute;
+import org.oic.simulator.SimulatorResourceModel;
+import org.oic.simulator.SimulatorResult;
+import org.oic.simulator.client.FindResourceListener;
+import org.oic.simulator.client.SimulatorRemoteResource;
+import org.oic.simulator.server.SimulatorSingleResource;
+import org.oic.simulator.test.ExceptionType;
+import org.oic.simulator.utils.ObjectHolder;
+
+import junit.framework.TestCase;
+
+/**
+ * This class tests the APIs of SimulatorRemoteResource class.
+ */
+public class SimulatorRemoteResourceTest extends TestCase {
+    private static final String            SINGLE_RES_RAML = "./ramls/oic.r.light.raml";
+    private static SimulatorSingleResource singleResource  = null;
+    private static SimulatorRemoteResource remoteResource  = null;
+
+    static {
+        System.loadLibrary("SimulatorManager");
+        System.loadLibrary("RamlParser");
+        System.loadLibrary("oc");
+        System.loadLibrary("oc_logger");
+        System.loadLibrary("octbstack");
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // Create single resource for first time
+        if (null == singleResource) {
+            singleResource = (SimulatorSingleResource) SimulatorManager
+                    .createResource(SINGLE_RES_RAML);
+            singleResource.start();
+        }
+
+        // Find the created resource for first time
+        if (null != singleResource && null == remoteResource) {
+            CountDownLatch lockObject = new CountDownLatch(1);
+            ObjectHolder<SimulatorRemoteResource> resourceHolder = new ObjectHolder<>();
+            FindResourceCallbackListener listener = new FindResourceCallbackListener(
+                    lockObject, resourceHolder);
+
+            try {
+                SimulatorManager.findResource(singleResource.getResourceType(),
+                        listener);
+
+                try {
+                    lockObject.await(10, TimeUnit.SECONDS);
+                } catch (InterruptedException e) {
+                }
+
+            } catch (InvalidArgsException e) {
+                e.printStackTrace();
+            } catch (SimulatorException e) {
+                e.printStackTrace();
+            }
+
+            remoteResource = resourceHolder.get();
+        }
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testGetUri_P01() {
+        String serverURI = null;
+        try {
+            serverURI = singleResource.getURI();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertNotNull(remoteResource.getURI());
+        assertEquals(serverURI, remoteResource.getURI());
+    }
+
+    public void testGetConnectivityType_P01() {
+        assertNotNull(remoteResource.getConnectivityType());
+    }
+
+    public void testGetResourceTypes_P01() {
+        assertNotNull(remoteResource.getResourceTypes());
+        assertTrue(remoteResource.getResourceTypes().size() > 0);
+    }
+
+    public void testGetResourceInterfaces_P01() {
+        assertNotNull(remoteResource.getResourceInterfaces());
+        assertTrue(remoteResource.getResourceInterfaces().size() > 0);
+    }
+
+    public void testGetHost_P01() {
+        assertNotNull(remoteResource.getHost());
+    }
+
+    public void testGetId_P01() {
+        assertNotNull(remoteResource.getId());
+    }
+
+    public void testIsObservable_P01() {
+        boolean serverObserveState = false;
+        try {
+            serverObserveState = singleResource.isObservable();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(serverObserveState, remoteResource.isObservable());
+    }
+
+    public void testGet_P01() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        GetResponseCallbackListener listener = new GetResponseCallbackListener(
+                lockObject, response);
+
+        try {
+            remoteResource.get(null, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testGet_P02() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        GetResponseCallbackListener listener = new GetResponseCallbackListener(
+                lockObject, response);
+
+        try {
+            Map<String, String> queryParams = new HashMap<>();
+            remoteResource.get(queryParams, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testGet_P03() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        GetResponseCallbackListener listener = new GetResponseCallbackListener(
+                lockObject, response);
+
+        try {
+            remoteResource.get(remoteResource.getResourceInterfaces().get(0),
+                    null, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testGet_P04() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        GetResponseCallbackListener listener = new GetResponseCallbackListener(
+                lockObject, response);
+
+        try {
+            Map<String, String> queryParams = new HashMap<>();
+            remoteResource.get(remoteResource.getResourceInterfaces().get(0),
+                    queryParams, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testGet_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            remoteResource.get(null, null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testGet_N02() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            remoteResource.get(remoteResource.getResourceInterfaces().get(0),
+                    null, null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testGet_N03() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            Map<String, String> queryParams = new HashMap<>();
+            remoteResource.get(null, queryParams,
+                    new SimulatorRemoteResource.GetResponseListener() {
+                        @Override
+                        public void onGetResponse(String uid,
+                                SimulatorResult result,
+                                SimulatorResourceModel resourceModel) {
+                        }
+                    });
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testPut_P01() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        PutResponseCallbackListener listener = new PutResponseCallbackListener(
+                lockObject, response);
+
+        try {
+            SimulatorResourceModel resModel = singleResource.getResourceModel();
+            remoteResource.put(null, resModel, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertNotNull(response.get().resourceModel());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testPut_P02() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        PutResponseCallbackListener listener = new PutResponseCallbackListener(
+                lockObject, response);
+
+        try {
+            SimulatorResourceModel resModel = singleResource.getResourceModel();
+            Map<String, String> queryParams = new HashMap<>();
+            remoteResource.put(queryParams, resModel, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertNotNull(response.get().resourceModel());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testPut_P03() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        PutResponseCallbackListener listener = new PutResponseCallbackListener(
+                lockObject, response);
+
+        try {
+            SimulatorResourceModel resModel = singleResource.getResourceModel();
+            remoteResource.put(remoteResource.getResourceInterfaces().get(0),
+                    null, resModel, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertNotNull(response.get().resourceModel());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testPut_P05() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        PutResponseCallbackListener listener = new PutResponseCallbackListener(
+                lockObject, response);
+
+        try {
+            SimulatorResourceModel resModel = singleResource.getResourceModel();
+            Map<String, String> queryParams = new HashMap<>();
+            remoteResource.put(remoteResource.getResourceInterfaces().get(0),
+                    queryParams, resModel, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertNotNull(response.get().resourceModel());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testPut_P04() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        PutResponseCallbackListener listener = new PutResponseCallbackListener(
+                lockObject, response);
+
+        try {
+            SimulatorResourceModel resModel = singleResource.getResourceModel();
+            Map<String, String> queryParams = new HashMap<>();
+            remoteResource.put(queryParams, null, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertNotNull(response.get().resourceModel());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testPut_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            SimulatorResourceModel resModel = singleResource.getResourceModel();
+            remoteResource.put(null, resModel, null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testPut_N02() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            SimulatorResourceModel resModel = singleResource.getResourceModel();
+            remoteResource.put(remoteResource.getResourceInterfaces().get(0),
+                    null, resModel, null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testPut_N03() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            SimulatorResourceModel resModel = singleResource.getResourceModel();
+            Map<String, String> queryParams = new HashMap<>();
+            remoteResource.put(null, queryParams, resModel,
+                    new SimulatorRemoteResource.PutResponseListener() {
+                        @Override
+                        public void onPutResponse(String uid,
+                                SimulatorResult result,
+                                SimulatorResourceModel resourceModel) {
+                        }
+                    });
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testPost_P01() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        PostResponseCallbackListener listener = new PostResponseCallbackListener(
+                lockObject, response);
+
+        try {
+            SimulatorResourceModel resModel = singleResource.getResourceModel();
+            remoteResource.post(null, resModel, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertNotNull(response.get().resourceModel());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testPost_P02() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        PostResponseCallbackListener listener = new PostResponseCallbackListener(
+                lockObject, response);
+
+        try {
+            SimulatorResourceModel resModel = singleResource.getResourceModel();
+            Map<String, String> queryParams = new HashMap<>();
+            remoteResource.post(queryParams, resModel, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertNotNull(response.get().resourceModel());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testPost_P03() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        PostResponseCallbackListener listener = new PostResponseCallbackListener(
+                lockObject, response);
+
+        try {
+            SimulatorResourceModel resModel = singleResource.getResourceModel();
+            remoteResource.post(remoteResource.getResourceInterfaces().get(0),
+                    null, resModel, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertNotNull(response.get().resourceModel());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testPost_P04() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        PostResponseCallbackListener listener = new PostResponseCallbackListener(
+                lockObject, response);
+
+        try {
+            SimulatorResourceModel resModel = singleResource.getResourceModel();
+            Map<String, String> queryParams = new HashMap<>();
+            remoteResource.post(remoteResource.getResourceInterfaces().get(0),
+                    queryParams, resModel, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertNotNull(response.get().resourceModel());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testPost_P05() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        PostResponseCallbackListener listener = new PostResponseCallbackListener(
+                lockObject, response);
+
+        try {
+            SimulatorResourceModel resModel = singleResource.getResourceModel();
+            Map<String, String> queryParams = new HashMap<>();
+            remoteResource.post(queryParams, null, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertNotNull(response.get().resourceModel());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testPost_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            SimulatorResourceModel resModel = singleResource.getResourceModel();
+            remoteResource.post(null, resModel, null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testPost_N02() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            SimulatorResourceModel resModel = singleResource.getResourceModel();
+            remoteResource.post(remoteResource.getResourceInterfaces().get(0),
+                    null, resModel, null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testPost_N03() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            SimulatorResourceModel resModel = singleResource.getResourceModel();
+            Map<String, String> queryParams = new HashMap<>();
+            remoteResource.post(null, queryParams, resModel,
+                    new SimulatorRemoteResource.PostResponseListener() {
+                        @Override
+                        public void onPostResponse(String uid,
+                                SimulatorResult result,
+                                SimulatorResourceModel resourceModel) {
+                        }
+                    });
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testStartObserve_P01() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        ObserveNotificationCallbackListener listener = new ObserveNotificationCallbackListener(
+                lockObject, response);
+
+        try {
+            Map<String, String> queryParams = new HashMap<>();
+            remoteResource.startObserve(queryParams, listener);
+            singleResource.addAttribute(new SimulatorResourceAttribute(
+                    "boolean", new AttributeValue(true), null));
+            singleResource.removeAttribute("boolean");
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            remoteResource.stopObserve();
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertNotNull(response.get().resourceModel());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testStartObserve_P02() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        ObserveNotificationCallbackListener listener = new ObserveNotificationCallbackListener(
+                lockObject, response);
+
+        try {
+            remoteResource.startObserve(null, listener);
+            singleResource.addAttribute(new SimulatorResourceAttribute(
+                    "boolean", new AttributeValue(true), null));
+            singleResource.removeAttribute("boolean");
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            remoteResource.stopObserve();
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertNotNull(response.get().resourceModel());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testStartObserve_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            Map<String, String> queryParams = new HashMap<>();
+            remoteResource.startObserve(queryParams, null);
+
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testStopObserve_P01() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        ObserveNotificationCallbackListener listener = new ObserveNotificationCallbackListener(
+                lockObject, response);
+
+        try {
+            Map<String, String> queryParams = new HashMap<>();
+            remoteResource.startObserve(queryParams, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            response.set(null);
+            remoteResource.stopObserve();
+            singleResource.addAttribute(new SimulatorResourceAttribute(
+                    "boolean", new AttributeValue(true), null));
+            singleResource.removeAttribute("boolean");
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNull(response.get());
+    }
+
+    public void testSetConfigInfo_P01() {
+        boolean syncResult = false;
+        try {
+            remoteResource.setConfigInfo(SINGLE_RES_RAML);
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+    }
+
+    public void testSetConfigInfo_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            remoteResource.setConfigInfo("");
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testSetConfigInfo_N02() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            remoteResource.setConfigInfo(null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testStartVerification_P01() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        VerificationCallbackListener listener = new VerificationCallbackListener(
+                lockObject, response);
+
+        try {
+            remoteResource.setConfigInfo(SINGLE_RES_RAML);
+            remoteResource.startVerification(
+                    SimulatorRemoteResource.VerificationType.GET, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testStartVerification_P02() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        VerificationCallbackListener listener = new VerificationCallbackListener(
+                lockObject, response);
+
+        try {
+            remoteResource.setConfigInfo(SINGLE_RES_RAML);
+            remoteResource.startVerification(
+                    SimulatorRemoteResource.VerificationType.PUT, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testStartVerification_P03() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        VerificationCallbackListener listener = new VerificationCallbackListener(
+                lockObject, response);
+
+        try {
+            remoteResource.setConfigInfo(SINGLE_RES_RAML);
+            remoteResource.startVerification(
+                    SimulatorRemoteResource.VerificationType.POST, listener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+            }
+
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+        assertNotNull(response.get());
+        assertEquals(remoteResource.getId(), response.get().uid());
+    }
+
+    public void testStartVerification_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            remoteResource.setConfigInfo(SINGLE_RES_RAML);
+            remoteResource.startVerification(
+                    SimulatorRemoteResource.VerificationType.GET, null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testStopVerification_N01() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<ResponseDetails> response = new ObjectHolder<>();
+        VerificationCallbackListener listener = new VerificationCallbackListener(
+                lockObject, response);
+
+        try {
+            remoteResource.setConfigInfo(SINGLE_RES_RAML);
+            int id = remoteResource.startVerification(
+                    SimulatorRemoteResource.VerificationType.POST, listener);
+            remoteResource.stopVerification(id);
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
+    }
+}
+
+class ResponseDetails {
+    private String                 mUid      = null;
+    private SimulatorResourceModel mResModel = null;
+    private SimulatorResult        mResult   = SimulatorResult.SIMULATOR_ERROR;
+
+    ResponseDetails(String uid, SimulatorResult result,
+            SimulatorResourceModel resModel) {
+        mUid = uid;
+        mResModel = resModel;
+        mResult = result;
+    }
+
+    String uid() {
+        return mUid;
+    }
+
+    SimulatorResourceModel resourceModel() {
+        return mResModel;
+    }
+
+    SimulatorResult errorCode() {
+        return mResult;
+    }
+}
+
+class GetResponseCallbackListener implements
+        SimulatorRemoteResource.GetResponseListener {
+    private CountDownLatch                mLockObject;
+    private ObjectHolder<ResponseDetails> mResponse;
+
+    public GetResponseCallbackListener(CountDownLatch lockObject,
+            ObjectHolder<ResponseDetails> response) {
+        mLockObject = lockObject;
+        mResponse = response;
+    }
+
+    @Override
+    public void onGetResponse(String uid, SimulatorResult result,
+            SimulatorResourceModel resourceModel) {
+        mResponse.set(new ResponseDetails(uid, result, resourceModel));
+        mLockObject.countDown();
+    }
+}
+
+class PutResponseCallbackListener implements
+        SimulatorRemoteResource.PutResponseListener {
+    private CountDownLatch                mLockObject;
+    private ObjectHolder<ResponseDetails> mResponse;
+
+    public PutResponseCallbackListener(CountDownLatch lockObject,
+            ObjectHolder<ResponseDetails> response) {
+        mLockObject = lockObject;
+        mResponse = response;
+    }
+
+    @Override
+    public void onPutResponse(String uid, SimulatorResult result,
+            SimulatorResourceModel resourceModel) {
+        mResponse.set(new ResponseDetails(uid, result, resourceModel));
+        mLockObject.countDown();
+    }
+}
+
+class PostResponseCallbackListener implements
+        SimulatorRemoteResource.PostResponseListener {
+    private CountDownLatch                mLockObject;
+    private ObjectHolder<ResponseDetails> mResponse;
+
+    public PostResponseCallbackListener(CountDownLatch lockObject,
+            ObjectHolder<ResponseDetails> response) {
+        mLockObject = lockObject;
+        mResponse = response;
+    }
+
+    @Override
+    public void onPostResponse(String uid, SimulatorResult result,
+            SimulatorResourceModel resourceModel) {
+        mResponse.set(new ResponseDetails(uid, result, resourceModel));
+        mLockObject.countDown();
+    }
+}
+
+class ObserveNotificationCallbackListener implements
+        SimulatorRemoteResource.ObserveNotificationListener {
+    private CountDownLatch                mLockObject;
+    private ObjectHolder<ResponseDetails> mResponse;
+
+    public ObserveNotificationCallbackListener(CountDownLatch lockObject,
+            ObjectHolder<ResponseDetails> response) {
+        mLockObject = lockObject;
+        mResponse = response;
+    }
+
+    @Override
+    public void onObserveNotification(String uid,
+            SimulatorResourceModel resourceModel, int sequenceNumber) {
+        mResponse.set(new ResponseDetails(uid, SimulatorResult.SIMULATOR_OK,
+                resourceModel));
+        mLockObject.countDown();
+    }
+}
+
+class VerificationCallbackListener implements
+        SimulatorRemoteResource.VerificationListener {
+    private CountDownLatch                mLockObject;
+    private ObjectHolder<ResponseDetails> mResponse;
+
+    public VerificationCallbackListener(CountDownLatch lockObject,
+            ObjectHolder<ResponseDetails> response) {
+        mLockObject = lockObject;
+        mResponse = response;
+    }
+
+    @Override
+    public void onVerificationStarted(String uid, int id) {
+        mResponse.set(new ResponseDetails(uid, SimulatorResult.SIMULATOR_OK,
+                null));
+        mLockObject.countDown();
+    }
+
+    @Override
+    public void onVerificationAborted(String uid, int id) {
+        mResponse.set(new ResponseDetails(uid, SimulatorResult.SIMULATOR_OK,
+                null));
+        mLockObject.countDown();
+    }
+
+    @Override
+    public void onVerificationCompleted(String uid, int id) {
+        mResponse.set(new ResponseDetails(uid, SimulatorResult.SIMULATOR_OK,
+                null));
+        mLockObject.countDown();
+    }
+}
+
+class FindResourceCallbackListener implements FindResourceListener {
+    private CountDownLatch                        mLockObject;
+    private ObjectHolder<SimulatorRemoteResource> mResourceHolder;
+
+    public FindResourceCallbackListener(CountDownLatch lockObject,
+            ObjectHolder<SimulatorRemoteResource> resourceHolder) {
+        mLockObject = lockObject;
+        mResourceHolder = resourceHolder;
+    }
+
+    @Override
+    public void onResourceFound(SimulatorRemoteResource resource) {
+        mResourceHolder.set(resource);
+        mLockObject.countDown();
+    }
+}
\ No newline at end of file
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/GetListener.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/GetListener.java
deleted file mode 100644 (file)
index ed9fd7e..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.oic.simulator.clientcontroller.test;
-
-import java.util.concurrent.CountDownLatch;
-
-import org.oic.simulator.SimulatorResourceModel;
-import org.oic.simulator.clientcontroller.IGetListener;
-
-/**
- * This class implements methods for receiving notification when
- * response is received for GET request.
- */
-public class GetListener implements IGetListener
-{
-
-    private CountDownLatch lockObject;
-    private ListenerObject getListenerObject;
-
-    public GetListener(CountDownLatch lockObject, ListenerObject getListenerObject)
-    {
-        this.lockObject = lockObject;
-        this.getListenerObject = getListenerObject;
-    }
-
-    @Override
-    public void onGetCompleted(String uId, SimulatorResourceModel representation)
-    {
-        if (null != getListenerObject) {
-            getListenerObject.setuId(uId);
-            getListenerObject.setRepresentation(representation);
-        }
-
-        lockObject.countDown();
-    }
-
-    @Override
-    public void onGetFailed(Throwable ex)
-    {
-        if (null != getListenerObject)
-            getListenerObject.setEx(ex);
-
-        lockObject.countDown();
-    }
-}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/ListenerObject.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/ListenerObject.java
deleted file mode 100644 (file)
index 860cf6a..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.oic.simulator.clientcontroller.test;
-
-import org.oic.simulator.SimulatorResourceModel;
-
-/**
- * This class implements methods for setting/getting UID and
- * resource representation.
- */
-public class ListenerObject
-{
-
-    private String uId;
-    private SimulatorResourceModel representation;
-    private Throwable ex;
-
-    public void setuId(String uId)
-    {
-        this.uId = uId;
-    }
-
-    public String getuId()
-    {
-        return uId;
-    }
-
-    public void setRepresentation(SimulatorResourceModel representation)
-    {
-        this.representation = representation;
-    }
-
-    public SimulatorResourceModel getRepresentation()
-    {
-        return representation;
-    }
-
-    public void setEx(Throwable ex)
-    {
-        this.ex = ex;
-    }
-
-    public Throwable getEx()
-    {
-        return ex;
-    }
-}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/ObserveListener.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/ObserveListener.java
deleted file mode 100644 (file)
index ecc6c10..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.oic.simulator.clientcontroller.test;
-
-import java.util.concurrent.CountDownLatch;
-
-import org.oic.simulator.SimulatorResourceModel;
-import org.oic.simulator.clientcontroller.IObserveListener;
-
-/**
- * This class implements methods for receiving notification when
- * response is received for Observe request.
- */
-public class ObserveListener implements IObserveListener
-{
-
-    private CountDownLatch lockObject;
-    private ObserveListenerObject observeListenerObject;
-
-    public ObserveListener(CountDownLatch lockObject, ObserveListenerObject observeListenerObject)
-    {
-        this.lockObject = lockObject;
-        this.observeListenerObject = observeListenerObject;
-    }
-
-    @Override
-    public void onObserveCompleted(String uId, SimulatorResourceModel representation, int sequenceNumber)
-    {
-        observeListenerObject.setuId(uId);
-        observeListenerObject.setRepresentation(representation);
-        observeListenerObject.setSequenceNumber(sequenceNumber);
-
-        lockObject.countDown();
-    }
-
-    @Override
-    public void onObserveFailed(Throwable ex)
-    {
-        observeListenerObject.setEx(ex);
-        lockObject.countDown();
-    }
-}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/ObserveListenerObject.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/ObserveListenerObject.java
deleted file mode 100644 (file)
index 6bcca0c..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * 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.oic.simulator.clientcontroller.test;
-
-import org.oic.simulator.SimulatorResourceModel;
-
-/**
- * This class implements methods for setting/getting UID,
- * resource representation and sequence number for observe.
- */
-public class ObserveListenerObject
-{
-    private String uId;
-    private SimulatorResourceModel representation;
-    private int sequenceNumber;
-    private Throwable ex;
-
-    public void setuId(String uId)
-    {
-        this.uId = uId;
-    }
-
-    public String getuId()
-    {
-        return uId;
-    }
-
-    public void setRepresentation(SimulatorResourceModel representation)
-    {
-        this.representation = representation;
-    }
-
-    public SimulatorResourceModel getRepresentation()
-    {
-        return representation;
-    }
-
-    public void setSequenceNumber(int sequenceNumber)
-    {
-        this.sequenceNumber = sequenceNumber;
-    }
-
-    public int getSequenceNumber()
-    {
-        return sequenceNumber;
-    }
-
-    public void setEx(Throwable ex)
-    {
-        this.ex = ex;
-    }
-
-    public Throwable getEx()
-    {
-        return ex;
-    }
-}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/PostListener.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/PostListener.java
deleted file mode 100644 (file)
index 3942b51..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.oic.simulator.clientcontroller.test;
-
-import java.util.concurrent.CountDownLatch;
-
-import org.oic.simulator.SimulatorResourceModel;
-import org.oic.simulator.clientcontroller.IPostListener;
-
-/**
- * This class implements methods for receiving notification when
- * response is received for POST request.
- */
-public class PostListener implements IPostListener
-{
-
-    private CountDownLatch lockObject;
-    private ListenerObject postListenerObject;
-
-    public PostListener(CountDownLatch lockObject, ListenerObject postListenerObject)
-    {
-        this.lockObject = lockObject;
-        this.postListenerObject = postListenerObject;
-    }
-
-    @Override
-    public void onPostCompleted(String uId, SimulatorResourceModel representation)
-    {
-        if (null != postListenerObject) {
-            postListenerObject.setuId(uId);
-            postListenerObject.setRepresentation(representation);
-        }
-
-        lockObject.countDown();
-    }
-
-    @Override
-    public void onPostFailed(Throwable ex)
-    {
-        if (null != postListenerObject)
-            postListenerObject.setEx(ex);
-
-        lockObject.countDown();
-    }
-}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/PutListener.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/PutListener.java
deleted file mode 100644 (file)
index 1dafed3..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * 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.oic.simulator.clientcontroller.test;
-
-import java.util.concurrent.CountDownLatch;
-
-import org.oic.simulator.SimulatorResourceModel;
-import org.oic.simulator.clientcontroller.IPutListener;
-
-/**
- * This class implements methods for receiving notification when
- * response is received for PUT request.
- */
-public class PutListener implements IPutListener
-{
-    private CountDownLatch lockObject;
-    private ListenerObject putListenerObject;
-
-    public PutListener(CountDownLatch lockObject, ListenerObject putListenerObject)
-    {
-        this.lockObject = lockObject;
-        this.putListenerObject = putListenerObject;
-    }
-
-    @Override
-    public void onPutCompleted(String uId, SimulatorResourceModel representation)
-    {
-        if (null != putListenerObject) {
-            putListenerObject.setuId(uId);
-            putListenerObject.setRepresentation(representation);
-        }
-
-        lockObject.countDown();
-    }
-
-    @Override
-    public void onPutFailed(Throwable ex)
-    {
-        if (null != putListenerObject)
-            putListenerObject.setEx(ex);
-
-        lockObject.countDown();
-    }
-}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/SimulatorRemoteResourceTest.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/SimulatorRemoteResourceTest.java
deleted file mode 100644 (file)
index 6cc820a..0000000
+++ /dev/null
@@ -1,915 +0,0 @@
-/*
- * 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.oic.simulator.clientcontroller.test;
-
-import java.util.HashMap;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import junit.framework.TestCase;
-
-import org.oic.simulator.SimulatorException;
-import org.oic.simulator.SimulatorManager;
-import org.oic.simulator.SimulatorResourceModel;
-import org.oic.simulator.clientcontroller.SimulatorObserveType;
-import org.oic.simulator.clientcontroller.SimulatorRemoteResource;
-import org.oic.simulator.clientcontroller.SimulatorVerificationType;
-import org.oic.simulator.serviceprovider.SimulatorResourceServer;
-import org.oic.simulator.test.FindResourceListener;
-import org.oic.simulator.test.ResourceModelChangeListener;
-import org.oic.simulator.test.ResourceModelObject;
-import org.oic.simulator.test.SimulatorRemoteResourceObject;
-
-/**
- * This class tests the functionality of Simulator Remote Resource
- * class APIs.
- */
-public class SimulatorRemoteResourceTest extends TestCase
-{
-    private static final String CONFIG_PATH = "./ramls/simple-light.raml";
-    //  private static final String RESOURCE_TYPE = "oic.light";
-
-    private CountDownLatch lockObject;
-    private ResourceModelObject resourceModelObject;
-    private ResourceModelChangeListener resourceModelChangeListener;
-
-    private SimulatorRemoteResourceObject simulatorRemoteResourceObject;
-    private SimulatorRemoteResource simulatorRemoteResource;
-
-    private SimulatorResourceServer simulatorResourceServer;
-
-    private FindResourceListener findResourceListener;
-
-    static
-    {
-        System.loadLibrary("SimulatorManager");
-        System.loadLibrary("RamlParser");
-        System.loadLibrary("oc");
-        System.loadLibrary("oc_logger");
-        System.loadLibrary("octbstack");
-    }
-
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-
-        lockObject = new CountDownLatch(1);
-        resourceModelObject = new ResourceModelObject();
-        resourceModelChangeListener = new ResourceModelChangeListener(resourceModelObject);
-
-        simulatorResourceServer = SimulatorManager.createResource(CONFIG_PATH, resourceModelChangeListener);
-
-        simulatorRemoteResourceObject = new SimulatorRemoteResourceObject();
-
-        findResourceListener = new FindResourceListener(lockObject, simulatorRemoteResourceObject);
-
-        SimulatorManager.findResource(findResourceListener);
-
-        try
-        {
-            lockObject.await(10, TimeUnit.SECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        simulatorRemoteResource = simulatorRemoteResourceObject.getSimulatorRemoteResource();
-    }
-
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-
-        SimulatorManager.deleteResource(simulatorResourceServer);
-
-        lockObject = null;
-        resourceModelObject = null;
-        resourceModelChangeListener = null;
-
-        simulatorRemoteResourceObject = null;
-        findResourceListener = null;
-
-        simulatorRemoteResource = null;
-    }
-
-    public void testGetUri_P01()
-    {
-        assertNotNull(simulatorRemoteResource.getUri());
-    }
-
-    public void testGetIsObservable_P01()
-    {
-        assertTrue(simulatorRemoteResource.getIsObservable());
-    }
-
-    public void testGetConnectivityType_P01()
-    {
-        assertNotNull(simulatorRemoteResource.getConnectivityType());
-    }
-
-    public void testGetResourceTypes_P01()
-    {
-        assertTrue(simulatorRemoteResource.getResourceTypes() != null && simulatorRemoteResource.getResourceTypes().size() > 0);
-    }
-
-    public void testGetResourceInterfaces_P01()
-    {
-        assertTrue(simulatorRemoteResource.getResourceInterfaces() != null && simulatorRemoteResource.getResourceInterfaces().size() > 0);
-    }
-
-    public void testGetId_P01()
-    {
-        assertNotNull(simulatorRemoteResource.getId());
-    }
-
-    public void testStartObserve_P01()
-    {
-        boolean result = true;
-        HashMap<String, String> queryParamMap = new HashMap<String, String>();
-
-        lockObject = new CountDownLatch(1);
-
-        ObserveListenerObject observeListenerObject = new ObserveListenerObject();
-        ObserveListener observeListener = new ObserveListener(lockObject, observeListenerObject);
-
-        try
-        {
-            simulatorRemoteResource.startObserve(SimulatorObserveType.OBSERVE, queryParamMap, observeListener);
-            simulatorResourceServer.addAttributeString("test", "test");
-        }
-        catch (Exception e1)
-        {
-            result = false;
-        }
-
-        try
-        {
-            lockObject.await(10, TimeUnit.SECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        assertTrue(observeListenerObject.getRepresentation() != null && result);
-
-        try
-        {
-            simulatorRemoteResource.stopObserve();
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-
-        observeListenerObject = null;
-        observeListener = null;
-    }
-
-    public void testStopObserve_P01()
-    {
-        boolean result = true;
-
-        HashMap<String, String> queryParamMap = new HashMap<String, String>();
-        lockObject = new CountDownLatch(1);
-        ObserveListenerObject observeListenerObject = new ObserveListenerObject();
-        ObserveListener observeListener = new ObserveListener(lockObject, observeListenerObject);
-
-        try
-        {
-            simulatorRemoteResource.startObserve(SimulatorObserveType.OBSERVE, queryParamMap, observeListener);
-            simulatorResourceServer.addAttributeString("test", "test");
-        }
-        catch (Exception e1)
-        {
-            e1.printStackTrace();
-            result = false;
-        }
-
-        try
-        {
-            lockObject.await(10, TimeUnit.SECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        result = result && observeListenerObject.getRepresentation() != null;
-
-        try
-        {
-            simulatorRemoteResource.stopObserve();
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        assertTrue(result);
-
-        observeListenerObject = null;
-        observeListener = null;
-    }
-
-    public void testGetQueryParamGetListener_P01()
-    {
-        boolean result = true;
-        lockObject = new CountDownLatch(1);
-        HashMap<String, String> queryParamMap = new HashMap<String, String>();
-
-        ListenerObject getListenerObject = new ListenerObject();
-        GetListener getListener = new GetListener(lockObject, getListenerObject);
-
-        try
-        {
-            simulatorRemoteResource.get(queryParamMap, getListener);
-        }
-        catch (Exception e1)
-        {
-            e1.printStackTrace();
-            result = false;
-        }
-
-        try
-        {
-            lockObject.await(10, TimeUnit.SECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        if(getListenerObject.getEx() == null)
-        {
-            try
-            {
-                result = result && getListenerObject.getRepresentation() != null && getListenerObject.getRepresentation().size() > 0;
-            }
-            catch (SimulatorException e)
-            {
-                result = false;
-                e.printStackTrace();
-            }
-        }
-        else
-            result = false;
-
-        assertTrue(result);
-    }
-
-    public void testGetStringMapOfStringStringIGetListener_P01()
-    {
-        boolean result = true;
-        lockObject = new CountDownLatch(1);
-        HashMap<String, String> queryParamMap = new HashMap<String, String>();
-
-        String resourceInterface = "oic.if.baseline";
-
-        ListenerObject getListenerObject = new ListenerObject();
-        GetListener getListener = new GetListener(lockObject, getListenerObject);
-
-        try
-        {
-            simulatorRemoteResource.get(resourceInterface, queryParamMap, getListener);
-        }
-        catch (Exception e1)
-        {
-            e1.printStackTrace();
-            result = false;
-        }
-
-        try
-        {
-            lockObject.await(10, TimeUnit.SECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        if(getListenerObject.getEx() == null)
-        {
-            try
-            {
-                result = result && getListenerObject.getRepresentation() != null && getListenerObject.getRepresentation().size() > 0;
-            }
-            catch (SimulatorException e)
-            {
-                result = false;
-                e.printStackTrace();
-            }
-        }
-        else
-            result = false;
-
-        assertTrue(result);
-    }
-
-    public void testPut_P01()
-    {
-        boolean result = true;
-        SimulatorResourceModel model = new SimulatorResourceModel();
-
-        lockObject = new CountDownLatch(1);
-
-        ListenerObject listenerObject = null;
-
-        try
-        {
-            listenerObject = new ListenerObject();
-            PutListener putListener = new PutListener(lockObject, listenerObject);
-
-            model.addAttributeInt("intensity", 5);
-            model.addAttributeString("power", "off");
-
-            simulatorRemoteResource.put(model, null, putListener);
-        }
-        catch(Exception e)
-        {
-            result = false;
-        }
-
-        try
-        {
-            lockObject.await(10, TimeUnit.SECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        assertTrue(result && listenerObject != null && listenerObject.getRepresentation() != null && listenerObject.getuId() != null);
-    }
-
-    /**
-     * model as null
-     */
-
-    public void testPut_N01() {
-        boolean result = true;
-        ListenerObject listenerObject = new ListenerObject();
-        PutListener putListener = new PutListener(lockObject, listenerObject);
-
-        try {
-            simulatorRemoteResource.put(null, null, putListener);
-            result = false;
-        } catch (Exception e1) {
-            result = true;
-        }
-
-        try {
-            lockObject.await(10, TimeUnit.SECONDS);
-        } catch (InterruptedException e) {
-        }
-
-        assertTrue(result && listenerObject.getRepresentation() == null && listenerObject.getuId() == null);
-    }
-
-    public void testPost_P01()
-    {
-        boolean result = true;
-        ListenerObject listenerObject = null;
-        lockObject = new CountDownLatch(1);
-
-        SimulatorResourceModel model = new SimulatorResourceModel();
-        try
-        {
-            model.addAttributeInt("intensity", 8);
-
-            listenerObject = new ListenerObject();
-            PostListener postListener = new PostListener(lockObject, listenerObject);
-
-            simulatorRemoteResource.post(model, null, postListener);
-        }
-        catch(Exception e)
-        {
-            result = false;
-        }
-
-        try
-        {
-            lockObject.await(10, TimeUnit.SECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        assertTrue(result && listenerObject != null && listenerObject.getRepresentation() != null && listenerObject.getuId() != null);
-    }
-
-    /**
-     * Model is set to null
-     */
-
-    public void testPost_N01() {
-        boolean result = true;
-
-        lockObject = new CountDownLatch(1);
-
-        ListenerObject listenerObject = new ListenerObject();
-        PostListener postListener = new PostListener(lockObject, listenerObject);
-
-        try {
-            simulatorRemoteResource.post(null, null, postListener);
-            result = false;
-        } catch (Exception e1) {
-            result = true;
-        }
-
-        try {
-            lockObject.await(10, TimeUnit.SECONDS);
-        } catch (InterruptedException e) {
-        }
-
-        assertTrue(result && listenerObject.getRepresentation() == null && listenerObject.getuId() == null);
-    }
-
-    public void testGet_P01()
-    {
-        boolean result = true;
-        ListenerObject listenerObject = null;
-        lockObject = new CountDownLatch(1);
-
-        try
-        {
-            listenerObject = new ListenerObject();
-            GetListener onGetListener = new GetListener(lockObject, listenerObject);
-
-            String resInterface = simulatorRemoteResource.getResourceInterfaces().get(0);
-
-            if(resInterface != null)
-                simulatorRemoteResource.get(resInterface,null, onGetListener);
-            else
-                result = false;
-        }
-        catch(Exception e)
-        {
-            result = false;
-        }
-
-        try
-        {
-            lockObject.await(10, TimeUnit.SECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        assertTrue(result && listenerObject != null && listenerObject.getRepresentation() != null && listenerObject.getuId() != null);
-    }
-
-    /**
-     * null resInterface
-     */
-    public void testGet_N01()
-    {
-        boolean result = false;
-        ListenerObject listenerObject = null;
-        lockObject = new CountDownLatch(1);
-
-        try
-        {
-            listenerObject = new ListenerObject();
-            GetListener onGetListener = new GetListener(lockObject, listenerObject);
-
-            simulatorRemoteResource.get(null, null, onGetListener);
-            result = false;
-        }
-        catch(Exception e)
-        {
-            result = true;
-        }
-
-        try
-        {
-            lockObject.await(10, TimeUnit.SECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        assertTrue(result);
-    }
-
-    /**
-     * null listener
-     */
-    public void testGet_N02()
-    {
-        boolean result = false;
-        try
-        {
-            String resInterface = simulatorRemoteResource.getResourceInterfaces().get(0);
-
-            if(resInterface != null)
-            {
-                simulatorRemoteResource.get( resInterface,null, null);
-            }
-
-            result = false;
-        }
-        catch(Exception e)
-        {
-            result = true;
-        }
-
-        assertTrue(result);
-    }
-
-    /**
-     * all params as null
-     */
-    public void testGet_N03()
-    {
-        boolean result = false;
-        try
-        {
-            simulatorRemoteResource.get(null, null, null);
-            result = false;
-        }
-        catch(Exception e)
-        {
-            result = true;
-        }
-
-        assertTrue(result);
-    }
-
-    public void testGetWithoutResInterface_P01()
-    {
-        boolean result = true;
-        ListenerObject listenerObject = null;
-        lockObject = new CountDownLatch(1);
-
-        try
-        {
-            listenerObject = new ListenerObject();
-            GetListener onGetListener = new GetListener(lockObject, listenerObject);
-
-            simulatorRemoteResource.get(null, onGetListener);
-        }
-        catch(Exception e)
-        {
-            result = false;
-        }
-
-        try
-        {
-            lockObject.await(10, TimeUnit.SECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        assertTrue(result && listenerObject != null && listenerObject.getRepresentation() != null && listenerObject.getuId() != null);
-    }
-
-    /**
-     * null listener
-     */
-    public void testGetWithoutResInterface_N01()
-    {
-        boolean result = false;
-        try
-        {
-            simulatorRemoteResource.get(null, null);
-            result = false;
-        }
-        catch(Exception e)
-        {
-            result = true;
-        }
-
-        assertTrue(result);
-    }
-
-    public void testSetConfigInfo_P01()
-    {
-        boolean result = true;
-        try
-        {
-            simulatorRemoteResource.setConfigInfo(CONFIG_PATH);
-        }
-        catch (Exception e2)
-        {
-            e2.printStackTrace();
-            result = false;
-        }
-
-        lockObject = new CountDownLatch(1);
-        VerifyListenerObject verifyListenerObject = new VerifyListenerObject();
-        VerifyListener verifyListener = new VerifyListener(lockObject, verifyListenerObject);
-
-        try
-        {
-            simulatorRemoteResource.startVerification(SimulatorVerificationType.RQ_TYPE_POST, verifyListener);
-        }
-        catch (Exception e1)
-        {
-            e1.printStackTrace();
-            result = false;
-        }
-
-        try
-        {
-            lockObject.await(10, TimeUnit.MILLISECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        assertTrue(result && verifyListenerObject.getWhichOne().equals("started")&&
-                   verifyListenerObject.getuId() != null &&
-                   verifyListenerObject.getId() != -1);
-    }
-
-    /**
-     * Passing empty
-     */
-    public void testSetConfigInfo_N01()
-    {
-        boolean result = true;
-        try
-        {
-            simulatorRemoteResource.setConfigInfo("");
-            result = false;
-        }
-        catch (Exception e2)
-        {
-            result = true;
-        }
-
-        assertTrue(result);
-    }
-
-    public void testStartVerification_P01()
-    {
-        boolean result = true;
-        lockObject = new CountDownLatch(1);
-        try
-        {
-            simulatorRemoteResource.setConfigInfo(CONFIG_PATH);
-        }
-        catch (Exception e1)
-        {
-            e1.printStackTrace();
-            result = false;
-        }
-
-        VerifyListenerObject verifyListenerObject = new VerifyListenerObject();
-        VerifyListener verifyListener = new VerifyListener(lockObject, verifyListenerObject);
-        try
-        {
-            result =  result && simulatorRemoteResource.startVerification(SimulatorVerificationType.RQ_TYPE_POST, verifyListener) != -1;
-        }
-        catch (Exception e1)
-        {
-            e1.printStackTrace();
-            result = false;
-        }
-
-        try
-        {
-            lockObject.await(10, TimeUnit.MILLISECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        assertTrue(result && verifyListenerObject.getWhichOne().equals("started") &&
-                   verifyListenerObject.getuId() != null &&
-                   verifyListenerObject.getId() != -1);
-    }
-
-    public void testStartVerification_P02()
-    {
-        boolean result = true;
-        lockObject = new CountDownLatch(1);
-        try
-        {
-            simulatorRemoteResource.setConfigInfo(CONFIG_PATH);
-        }
-        catch (Exception e1)
-        {
-            e1.printStackTrace();
-            result = false;
-        }
-
-        VerifyListenerObject verifyListenerObject = new VerifyListenerObject();
-        VerifyListener verifyListener = new VerifyListener(lockObject, verifyListenerObject);
-        try
-        {
-            result =  result && simulatorRemoteResource.startVerification(SimulatorVerificationType.RQ_TYPE_PUT, verifyListener) != -1;
-        }
-        catch (Exception e1)
-        {
-            e1.printStackTrace();
-            result = false;
-        }
-
-        try
-        {
-            lockObject.await(10, TimeUnit.MILLISECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        assertTrue(result && verifyListenerObject.getWhichOne().equals("started") &&
-                   verifyListenerObject.getuId() != null &&
-                   verifyListenerObject.getId() != -1);
-    }
-
-    public void testStartVerification_P03()
-    {
-        boolean result = true;
-        lockObject = new CountDownLatch(1);
-        try
-        {
-            simulatorRemoteResource.setConfigInfo(CONFIG_PATH);
-        }
-        catch (Exception e1)
-        {
-            e1.printStackTrace();
-            result = false;
-        }
-
-        VerifyListenerObject verifyListenerObject = new VerifyListenerObject();
-        VerifyListener verifyListener = new VerifyListener(lockObject, verifyListenerObject);
-        try
-        {
-            result =  result && simulatorRemoteResource.startVerification(SimulatorVerificationType.RQ_TYPE_GET, verifyListener) != -1;
-        }
-        catch (Exception e1)
-        {
-            e1.printStackTrace();
-            result = false;
-        }
-
-        try
-        {
-            lockObject.await(10, TimeUnit.MILLISECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        assertTrue(result && verifyListenerObject.getWhichOne().equals("started") &&
-                   verifyListenerObject.getuId() != null &&
-                   verifyListenerObject.getId() != -1);
-    }
-
-    /**
-     * setting listener to null
-     */
-    public void testStartVerification_N01()
-    {
-        boolean result = true;
-        try
-        {
-            simulatorRemoteResource.setConfigInfo(CONFIG_PATH);
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-            result = false;
-        }
-
-        try
-        {
-            result = result && (simulatorRemoteResource.startVerification(SimulatorVerificationType.RQ_TYPE_POST, null) == -1);
-            result = false;
-        }
-        catch (Exception e)
-        {
-            result = true;
-        }
-        assertTrue(result);
-    }
-
-    public void testStopVerification_P01()
-    {
-        boolean result = true;
-        lockObject = new CountDownLatch(2);
-        try
-        {
-            simulatorRemoteResource.setConfigInfo(CONFIG_PATH);
-        }
-        catch (Exception e1)
-        {
-            e1.printStackTrace();
-            result = false;
-        }
-
-        VerifyListenerObject verifyListenerObject = new VerifyListenerObject();
-        VerifyListener verifyListener = new VerifyListener(lockObject, verifyListenerObject);
-        try
-        {
-            result =  result && simulatorRemoteResource.startVerification(SimulatorVerificationType.RQ_TYPE_POST, verifyListener) != -1;
-        }
-        catch (Exception e1)
-        {
-            e1.printStackTrace();
-            result = false;
-        }
-
-        try
-        {
-            lockObject.await(10, TimeUnit.MILLISECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        result = result && verifyListenerObject.getWhichOne().equals("started") &&
-                 verifyListenerObject.getuId() != null &&
-                 verifyListenerObject.getId() != -1;
-
-        try
-        {
-            simulatorRemoteResource.stopVerification(verifyListenerObject.getId());
-        }
-        catch (Exception e1)
-        {
-            e1.printStackTrace();
-            result = false;
-        }
-
-        try
-        {
-            lockObject.await(100, TimeUnit.MILLISECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        assertTrue(result && verifyListenerObject.getWhichOne().equals("aborted") &&
-                   verifyListenerObject.getuId() != null &&
-                   verifyListenerObject.getId() != -1);
-    }
-
-    /**
-     * Random id. This is just to check the crash
-     */
-    public void testStopVerification_N01()
-    {
-        boolean result = true;
-        lockObject = new CountDownLatch(1);
-        try
-        {
-            simulatorRemoteResource.setConfigInfo(CONFIG_PATH);
-        }
-        catch (Exception e2)
-        {
-            result = false;
-            e2.printStackTrace();
-        }
-
-        VerifyListenerObject verifyListenerObject = new VerifyListenerObject();
-        VerifyListener verifyListener = new VerifyListener(lockObject, verifyListenerObject);
-        try
-        {
-            result =  result && simulatorRemoteResource.startVerification(SimulatorVerificationType.RQ_TYPE_POST, verifyListener) != -1;
-        }
-        catch (Exception e1)
-        {
-            e1.printStackTrace();
-            result = false;
-        }
-
-        try
-        {
-            lockObject.await(10, TimeUnit.SECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        result = result && verifyListenerObject.getWhichOne().equals("started") &&
-                 verifyListenerObject.getuId() != null &&
-                 verifyListenerObject.getId() != -1;
-
-        try
-        {
-            simulatorRemoteResource.stopVerification(123435);
-            result = false;
-        }
-        catch (Exception e)
-        {
-            result = true;
-        }
-
-        assertTrue(result);
-    }
-}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/VerifyListener.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/VerifyListener.java
deleted file mode 100644 (file)
index 2e16ef5..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.oic.simulator.clientcontroller.test;
-
-import java.util.concurrent.CountDownLatch;
-
-import org.oic.simulator.clientcontroller.IVerificationListener;
-
-/**
- * This class implements listeners for getting verification
- * status callbacks.
- */
-public class VerifyListener implements IVerificationListener
-{
-
-    private CountDownLatch lockObject;
-    private VerifyListenerObject verifyListenerObject;
-
-    public VerifyListener(CountDownLatch lockObject, VerifyListenerObject verifyListenerObject)
-    {
-        this.lockObject = lockObject;
-        this.verifyListenerObject = verifyListenerObject;
-    }
-
-    @Override
-    public void onVerificationStarted(String uId, int id)
-    {
-        verifyListenerObject.setId(id);
-        verifyListenerObject.setuId(uId);
-        verifyListenerObject.setWhichOne("started");
-
-        lockObject.countDown();
-    }
-
-    @Override
-    public void onVerificationAborted(String uId, int id)
-    {
-        verifyListenerObject.setId(id);
-        verifyListenerObject.setuId(uId);
-        verifyListenerObject.setWhichOne("aborted");
-
-        lockObject.countDown();
-    }
-
-    @Override
-    public void onVerificationCompleted(String uId, int id)
-    {
-        verifyListenerObject.setId(id);
-        verifyListenerObject.setuId(uId);
-        verifyListenerObject.setWhichOne("completed");
-
-        lockObject.countDown();
-    }
-}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/VerifyListenerObject.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/VerifyListenerObject.java
deleted file mode 100644 (file)
index 45a2eaf..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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.oic.simulator.clientcontroller.test;
-
-/**
- * This class tests the functionality of getting/setting
- * verification ID.
- */
-public class VerifyListenerObject
-{
-
-    private String uId;
-    private int id;
-    private String whichOne;
-
-    public void setuId(String uId)
-    {
-        this.uId = uId;
-    }
-
-    public String getuId()
-    {
-        return uId;
-    }
-
-    public void setId(int id)
-    {
-        this.id = id;
-    }
-
-    public int getId()
-    {
-        return id;
-    }
-
-    public void setWhichOne(String whichOne)
-    {
-        this.whichOne = whichOne;
-    }
-
-    public String getWhichOne()
-    {
-        return whichOne;
-    }
-}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/server/test/SimulatorCollectionResourceTest.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/server/test/SimulatorCollectionResourceTest.java
new file mode 100644 (file)
index 0000000..5dd5dc4
--- /dev/null
@@ -0,0 +1,290 @@
+/*
+ * 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.oic.simulator.server.test;
+
+import java.util.Vector;
+
+import org.oic.simulator.InvalidArgsException;
+import org.oic.simulator.SimulatorException;
+import org.oic.simulator.SimulatorManager;
+import org.oic.simulator.server.SimulatorCollectionResource;
+import org.oic.simulator.server.SimulatorResource;
+import org.oic.simulator.test.ExceptionType;
+
+import junit.framework.TestCase;
+
+public class SimulatorCollectionResourceTest extends TestCase {
+    static {
+        System.loadLibrary("SimulatorManager");
+        System.loadLibrary("RamlParser");
+        System.loadLibrary("oc");
+        System.loadLibrary("oc_logger");
+        System.loadLibrary("octbstack");
+    }
+
+    private static final String         COLLECTION_RES_RAML = "./ramls/oic.d.airconditioner.raml";
+    private SimulatorCollectionResource collectionResource  = null;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        // collectionResource = (SimulatorCollectionResource)
+        // SimulatorManager.createResource(
+        // COLLECTION_RES_RAML);
+        collectionResource = (SimulatorCollectionResource) SimulatorManager
+                .createResource(SimulatorResource.Type.COLLECTION,
+                        "test-collection", "/test/collection",
+                        "test.collection");
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        collectionResource = null;
+    }
+
+    public void testAddChildResource_P01() {
+        SimulatorResource childResource = null;
+
+        try {
+            String name = "child-resource";
+            String uri = "/child/resource";
+            String resType = "child.resource";
+
+            childResource = SimulatorManager.createResource(
+                    SimulatorResource.Type.SINGLE, name, uri, resType);
+        } catch (InvalidArgsException e1) {
+            e1.printStackTrace();
+        } catch (SimulatorException e1) {
+            e1.printStackTrace();
+        }
+
+        if (null == childResource)
+            return;
+
+        Vector<SimulatorResource> result = null;
+        try {
+            collectionResource.addChildResource(childResource);
+            result = collectionResource.getChildResource();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertNotNull(result);
+        assertEquals(1, result.size());
+    }
+
+    public void testAddChildResource_P02() {
+        SimulatorResource childResource = null;
+
+        try {
+            String name = "child-resource";
+            String uri = "/child/resource";
+            String resType = "child.resource";
+
+            childResource = SimulatorManager.createResource(
+                    SimulatorResource.Type.COLLECTION, name, uri, resType);
+        } catch (InvalidArgsException e1) {
+            e1.printStackTrace();
+        } catch (SimulatorException e1) {
+            e1.printStackTrace();
+        }
+
+        if (null == childResource)
+            return;
+
+        Vector<SimulatorResource> result = null;
+        try {
+            collectionResource.addChildResource(childResource);
+            result = collectionResource.getChildResource();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertNotNull(result);
+        assertEquals(1, result.size());
+    }
+
+    public void testAddChildResource_P03() {
+        SimulatorResource childResource1 = null;
+        SimulatorResource childResource2 = null;
+
+        try {
+            String name = "child-resource";
+            String uri = "/child/resource";
+            String resType = "child.resource";
+
+            childResource1 = SimulatorManager.createResource(
+                    SimulatorResource.Type.SINGLE, name, uri, resType);
+            childResource2 = SimulatorManager.createResource(
+                    SimulatorResource.Type.COLLECTION, name + "-2", uri + "/2",
+                    resType);
+        } catch (InvalidArgsException e1) {
+            e1.printStackTrace();
+        } catch (SimulatorException e1) {
+            e1.printStackTrace();
+        }
+
+        if (null == childResource1 || null == childResource2)
+            return;
+
+        Vector<SimulatorResource> result = null;
+        try {
+            collectionResource.addChildResource(childResource1);
+            collectionResource.addChildResource(childResource2);
+            result = collectionResource.getChildResource();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertNotNull(result);
+        assertEquals(2, result.size());
+    }
+
+    public void testAddChildResource_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            collectionResource.addChildResource(null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testRemoveChildResource_P01() {
+        SimulatorResource childResource = null;
+        Vector<SimulatorResource> result = null;
+
+        try {
+            String name = "child-resource";
+            String uri = "/child/resource";
+            String resType = "child.resource";
+
+            childResource = SimulatorManager.createResource(
+                    SimulatorResource.Type.COLLECTION, name, uri, resType);
+            collectionResource.addChildResource(childResource);
+            result = collectionResource.getChildResource();
+        } catch (InvalidArgsException e1) {
+            e1.printStackTrace();
+        } catch (SimulatorException e1) {
+            e1.printStackTrace();
+        }
+
+        if (null == childResource || null == result)
+            return;
+
+        int count = result.size();
+        try {
+            collectionResource.removeChildResource(childResource);
+            result = collectionResource.getChildResource();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue((count == 1 && result == null)
+                || (count > 1 && result.size() == count - 1));
+    }
+
+    public void testRemoveChildResource_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            collectionResource.removeChildResource(null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testRemoveChildResourceByUri_P01() {
+        SimulatorResource childResource = null;
+        Vector<SimulatorResource> result = null;
+
+        try {
+            String name = "child-resource";
+            String uri = "/child/resource";
+            String resType = "child.resource";
+
+            childResource = SimulatorManager.createResource(
+                    SimulatorResource.Type.COLLECTION, name, uri, resType);
+            collectionResource.addChildResource(childResource);
+            result = collectionResource.getChildResource();
+        } catch (InvalidArgsException e1) {
+            e1.printStackTrace();
+        } catch (SimulatorException e1) {
+            e1.printStackTrace();
+        }
+
+        if (null == childResource || null == result)
+            return;
+
+        int count = result.size();
+        try {
+            collectionResource.removeChildResourceByUri(childResource.getURI());
+            result = collectionResource.getChildResource();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue((count == 1 && result == null)
+                || (count > 1 && result.size() == count - 1));
+    }
+
+    public void testRemoveChildResourceByUri_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            collectionResource.removeChildResourceByUri(null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testRemoveChildResourceByUri_N02() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            String uri = "";
+            collectionResource.removeChildResourceByUri(uri);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/server/test/SimulatorResourceTest.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/server/test/SimulatorResourceTest.java
new file mode 100644 (file)
index 0000000..33cde70
--- /dev/null
@@ -0,0 +1,419 @@
+/*
+ * 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.oic.simulator.server.test;
+
+import java.util.Vector;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.oic.simulator.InvalidArgsException;
+import org.oic.simulator.SimulatorException;
+import org.oic.simulator.SimulatorManager;
+import org.oic.simulator.client.FindResourceListener;
+import org.oic.simulator.client.SimulatorRemoteResource;
+import org.oic.simulator.server.SimulatorResource;
+import org.oic.simulator.test.ExceptionType;
+import org.oic.simulator.utils.ObjectHolder;
+
+import junit.framework.TestCase;
+
+/**
+ * This class tests the APIs of SimulatorResource class
+ */
+public class SimulatorResourceTest extends TestCase {
+    private static final String RES_NAME = "test-resource";
+    private static final String RES_URI  = "/test/resource";
+    private static final String RES_TYPE = "test.resource";
+    private SimulatorResource   resource = null;
+
+    static {
+        System.loadLibrary("SimulatorManager");
+        System.loadLibrary("RamlParser");
+        System.loadLibrary("oc");
+        System.loadLibrary("oc_logger");
+        System.loadLibrary("octbstack");
+    }
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        resource = SimulatorManager.createResource(
+                SimulatorResource.Type.SINGLE, RES_NAME, RES_URI, RES_TYPE);
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        resource = null;
+    }
+
+    public void testGetName_P01() {
+        String name = null;
+
+        try {
+            name = resource.getName();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(RES_NAME, name);
+    }
+
+    public void testGetType_P01() {
+        SimulatorResource.Type type = SimulatorResource.Type.SINGLE;
+
+        try {
+            type = resource.getType();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(SimulatorResource.Type.SINGLE, type);
+    }
+
+    public void testGetURI_P01() {
+        String uri = null;
+
+        try {
+            uri = resource.getURI();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(RES_URI, uri);
+    }
+
+    public void testGetResourceType_P01() {
+        String resType = null;
+
+        try {
+            resType = resource.getResourceType();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(RES_TYPE, resType);
+    }
+
+    public void testGetInterface_P01() {
+        Vector<String> interfaces = null;
+
+        try {
+            interfaces = resource.getInterface();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertNotNull(interfaces);
+        assertTrue(interfaces.size() > 0);
+    }
+
+    public void testSetName_P01() {
+        String name = "new-name";
+        String newName = null;
+
+        try {
+            resource.setName(name);
+            newName = resource.getName();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(name, newName);
+    }
+
+    public void testSetName_N01() {
+        String newName = "";
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            resource.setName(newName);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertEquals(ExceptionType.INVALID_ARGS, exType);
+    }
+
+    public void testSetName_N02() {
+        String newName = null;
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            resource.setName(newName);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertEquals(ExceptionType.INVALID_ARGS, exType);
+    }
+
+    public void testSetURI_P01() {
+        String newUri = "/test/newuri/1";
+        String uri = null;
+
+        try {
+            resource.setURI(newUri);
+            uri = resource.getURI();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(newUri, uri);
+    }
+
+    public void testSetURI_N01() {
+        String newUri = "";
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            resource.setURI(newUri);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertEquals(ExceptionType.INVALID_ARGS, exType);
+    }
+
+    public void testSetURI_N02() {
+        String newUri = null;
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            resource.setURI(newUri);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertEquals(ExceptionType.INVALID_ARGS, exType);
+    }
+
+    public void testSetResourceType_P01() {
+        String newResType = "test.newresource";
+        String resType = null;
+
+        try {
+            resource.setResourceType(newResType);
+            resType = resource.getResourceType();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(newResType, resType);
+    }
+
+    public void testSetResourceType_N01() {
+        String newResType = "";
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            resource.setResourceType(newResType);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertEquals(ExceptionType.INVALID_ARGS, exType);
+    }
+
+    public void testSetResourceType_N02() {
+        String newResType = null;
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            resource.setResourceType(newResType);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertEquals(ExceptionType.INVALID_ARGS, exType);
+    }
+
+    public void testSetObservable_P01() {
+        boolean newState = true;
+        boolean state = false;
+        try {
+            resource.setObservable(newState);
+            state = resource.isObservable();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(newState, state);
+    }
+
+    public void testSetObservable_P02() {
+        boolean newState = false;
+        boolean state = true;
+        try {
+            resource.setObservable(newState);
+            state = resource.isObservable();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(newState, state);
+    }
+
+    public void testIsObservable_P01() {
+        boolean state = false;
+
+        try {
+            state = resource.isObservable();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(true, state);
+    }
+
+    public void testIsStarted_P01() {
+        boolean state = true;
+
+        try {
+            state = resource.isStarted();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(false, state);
+    }
+
+    public void testIsStarted_P02() {
+        boolean state = false;
+
+        try {
+            resource.start();
+            state = resource.isStarted();
+            resource.stop();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(true, state);
+    }
+
+    public void testIsStarted_P03() {
+        boolean state = true;
+
+        try {
+            resource.start();
+            resource.stop();
+            state = resource.isStarted();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(false, state);
+    }
+
+    public void testStart_P01() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        ObjectHolder<SimulatorRemoteResource> resourceHolder = new ObjectHolder<>();
+        FindResourceCallbackListener listener = new FindResourceCallbackListener(
+                lockObject, resourceHolder);
+
+        try {
+            resource.start();
+            SimulatorManager.findResource(resource.getResourceType(), listener);
+
+            // Wait for the resource to found
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        try {
+            resource.stop();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertNotNull(resourceHolder.get());
+    }
+
+    public void testStop_P01() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        ObjectHolder<SimulatorRemoteResource> resourceHolder = new ObjectHolder<>();
+        FindResourceCallbackListener listener = new FindResourceCallbackListener(
+                lockObject, resourceHolder);
+
+        try {
+            resource.start();
+            resource.stop();
+            SimulatorManager.findResource(resource.getResourceType(), listener);
+
+            // Wait for the resource to found
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        try {
+            resource.stop();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertNull(resourceHolder.get());
+    }
+}
+
+class FindResourceCallbackListener implements FindResourceListener {
+
+    private CountDownLatch                        mLockObject;
+    private ObjectHolder<SimulatorRemoteResource> mResourceHolder;
+
+    public FindResourceCallbackListener(CountDownLatch lockObject,
+            ObjectHolder<SimulatorRemoteResource> resourceHolder) {
+        mLockObject = lockObject;
+        mResourceHolder = resourceHolder;
+    }
+
+    @Override
+    public void onResourceFound(SimulatorRemoteResource resource) {
+        mResourceHolder.set(resource);
+        mLockObject.countDown();
+    }
+}
\ No newline at end of file
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/server/test/SimulatorSingleResourceTest.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/server/test/SimulatorSingleResourceTest.java
new file mode 100644 (file)
index 0000000..b6bcc94
--- /dev/null
@@ -0,0 +1,649 @@
+/*
+ * 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.oic.simulator.server.test;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.oic.simulator.AttributeProperty;
+import org.oic.simulator.AttributeValue;
+import org.oic.simulator.InvalidArgsException;
+import org.oic.simulator.SimulatorException;
+import org.oic.simulator.SimulatorManager;
+import org.oic.simulator.SimulatorResourceAttribute;
+import org.oic.simulator.SimulatorResourceModel;
+import org.oic.simulator.server.SimulatorResource;
+import org.oic.simulator.server.SimulatorResource.AutoUpdateListener;
+import org.oic.simulator.server.SimulatorSingleResource;
+import org.oic.simulator.test.ExceptionType;
+import org.oic.simulator.utils.ObjectHolder;
+
+import junit.framework.TestCase;
+
+public class SimulatorSingleResourceTest extends TestCase {
+    static {
+        System.loadLibrary("SimulatorManager");
+        System.loadLibrary("RamlParser");
+        System.loadLibrary("oc");
+        System.loadLibrary("oc_logger");
+        System.loadLibrary("octbstack");
+    }
+
+    private static final String     SINGLE_RES_RAML = "./ramls/oic.r.light.raml";
+    private static final String     INT_KEY         = "Interger";
+    private static final String     DOUBLE_KEY      = "Double";
+    private static final String     BOOL_KEY        = "Boolean";
+    private static final String     STRING_KEY      = "String";
+    private SimulatorSingleResource singleResource  = null;
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        singleResource = (SimulatorSingleResource) SimulatorManager
+                .createResource(SimulatorResource.Type.SINGLE, "test-resource",
+                        "/test/resource", "test.resource");
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        singleResource = null;
+    }
+
+    SimulatorSingleResource createResourceFromRAML() {
+        try {
+            return (SimulatorSingleResource) SimulatorManager
+                    .createResource(SINGLE_RES_RAML);
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        return null;
+    }
+
+    public void testGetResourceModel_P01() {
+        SimulatorResourceModel resModel = null;
+
+        try {
+            SimulatorSingleResource resource = createResourceFromRAML();
+            resModel = resource.getResourceModel();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertNotNull(resModel);
+        assertTrue(resModel.size() > 0);
+    }
+
+    public void testAddAttributeInteger_P01() {
+        int result = -1;
+
+        try {
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    INT_KEY, new AttributeValue(2), null);
+            singleResource.addAttribute(attribute);
+            result = ((Integer) singleResource.getAttribute(INT_KEY).value()
+                    .get()).intValue();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(2, result);
+    }
+
+    public void testAddAttributeDouble_P01() {
+        double result = 0.0;
+
+        try {
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    DOUBLE_KEY, new AttributeValue(4.0), null);
+            singleResource.addAttribute(attribute);
+            result = ((Double) singleResource.getAttribute(DOUBLE_KEY).value()
+                    .get()).doubleValue();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(4.0, result);
+    }
+
+    public void testAddAttributeBoolean_P01() {
+        boolean result = false;
+
+        try {
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    BOOL_KEY, new AttributeValue(true), null);
+            singleResource.addAttribute(attribute);
+            result = ((Boolean) singleResource.getAttribute(BOOL_KEY).value()
+                    .get()).booleanValue();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(true, result);
+    }
+
+    public void testaddAttributeString_P01() {
+        String result = null;
+
+        try {
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    STRING_KEY, new AttributeValue("string-value"), null);
+            singleResource.addAttribute(attribute);
+            result = (String) singleResource.getAttribute(STRING_KEY).value()
+                    .get();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals("string-value", result);
+    }
+
+    public void testUpdateAttributeInteger_P01() {
+        int result = -1;
+
+        try {
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    INT_KEY, new AttributeValue(10), null);
+            singleResource.addAttribute(attribute);
+            singleResource.updateAttribute(INT_KEY, new AttributeValue(12));
+            result = ((Integer) singleResource.getAttribute(INT_KEY).value()
+                    .get()).intValue();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(12, result);
+    }
+
+    public void testUpdateAttributeDouble_P01() {
+        double result = 0.0;
+
+        try {
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    DOUBLE_KEY, new AttributeValue(22.0), null);
+            singleResource.addAttribute(attribute);
+            singleResource
+                    .updateAttribute(DOUBLE_KEY, new AttributeValue(25.3));
+            result = ((Double) singleResource.getAttribute(DOUBLE_KEY).value()
+                    .get()).doubleValue();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(25.3, result);
+    }
+
+    public void testUpdateAttributeBoolean_P01() {
+        boolean result = true;
+
+        try {
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    BOOL_KEY, new AttributeValue(true), null);
+            singleResource.addAttribute(attribute);
+            singleResource.updateAttribute(BOOL_KEY, new AttributeValue(false));
+            result = ((Boolean) singleResource.getAttribute(BOOL_KEY).value()
+                    .get()).booleanValue();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(false, result);
+    }
+
+    public void testupdateAttributeString_P01() {
+        String result = null;
+
+        try {
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    STRING_KEY, new AttributeValue("old-value"), null);
+            singleResource.addAttribute(attribute);
+            singleResource.updateAttribute(STRING_KEY, new AttributeValue(
+                    "new-value"));
+            result = (String) singleResource.getAttribute(STRING_KEY).value()
+                    .get();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals("new-value", result);
+    }
+
+    public void testSetRange_P01() {
+        int result = -1;
+
+        try {
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    INT_KEY, new AttributeValue(10), new AttributeProperty(1,
+                            12));
+            singleResource.addAttribute(attribute);
+            singleResource.updateAttribute(INT_KEY, new AttributeValue(3));
+            result = ((Integer) singleResource.getAttribute(INT_KEY).value()
+                    .get()).intValue();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(3, result);
+    }
+
+    public void testSetRange_N01() {
+        int result = -1;
+
+        try {
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    INT_KEY, new AttributeValue(10), new AttributeProperty(1,
+                            12));
+            singleResource.addAttribute(attribute);
+            singleResource.updateAttribute(INT_KEY, new AttributeValue(13));
+            result = ((Integer) singleResource.getAttribute(INT_KEY).value()
+                    .get()).intValue();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(10, result);
+    }
+
+    public void testSetAllowedValuesInteger_P01() {
+        int result = -1;
+
+        try {
+            int[] values = { 1, 10, 20, 50 };
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    INT_KEY, new AttributeValue(10), new AttributeProperty(
+                            values));
+            singleResource.addAttribute(attribute);
+            singleResource.updateAttribute(INT_KEY, new AttributeValue(20));
+            result = ((Integer) singleResource.getAttribute(INT_KEY).value()
+                    .get()).intValue();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(20, result);
+    }
+
+    public void testSetAllowedValuesInteger_N01() {
+        int result = -1;
+
+        try {
+            int[] values = { 1, 10, 20, 50 };
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    INT_KEY, new AttributeValue(10), new AttributeProperty(
+                            values));
+            singleResource.addAttribute(attribute);
+            singleResource.updateAttribute(INT_KEY, new AttributeValue(15));
+            result = ((Integer) singleResource.getAttribute(INT_KEY).value()
+                    .get()).intValue();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(10, result);
+    }
+
+    public void testSetAllowedValuesDouble_P01() {
+        double result = 0.0;
+
+        try {
+            double[] values = { 11.5, 10.5, 20.5, 50.5 };
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    DOUBLE_KEY, new AttributeValue(11.5),
+                    new AttributeProperty(values));
+            singleResource.addAttribute(attribute);
+            singleResource
+                    .updateAttribute(DOUBLE_KEY, new AttributeValue(10.5));
+            result = ((Double) singleResource.getAttribute(DOUBLE_KEY).value()
+                    .get()).doubleValue();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(10.5, result);
+    }
+
+    public void testSetAllowedValuesDouble_N01() {
+        double result = 0.0;
+
+        try {
+            double[] values = { 11.5, 10.5, 20.5, 50.5 };
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    DOUBLE_KEY, new AttributeValue(11.5),
+                    new AttributeProperty(values));
+            singleResource.addAttribute(attribute);
+            singleResource.updateAttribute(DOUBLE_KEY, new AttributeValue(2.2));
+            result = ((Double) singleResource.getAttribute(DOUBLE_KEY).value()
+                    .get()).doubleValue();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals(11.5, result);
+    }
+
+    public void testsetAllowedValuesString_P01() {
+        String result = null;
+
+        try {
+            String[] values = { "monday", "tuesday", "wednesday" };
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    STRING_KEY, new AttributeValue("monday"),
+                    new AttributeProperty(values));
+            singleResource.addAttribute(attribute);
+            singleResource.updateAttribute(STRING_KEY, new AttributeValue(
+                    "tuesday"));
+            result = (String) singleResource.getAttribute(STRING_KEY).value()
+                    .get();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals("tuesday", result);
+    }
+
+    public void testsetAllowedValuesString_N01() {
+        String result = null;
+
+        try {
+            String[] values = { "monday", "tuesday", "wednesday" };
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    STRING_KEY, new AttributeValue("monday"),
+                    new AttributeProperty(values));
+            singleResource.addAttribute(attribute);
+            singleResource.updateAttribute(STRING_KEY, new AttributeValue(
+                    "friday"));
+            result = (String) singleResource.getAttribute(STRING_KEY).value()
+                    .get();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertEquals("monday", result);
+    }
+
+    public void testRemoveAttribute_P01() {
+        SimulatorResourceAttribute result = null;
+
+        try {
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    STRING_KEY, new AttributeValue("friday"), null);
+            singleResource.addAttribute(attribute);
+            singleResource.removeAttribute(STRING_KEY);
+            result = singleResource.getAttribute(STRING_KEY);
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertNull(result);
+    }
+
+    public void testRemoveAttribute_N02() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                    STRING_KEY, new AttributeValue("friday"), null);
+            singleResource.addAttribute(attribute);
+            singleResource.removeAttribute(null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertEquals(ExceptionType.INVALID_ARGS, exType);
+    }
+
+    public void testRemoveAttribute_N03() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            singleResource.removeAttribute("");
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertEquals(ExceptionType.INVALID_ARGS, exType);
+    }
+
+    public void testStartResourceAutomation_P01() {
+        SimulatorSingleResource resource = createResourceFromRAML();
+        if (null == resource)
+            return;
+
+        CountDownLatch lockObject = new CountDownLatch(1);
+        ObjectHolder<AutoUpdateInfo> autoUpdateHolder = new ObjectHolder<>();
+        AutoUpdateCompleteListener automationListener = new AutoUpdateCompleteListener(
+                lockObject, autoUpdateHolder);
+        int id = -1;
+
+        try {
+            resource.start();
+            id = resource.startResourceUpdation(
+                    SimulatorResource.AutoUpdateType.REPEAT, 1000,
+                    automationListener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+
+            resource.stopUpdation(id);
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        try {
+            resource.stop();
+            resource.stopUpdation(id);
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertNotNull(autoUpdateHolder.get());
+        assertEquals(id, autoUpdateHolder.get().getId());
+    }
+
+    public void testStartResourceAutomation_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            singleResource.startResourceUpdation(
+                    SimulatorResource.AutoUpdateType.ONE_TIME, 500, null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertEquals(ExceptionType.INVALID_ARGS, exType);
+    }
+
+    public void testStartAttributeAutomation_P01() {
+        SimulatorSingleResource resource = createResourceFromRAML();
+        if (null == resource)
+            return;
+
+        String attributeName = null;
+        try {
+            for (SimulatorResourceAttribute resAttribute : resource
+                    .getResourceModel().getAttributes().values())
+                attributeName = resAttribute.name();
+        } catch (SimulatorException e1) {
+            e1.printStackTrace();
+        }
+
+        if (null == attributeName)
+            return;
+
+        CountDownLatch lockObject = new CountDownLatch(1);
+        ObjectHolder<AutoUpdateInfo> autoUpdateHolder = new ObjectHolder<>();
+        AutoUpdateCompleteListener automationListener = new AutoUpdateCompleteListener(
+                lockObject, autoUpdateHolder);
+        int id = -1;
+
+        try {
+            resource.start();
+            id = resource.startAttributeUpdation(attributeName,
+                    SimulatorResource.AutoUpdateType.REPEAT, 100,
+                    automationListener);
+
+            try {
+                lockObject.await(10, TimeUnit.SECONDS);
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+
+            resource.stopUpdation(id);
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        try {
+            resource.stop();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertNotNull(autoUpdateHolder.get());
+        assertEquals(id, autoUpdateHolder.get().getId());
+    }
+
+    public void testStartAttributeAutomation_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            singleResource.startAttributeUpdation("intensity",
+                    SimulatorResource.AutoUpdateType.ONE_TIME, 1000, null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertEquals(ExceptionType.INVALID_ARGS, exType);
+    }
+
+    public void testStopUpdation_P01() {
+        SimulatorSingleResource resource = createResourceFromRAML();
+        if (null == resource)
+            return;
+
+        CountDownLatch lockObject = new CountDownLatch(1);
+        ObjectHolder<AutoUpdateInfo> autoUpdateHolder = new ObjectHolder<>();
+        AutoUpdateCompleteListener automationListener = new AutoUpdateCompleteListener(
+                lockObject, autoUpdateHolder);
+        boolean result = false;
+        try {
+            resource.start();
+            int id = resource.startResourceUpdation(
+                    SimulatorResource.AutoUpdateType.REPEAT, 1000,
+                    automationListener);
+            resource.stopUpdation(id);
+            result = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        try {
+            resource.stop();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(result);
+    }
+}
+
+class AutoUpdateInfo {
+    private String uri = null;
+    private int    id  = -1;
+
+    AutoUpdateInfo(String uri, int id) {
+        this.uri = uri;
+        this.id = id;
+    }
+
+    public String getUri() {
+        return uri;
+    }
+
+    public int getId() {
+        return id;
+    }
+}
+
+class AutoUpdateCompleteListener implements AutoUpdateListener {
+    private CountDownLatch               lock;
+    private ObjectHolder<AutoUpdateInfo> autoUpdateHolder;
+
+    public AutoUpdateCompleteListener(CountDownLatch lock,
+            ObjectHolder<AutoUpdateInfo> autoUpdateHolder) {
+        this.lock = lock;
+        this.autoUpdateHolder = autoUpdateHolder;
+    }
+
+    @Override
+    public void onUpdateComplete(String uri, int id) {
+        autoUpdateHolder.set(new AutoUpdateInfo(uri, id));
+        lock.countDown();
+    }
+}
\ No newline at end of file
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/AutomationListener.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/AutomationListener.java
deleted file mode 100644 (file)
index cb545db..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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.oic.simulator.serviceprovider.test;
-
-import java.util.concurrent.CountDownLatch;
-import org.oic.simulator.IAutomation;
-
-/**
- * This class implements methods for receiving notifications on
- * completion of automation.
- */
-public class AutomationListener implements IAutomation
-{
-
-    private CountDownLatch lockObject;
-    private AutomationObject automationObject;
-
-    public AutomationListener(CountDownLatch lockObject, AutomationObject automationObject)
-    {
-        this.lockObject = lockObject;
-        this.automationObject = automationObject;
-    }
-
-    @Override
-    public void onAutomationComplete(String resourceURI, int automationId)
-    {
-        automationObject.setAutomationId(automationId);
-        automationObject.setResourceURI(resourceURI);
-
-        lockObject.countDown();
-    }
-}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/Observer.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/Observer.java
deleted file mode 100644 (file)
index ca69964..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.oic.simulator.serviceprovider.test;
-
-import java.util.concurrent.CountDownLatch;
-
-import org.oic.simulator.serviceprovider.IObserver;
-import org.oic.simulator.serviceprovider.ObserverInfo;
-
-/**
- * This class implements methods for receiving observer
- * change callbacks.
- */
-public class Observer implements IObserver
-{
-    private CountDownLatch lockObject;
-    private ObserverObject observerObject;
-
-    public Observer(CountDownLatch lockObject, ObserverObject observerObject)
-    {
-        this.lockObject = lockObject;
-        this.observerObject = observerObject;
-    }
-
-    @Override
-    public void onObserverChanged(String resourceURI, int state, ObserverInfo observer)
-    {
-        observerObject.setState(state);
-        observerObject.setResourceURI(resourceURI);
-        observerObject.setObserver(observer);
-
-        lockObject.countDown();
-    }
-}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/ObserverObject.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/ObserverObject.java
deleted file mode 100644 (file)
index 14bd6a1..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.oic.simulator.serviceprovider.test;
-
-import org.oic.simulator.serviceprovider.ObserverInfo;
-
-/**
- * This class provides methods to set/get observers and state
- * information.
- */
-public class ObserverObject
-{
-    private String resourceURI;
-    private int state;
-    private ObserverInfo observer;
-
-    public void setResourceURI(String resourceURI)
-    {
-        this.resourceURI = resourceURI;
-    }
-
-    public String getResourceURI()
-    {
-        return resourceURI;
-    }
-
-    public void setState(int state)
-    {
-        this.state = state;
-    }
-
-    public int getState()
-    {
-        return state;
-    }
-
-    public void setObserver(ObserverInfo observer)
-    {
-        this.observer = observer;
-    }
-
-    public ObserverInfo getObserver()
-    {
-        return observer;
-    }
-}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/SimlatorResourceServerTest.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/SimlatorResourceServerTest.java
deleted file mode 100644 (file)
index cfbe5d2..0000000
+++ /dev/null
@@ -1,936 +0,0 @@
-/*
- * 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.oic.simulator.serviceprovider.test;
-
-import java.util.Vector;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import junit.framework.TestCase;
-
-import org.oic.simulator.InvalidArgsException;
-import org.oic.simulator.ResourceAttribute;
-import org.oic.simulator.SimulatorException;
-import org.oic.simulator.SimulatorManager;
-import org.oic.simulator.SimulatorResourceModel;
-import org.oic.simulator.serviceprovider.AutomationType;
-import org.oic.simulator.serviceprovider.SimulatorResourceServer;
-import org.oic.simulator.test.ResourceModelChangeListener;
-import org.oic.simulator.test.ResourceModelObject;
-
-/**
- * This class tests the functionality of Simulator Resource Server
- * class APIs.
- */
-public class SimlatorResourceServerTest extends TestCase
-{
-
-    private static final String CONFIG_PATH = "./ramls/simple-light.raml";
-
-    private static final String KEY = "testkey";
-
-    private CountDownLatch lockObject;
-    private ResourceModelObject resourceModelObject;
-    private ResourceModelChangeListener resourceModelChangeListener;
-
-    private SimulatorResourceServer simulatorResourceServer;
-
-    static
-    {
-        System.loadLibrary("SimulatorManager");
-        System.loadLibrary("RamlParser");
-        System.loadLibrary("oc");
-        System.loadLibrary("oc_logger");
-        System.loadLibrary("octbstack");
-    }
-
-    protected void setUp() throws Exception
-    {
-        super.setUp();
-        lockObject= new CountDownLatch(1);
-        resourceModelObject = new ResourceModelObject();
-        resourceModelChangeListener = new ResourceModelChangeListener(resourceModelObject);
-        simulatorResourceServer = SimulatorManager.createResource(CONFIG_PATH, resourceModelChangeListener);
-    }
-
-    protected void tearDown() throws Exception
-    {
-        super.tearDown();
-
-        SimulatorManager.deleteResource(simulatorResourceServer);
-
-        lockObject = null;
-        resourceModelObject = null;
-        resourceModelChangeListener = null;
-
-        simulatorResourceServer = null;
-    }
-
-    public void testGetURI_P01()
-    {
-        assertNotNull(simulatorResourceServer.getURI());
-    }
-
-    public void testGetResourceType_P01()
-    {
-        assertNotNull(simulatorResourceServer.getResourceType());
-    }
-
-    public void testGetInterfaceType_P01()
-    {
-        assertNotNull(simulatorResourceServer.getInterfaceType());
-    }
-
-    public void testGetModel_P01()
-    {
-        boolean result = false;
-
-        try
-        {
-            if(simulatorResourceServer.getModel() != null && simulatorResourceServer.getModel().size() > 0)
-                result = true;
-        }
-        catch (InvalidArgsException e)
-        {
-            e.printStackTrace();
-        }
-        catch (SimulatorException e)
-        {
-            e.printStackTrace();
-        }
-
-        assertTrue(result);
-    }
-
-    public void testAddAttributeInteger_P01()
-    {
-        try
-        {
-            simulatorResourceServer.addAttributeInteger(KEY, 2);
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-        assertEquals(Integer.parseInt(getValue(KEY) + ""), 2);
-    }
-
-    public void testAddAttributeDouble_P01()
-    {
-        try
-        {
-            simulatorResourceServer.addAttributeDouble(KEY, 4.0);
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-        assertEquals(Double.parseDouble(getValue(KEY) + ""), 4.0);
-    }
-
-    public void testAddAttributeBoolean_P01()
-    {
-        try
-        {
-            simulatorResourceServer.addAttributeBoolean(KEY, Boolean.parseBoolean("true"));
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-        assertEquals(Boolean.parseBoolean(getValue(KEY).toString() + ""), true);
-    }
-
-    public void testaddAttributeString_P01()
-    {
-        try
-        {
-            simulatorResourceServer.addAttributeString(KEY, "test");
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-        assertEquals(getValue(KEY) + "", "test");
-    }
-
-    public void testUpdateAttributeInteger_P01()
-    {
-        boolean result = true;
-
-        try
-        {
-            simulatorResourceServer.addAttributeInteger(KEY, 10);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && Integer.parseInt(getValue(KEY) + "") == 10;
-
-        try
-        {
-            simulatorResourceServer.updateAttributeInteger(KEY, 12);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-        result = result && Integer.parseInt(getValue(KEY) + "") == 12;
-
-        assertTrue(result);
-    }
-
-    public void testUpdateAttributeDouble_P01()
-    {
-        boolean result = true;
-
-        try
-        {
-            simulatorResourceServer.addAttributeDouble(KEY, 22.0);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && Double.parseDouble(getValue(KEY) + "") == 22.0;
-
-        try
-        {
-            simulatorResourceServer.updateAttributeDouble(KEY, 25.3);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && Double.parseDouble(getValue(KEY) + "") == 25.3;
-
-        assertTrue(result);
-    }
-
-    public void testUpdateAttributeBoolean_P01()
-    {
-        boolean result = true;
-
-        try
-        {
-            simulatorResourceServer.addAttributeBoolean(KEY, Boolean.parseBoolean("true"));
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && Boolean.parseBoolean(getValue(KEY) + "")==true;
-
-        try
-        {
-            simulatorResourceServer.updateAttributeBoolean(KEY, Boolean.parseBoolean("false"));
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && !Boolean.parseBoolean(getValue(KEY) + "");
-
-        assertTrue(result);
-    }
-
-    public void testupdateAttributeString_P01()
-    {
-        boolean result = true;
-
-        try
-        {
-            simulatorResourceServer.addAttributeString(KEY, "old");
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && getValue(KEY).equals("old");
-
-        try
-        {
-            simulatorResourceServer.updateAttributeString(KEY, "new");
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && getValue(KEY).equals("new");
-
-        assertTrue(result);
-    }
-
-    public void testSetRange_P01()
-    {
-        boolean result = true;
-
-        try
-        {
-            simulatorResourceServer.addAttributeInteger(KEY, 10);
-            simulatorResourceServer.setRange(KEY, 1, 12);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && Integer.parseInt(getValue(KEY) + "") == 10;
-
-        try
-        {
-            simulatorResourceServer.updateAttributeInteger(KEY, 3);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && Integer.parseInt(getValue(KEY) + "") == 3;
-
-        assertTrue(result);
-    }
-
-    /**
-     * Try to set the value out of range
-     */
-    public void testSetRange_N01()
-    {
-        boolean result = true;
-
-        try
-        {
-            simulatorResourceServer.addAttributeInteger(KEY, 10);
-            simulatorResourceServer.setRange(KEY, 1, 12);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && Integer.parseInt(getValue(KEY) + "") == 10;
-
-        try
-        {
-            simulatorResourceServer.updateAttributeInteger(KEY, 13);
-            result = false;
-        }
-        catch (Exception e)
-        {
-            result = true;
-        }
-
-        result = result && Integer.parseInt(getValue(KEY) + "") == 10;
-
-        assertTrue(result);
-    }
-
-    public void testSetAllowedValuesInteger_P01()
-    {
-        boolean result = true;
-
-        try
-        {
-            simulatorResourceServer.addAttributeInteger(KEY, 10);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        Vector<Integer> values = new Vector<Integer>();
-        values.add(1);
-        values.add(10);
-        values.add(20);
-        values.add(50);
-
-        try
-        {
-            simulatorResourceServer.setAllowedValuesInteger(KEY, values);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && Integer.parseInt(getValue(KEY) + "") == 10;
-
-        try
-        {
-            simulatorResourceServer.updateAttributeInteger(KEY, 20);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && Integer.parseInt(getValue(KEY) + "") == 20;
-
-        assertTrue(result);
-    }
-
-    /**
-     * Try setting with out of range
-     */
-    public void testSetAllowedValuesInteger_N01()
-    {
-        boolean result = true;
-
-        try
-        {
-            simulatorResourceServer.addAttributeInteger(KEY, 10);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        Vector<Integer> values = new Vector<Integer>();
-        values.add(1);
-        values.add(10);
-        values.add(20);
-        values.add(50);
-
-        try
-        {
-            simulatorResourceServer.setAllowedValuesInteger(KEY, values);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && Integer.parseInt(getValue(KEY) + "") == 10;
-
-        try
-        {
-            simulatorResourceServer.updateAttributeInteger(KEY, 2);
-            result = false;
-        }
-        catch (Exception e)
-        {
-            result = true;
-        }
-
-        result = result && Integer.parseInt(getValue(KEY) + "") == 10;
-
-        assertTrue(result);
-    }
-
-    /**
-     * Try setting values multiple times
-     */
-    public void testSetAllowedValuesDouble_P01()
-    {
-        boolean result = true;
-
-        try
-        {
-            simulatorResourceServer.addAttributeDouble(KEY, 11.5);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        Vector<Double> values = new Vector<Double>();
-        values.add(11.5);
-        values.add(10.5);
-        values.add(20.5);
-        values.add(50.5);
-
-        try
-        {
-            simulatorResourceServer.setAllowedValuesDouble(KEY, values);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && Double.parseDouble(getValue(KEY) + "") == 11.5;
-
-        try
-        {
-            simulatorResourceServer.updateAttributeDouble(KEY, 10.5);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && Double.parseDouble(getValue(KEY) + "") == 10.5;
-
-        assertTrue(result);
-    }
-
-    /**
-     * Try setting with out of range
-     */
-    public void testSetAllowedValuesDouble_N01()
-    {
-        boolean result = true;
-
-        try
-        {
-            simulatorResourceServer.addAttributeDouble(KEY, 10.5);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        Vector<Double> values = new Vector<Double>();
-        values.add(11.5);
-        values.add(10.5);
-        values.add(20.5);
-        values.add(50.5);
-
-        try
-        {
-            simulatorResourceServer.setAllowedValuesDouble(KEY, values);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && Double.parseDouble(getValue(KEY) + "") == 10.5;
-
-        try
-        {
-            simulatorResourceServer.updateAttributeDouble(KEY, 2.2);
-            result = false;
-        }
-        catch (Exception e)
-        {
-            result = true;
-        }
-
-        result = result && Double.parseDouble(getValue(KEY) + "") == 10.5;
-
-        assertTrue(result);
-    }
-
-    public void testsetAllowedValuesString_P01()
-    {
-        boolean result = true;
-
-        try
-        {
-            simulatorResourceServer.addAttributeString(KEY, "mon");
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        Vector<String> values = new Vector<String>();
-        values.add("mon");
-        values.add("tue");
-        values.add("wed");
-
-        try
-        {
-            simulatorResourceServer.setAllowedValuesString(KEY, values);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && getValue(KEY).equals("mon");
-
-        try
-        {
-            simulatorResourceServer.updateAttributeString(KEY, "tue");
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && getValue(KEY).equals("tue");
-
-        assertTrue(result);
-    }
-
-    /**
-     * Set the value that is not in allowed values
-     */
-    public void testsetAllowedValuesString_N01()
-    {
-        boolean result = true;
-
-        try
-        {
-            simulatorResourceServer.addAttributeString(KEY, "mon");
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        Vector<String> values = new Vector<String>();
-        values.add("mon");
-        values.add("tue");
-        values.add("wed");
-
-        try
-        {
-            simulatorResourceServer.setAllowedValuesString(KEY, values);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && getValue(KEY).equals("mon");
-
-        try
-        {
-            simulatorResourceServer.updateAttributeString(KEY, "thu");
-            result = false;
-        }
-        catch (Exception e)
-        {
-            result = true;
-        }
-
-        result = result && getValue(KEY).equals("mon");
-
-        assertTrue(result);
-    }
-
-    public void testRemoveAttribute_P01()
-    {
-        boolean result = true;
-
-        try
-        {
-            simulatorResourceServer.addAttributeString(KEY, "fri");
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        result = result && getValue(KEY).equals("fri");
-
-        try
-        {
-            simulatorResourceServer.removeAttribute(KEY);
-            result = result && !simulatorResourceServer.getModel().getAttributes().containsKey(KEY);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        assertTrue(result);
-    }
-
-    /**
-     * Try removing the attribute thats not present
-     */
-    public void testRemoveAttribute_N01()
-    {
-        boolean result = false;
-
-        try
-        {
-            simulatorResourceServer.removeAttribute("something");
-        }
-        catch (Exception e)
-        {
-            result = true;
-        }
-
-        assertTrue(result);
-    }
-
-    /**
-     * Try removing when null is passed
-     */
-    public void testRemoveAttribute_N02()
-    {
-        boolean result = false;
-
-        try
-        {
-            simulatorResourceServer.removeAttribute(null);
-        }
-        catch (Exception e)
-        {
-            result = true;
-        }
-
-        assertTrue(result);
-    }
-
-    /**
-     * Try removing when attribute is empty
-     */
-    public void testRemoveAttribute_N03()
-    {
-        boolean result = false;
-
-        try
-        {
-            simulatorResourceServer.removeAttribute("");
-        }
-        catch (Exception e)
-        {
-            result = true;
-        }
-
-        assertTrue(result);
-    }
-
-    public void testStartResourceAutomation_P01()
-    {
-        boolean result = true;
-        lockObject = new CountDownLatch(1);
-        AutomationObject automationObject = new AutomationObject();
-        AutomationListener automationListener = new AutomationListener(lockObject, automationObject);
-        int id = 0;
-        try
-        {
-            id = simulatorResourceServer.startResourceAutomation(AutomationType.NORMAL, automationListener);
-        }
-        catch (Exception e)
-        {
-            result = false;
-            e.printStackTrace();
-        }
-
-        try
-        {
-            lockObject.await(15,TimeUnit.SECONDS);
-        }
-        catch (InterruptedException e)
-        {
-            e.printStackTrace();
-        }
-
-        assertTrue(result && automationObject.getResourceURI() != null && automationObject.getAutomationId() != -1 && id != -1);
-
-        try
-        {
-            simulatorResourceServer.stopAutomation(id);
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * null listener
-     */
-    public void testStartResourceAutomation_N01()
-    {
-        boolean result = true;
-        int id = 0;
-        try
-        {
-            id = simulatorResourceServer.startResourceAutomation(AutomationType.NORMAL, null);
-        }
-        catch (Exception e)
-        {
-            result = false;
-        }
-        assertTrue(!result && id == 0);
-    }
-
-    public void testStartAttributeAutomation_P01()
-    {
-        boolean result = true;
-        lockObject = new CountDownLatch(1);
-        AutomationObject automationObject = new AutomationObject();
-        AutomationListener automationListener = new AutomationListener(lockObject, automationObject);
-        int id = 0;
-        try
-        {
-            simulatorResourceServer.addAttributeInteger(KEY, 10);
-            id = simulatorResourceServer.startAttributeAutomation(KEY,
-                    AutomationType.NORMAL, automationListener);
-        }
-        catch (Exception e)
-        {
-            result = false;
-        }
-
-        try
-        {
-            lockObject.await(10, TimeUnit.SECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        assertTrue(result && automationObject.getResourceURI() != null && automationObject.getAutomationId() != -1 && id != -1);
-
-        try
-        {
-            simulatorResourceServer.stopAutomation(id);
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-    }
-
-    /**
-     * null listener
-     */
-    public void testStartAttributeAutomation_N01()
-    {
-        boolean result = false;
-        int id = 0;
-        try
-        {
-            id = simulatorResourceServer.startAttributeAutomation(simulatorResourceServer.getModel().getAttributes().get(0).getName(),
-                    AutomationType.NORMAL, null);
-            result = false;
-        }
-        catch (Exception e)
-        {
-            result = true;
-        }
-
-        assertTrue(result && id != -1);
-    }
-
-    public void testStopAutomation_P01()
-    {
-        boolean result = true;
-
-        lockObject = new CountDownLatch(1);
-
-        AutomationObject automationObject = new AutomationObject();
-        AutomationListener automationListener = new AutomationListener(lockObject, automationObject);
-
-        int id = 0;
-        try
-        {
-            id = simulatorResourceServer.startResourceAutomation(AutomationType.NORMAL, automationListener);
-        }
-        catch(Exception e)
-        {
-            result = false;
-        }
-
-        try
-        {
-            lockObject.await(05, TimeUnit.SECONDS);
-        }
-        catch (InterruptedException e)
-        {
-        }
-
-        try
-        {
-            simulatorResourceServer.stopAutomation(id);
-        }
-        catch(Exception e)
-        {
-            result = false;
-        }
-
-        assertTrue(result);
-    }
-
-    /**
-     * checking for crash
-     * random id
-     */
-    public void testStopAutomation_N01()
-    {
-        boolean result = false;
-        try
-        {
-            simulatorResourceServer.stopAutomation(144353544);
-        }
-        catch (Exception e)
-        {
-            result = true;
-            e.printStackTrace();
-        }
-        assertTrue(result);
-    }
-
-    private Object getValue(Object key)
-    {
-        SimulatorResourceModel simulatorResourceModel = null;
-        try
-        {
-            simulatorResourceModel = simulatorResourceServer.getModel();
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
-        }
-
-        ResourceAttribute resourceAttribute = null;
-        try
-        {
-            resourceAttribute = simulatorResourceModel.getAttributes().get(key);
-        }
-        catch (SimulatorException e)
-        {
-            e.printStackTrace();
-        }
-        return resourceAttribute.getValue();
-    }
-}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/AttributeValueTest.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/AttributeValueTest.java
new file mode 100644 (file)
index 0000000..f382716
--- /dev/null
@@ -0,0 +1,478 @@
+/*
+ * 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.oic.simulator.test;
+
+import org.oic.simulator.AttributeValue;
+import org.oic.simulator.InvalidArgsException;
+import org.oic.simulator.SimulatorResourceModel;
+
+import junit.framework.TestCase;
+
+public class AttributeValueTest extends TestCase {
+    private static final String INT_KEY    = "Interger";
+    private static final String DOUBLE_KEY = "Double";
+    private static final String BOOL_KEY   = "Boolean";
+    private static final String STRING_KEY = "String";
+
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testAttributeValueInt_P01() {
+        AttributeValue value = new AttributeValue(5);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.INTEGER
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.INTEGER
+                && value.typeInfo().mDepth == 0);
+    }
+
+    public void testAttributeValueInt_P02() {
+        AttributeValue attribute = new AttributeValue(new Integer(5));
+        assertNotNull(attribute);
+        assertTrue(attribute.typeInfo() != null
+                && attribute.typeInfo().mType == AttributeValue.ValueType.INTEGER
+                && attribute.typeInfo().mBaseType == AttributeValue.ValueType.INTEGER
+                && attribute.typeInfo().mDepth == 0);
+    }
+
+    public void testAttributeValueDouble_P01() {
+        AttributeValue value = new AttributeValue(5.00);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.DOUBLE
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.DOUBLE
+                && value.typeInfo().mDepth == 0);
+    }
+
+    public void testAttributeValueDouble_P02() {
+        AttributeValue value = new AttributeValue(new Double(5.00));
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.DOUBLE
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.DOUBLE
+                && value.typeInfo().mDepth == 0);
+    }
+
+    public void testAttributeValueBoolean_P01() {
+        AttributeValue value = new AttributeValue(true);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.BOOLEAN
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.BOOLEAN
+                && value.typeInfo().mDepth == 0);
+    }
+
+    public void testAttributeValueBoolean_P02() {
+        AttributeValue value = new AttributeValue(new Boolean(true));
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.BOOLEAN
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.BOOLEAN
+                && value.typeInfo().mDepth == 0);
+    }
+
+    public void testAttributeValueString_P01() {
+        AttributeValue value = new AttributeValue("String");
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.STRING
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.STRING
+                && value.typeInfo().mDepth == 0);
+    }
+
+    public void testAttributeValueString_P02() {
+        AttributeValue value = new AttributeValue(new String("String"));
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.STRING
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.STRING
+                && value.typeInfo().mDepth == 0);
+    }
+
+    public void testAttributeValueSimulatorResourceModel() {
+        SimulatorResourceModel model = new SimulatorResourceModel();
+        try {
+            model.addAttribute(INT_KEY, new AttributeValue(1));
+            model.addAttribute(DOUBLE_KEY, new AttributeValue(1.00));
+            model.addAttribute(BOOL_KEY, new AttributeValue(true));
+            model.addAttribute(STRING_KEY, new AttributeValue("string"));
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        }
+
+        if (model.size() != 4)
+            fail("Failed to construct model for continuing test!");
+
+        AttributeValue value = new AttributeValue(model);
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.RESOURCEMODEL
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.RESOURCEMODEL
+                && value.typeInfo().mDepth == 0);
+    }
+
+    public void testAttributeValueIntArray_P01() {
+        int[] array = { 1, 2, 3 };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.INTEGER
+                && value.typeInfo().mDepth == 1);
+    }
+
+    public void testAttributeValueIntArray_P02() {
+        Integer[] array = { new Integer(1), new Integer(2), new Integer(3) };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.INTEGER
+                && value.typeInfo().mDepth == 1);
+    }
+
+    public void testAttributeValueDoubleArray_P01() {
+        double[] array = { 1.00, 2.00, 3.00 };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.DOUBLE
+                && value.typeInfo().mDepth == 1);
+    }
+
+    public void testAttributeValueDoubleArray_P02() {
+        Double[] array = { new Double(1.00), new Double(2.00), new Double(3.00) };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.DOUBLE
+                && value.typeInfo().mDepth == 1);
+    }
+
+    public void testAttributeValueBooleanArray_P01() {
+        boolean[] array = { true };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.BOOLEAN
+                && value.typeInfo().mDepth == 1);
+    }
+
+    public void testAttributeValueBooleanArray_P02() {
+        boolean[] array = { new Boolean(true) };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.BOOLEAN
+                && value.typeInfo().mDepth == 1);
+    }
+
+    public void testAttributeValueStringArray_P01() {
+        String[] array = { "string1", "string2" };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.STRING
+                && value.typeInfo().mDepth == 1);
+    }
+
+    public void testAttributeValueStringArray_P02() {
+        String[] array = { new String("string1"), new String("string2") };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.STRING
+                && value.typeInfo().mDepth == 1);
+    }
+
+    public void testAttributeValueSimulatorResourceModelArray() {
+        SimulatorResourceModel childModel = new SimulatorResourceModel();
+        try {
+            childModel.addAttribute(INT_KEY, new AttributeValue(1));
+            childModel.addAttribute(DOUBLE_KEY, new AttributeValue(1.00));
+            childModel.addAttribute(BOOL_KEY, new AttributeValue(true));
+            childModel.addAttribute(STRING_KEY, new AttributeValue("string"));
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        }
+
+        if (childModel.size() != 4)
+            fail("Failed to construct model for continuing test!");
+
+        SimulatorResourceModel[] array = { childModel };
+
+        AttributeValue value = new AttributeValue(array);
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.RESOURCEMODEL
+                && value.typeInfo().mDepth == 1);
+    }
+
+    public void testAttributeValueIntArrayArray_P01() {
+        int[][] array = { { 1, 2, 3 } };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.INTEGER
+                && value.typeInfo().mDepth == 2);
+    }
+
+    public void testAttributeValueIntArrayArray_P02() {
+        Integer[][] array = { { new Integer(1), new Integer(2), new Integer(3) } };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.INTEGER
+                && value.typeInfo().mDepth == 2);
+    }
+
+    public void testAttributeValueDoubleArrayArray_P01() {
+        double[][] array = { { 1.00, 2.00, 3.00 } };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.DOUBLE
+                && value.typeInfo().mDepth == 2);
+    }
+
+    public void testAttributeValueDoubleArrayArray_P02() {
+        Double[][] array = { { new Double(1.00), new Double(2.00),
+                new Double(3.00) } };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.DOUBLE
+                && value.typeInfo().mDepth == 2);
+    }
+
+    public void testAttributeValueBooleanArrayArray_P01() {
+        boolean[][] array = { { true } };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.BOOLEAN
+                && value.typeInfo().mDepth == 2);
+    }
+
+    public void testAttributeValueBooleanArrayArray_P02() {
+        Boolean[][] array = { { new Boolean(true) } };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.BOOLEAN
+                && value.typeInfo().mDepth == 2);
+    }
+
+    public void testAttributeValueStringArrayArray_P01() {
+        String[][] array = { { "string" } };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.STRING
+                && value.typeInfo().mDepth == 2);
+    }
+
+    public void testAttributeValueStringArrayArray_P02() {
+        String[][] array = { { new String("string") } };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.STRING
+                && value.typeInfo().mDepth == 2);
+    }
+
+    public void testAttributeValueSimulatorResourceModelArrayArray() {
+        SimulatorResourceModel childModel = new SimulatorResourceModel();
+        try {
+            childModel.addAttribute(INT_KEY, new AttributeValue(1));
+            childModel.addAttribute(DOUBLE_KEY, new AttributeValue(1.00));
+            childModel.addAttribute(BOOL_KEY, new AttributeValue(true));
+            childModel.addAttribute(STRING_KEY, new AttributeValue("string"));
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        }
+
+        if (childModel.size() != 4)
+            fail("Failed to construct model for continuing test!");
+
+        SimulatorResourceModel[][] array = { { childModel } };
+
+        AttributeValue value = new AttributeValue(array);
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.RESOURCEMODEL
+                && value.typeInfo().mDepth == 2);
+    }
+
+    public void testAttributeValueIntArrayArrayArray_P01() {
+        int[][][] array = { { { 1, 2, 3 } } };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.INTEGER
+                && value.typeInfo().mDepth == 3);
+    }
+
+    public void testAttributeValueIntArrayArrayArray_P02() {
+        Integer[][][] array = { { { new Integer(1), new Integer(2),
+                new Integer(3) } } };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.INTEGER
+                && value.typeInfo().mDepth == 3);
+    }
+
+    public void testAttributeValueDoubleArrayArrayArray_P01() {
+        double[][][] array = { { { 1.00, 2.00, 3.00 } } };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.DOUBLE
+                && value.typeInfo().mDepth == 3);
+    }
+
+    public void testAttributeValueDoubleArrayArrayArray_P02() {
+        Double[][][] array = { { { new Double(1.00), new Double(2.00),
+                new Double(3.00) } } };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.DOUBLE
+                && value.typeInfo().mDepth == 3);
+    }
+
+    public void testAttributeValueBooleanArrayArrayArray_P01() {
+        boolean[][][] array = { { { true } } };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.BOOLEAN
+                && value.typeInfo().mDepth == 3);
+    }
+
+    public void testAttributeValueBooleanArrayArrayArray_P02() {
+        Boolean[][][] array = { { { new Boolean(true) } } };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.BOOLEAN
+                && value.typeInfo().mDepth == 3);
+    }
+
+    public void testAttributeValueStringArrayArrayArray_P01() {
+        String[][][] array = { { { "string" } } };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.STRING
+                && value.typeInfo().mDepth == 3);
+    }
+
+    public void testAttributeValueStringArrayArrayArray_P02() {
+        String[][][] array = { { { new String("string") } } };
+        AttributeValue value = new AttributeValue(array);
+
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.STRING
+                && value.typeInfo().mDepth == 3);
+    }
+
+    public void testAttributeValueSimulatorResourceModelArrayArrayArray() {
+        SimulatorResourceModel childModel = new SimulatorResourceModel();
+        try {
+            childModel.addAttribute(INT_KEY, new AttributeValue(1));
+            childModel.addAttribute(DOUBLE_KEY, new AttributeValue(1.00));
+            childModel.addAttribute(BOOL_KEY, new AttributeValue(true));
+            childModel.addAttribute(STRING_KEY, new AttributeValue("string"));
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        }
+
+        if (childModel.size() != 4)
+            fail("Failed to construct model for continuing test!");
+
+        SimulatorResourceModel[][][] array = { { { childModel } } };
+
+        AttributeValue value = new AttributeValue(array);
+        assertNotNull(value);
+        assertTrue(value.typeInfo() != null
+                && value.typeInfo().mType == AttributeValue.ValueType.ARRAY
+                && value.typeInfo().mBaseType == AttributeValue.ValueType.RESOURCEMODEL
+                && value.typeInfo().mDepth == 3);
+    }
+}
 
 package org.oic.simulator.test;
 
-import org.oic.simulator.clientcontroller.SimulatorRemoteResource;
-
-/**
- * This class provides methods to set/get remote resource objects.
- */
-public class SimulatorRemoteResourceObject
-{
-
-    private SimulatorRemoteResource simulatorRemoteResource;
-
-    public void setSimulatorRemoteResource(SimulatorRemoteResource simulatorRemoteResource)
-    {
-        this.simulatorRemoteResource = simulatorRemoteResource;
-    }
-
-    public SimulatorRemoteResource getSimulatorRemoteResource()
-    {
-        return simulatorRemoteResource;
-    }
+public enum ExceptionType {
+    UNKNOWN, INVALID_ARGS, NOT_SUPPORTED, OPERATION_IN_PROGRESS, SIMULATOR
 }
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/FindResourceListener.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/FindResourceListener.java
deleted file mode 100644 (file)
index a8469aa..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.oic.simulator.test;
-
-import java.util.concurrent.CountDownLatch;
-
-import org.oic.simulator.clientcontroller.IFindResourceListener;
-import org.oic.simulator.clientcontroller.SimulatorRemoteResource;
-
-/**
- * This class implements methods for receiving notification when
- * resources are discovered in network.
- */
-public class FindResourceListener implements IFindResourceListener
-{
-
-    private CountDownLatch lockObject;
-    private SimulatorRemoteResourceObject simulatorRemoteResource;
-
-    public FindResourceListener(CountDownLatch lockObject, SimulatorRemoteResourceObject simulatorRemoteResource)
-    {
-        this.lockObject = lockObject;
-        this.simulatorRemoteResource = simulatorRemoteResource;
-    }
-
-    @Override
-    public void onResourceCallback(SimulatorRemoteResource resource)
-    {
-        simulatorRemoteResource.setSimulatorRemoteResource(resource);
-
-        lockObject.countDown();
-    }
-}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/ResourceModelChangeListener.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/ResourceModelChangeListener.java
deleted file mode 100644 (file)
index 9c199b8..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.oic.simulator.test;
-
-import org.oic.simulator.SimulatorResourceModel;
-import org.oic.simulator.serviceprovider.IResourceModelChangedListener;
-
-/**
- * This class implements methods for receiving notification when
- *  resource model is changed.
- */
-public class ResourceModelChangeListener implements IResourceModelChangedListener
-{
-
-    private ResourceModelObject toReturn;
-
-    public ResourceModelChangeListener(Object toReturn)
-    {
-        this.toReturn = (ResourceModelObject)toReturn;
-    }
-
-    @Override
-    public void onResourceModelChanged(String resourceURI, SimulatorResourceModel resourceModel)
-    {
-        toReturn.setResourceURI(resourceURI);
-        toReturn.setResourceModel(resourceModel);
-    }
-}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/ResourceModelObject.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/ResourceModelObject.java
deleted file mode 100644 (file)
index b636d6a..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.oic.simulator.test;
-
-import org.oic.simulator.SimulatorResourceModel;
-
-/**
- * This class implements methods for setting/getting
- * resource model.
- */
-public class ResourceModelObject
-{
-    private String resourceURI;
-    private SimulatorResourceModel resourceModel;
-
-    public void setResourceURI(String resourceURI)
-    {
-        this.resourceURI = resourceURI;
-    }
-
-    public String getResourceURI()
-    {
-        return resourceURI;
-    }
-
-    public void setResourceModel(SimulatorResourceModel resourceModel)
-    {
-        this.resourceModel = resourceModel;
-    }
-
-    public SimulatorResourceModel getResourceModel()
-    {
-        return resourceModel;
-    }
-}
index 7fb25db..c63170a 100644 (file)
 
 package org.oic.simulator.test;
 
+import java.util.Vector;
 import java.util.concurrent.CountDownLatch;
-import junit.framework.TestCase;
+import java.util.concurrent.TimeUnit;
 
+import org.oic.simulator.DeviceInfo;
+import org.oic.simulator.DeviceListener;
+import org.oic.simulator.InvalidArgsException;
 import org.oic.simulator.PlatformInfo;
+import org.oic.simulator.PlatformListener;
+import org.oic.simulator.SimulatorException;
 import org.oic.simulator.SimulatorManager;
-import org.oic.simulator.serviceprovider.SimulatorResourceServer;
+import org.oic.simulator.client.FindResourceListener;
+import org.oic.simulator.client.SimulatorRemoteResource;
+import org.oic.simulator.server.SimulatorResource;
+import org.oic.simulator.utils.ObjectHolder;
+import org.oic.simulator.utils.SampleSingleResource;
+
+import junit.framework.TestCase;
 
 /**
- * This class tests the functionality of Simulator Manager
- * class APIs.
+ * This class tests the functionality of Simulator Manager class APIs.
  */
-public class SimulatorManagerTest extends TestCase
-{
-
-    private static final String CONFIG_PATH = "./ramls/simple-light.raml";
-    private static final String RESOURCE_TYPE = "oic.r.light";
-
-    private CountDownLatch lockObject;
-    private ResourceModelObject resourceModelObject;
-    private ResourceModelChangeListener resourceModelChangeListener;
+public class SimulatorManagerTest extends TestCase {
+    private static final String SINGLE_RES_RAML     = "./ramls/oic.r.light.raml";
+    private static final String COLLECTION_RES_RAML = "./ramls/oic.d.airconditioner.raml";
 
-
-    static
-    {
+    static {
         System.loadLibrary("SimulatorManager");
+        System.loadLibrary("RamlParser");
+        System.loadLibrary("oc");
+        System.loadLibrary("oc_logger");
+        System.loadLibrary("octbstack");
     }
 
     @Override
-    protected void setUp() throws Exception
-    {
+    protected void setUp() throws Exception {
         super.setUp();
-
-        lockObject = new CountDownLatch(1);
     }
 
     @Override
-    protected void tearDown() throws Exception
-    {
+    protected void tearDown() throws Exception {
         super.tearDown();
-
-        resourceModelObject = null;
-        resourceModelChangeListener = null;
-        lockObject = null;
     }
 
-    private SimulatorResourceServer createResource()
-    {
-        resourceModelObject = new ResourceModelObject();
-        resourceModelChangeListener = new ResourceModelChangeListener(resourceModelObject);
+    public void testCreateResource_P01() {
+        SimulatorResource resource = null;
+        SimulatorResource.Type resType = SimulatorResource.Type.SINGLE;
 
-        SimulatorResourceServer simulatorResourceServer = null;
-        try
-        {
-            simulatorResourceServer = SimulatorManager.createResource(CONFIG_PATH, resourceModelChangeListener);
-        }
-        catch (Exception e)
-        {
+        try {
+            resource = SimulatorManager.createResource(SINGLE_RES_RAML);
+            resType = resource.getType();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
             e.printStackTrace();
         }
 
-        return simulatorResourceServer;
+        assertNotNull(resource);
+        assertTrue(resType == SimulatorResource.Type.SINGLE);
     }
 
-    private SimulatorResourceServer[] createResources(int n)
-    {
-        resourceModelObject = new ResourceModelObject();
-        resourceModelChangeListener = new ResourceModelChangeListener(resourceModelObject);
+    public void testCreateResource_P02() {
+        SimulatorResource resource = null;
+        SimulatorResource.Type resType = SimulatorResource.Type.COLLECTION;
 
-        SimulatorResourceServer[] simulatorResourceServers = null;
-        try
-        {
-            simulatorResourceServers = SimulatorManager.createResource(CONFIG_PATH, n, resourceModelChangeListener);
-        }
-        catch (Exception e)
-        {
+        try {
+            resource = SimulatorManager.createResource(COLLECTION_RES_RAML);
+            resType = resource.getType();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
             e.printStackTrace();
         }
 
-        return simulatorResourceServers;
+        assertNotNull(resource);
+        assertTrue(resType == SimulatorResource.Type.COLLECTION);
     }
 
-    private void deleteResource(SimulatorResourceServer sim)
-    {
-        try
-        {
-            SimulatorManager.deleteResource(sim);
-        }
-        catch (Exception e)
-        {
-            e.printStackTrace();
+    public void testCreateResource_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            String configPath = "";
+            SimulatorResource resource = SimulatorManager
+                    .createResource(configPath);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
         }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
     }
 
-    public void testCreateResource_P01()
-    {
-        SimulatorResourceServer simulatorResourceServer = createResource();
+    public void testCreateResource_N02() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
 
-        assertNotNull(simulatorResourceServer);
+        try {
+            SimulatorResource resource = SimulatorManager.createResource(null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
 
-        deleteResource(simulatorResourceServer);
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
     }
 
-    /**
-     * When config path is empty
-     */
-    public void testCreateResource_N01()
-    {
-        String configPath = "";
-        boolean result = false;
+    public void testCreateResourceWithCount_P01() {
+        Vector<SimulatorResource> resources = null;
+        SimulatorResource.Type resType = SimulatorResource.Type.SINGLE;
 
-        resourceModelObject = new ResourceModelObject();
-        resourceModelChangeListener = new ResourceModelChangeListener(resourceModelObject);
-
-        SimulatorResourceServer simulatorResourceServer = null;
-        try
-        {
-            simulatorResourceServer = SimulatorManager.createResource(configPath, resourceModelChangeListener);
+        try {
+            resources = SimulatorManager.createResource(SINGLE_RES_RAML, 1);
+            resType = resources.elementAt(0).getType();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
         }
-        catch (Exception e)
-        {
-            result = true;
+
+        assertNotNull(resources);
+        assertTrue(resources.size() == 1);
+        assertTrue(resType == SimulatorResource.Type.SINGLE);
+    }
+
+    public void testCreateResourceWithCount_P02() {
+        Vector<SimulatorResource> resources = null;
+        SimulatorResource.Type resType = SimulatorResource.Type.COLLECTION;
+
+        try {
+            resources = SimulatorManager.createResource(COLLECTION_RES_RAML, 1);
+            resType = resources.elementAt(0).getType();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
         }
 
-        assertTrue(simulatorResourceServer == null && result);
+        assertNotNull(resources);
+        assertTrue(resources.size() == 1);
+        assertTrue(resType == SimulatorResource.Type.COLLECTION);
     }
 
-    /**
-     * When listener is not set. Passed null
-     */
-    public void testCreateResource_N02()
-    {
-        boolean result = false;
-        SimulatorResourceServer simulatorResourceServer = null;
-        try
-        {
-            simulatorResourceServer = SimulatorManager.createResource(CONFIG_PATH, null);
+    public void testCreateResourceWithCount_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            String configPath = "";
+            Vector<SimulatorResource> resource = SimulatorManager
+                    .createResource(configPath, 1);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
         }
-        catch (Exception e)
-        {
-            result = true;
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testCreateResourceWithCount_N02() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            Vector<SimulatorResource> resource = SimulatorManager
+                    .createResource(null, 1);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
         }
-        assertTrue(simulatorResourceServer == null && result);
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
     }
 
-    /**
-     * When listener and config path are set to null
-     */
-    public void testCreateResource_N03()
-    {
-        boolean result = false;
-        SimulatorResourceServer simulatorResourceServer = null;
-        try
-        {
-            simulatorResourceServer = SimulatorManager.createResource(null, null);
+    public void testCreateResourceWithCount_N03() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            Vector<SimulatorResource> resource = SimulatorManager
+                    .createResource(SINGLE_RES_RAML, 0);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
         }
-        catch (Exception e)
-        {
-            result = true;
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testCreateResourceWithCount_N04() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            Vector<SimulatorResource> resource = SimulatorManager
+                    .createResource(SINGLE_RES_RAML, -1);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
         }
-        assertTrue(simulatorResourceServer == null && result);
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
     }
 
-    public void testCreateResourceCount_P01()
-    {
-        int count = 5;
+    public void testCreateResourceByType_P01() {
+        SimulatorResource resource = null;
+        SimulatorResource.Type resType = SimulatorResource.Type.SINGLE;
 
-        SimulatorResourceServer[] simulatorResourceServers = createResources(count);
+        try {
+            String name = "test-singleresource";
+            String uri = "/test/singleresource";
+            String resourceType = "test.singleresource";
 
-        assertTrue(simulatorResourceServers != null && simulatorResourceServers.length == 5);
+            resource = SimulatorManager.createResource(
+                    SimulatorResource.Type.SINGLE, name, uri, resourceType);
+            resType = resource.getType();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
 
-        for(SimulatorResourceServer srs : simulatorResourceServers)
-            deleteResource(srs);
+        assertNotNull(resource);
+        assertTrue(resType == SimulatorResource.Type.SINGLE);
     }
 
-    /**
-     * When config path is empty
-     */
-    public void testCreateResourceCount_N01()
-    {
-        int count = 5;
-        String configPath = "";
-        boolean result = false;
+    public void testCreateResourceByType_P02() {
+        SimulatorResource resource = null;
+        SimulatorResource.Type resType = SimulatorResource.Type.COLLECTION;
 
-        resourceModelObject = new ResourceModelObject();
-        resourceModelChangeListener = new ResourceModelChangeListener(resourceModelObject);
+        try {
+            String name = "test-collectionresource";
+            String uri = "/test/collectionresource";
+            String resourceType = "test.collectionresource";
 
-        SimulatorResourceServer[] simulatorResourceServers = null;
-        try
-        {
-            SimulatorManager.setDeviceInfo("test");
-            simulatorResourceServers = SimulatorManager.createResource(configPath, count, resourceModelChangeListener);
-        }
-        catch (Exception e)
-        {
-            result = true;
+            resource = SimulatorManager.createResource(
+                    SimulatorResource.Type.COLLECTION, name, uri, resourceType);
+            resType = resource.getType();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
         }
 
-        assertTrue(simulatorResourceServers == null && result);
+        assertNotNull(resource);
+        assertTrue(resType == SimulatorResource.Type.COLLECTION);
     }
 
-    /**
-     * When listener is not set
-     */
-    public void testCreateResourceCount_N02()
-    {
-        int count = 5;
-        boolean result = false;
+    public void testCreateResourceByType_N01() {
+        ExceptionType exType = ExceptionType.INVALID_ARGS;
 
-        SimulatorResourceServer[] simulatorResourceServers = null;
-        try
-        {
-            simulatorResourceServers = SimulatorManager.createResource(CONFIG_PATH, count, null);
-        }
-        catch (Exception e)
-        {
-            result = true;
+        try {
+            String name = "";
+            String uri = "/test/resource";
+            String resourceType = "test.resource";
+
+            SimulatorResource resource = SimulatorManager.createResource(
+                    SimulatorResource.Type.SINGLE, name, uri, resourceType);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
         }
 
-        assertTrue(simulatorResourceServers == null && result);
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
     }
 
-    /**
-     * When configPath and listener are set to null
-     */
-    public void testCreateResourceCount_N03()
-    {
-        int count = 5;
-        boolean result = false;
+    public void testCreateResourceByType_N02() {
+        ExceptionType exType = ExceptionType.INVALID_ARGS;
 
-        SimulatorResourceServer[] simulatorResourceServers = null;
-        try
-        {
-            simulatorResourceServers = SimulatorManager.createResource(null, count, null);
-        }
-        catch (Exception e)
-        {
-            result = true;
+        try {
+            String name = null;
+            String uri = "/test/resource";
+            String resourceType = "test.resource";
+
+            SimulatorResource resource = SimulatorManager.createResource(
+                    SimulatorResource.Type.SINGLE, name, uri, resourceType);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
         }
 
-        assertTrue(simulatorResourceServers == null && result);
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
     }
 
-    /**
-     * When count is set to 0
-     */
-    public void testCreateResourceCount_N04()
-    {
-        int count = 0;
+    public void testCreateResourceByType_N03() {
+        ExceptionType exType = ExceptionType.INVALID_ARGS;
+
+        try {
+            String name = "test-resource";
+            String uri = "";
+            String resourceType = "test.resource";
 
-        SimulatorResourceServer[] simulatorResourceServers = createResources(count);
+            SimulatorResource resource = SimulatorManager.createResource(
+                    SimulatorResource.Type.SINGLE, name, uri, resourceType);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
 
-        assertTrue(simulatorResourceServers == null);
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
     }
 
-    /**
-     * When count is set to -ve
-     */
+    public void testCreateResourceByType_N04() {
+        ExceptionType exType = ExceptionType.INVALID_ARGS;
 
-    public void testCreateResourceCount_N05()
-    {
-        int count = -10;
+        try {
+            String name = "test-resource";
+            String uri = null;
+            String resourceType = "test.resource";
 
-        SimulatorResourceServer[] simulatorResourceServers = createResources(count);
+            SimulatorResource resource = SimulatorManager.createResource(
+                    SimulatorResource.Type.SINGLE, name, uri, resourceType);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
 
-        assertTrue(simulatorResourceServers == null  );
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
     }
 
-    public void testDeleteResource_P01()
-    {
-        boolean result = true;
+    public void testCreateResourceByType_N05() {
+        ExceptionType exType = ExceptionType.INVALID_ARGS;
 
-        SimulatorResourceServer simRes = createResource();
+        try {
+            String name = "test-resource";
+            String uri = "/test/resource";;
+            String resourceType = "";
 
-        try
-        {
-            SimulatorManager.deleteResource(simRes);
-        }
-        catch (Exception e)
-        {
-            result = false;
+            SimulatorResource resource = SimulatorManager.createResource(
+                    SimulatorResource.Type.SINGLE, name, uri, resourceType);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
         }
 
-        assertTrue(result);
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
     }
 
-    public void testDeleteResource_P02()
-    {
-        boolean result = true;
+    public void testCreateResourceByType_N06() {
+        ExceptionType exType = ExceptionType.INVALID_ARGS;
 
-        SimulatorResourceServer[] simResoruces = createResources(4);
+        try {
+            String name = "test-resource";
+            String uri = "/test/resource";;
+            String resourceType = null;
 
-        try
-        {
-            SimulatorManager.deleteResource(simResoruces[0]);
-        }
-        catch (Exception e)
-        {
-            result = false;
+            SimulatorResource resource = SimulatorManager.createResource(
+                    SimulatorResource.Type.SINGLE, name, uri, resourceType);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
         }
 
-        for(SimulatorResourceServer simResServer : simResoruces)
-            deleteResource(simResServer);
-
-        assertTrue(result);
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
     }
 
-    public void testDeleteResources_P01()
-    {
-        boolean result = true;
+    public void testFindResource_P01() {
+        // Creating sample single resource to test this API
+        SampleSingleResource testResource = new SampleSingleResource();
+        if (false == testResource.start())
+            return;
+
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<SimulatorRemoteResource> resourceHolder = new ObjectHolder<>();
+        FindResourceCallbackListener listener = new FindResourceCallbackListener(
+                lockObject, resourceHolder);
+
+        try {
+            String resourceType = testResource.mResourceType;
+            SimulatorManager.findResource(resourceType, listener);
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        if (false == syncResult)
+            testResource.stop();
 
-        createResources(4);
+        assertTrue(syncResult);
 
-        try
-        {
-            SimulatorManager.deleteResources(RESOURCE_TYPE);
-        }
-        catch (Exception e)
-        {
-            result = false;
+        // Wait for the resource to found
+        try {
+            lockObject.await(10, TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
         }
 
-        assertTrue(result);
+        testResource.stop();
+        assertNotNull(resourceHolder.get());
     }
 
-    public void testFindResouce_P01()
-    {
-        boolean result = true;
+    public void testFindResource_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            String resourceType = "test.singleresource";
+            SimulatorManager.findResource(resourceType, null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
 
-        SimulatorResourceServer simulatorResourceServer = createResource();
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
 
-        SimulatorRemoteResourceObject simulatorRemoteResource = new SimulatorRemoteResourceObject();
+    public void testFindResource_N02() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            String resourceType = "";
+            SimulatorManager.findResource(resourceType,
+                    new FindResourceListener() {
+                        @Override
+                        public void onResourceFound(
+                                SimulatorRemoteResource resource) {
+                        }
+                    });
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
 
-        FindResourceListener findResourceListener = new FindResourceListener(lockObject, simulatorRemoteResource);
+    public void testFindResource_N03() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            String resourceType = null;
+            SimulatorManager.findResource(resourceType,
+                    new FindResourceListener() {
+                        @Override
+                        public void onResourceFound(
+                                SimulatorRemoteResource resource) {
+                        }
+                    });
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
 
-        try
-        {
-            SimulatorManager.findResource(findResourceListener);
-        }
-        catch (Exception e)
-        {
-            result = false;
+    public void testFindResourceAll_P01() {
+        // Creating sample single resource to test this API
+        SampleSingleResource testResource = new SampleSingleResource();
+        if (false == testResource.start())
+            return;
+
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<SimulatorRemoteResource> resourceHolder = new ObjectHolder<>();
+        FindResourceCallbackListener listener = new FindResourceCallbackListener(
+                lockObject, resourceHolder);
+
+        try {
+            SimulatorManager.findResource(listener);
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
         }
 
-        assertTrue(result);
+        if (false == syncResult)
+            testResource.stop();
 
-        deleteResource(simulatorResourceServer);
-    }
+        assertTrue(syncResult);
 
-    /**
-     * Pass null to listener
-     */
-    public void testFindResouce_N01()
-    {
-        boolean result = true;
+        // Wait for the resource to found
+        try {
+            lockObject.await(10, TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
+        }
 
-        SimulatorResourceServer simulatorResourceServer = createResource();
+        testResource.stop();
+        assertNotNull(resourceHolder.get());
+    }
 
-        try
-        {
+    public void testFindResourceAll_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
             SimulatorManager.findResource(null);
-            result = false;
-        }
-        catch (Exception e)
-        {
-            result = true;
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
         }
 
-        assertTrue(result);
-
-        deleteResource(simulatorResourceServer);
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
     }
 
-    /**
-     *  checking for crash
-     */
-    public void testSetDeviceInfo_P01()
-    {
-        SimulatorManager.setDeviceInfo("test");
+    public void testregisterDeviceInfo_P01() {
+        boolean syncResult = false;
+
+        try {
+            String deviceName = "test-device";
+            SimulatorManager.setDeviceInfo(deviceName);
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        assertTrue(syncResult);
     }
 
-    /**
-     *  checking for crash
-     *  Pass empty
-     */
-    public void testSetDeviceInfo_N01()
-    {
-        try
-        {
-            SimulatorManager.setDeviceInfo("");
+    public void testregisterDeviceInfo_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            String deviceName = "";
+            SimulatorManager.setDeviceInfo(deviceName);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
         }
-        catch(Exception e)
-        {
-            System.out.println("Exception hit");
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+
+    public void testregisterDeviceInfo_N02() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            String deviceName = null;
+            SimulatorManager.setDeviceInfo(deviceName);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
         }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
     }
 
-    /**
-    *  checking for crash
-    * pass null
-    */
-    public void testSetDeviceInfo_N02()
-    {
-        try
-        {
-            SimulatorManager.setDeviceInfo(null);
+    public void testregisterPlatformInfo_P01() {
+        boolean syncResult = false;
+
+        try {
+            PlatformInfo platformInfo = new PlatformInfo();
+            platformInfo.setManufacturerName("Samsung");
+
+            SimulatorManager.setPlatformInfo(platformInfo);
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
         }
-        catch(Exception e)
-        {
-            System.out.println("Exception hit");
+
+        assertTrue(syncResult);
+    }
+
+    public void testregisterPlatformInfo_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            PlatformInfo platformInfo = null;
+            SimulatorManager.setPlatformInfo(platformInfo);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
         }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
     }
 
-    public void testGetDeviceInfo_N01()
-    {
-        try
-        {
-            SimulatorManager.getDeviceInfo(null);
+    public void testFindDevices_P01() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<DeviceInfo> infoHolder = new ObjectHolder<>();
+        DeviceInfoListener listener = new DeviceInfoListener(lockObject,
+                infoHolder);
+
+        try {
+            SimulatorManager.setDeviceInfo("Samsung");
+            SimulatorManager.findDevices(listener);
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
         }
-        catch(Exception e)
-        {
-            System.out.println(" Exception hit");
+
+        assertTrue(syncResult);
+
+        // Wait for the asynchronous response
+        try {
+            lockObject.await(10, TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
         }
+
+        assertNotNull(infoHolder.get());
     }
 
-    /**
-     * Checking for crash
-     */
-    public void testSetPlatformInfo_P01()
-    {
-        PlatformInfo platformInfo = new PlatformInfo();
-        platformInfo.setDateOfManufacture("asdf");
-        platformInfo.setFirmwareVersion("asdf");
-        platformInfo.setHardwareVersion("asdf");
-        platformInfo.setManufacturerName("asdfdfg");
-        platformInfo.setManufacturerUrl("asdffdg");
-        platformInfo.setModelNumber("fddfg");
-        platformInfo.setOperationSystemVersion("sadfg");
-        platformInfo.setPlatformID("asdf");
-        platformInfo.setPlatformVersion("asdfgfdg");
-        platformInfo.setSupportUrl("adfgg");
-        platformInfo.setSystemTime("adsfgfg");
+    public void testFindDevices_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
 
-        SimulatorManager.setPlatformInfo(platformInfo);
+        try {
+            SimulatorManager.findDevices(null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
+        }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
     }
 
-    /**
-     * Checking for crash
-     */
-    public void testSetPlatformInfo_N01()
-    {
-        try
-        {
-            SimulatorManager.setPlatformInfo(null);
+    public void testGetPlatformInfo_P01() {
+        CountDownLatch lockObject = new CountDownLatch(1);
+        boolean syncResult = false;
+        ObjectHolder<PlatformInfo> infoHolder = new ObjectHolder<>();
+        PlatformInfoListener listener = new PlatformInfoListener(lockObject,
+                infoHolder);
+
+        try {
+            SimulatorManager.getPlatformInformation(listener);
+            syncResult = true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
         }
-        catch(Exception e)
-        {
-          System.out.println("Exception Hit");
+
+        assertTrue(syncResult);
+
+        // Wait for the asynchronous response
+        try {
+            lockObject.await(10, TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
         }
+
+        assertNotNull(infoHolder.get());
     }
 
-    public void testGetPlatformInfo_N01()
-    {
-        try
-        {
-            SimulatorManager.getPlatformInfo(null);
-        }
-        catch (Exception e)
-        {
-            System.out.println("Exception Hit");
+    public void testGetPlatformInfo_N01() {
+        ExceptionType exType = ExceptionType.UNKNOWN;
+
+        try {
+            SimulatorManager.getPlatformInformation(null);
+        } catch (InvalidArgsException e) {
+            exType = ExceptionType.INVALID_ARGS;
+        } catch (SimulatorException e) {
+            exType = ExceptionType.SIMULATOR;
         }
+
+        assertTrue(exType == ExceptionType.INVALID_ARGS);
+    }
+}
+
+class FindResourceCallbackListener implements FindResourceListener {
+    private CountDownLatch                        mLockObject;
+    private ObjectHolder<SimulatorRemoteResource> mResourceHolder;
+
+    public FindResourceCallbackListener(CountDownLatch lockObject,
+            ObjectHolder<SimulatorRemoteResource> resourceHolder) {
+        mLockObject = lockObject;
+        mResourceHolder = resourceHolder;
+    }
+
+    @Override
+    public void onResourceFound(SimulatorRemoteResource resource) {
+        mResourceHolder.set(resource);
+        mLockObject.countDown();
+    }
+}
+
+class DeviceInfoListener implements DeviceListener {
+    private CountDownLatch           mLockObject;
+    private ObjectHolder<DeviceInfo> mInfoHolder;
+
+    public DeviceInfoListener(CountDownLatch lockObject,
+            ObjectHolder<DeviceInfo> infoHolder) {
+        mLockObject = lockObject;
+        mInfoHolder = infoHolder;
+    }
+
+    @Override
+    public void onDeviceFound(DeviceInfo devInfo) {
+        mInfoHolder.set(devInfo);
+        mLockObject.countDown();
+    }
+}
+
+class PlatformInfoListener implements PlatformListener {
+
+    private CountDownLatch             mLockObject;
+    private ObjectHolder<PlatformInfo> mInfoHolder;
+
+    public PlatformInfoListener(CountDownLatch lockObject,
+            ObjectHolder<PlatformInfo> infoHolder) {
+        mLockObject = lockObject;
+        mInfoHolder = infoHolder;
+    }
+
+    @Override
+    public void onPlatformFound(PlatformInfo platformInfo) {
+        mInfoHolder.set(platformInfo);
+        mLockObject.countDown();
     }
 }
index 2748e09..76ae00e 100644 (file)
@@ -18,317 +18,234 @@ package org.oic.simulator.test;
 
 import java.util.Map;
 
-import junit.framework.TestCase;
-
-import org.oic.simulator.ResourceAttribute;
+import org.oic.simulator.AttributeValue;
+import org.oic.simulator.InvalidArgsException;
+import org.oic.simulator.SimulatorResourceAttribute;
 import org.oic.simulator.SimulatorResourceModel;
 
+import junit.framework.TestCase;
+
 /**
- * This class tests the functionality of Simulator Resource Model
- * class APIs.
+ * This class tests the APIs of SimulatorResourceModel class.
  */
-public class SimulatorResourceModelTest extends TestCase
-{
-
-    private SimulatorResourceModel simulatorResourceModel;
-
-    private static final String KEY = "test";
-
-    static
-    {
-        System.loadLibrary("SimulatorManager");
-        System.loadLibrary("RamlParser");
-        System.loadLibrary("oc");
-        System.loadLibrary("oc_logger");
-        System.loadLibrary("octbstack");
-    }
+public class SimulatorResourceModelTest extends TestCase {
+    private static final String INT_KEY    = "Interger";
+    private static final String DOUBLE_KEY = "Double";
+    private static final String BOOL_KEY   = "Boolean";
+    private static final String STRING_KEY = "String";
 
     @Override
-    protected void setUp() throws Exception
-    {
+    protected void setUp() throws Exception {
         super.setUp();
-
-        simulatorResourceModel = new SimulatorResourceModel();
     }
 
     @Override
-    protected void tearDown() throws Exception
-    {
+    protected void tearDown() throws Exception {
         super.tearDown();
-
-        simulatorResourceModel = null;
     }
 
-    public void testAddAttributeInt_P01()
-    {
-        int val = 100;
-
-        boolean result = true;
-        try
-        {
-            simulatorResourceModel.addAttributeInt(KEY, val);
-            result = result && Integer.parseInt(simulatorResourceModel.getAttribute(KEY).getValue().toString()) == val;
-        }
-        catch(Exception e)
-        {
-            result = false;
-        }
-
-        assertTrue(result);
+    public void testSimulatorResourceModel_P01() {
+        SimulatorResourceModel resModel = new SimulatorResourceModel();
+        assertNotNull(resModel);
     }
 
-    public void testAddAttributeInt_N01()
-    {
-        int val = -10;
+    public void testAddAttributeInt_P01() {
+        int result = -1;
 
-        boolean result = true;
-        try
-        {
-            simulatorResourceModel.addAttributeInt(KEY, val);
-            result = result && Integer.parseInt(simulatorResourceModel.getAttribute(KEY).getValue().toString()) == val;
-        }
-        catch(Exception e)
-        {
-            result = false;
+        SimulatorResourceModel resModel = new SimulatorResourceModel();
+        SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                INT_KEY, new AttributeValue(10), null);
+        try {
+            resModel.addAttribute(attribute);
+            result = ((Integer) resModel.getAttribute(INT_KEY).value().get())
+                    .intValue();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
         }
 
-        assertTrue(result);
+        assertEquals(10, result);
     }
 
-    public void testAddAttributeInt_N02()
-    {
-        int val = 666666;
+    public void testAddAttributeInt_P02() {
+        int result = -1;
 
-        boolean result = true;
-        try
-        {
-            simulatorResourceModel.addAttributeInt(KEY, val);
-            result = result && Integer.parseInt(simulatorResourceModel.getAttribute(KEY).getValue().toString()) == val;
-        }
-        catch(Exception e)
-        {
-            result = false;
+        SimulatorResourceModel resModel = new SimulatorResourceModel();
+        SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                INT_KEY, new AttributeValue(-10), null);
+        try {
+            resModel.addAttribute(attribute);
+            result = ((Integer) resModel.getAttribute(INT_KEY).value().get())
+                    .intValue();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
         }
 
-        assertTrue(result);
+        assertEquals(-10, result);
     }
 
-    public void testAddAttributeDouble_P01()
-    {
-        double val = 10.11;
+    public void testAddAttributeDouble_P01() {
+        double result = 0.0;
 
-        boolean result = true;
-        try
-        {
-            simulatorResourceModel.addAttributeDouble(KEY, val);
-            result = result && Double.parseDouble(simulatorResourceModel.getAttribute(KEY).getValue().toString()) == val;
-        }
-        catch(Exception e)
-        {
-            result = false;
+        SimulatorResourceModel resModel = new SimulatorResourceModel();
+        SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                DOUBLE_KEY, new AttributeValue(4.0), null);
+        try {
+            resModel.addAttribute(attribute);
+            result = ((Double) resModel.getAttribute(DOUBLE_KEY).value().get())
+                    .doubleValue();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
         }
 
-        assertTrue(result);
+        assertEquals(4.0, result);
     }
 
-    public void testAddAttributeDouble_N01()
-    {
-        double val = -11.12;
+    public void testAddAttributeDouble_P02() {
+        double result = 0.0;
 
-        boolean result = true;
-        try
-        {
-            simulatorResourceModel.addAttributeDouble(KEY, val);
-            result = result && Double.parseDouble(simulatorResourceModel.getAttribute(KEY).getValue().toString()) == val;
-        }
-        catch(Exception e)
-        {
-            result = false;
+        SimulatorResourceModel resModel = new SimulatorResourceModel();
+        SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                DOUBLE_KEY, new AttributeValue(-4.0), null);
+        try {
+            resModel.addAttribute(attribute);
+            result = ((Double) resModel.getAttribute(DOUBLE_KEY).value().get())
+                    .doubleValue();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
         }
 
-        assertTrue(result);
+        assertEquals(-4.0, result);
     }
 
-    public void testAddAttributeDouble_N02()
-    {
-        double val = 0.0044444444444;
+    public void testAddAttributeBoolean_P01() {
+        boolean result = false;
 
-        boolean result = true;
-        try
-        {
-            simulatorResourceModel.addAttributeDouble(KEY, val);
-            result = result && Double.parseDouble(simulatorResourceModel.getAttribute(KEY).getValue().toString()) == val;
-        }
-        catch(Exception e)
-        {
-            result = false;
+        SimulatorResourceModel resModel = new SimulatorResourceModel();
+        SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                BOOL_KEY, new AttributeValue(true), null);
+        try {
+            resModel.addAttribute(attribute);
+            result = ((Boolean) resModel.getAttribute(BOOL_KEY).value().get())
+                    .booleanValue();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
         }
 
-        assertTrue(result);
+        assertEquals(true, result);
     }
 
-    public void testAddAttributeString_P01()
-    {
-        String val = "asdf";
+    public void testAddAttributeString_P01() {
+        String result = null;
 
-        boolean result = true;
-        try
-        {
-            simulatorResourceModel.addAttributeString(KEY, val);
-            result = result && simulatorResourceModel.getAttribute(KEY).getValue().toString().equals(val);
-        }
-        catch(Exception e)
-        {
-            result = false;
+        SimulatorResourceModel resModel = new SimulatorResourceModel();
+        SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                STRING_KEY, new AttributeValue("string-value"), null);
+        try {
+            resModel.addAttribute(attribute);
+            result = (String) resModel.getAttribute(STRING_KEY).value().get();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
         }
 
-        assertTrue(result);
+        assertEquals("string-value", result);
     }
 
-    public void testAddAttributeString_N01()
-    {
-        String val = "";
+    public void testAddAttributeString_P02() {
+        String result = null;
 
-        boolean result = true;
-        try
-        {
-            simulatorResourceModel.addAttributeString(KEY, val);
-            result = result && simulatorResourceModel.getAttribute(KEY).getValue().toString().equals(val);
-        }
-        catch(Exception e)
-        {
-            result = false;
+        SimulatorResourceModel resModel = new SimulatorResourceModel();
+        SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                STRING_KEY, new AttributeValue(""), null);
+        try {
+            resModel.addAttribute(attribute);
+            result = (String) resModel.getAttribute(STRING_KEY).value().get();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
         }
 
-        assertTrue(result);
+        assertEquals("", result);
     }
 
-   public void testAddAttributeString_N02() {
-        String val = null;
+    public void testAddAttributeString_P03() {
+        String result = null;
 
-        boolean result = false;
+        SimulatorResourceModel resModel = new SimulatorResourceModel();
+        SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
+                STRING_KEY, new AttributeValue("@#$$&^*^(*^&"), null);
         try {
-
-            simulatorResourceModel.addAttributeString(KEY, val);
-
-            result = result && simulatorResourceModel.getAttribute(KEY).getValue().toString().equals(val);
-
-        } catch(Exception e) {
-            result = true;
+            resModel.addAttribute(attribute);
+            result = (String) resModel.getAttribute(STRING_KEY).value().get();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
         }
 
-        assertTrue(result);
+        assertEquals("@#$$&^*^(*^&", result);
     }
 
-    public void testAddAttributeString_N03()
-    {
-        String val = "@#$$&^*^(*^&";
+    public void testSize_P01() {
+        int result = -1;
 
-        boolean result = true;
-        try
-        {
-            simulatorResourceModel.addAttributeString(KEY, val);
-            result = result && simulatorResourceModel.getAttribute(KEY).getValue().toString().equals(val);
-        }
-        catch(Exception e)
-        {
-            result = false;
-        }
+        SimulatorResourceModel resModel = new SimulatorResourceModel();
+        result = resModel.size();
 
-        assertTrue(result);
+        assertEquals(0, result);
     }
 
-    public void testAddAttributeBoolean_P01()
-    {
-        boolean result = true;
-
-        boolean val;
-
-        try
-        {
-            val=Boolean.parseBoolean("true");
-            simulatorResourceModel.addAttributeBoolean(KEY, val);
+    public void testSize_P02() {
+        int result = -1;
 
-            result = result && ((Boolean.parseBoolean(simulatorResourceModel.getAttribute(KEY).getValue().toString()+"")));
-
-            val = Boolean.parseBoolean("false");
-
-            simulatorResourceModel.addAttributeBoolean(KEY, val);
-
-            result = result && !((Boolean.parseBoolean(simulatorResourceModel.getAttribute(KEY).getValue().toString()+"")));
-        }
-        catch (Exception e)
-        {
-            result = false;
+        SimulatorResourceModel resModel = new SimulatorResourceModel();
+        try {
+            resModel.addAttribute(new SimulatorResourceAttribute(INT_KEY,
+                    new AttributeValue(1234), null));
+            resModel.addAttribute(new SimulatorResourceAttribute(DOUBLE_KEY,
+                    new AttributeValue(1.234), null));
+            resModel.addAttribute(new SimulatorResourceAttribute(BOOL_KEY,
+                    new AttributeValue(true), null));
+            resModel.addAttribute(new SimulatorResourceAttribute(STRING_KEY,
+                    new AttributeValue("string-value"), null));
+            result = resModel.size();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
         }
 
-        assertTrue(result);
+        assertEquals(4, result);
     }
 
-    public void testSize_P01()
-    {
-        boolean result = true;
-
-        try
-        {
-            simulatorResourceModel.addAttributeInt("test1", 1234);
-
-            result = result && (simulatorResourceModel.size() == 1);
+    public void testGetAttribute_P01() {
+        SimulatorResourceAttribute result = null;
 
-            simulatorResourceModel.addAttributeString("test2", "asdf");
-            simulatorResourceModel.addAttributeBoolean("test3", Boolean.parseBoolean("true"));
-            simulatorResourceModel.addAttributeDouble("test4", 22.435234);
-
-            result = result && (simulatorResourceModel.size() == 4);
-        }
-        catch(Exception e)
-        {
-            result = false;
+        SimulatorResourceModel resModel = new SimulatorResourceModel();
+        try {
+            resModel.addAttribute(new SimulatorResourceAttribute(INT_KEY,
+                    new AttributeValue(10), null));
+            result = resModel.getAttribute(INT_KEY);
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
         }
-        assertTrue(result);
-    }
-
-    public void testGetAttributes_P01()
-    {
-        boolean result = true;
-
-        try
-        {
-            simulatorResourceModel.addAttributeInt("test1", 1234);
-            simulatorResourceModel.addAttributeString("test2", "asdf");
-            simulatorResourceModel.addAttributeBoolean("test3", Boolean.parseBoolean("true"));
-            simulatorResourceModel.addAttributeDouble("test4", 22.435234);
-
-            Map<String, ResourceAttribute> attributes = simulatorResourceModel.getAttributes();
 
-            result = result && (((Integer)attributes.get("test1").getValue()) == 1234) &&
-                     (((String)attributes.get("test2").getValue()).equals("asdf")) &&
-                     ((Boolean.parseBoolean(attributes.get("test3").getValue().toString() + "")==true)) &&
-                     (((Double)attributes.get("test4").getValue()) == 22.435234);
-        }
-        catch(Exception e)
-        {
-            result = false;
-        }
-        assertTrue(result);
+        assertNotNull(result);
     }
 
-    public void testGetAttribute_P01()
-    {
-        int val = 100;
-
-        boolean result = true;
-
-        try
-        {
-            simulatorResourceModel.addAttributeInt(KEY, val);
+    public void testGetAttributes_P01() {
+        Map<String, SimulatorResourceAttribute> result = null;
 
-            result = result && Integer.parseInt(simulatorResourceModel.getAttribute(KEY).getValue().toString()) == val;
-        }
-        catch(Exception e)
-        {
-            result = false;
-        }
-        assertTrue(result);
+        SimulatorResourceModel resModel = new SimulatorResourceModel();
+        try {
+            resModel.addAttribute(new SimulatorResourceAttribute(INT_KEY,
+                    new AttributeValue(1234), null));
+            resModel.addAttribute(new SimulatorResourceAttribute(DOUBLE_KEY,
+                    new AttributeValue(1.234), null));
+            resModel.addAttribute(new SimulatorResourceAttribute(BOOL_KEY,
+                    new AttributeValue(true), null));
+            resModel.addAttribute(new SimulatorResourceAttribute(STRING_KEY,
+                    new AttributeValue("string-value"), null));
+            result = resModel.getAttributes();
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        }
+
+        assertNotNull(result);
+        assertEquals(4, result.size());
     }
 }
  * limitations under the License.
  */
 
-package org.oic.simulator.serviceprovider.test;
+package org.oic.simulator.utils;
 
-/**
- * This class implements methods for setting/getting URI
- * and automation ID.
- */
-public class AutomationObject
-{
-
-    private String resourceURI;
-    private int automationId;
-
-    public void setResourceURI(String resourceURI)
-    {
-        this.resourceURI = resourceURI;
-    }
-
-    public String getResourceURI()
-    {
-        return resourceURI;
-    }
+public class ObjectHolder<T> {
+    private T mObject;
 
-    public void setAutomationId(int automationId)
-    {
-        this.automationId = automationId;
+    public void set(T object) {
+        mObject = object;
     }
 
-    public int getAutomationId()
-    {
-        return automationId;
+    public T get() {
+        return mObject;
     }
 }
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/utils/SampleSingleResource.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/utils/SampleSingleResource.java
new file mode 100644 (file)
index 0000000..fd88189
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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.oic.simulator.utils;
+
+import org.oic.simulator.InvalidArgsException;
+import org.oic.simulator.SimulatorException;
+import org.oic.simulator.SimulatorManager;
+import org.oic.simulator.server.SimulatorResource;
+import org.oic.simulator.server.SimulatorSingleResource;
+
+public class SampleSingleResource {
+
+    private SimulatorSingleResource mResource;
+    public String                   mName         = "test-singleresource";
+    public String                   mUri          = "/test/singleresource";
+    public String                   mResourceType = "test.singleresource";
+
+    public boolean start() {
+        try {
+            mResource = (SimulatorSingleResource) SimulatorManager
+                    .createResource(SimulatorResource.Type.SINGLE, mName, mUri,
+                            mResourceType);
+            mResource.start();
+            return true;
+        } catch (InvalidArgsException e) {
+            e.printStackTrace();
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        return false;
+    }
+
+    public boolean stop() {
+        try {
+            mResource.stop();
+            mResource = null;
+            return true;
+        } catch (SimulatorException e) {
+            e.printStackTrace();
+        }
+
+        return false;
+    }
+}