Added Junit test cases for Simulator Java APIs.
authorspurthi.segu <spurthi.segu@samsung.com>
Tue, 6 Oct 2015 06:19:10 +0000 (11:49 +0530)
committerMadan Lanka <lanka.madan@samsung.com>
Tue, 6 Oct 2015 11:47:22 +0000 (11:47 +0000)
Change-Id: I5ce72d2ed3ade45e984deb9dc0d50c0983344baa
Signed-off-by: spurthi.segu <spurthi.segu@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3593
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
23 files changed:
service/simulator/unittests/SimulatorTest/.classpath [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/.codepro/deadCodeEntryPoints.xml [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/.project [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/GetListener.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/ListenerObject.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/ObserveListener.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/ObserveListenerObject.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/PostListener.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/PutListener.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/SimulatorRemoteResourceTest.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/VerifyListener.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/VerifyListenerObject.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/AutomationListener.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/AutomationObject.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/Observer.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/ObserverObject.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/SimlatorResourceServerTest.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/FindResourceListener.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/ResourceModelChangeListener.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/ResourceModelObject.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/SimulatorManagerTest.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/SimulatorRemoteResourceObject.java [new file with mode: 0644]
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/SimulatorResourceModelTest.java [new file with mode: 0644]

diff --git a/service/simulator/unittests/SimulatorTest/.classpath b/service/simulator/unittests/SimulatorTest/.classpath
new file mode 100644 (file)
index 0000000..1966233
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="src" path="src" />
+       <classpathentry exported="true" kind="con"
+               path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7" />
+       <classpathentry combineaccessrules="false" exported="true"
+               kind="src" path="/Simulator" />
+       <classpathentry exported="true" kind="con"
+               path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3" />
+       <classpathentry kind="output" path="bin" />
+</classpath>
diff --git a/service/simulator/unittests/SimulatorTest/.codepro/deadCodeEntryPoints.xml b/service/simulator/unittests/SimulatorTest/.codepro/deadCodeEntryPoints.xml
new file mode 100644 (file)
index 0000000..f88c24c
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated by Code Pro -->
+<entry-points version="1">
+       <explicit-entry-points />
+       <include-main enabled="true" />
+       <include-tests enabled="false" />
+       <include-xml enabled="true" />
+</entry-points>
\ No newline at end of file
diff --git a/service/simulator/unittests/SimulatorTest/.project b/service/simulator/unittests/SimulatorTest/.project
new file mode 100644 (file)
index 0000000..3ca1ead
--- /dev/null
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>SimulatorTest</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
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
new file mode 100644 (file)
index 0000000..ed9fd7e
--- /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.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
new file mode 100644 (file)
index 0000000..860cf6a
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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
new file mode 100644 (file)
index 0000000..ecc6c10
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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
new file mode 100644 (file)
index 0000000..6bcca0c
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * 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
new file mode 100644 (file)
index 0000000..3942b51
--- /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.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
new file mode 100644 (file)
index 0000000..1dafed3
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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
new file mode 100644 (file)
index 0000000..0ceab6d
--- /dev/null
@@ -0,0 +1,864 @@
+/*
+ * 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);
+    }
+
+    public void testPost_P01()
+    {
+        boolean result = true;
+        ListenerObject listenerObject = null;
+        lockObject = new CountDownLatch(1);
+
+        SimulatorResourceModel model = new SimulatorResourceModel();
+        try
+        {
+            model.addAttributeInt("intensity", 8);
+            //model.addAttributeString("power", "off");
+
+            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);
+    }
+
+    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);
+            else
+                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
new file mode 100644 (file)
index 0000000..2e16ef5
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * 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
new file mode 100644 (file)
index 0000000..45a2eaf
--- /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.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/serviceprovider/test/AutomationListener.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/AutomationListener.java
new file mode 100644 (file)
index 0000000..cb545db
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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/AutomationObject.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/AutomationObject.java
new file mode 100644 (file)
index 0000000..9ada5d8
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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;
+
+/**
+ * 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 void setAutomationId(int automationId)
+    {
+        this.automationId = automationId;
+    }
+
+    public int getAutomationId()
+    {
+        return automationId;
+    }
+}
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
new file mode 100644 (file)
index 0000000..ca69964
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * 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
new file mode 100644 (file)
index 0000000..14bd6a1
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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
new file mode 100644 (file)
index 0000000..0952af1
--- /dev/null
@@ -0,0 +1,938 @@
+/*
+ * 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("YamlParser");
+        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, true);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+        assertEquals(Boolean.parseBoolean(getValue(KEY) + ""), 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, true);
+        }
+        catch (Exception e)
+        {
+            result = false;
+            e.printStackTrace();
+        }
+
+        result = result && Boolean.parseBoolean(getValue(KEY) + "")==true;
+
+        try
+        {
+            simulatorResourceServer.updateAttributeBoolean(KEY, 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(10,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 == -1);
+    }
+
+    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
+        {
+            id = simulatorResourceServer.startAttributeAutomation(simulatorResourceServer.getModel().getAttributes().get(0).getName(),
+                    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(10, TimeUnit.SECONDS);
+        }
+        catch (InterruptedException e)
+        {
+        }
+
+        result = result && automationObject.getResourceURI() != null && automationObject.getAutomationId() != -1 && id != -1;
+
+        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/FindResourceListener.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/FindResourceListener.java
new file mode 100644 (file)
index 0000000..a8469aa
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * 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
new file mode 100644 (file)
index 0000000..9c199b8
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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
new file mode 100644 (file)
index 0000000..b636d6a
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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;
+    }
+}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/SimulatorManagerTest.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/SimulatorManagerTest.java
new file mode 100644 (file)
index 0000000..c46653c
--- /dev/null
@@ -0,0 +1,422 @@
+/*
+ * 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 junit.framework.TestCase;
+
+import org.oic.simulator.DeviceInfo;
+import org.oic.simulator.PlatformInfo;
+import org.oic.simulator.SimulatorManager;
+import org.oic.simulator.serviceprovider.SimulatorResourceServer;
+
+/**
+ * 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;
+
+    private DeviceInfo info;
+    private PlatformInfo platformInfo;
+
+    static
+    {
+        System.loadLibrary("SimulatorManager");
+        System.loadLibrary("RamlParser");
+        System.loadLibrary("oc");
+        System.loadLibrary("oc_logger");
+        System.loadLibrary("octbstack");
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+
+        lockObject = new CountDownLatch(1);
+    }
+
+    @Override
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+
+        resourceModelObject = null;
+        resourceModelChangeListener = null;
+        lockObject = null;
+    }
+
+    private SimulatorResourceServer createResource()
+    {
+        resourceModelObject = new ResourceModelObject();
+        resourceModelChangeListener = new ResourceModelChangeListener(resourceModelObject);
+
+        SimulatorResourceServer simulatorResourceServer = null;
+        try
+        {
+            simulatorResourceServer = SimulatorManager.createResource(CONFIG_PATH, resourceModelChangeListener);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+
+        return simulatorResourceServer;
+    }
+
+    private SimulatorResourceServer[] createResources(int n)
+    {
+        resourceModelObject = new ResourceModelObject();
+        resourceModelChangeListener = new ResourceModelChangeListener(resourceModelObject);
+
+        SimulatorResourceServer[] simulatorResourceServers = null;
+        try
+        {
+            simulatorResourceServers = SimulatorManager.createResource(CONFIG_PATH, n, resourceModelChangeListener);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+
+        return simulatorResourceServers;
+    }
+
+    private void deleteResource(SimulatorResourceServer sim)
+    {
+        try
+        {
+            SimulatorManager.deleteResource(sim);
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    public void testCreateResource_P01()
+    {
+        SimulatorResourceServer simulatorResourceServer = createResource();
+
+        assertNotNull(simulatorResourceServer);
+
+        deleteResource(simulatorResourceServer);
+    }
+
+    /**
+     * When config path is empty
+     */
+    public void testCreateResource_N01()
+    {
+        String configPath = "";
+        boolean result = false;
+
+        resourceModelObject = new ResourceModelObject();
+        resourceModelChangeListener = new ResourceModelChangeListener(resourceModelObject);
+
+        SimulatorResourceServer simulatorResourceServer = null;
+        try
+        {
+            simulatorResourceServer = SimulatorManager.createResource(configPath, resourceModelChangeListener);
+        }
+        catch (Exception e)
+        {
+            result = true;
+        }
+
+        assertTrue(simulatorResourceServer == null && result);
+    }
+
+    /**
+     * When listener is not set. Passed null
+     */
+    public void testCreateResource_N02()
+    {
+        boolean result = false;
+        SimulatorResourceServer simulatorResourceServer = null;
+        try
+        {
+            simulatorResourceServer = SimulatorManager.createResource(CONFIG_PATH, null);
+        }
+        catch (Exception e)
+        {
+            result = true;
+        }
+        assertTrue(simulatorResourceServer == null && result);
+    }
+
+    /**
+     * 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);
+        }
+        catch (Exception e)
+        {
+            result = true;
+        }
+        assertTrue(simulatorResourceServer == null && result);
+    }
+
+    public void testCreateResourceCount_P01()
+    {
+        int count = 5;
+
+        SimulatorResourceServer[] simulatorResourceServers = createResources(count);
+
+        assertTrue(simulatorResourceServers != null && simulatorResourceServers.length == 5);
+
+        for(SimulatorResourceServer srs : simulatorResourceServers)
+            deleteResource(srs);
+    }
+
+    /**
+     * When config path is empty
+     */
+    public void testCreateResourceCount_N01()
+    {
+        int count = 5;
+        String configPath = "";
+        boolean result = false;
+
+        resourceModelObject = new ResourceModelObject();
+        resourceModelChangeListener = new ResourceModelChangeListener(resourceModelObject);
+
+        SimulatorResourceServer[] simulatorResourceServers = null;
+        try
+        {
+            simulatorResourceServers = SimulatorManager.createResource(configPath, count, resourceModelChangeListener);
+        }
+        catch (Exception e)
+        {
+            result = true;
+        }
+
+        assertTrue(simulatorResourceServers == null && result);
+    }
+
+    /**
+     * When listener is not set
+     */
+    public void testCreateResourceCount_N02()
+    {
+        int count = 5;
+        boolean result = false;
+
+        SimulatorResourceServer[] simulatorResourceServers = null;
+
+        try
+        {
+            simulatorResourceServers = SimulatorManager.createResource(CONFIG_PATH, count, null);
+        }
+        catch (Exception e)
+        {
+            result = true;
+        }
+
+        assertTrue(simulatorResourceServers == null && result);
+    }
+
+    /**
+     * When configPath and listener are set to null
+     */
+    public void testCreateResourceCount_N03()
+    {
+        int count = 5;
+        boolean result = false;
+
+        SimulatorResourceServer[] simulatorResourceServers = null;
+        try
+        {
+            simulatorResourceServers = SimulatorManager.createResource(null, count, null);
+        }
+        catch (Exception e)
+        {
+            result = true;
+        }
+
+        assertTrue(simulatorResourceServers == null && result);
+    }
+
+    /**
+     * When count is set to 0
+     */
+    public void testCreateResourceCount_N04()
+    {
+        int count = 0;
+
+        SimulatorResourceServer[] simulatorResourceServers = createResources(count);
+
+        assertTrue(simulatorResourceServers == null);
+    }
+
+    public void testDeleteResource_P01()
+    {
+        boolean result = true;
+
+        SimulatorResourceServer simRes = createResource();
+
+        try
+        {
+            SimulatorManager.deleteResource(simRes);
+        }
+        catch (Exception e)
+        {
+            result = false;
+        }
+
+        assertTrue(result);
+    }
+
+    public void testDeleteResource_P02()
+    {
+        boolean result = true;
+
+        SimulatorResourceServer[] simResoruces = createResources(4);
+
+        try
+        {
+            SimulatorManager.deleteResource(simResoruces[0]);
+        }
+        catch (Exception e)
+        {
+            result = false;
+        }
+
+        for(SimulatorResourceServer simResServer : simResoruces)
+            deleteResource(simResServer);
+
+        assertTrue(result);
+    }
+
+    public void testDeleteResources_P01()
+    {
+        boolean result = true;
+
+        createResources(4);
+
+        try
+        {
+            SimulatorManager.deleteResources(RESOURCE_TYPE);
+        }
+        catch (Exception e)
+        {
+            result = false;
+        }
+
+        assertTrue(result);
+    }
+
+    public void testFindResouce_P01()
+    {
+        boolean result = true;
+
+        SimulatorResourceServer simulatorResourceServer = createResource();
+
+        SimulatorRemoteResourceObject simulatorRemoteResource = new SimulatorRemoteResourceObject();
+
+        FindResourceListener findResourceListener = new FindResourceListener(lockObject, simulatorRemoteResource);
+
+        try
+        {
+            SimulatorManager.findResource(findResourceListener);
+        }
+        catch (Exception e)
+        {
+            result = false;
+        }
+
+        assertTrue(result);
+
+        deleteResource(simulatorResourceServer);
+    }
+
+    /**
+     * Pass null to listener
+     */
+    public void testFindResouce_N01()
+    {
+        boolean result = true;
+
+        SimulatorResourceServer simulatorResourceServer = createResource();
+
+        try
+        {
+            SimulatorManager.findResource(null);
+            result = false;
+        }
+        catch (Exception e)
+        {
+            result = true;
+        }
+
+        assertTrue(result);
+
+        deleteResource(simulatorResourceServer);
+    }
+
+    /**
+     *  checking for crash
+     */
+    public void testSetDeviceInfo_P01()
+    {
+        SimulatorManager.setDeviceInfo("test");
+    }
+
+    /**
+     *  checking for crash
+     *  Pass empty
+     */
+    public void testSetDeviceInfo_N01()
+    {
+        SimulatorManager.setDeviceInfo("");
+    }
+
+    /**
+     * 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");
+
+        SimulatorManager.setPlatformInfo(platformInfo);
+    }
+}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/SimulatorRemoteResourceObject.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/SimulatorRemoteResourceObject.java
new file mode 100644 (file)
index 0000000..17c5196
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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.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;
+    }
+}
diff --git a/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/SimulatorResourceModelTest.java b/service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/SimulatorResourceModelTest.java
new file mode 100644 (file)
index 0000000..23448e4
--- /dev/null
@@ -0,0 +1,316 @@
+/*
+ * 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.Map;
+
+import junit.framework.TestCase;
+
+import org.oic.simulator.ResourceAttribute;
+import org.oic.simulator.SimulatorResourceModel;
+
+/**
+ * This class tests the functionality of Simulator Resource Model
+ * class APIs.
+ */
+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");
+    }
+
+    @Override
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+
+        simulatorResourceModel = new SimulatorResourceModel();
+    }
+
+    @Override
+    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 testAddAttributeInt_N01()
+    {
+        int val = -10;
+
+        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 testAddAttributeInt_N02()
+    {
+        int val = 666666;
+
+        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 testAddAttributeDouble_P01()
+    {
+        double val = 10.11;
+
+        boolean result = true;
+        try
+        {
+            simulatorResourceModel.addAttributeDouble(KEY, val);
+            result = result && Double.parseDouble(simulatorResourceModel.getAttribute(KEY).getValue().toString()) == val;
+        }
+        catch(Exception e)
+        {
+            result = false;
+        }
+
+        assertTrue(result);
+    }
+
+    public void testAddAttributeDouble_N01()
+    {
+        double val = -11.12;
+
+        boolean result = true;
+        try
+        {
+            simulatorResourceModel.addAttributeDouble(KEY, val);
+            result = result && Double.parseDouble(simulatorResourceModel.getAttribute(KEY).getValue().toString()) == val;
+        }
+        catch(Exception e)
+        {
+            result = false;
+        }
+
+        assertTrue(result);
+    }
+
+    public void testAddAttributeDouble_N02()
+    {
+        double val = 0.0044444444444;
+
+        boolean result = true;
+        try
+        {
+            simulatorResourceModel.addAttributeDouble(KEY, val);
+            result = result && Double.parseDouble(simulatorResourceModel.getAttribute(KEY).getValue().toString()) == val;
+        }
+        catch(Exception e)
+        {
+            result = false;
+        }
+
+        assertTrue(result);
+    }
+
+    public void testAddAttributeString_P01()
+    {
+        String val = "asdf";
+
+        boolean result = true;
+        try
+        {
+            simulatorResourceModel.addAttributeString(KEY, val);
+            result = result && simulatorResourceModel.getAttribute(KEY).getValue().toString().equals(val);
+        }
+        catch(Exception e)
+        {
+            result = false;
+        }
+
+        assertTrue(result);
+    }
+
+    public void testAddAttributeString_N01()
+    {
+        String val = "";
+
+        boolean result = true;
+        try
+        {
+            simulatorResourceModel.addAttributeString(KEY, val);
+            result = result && simulatorResourceModel.getAttribute(KEY).getValue().toString().equals(val);
+        }
+        catch(Exception e)
+        {
+            result = false;
+        }
+
+        assertTrue(result);
+    }
+
+    public void testAddAttributeString_N03()
+    {
+        String val = "@#$$&^*^(*^&";
+
+        boolean result = true;
+        try
+        {
+            simulatorResourceModel.addAttributeString(KEY, val);
+            result = result && simulatorResourceModel.getAttribute(KEY).getValue().toString().equals(val);
+        }
+        catch(Exception e)
+        {
+            result = false;
+        }
+
+        assertTrue(result);
+    }
+
+    public void testAddAttributeBoolean_P01()
+    {
+        boolean result = true;
+
+        boolean val = true;
+
+        try
+        {
+            simulatorResourceModel.addAttributeBoolean(KEY, val);
+
+            result = result && ((Boolean.parseBoolean(simulatorResourceModel.getAttribute(KEY).getValue() + "")));
+
+            val = false;
+
+            simulatorResourceModel.addAttributeBoolean(KEY, val);
+
+            result = result && !((Boolean.parseBoolean(simulatorResourceModel.getAttribute(KEY).getValue() + "")));
+        }
+        catch (Exception e)
+        {
+            result = false;
+        }
+
+        assertTrue(result);
+    }
+
+    public void testSize_P01()
+    {
+        boolean result = true;
+
+        try
+        {
+            simulatorResourceModel.addAttributeInt("test1", 1234);
+
+            result = result && (simulatorResourceModel.size() == 1);
+
+            simulatorResourceModel.addAttributeString("test2", "asdf");
+            simulatorResourceModel.addAttributeBoolean("test3", true);
+            simulatorResourceModel.addAttributeDouble("test4", 22.435234);
+
+            result = result && (simulatorResourceModel.size() == 4);
+        }
+        catch(Exception e)
+        {
+            result = false;
+        }
+        assertTrue(result);
+    }
+
+    public void testGetAttributes_P01()
+    {
+        boolean result = true;
+
+        try
+        {
+            simulatorResourceModel.addAttributeInt("test1", 1234);
+            simulatorResourceModel.addAttributeString("test2", "asdf");
+            simulatorResourceModel.addAttributeBoolean("test3", 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() + "")==true)) &&
+                     (((Double)attributes.get("test4").getValue()) == 22.435234);
+        }
+        catch(Exception e)
+        {
+            result = false;
+        }
+        assertTrue(result);
+    }
+
+    public void testGetAttribute_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);
+    }
+}