Fix for POST automation UI issue, review comments and code cleanup from master branch.
authorspurthi.segu <spurthi.segu@samsung.com>
Tue, 13 Oct 2015 15:57:01 +0000 (21:27 +0530)
committerMadan Lanka <lanka.madan@samsung.com>
Wed, 14 Oct 2015 00:43:09 +0000 (00:43 +0000)
Change-Id: I9a6481ff22e479b8e455118a57cd9357eb1a0b8e
Signed-off-by: spurthi.segu <spurthi.segu@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3861
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
16 files changed:
service/simulator/inc/simulator_resource_server.h
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/PostRequestDialog.java
service/simulator/java/jni/simulator_device_info_jni.cpp
service/simulator/java/jni/simulator_remote_resource_jni.cpp
service/simulator/java/jni/simulator_remote_resource_jni.h
service/simulator/java/jni/simulator_resource_model_jni.cpp
service/simulator/java/jni/simulator_resource_server_jni.cpp
service/simulator/java/sdk/src/org/oic/simulator/SimulatorResourceModel.java
service/simulator/java/sdk/src/org/oic/simulator/clientcontroller/SimulatorRemoteResource.java
service/simulator/java/sdk/src/org/oic/simulator/serviceprovider/SimulatorResourceServer.java
service/simulator/src/client-controller/simulator_remote_resource_impl.cpp
service/simulator/src/common/simulator_resource_model.cpp
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/clientcontroller/test/SimulatorRemoteResourceTest.java
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/serviceprovider/test/SimlatorResourceServerTest.java
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/SimulatorManagerTest.java
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/SimulatorResourceModelTest.java

index 95791df..b6f61a1 100644 (file)
@@ -209,6 +209,7 @@ class SimulatorResourceServer
          *
          * @param attrName - Name of the attribute to be automated.
          * @param type - Automation type.
+         * @param updateInterval -Interval time in milliseconds for attribute value update automation.
          * @param callback - Callback to get notifiy when update automation is finished.
          * @param id - Identifier for automation.
          *
index 02a42a5..0938acc 100644 (file)
@@ -19,7 +19,6 @@ package oic.simulator.clientcontroller.view.dialogs;
 import java.util.List;
 
 import oic.simulator.clientcontroller.Activator;
-import oic.simulator.clientcontroller.manager.ResourceManager;
 import oic.simulator.clientcontroller.remoteresource.PutPostAttributeModel;
 import oic.simulator.clientcontroller.utils.Constants;
 
@@ -30,6 +29,7 @@ import org.eclipse.jface.viewers.CheckboxCellEditor;
 import org.eclipse.jface.viewers.ColumnLabelProvider;
 import org.eclipse.jface.viewers.EditingSupport;
 import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.StyledCellLabelProvider;
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.jface.viewers.TableViewerColumn;
@@ -37,6 +37,8 @@ import org.eclipse.jface.viewers.TextCellEditor;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.jface.viewers.ViewerCell;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.layout.GridLayout;
@@ -45,6 +47,7 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
 
 /**
  * This dialog is used for generating a POST request.
@@ -57,15 +60,12 @@ public class PostRequestDialog extends TitleAreaDialog {
             "Select"                                  };
     private final Integer[]             attTblColWidth = { 200, 200, 50 };
 
-    private ResourceManager             resourceManager;
-
     private List<PutPostAttributeModel> modelList      = null;
 
     public PostRequestDialog(Shell parentShell,
             List<PutPostAttributeModel> modelList) {
         super(parentShell);
         this.modelList = modelList;
-        resourceManager = Activator.getDefault().getResourceManager();
     }
 
     @Override
@@ -204,11 +204,33 @@ public class PostRequestDialog extends TitleAreaDialog {
     class AttributeValueEditor extends EditingSupport {
         private final TableViewer viewer;
         private final CellEditor  editor;
-
+        private final Text txt;
         public AttributeValueEditor(TableViewer viewer) {
             super(viewer);
             this.viewer = viewer;
             editor = new TextCellEditor(viewer.getTable());
+            txt = (Text)editor.getControl();
+            if(null != txt) {
+                txt.addModifyListener(new ModifyListener() {
+                    @Override
+                    public void modifyText(ModifyEvent e) {
+                        IStructuredSelection selection = (IStructuredSelection)AttributeValueEditor.this.viewer.getSelection();
+                        PutPostAttributeModel att = (PutPostAttributeModel)selection.getFirstElement();
+                        if(null == att) {
+                            return;
+                        }
+                        String newValue = txt.getText();
+                        if(null != newValue && !newValue.isEmpty()) {
+                            att.setModified(true);
+                        }
+                        else {
+                            att.setModified(false);
+                        }
+                        AttributeValueEditor.this.viewer.update(att, null);
+                    }
+                });
+
+            }
         }
 
         @Override
@@ -234,14 +256,6 @@ public class PostRequestDialog extends TitleAreaDialog {
             // If there is a change, then its corresponding check box should be
             // checked.
             String newValue = String.valueOf(value);
-            String actualValue = resourceManager.getAttributeValue(
-                    resourceManager.getCurrentResourceInSelection(),
-                    model.getAttName());
-            if (newValue.equals(actualValue)) {
-                model.setModified(false);
-            } else {
-                model.setModified(true);
-            }
             model.setAttValue(newValue);
             viewer.update(element, null);
         }
index be28c6d..c954a97 100644 (file)
@@ -27,12 +27,12 @@ jobject JDeviceInfo::toJava(DeviceInfo &deviceInfo)
     if (!m_env)
         return nullptr;
 
-    jmethodID constr = m_env->GetMethodID(gSimulatorClassRefs.classDeviceInfo, "<init>", "(V)V");
-    if (constr)
+    jmethodID deviceInfoMId = m_env->GetMethodID(gSimulatorClassRefs.classDeviceInfo, "<init>", "(V)V");
+    if (!deviceInfoMId)
         return nullptr;
 
-    jobject jDeviceInfo = (jobject) m_env->NewObject(gSimulatorClassRefs.classDeviceInfo, constr);
-    if (jDeviceInfo)
+    jobject jDeviceInfo = (jobject) m_env->NewObject(gSimulatorClassRefs.classDeviceInfo, deviceInfoMId);
+    if (!jDeviceInfo)
         return nullptr;
 
     setFieldValue(jDeviceInfo, "mName", deviceInfo.getName());
index 3b62939..63215b6 100644 (file)
@@ -739,7 +739,7 @@ Java_org_oic_simulator_clientcontroller_SimulatorRemoteResource_setConfigInfo
     if (!jConfigPath)
     {
         throwInvalidArgsException(env, SIMULATOR_INVALID_PARAM,
-                                  "Configuration file path is empty!");
+                                  "Configuration file path is null!");
         return;
     }
 
@@ -889,3 +889,9 @@ Java_org_oic_simulator_clientcontroller_SimulatorRemoteResource_stopVerification
     }
 }
 
+JNIEXPORT void JNICALL Java_org_oic_simulator_clientcontroller_SimulatorRemoteResource_dispose
+(JNIEnv *env, jobject thiz)
+{
+    JniSimulatorRemoteResource *resource = GetHandle<JniSimulatorRemoteResource>(env, thiz);
+    delete resource;
+}
\ No newline at end of file
index 50befef..b1fbecd 100644 (file)
@@ -73,6 +73,10 @@ JNIEXPORT void JNICALL
 Java_org_oic_simulator_clientcontroller_SimulatorRemoteResource_stopVerification
 (JNIEnv *env, jobject thiz, jint jId);
 
+JNIEXPORT void JNICALL
+Java_org_oic_simulator_clientcontroller_SimulatorRemoteResource_dispose
+(JNIEnv *, jobject);
+
 #ifdef __cplusplus
 }
 #endif
index 9d67689..65b9d9d 100644 (file)
@@ -316,6 +316,12 @@ Java_org_oic_simulator_SimulatorResourceModel_addAttributeString
         return;
     }
 
+    if (!jvalue)
+    {
+        throwInvalidArgsException(env, SIMULATOR_INVALID_PARAM, "Attribute value cannot be null!");
+        return;
+    }
+
     SimulatorResourceModelSP resModelPtr;
     resModelPtr = JSimulatorResourceModel::getResourceModelPtr(env, thiz);
     if (!resModelPtr)
index 1853c95..209ef47 100644 (file)
@@ -234,6 +234,12 @@ Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_addAttributeStrin
         return;
     }
 
+    if (!jValue)
+    {
+        throwInvalidArgsException(env, SIMULATOR_INVALID_PARAM, "Attribute value cannot be null!");
+        return;
+    }
+
     SimulatorResourceServerSP resource = JniSimulatorResource::getJniSimulatorResourceSP(env,
                                          jobject);
     if (!resource)
@@ -639,7 +645,25 @@ Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_removeAttribute
     }
 
     std::string str = env->GetStringUTFChars(jKey, NULL);
-    resource->removeAttribute(str);
+    try
+    {
+        resource->removeAttribute(str);
+    }
+    catch (InvalidArgsException &e)
+    {
+        throwInvalidArgsException(env, e.code(), e.what());
+        return;
+    }
+    catch (SimulatorException &e)
+    {
+        throwSimulatorException(env, e.code(), e.what());
+        return;
+    }
+    catch (...)
+    {
+        throwSimulatorException(env, SIMULATOR_ERROR, "Unknown Exception");
+        return;
+    }
 }
 
 JNIEXPORT jobjectArray JNICALL
index a276e0f..63961e9 100644 (file)
@@ -157,9 +157,7 @@ public class SimulatorResourceModel {
     protected void finalize() throws Throwable {
         try {
             dispose();
-        } catch(Throwable t){
-            throw t;
-        } finally{
+        } finally {
             super.finalize();
         }
     }
index 096e65e..1697681 100644 (file)
@@ -417,9 +417,7 @@ public class SimulatorRemoteResource {
     protected void finalize() throws Throwable {
         try {
             dispose();
-        } catch(Throwable t){
-            throw t;
-        } finally{
+        } finally {
             super.finalize();
         }
     }
index 2329be0..d601b53 100644 (file)
@@ -334,6 +334,8 @@ public class SimulatorResourceServer {
      * @param typeOfAutomation
      *            {@link AutomationType} indicating whether the automation is
      *            one-time or recursive.
+     * @param updateInterval
+     *            Interval time in milliseconds for attribute value update automation.
      * @param listener
      *            Listener to be notified when automation ends.
      *
@@ -361,6 +363,8 @@ public class SimulatorResourceServer {
      * @param typeOfAutomation
      *            {@link AutomationType} indicating whether the automation is
      *            one-time or recursive.
+     * @param updateInterval
+     *            Interval time in milliseconds for attribute value update automation.
      * @param listener
      *            Listener to be notified when automation ends.
      *
@@ -475,9 +479,7 @@ public class SimulatorResourceServer {
     protected void finalize() throws Throwable {
         try {
             dispose();
-        } catch(Throwable t){
-            throw t;
-        } finally{
+        } finally {
             super.finalize();
         }
     }
index 6b068af..178dccb 100644 (file)
@@ -356,7 +356,7 @@ void SimulatorRemoteResourceImpl::configure(const std::string &path)
 {
     if (path.empty())
     {
-        OC_LOG(ERROR, TAG, "Invalid path given for configuration !");
+        OC_LOG(ERROR, TAG, "Invalid path given for configuration!");
         throw InvalidArgsException(SIMULATOR_INVALID_PARAM, "Empty path string!");
     }
 
index 5cae008..2a1a67d 100644 (file)
@@ -19,6 +19,8 @@
  ******************************************************************/
 
 #include "simulator_resource_model.h"
+#include "simulator_exceptions.h"
+#include "logger.h"
 #include "OCPlatform.h"
 #include <sstream>
 #include <boost/lexical_cast.hpp>
@@ -315,9 +317,10 @@ void SimulatorResourceModel::updateAttributeFromAllowedValues(const std::string
 
 void SimulatorResourceModel::removeAttribute(const std::string &attrName)
 {
-   if (m_attributes.end() == m_attributes.find(attrName))
+   if (attrName.empty() || m_attributes.end() == m_attributes.find(attrName))
    {
-       return;
+       OC_LOG(ERROR, TAG, "Attribute name is empty or not found in model!");
+       throw InvalidArgsException(SIMULATOR_INVALID_PARAM, "Attribute not found in model!");
    }
 
     m_attributes.erase(attrName);
index 0ceab6d..6cc820a 100644 (file)
@@ -352,6 +352,30 @@ public class SimulatorRemoteResourceTest extends TestCase
         assertTrue(result && listenerObject != null && listenerObject.getRepresentation() != null && listenerObject.getuId() != null);
     }
 
+    /**
+     * model as null
+     */
+
+    public void testPut_N01() {
+        boolean result = true;
+        ListenerObject listenerObject = new ListenerObject();
+        PutListener putListener = new PutListener(lockObject, listenerObject);
+
+        try {
+            simulatorRemoteResource.put(null, null, putListener);
+            result = false;
+        } catch (Exception e1) {
+            result = true;
+        }
+
+        try {
+            lockObject.await(10, TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
+        }
+
+        assertTrue(result && listenerObject.getRepresentation() == null && listenerObject.getuId() == null);
+    }
+
     public void testPost_P01()
     {
         boolean result = true;
@@ -362,7 +386,6 @@ public class SimulatorRemoteResourceTest extends TestCase
         try
         {
             model.addAttributeInt("intensity", 8);
-            //model.addAttributeString("power", "off");
 
             listenerObject = new ListenerObject();
             PostListener postListener = new PostListener(lockObject, listenerObject);
@@ -385,6 +408,33 @@ public class SimulatorRemoteResourceTest extends TestCase
         assertTrue(result && listenerObject != null && listenerObject.getRepresentation() != null && listenerObject.getuId() != null);
     }
 
+    /**
+     * Model is set to null
+     */
+
+    public void testPost_N01() {
+        boolean result = true;
+
+        lockObject = new CountDownLatch(1);
+
+        ListenerObject listenerObject = new ListenerObject();
+        PostListener postListener = new PostListener(lockObject, listenerObject);
+
+        try {
+            simulatorRemoteResource.post(null, null, postListener);
+            result = false;
+        } catch (Exception e1) {
+            result = true;
+        }
+
+        try {
+            lockObject.await(10, TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
+        }
+
+        assertTrue(result && listenerObject.getRepresentation() == null && listenerObject.getuId() == null);
+    }
+
     public void testGet_P01()
     {
         boolean result = true;
@@ -398,8 +448,8 @@ public class SimulatorRemoteResourceTest extends TestCase
 
             String resInterface = simulatorRemoteResource.getResourceInterfaces().get(0);
 
-            if(resInterface == null)
-                simulatorRemoteResource.get(resInterface, null, onGetListener);
+            if(resInterface != null)
+                simulatorRemoteResource.get(resInterface,null, onGetListener);
             else
                 result = false;
         }
@@ -462,10 +512,12 @@ public class SimulatorRemoteResourceTest extends TestCase
         {
             String resInterface = simulatorRemoteResource.getResourceInterfaces().get(0);
 
-            if(resInterface == null)
-                simulatorRemoteResource.get(resInterface, null, null);
-            else
-                result = false;
+            if(resInterface != null)
+            {
+                simulatorRemoteResource.get( resInterface,null, null);
+            }
+
+            result = false;
         }
         catch(Exception e)
         {
@@ -796,7 +848,6 @@ public class SimulatorRemoteResourceTest extends TestCase
 
         try
         {
-
             lockObject.await(100, TimeUnit.MILLISECONDS);
         }
         catch (InterruptedException e)
index 0952af1..cfbe5d2 100644 (file)
@@ -53,7 +53,6 @@ public class SimlatorResourceServerTest extends TestCase
     {
         System.loadLibrary("SimulatorManager");
         System.loadLibrary("RamlParser");
-        System.loadLibrary("YamlParser");
         System.loadLibrary("oc");
         System.loadLibrary("oc_logger");
         System.loadLibrary("octbstack");
@@ -147,13 +146,13 @@ public class SimlatorResourceServerTest extends TestCase
     {
         try
         {
-            simulatorResourceServer.addAttributeBoolean(KEY, true);
+            simulatorResourceServer.addAttributeBoolean(KEY, Boolean.parseBoolean("true"));
         }
         catch (Exception e)
         {
             e.printStackTrace();
         }
-        assertEquals(Boolean.parseBoolean(getValue(KEY) + ""), true);
+        assertEquals(Boolean.parseBoolean(getValue(KEY).toString() + ""), true);
     }
 
     public void testaddAttributeString_P01()
@@ -236,7 +235,7 @@ public class SimlatorResourceServerTest extends TestCase
 
         try
         {
-            simulatorResourceServer.addAttributeBoolean(KEY, true);
+            simulatorResourceServer.addAttributeBoolean(KEY, Boolean.parseBoolean("true"));
         }
         catch (Exception e)
         {
@@ -248,7 +247,7 @@ public class SimlatorResourceServerTest extends TestCase
 
         try
         {
-            simulatorResourceServer.updateAttributeBoolean(KEY, false);
+            simulatorResourceServer.updateAttributeBoolean(KEY, Boolean.parseBoolean("false"));
         }
         catch (Exception e)
         {
@@ -757,7 +756,7 @@ public class SimlatorResourceServerTest extends TestCase
 
         try
         {
-            lockObject.await(10,TimeUnit.SECONDS);
+            lockObject.await(15,TimeUnit.SECONDS);
         }
         catch (InterruptedException e)
         {
@@ -791,7 +790,7 @@ public class SimlatorResourceServerTest extends TestCase
         {
             result = false;
         }
-        assertTrue(result && id == -1);
+        assertTrue(!result && id == 0);
     }
 
     public void testStartAttributeAutomation_P01()
@@ -803,7 +802,8 @@ public class SimlatorResourceServerTest extends TestCase
         int id = 0;
         try
         {
-            id = simulatorResourceServer.startAttributeAutomation(simulatorResourceServer.getModel().getAttributes().get(0).getName(),
+            simulatorResourceServer.addAttributeInteger(KEY, 10);
+            id = simulatorResourceServer.startAttributeAutomation(KEY,
                     AutomationType.NORMAL, automationListener);
         }
         catch (Exception e)
@@ -873,14 +873,12 @@ public class SimlatorResourceServerTest extends TestCase
 
         try
         {
-            lockObject.await(10, TimeUnit.SECONDS);
+            lockObject.await(05, TimeUnit.SECONDS);
         }
         catch (InterruptedException e)
         {
         }
 
-        result = result && automationObject.getResourceURI() != null && automationObject.getAutomationId() != -1 && id != -1;
-
         try
         {
             simulatorResourceServer.stopAutomation(id);
index c46653c..7fb25db 100644 (file)
@@ -19,7 +19,6 @@ 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;
@@ -38,16 +37,10 @@ public class SimulatorManagerTest extends TestCase
     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
@@ -212,6 +205,7 @@ public class SimulatorManagerTest extends TestCase
         SimulatorResourceServer[] simulatorResourceServers = null;
         try
         {
+            SimulatorManager.setDeviceInfo("test");
             simulatorResourceServers = SimulatorManager.createResource(configPath, count, resourceModelChangeListener);
         }
         catch (Exception e)
@@ -231,7 +225,6 @@ public class SimulatorManagerTest extends TestCase
         boolean result = false;
 
         SimulatorResourceServer[] simulatorResourceServers = null;
-
         try
         {
             simulatorResourceServers = SimulatorManager.createResource(CONFIG_PATH, count, null);
@@ -277,6 +270,19 @@ public class SimulatorManagerTest extends TestCase
         assertTrue(simulatorResourceServers == null);
     }
 
+    /**
+     * When count is set to -ve
+     */
+
+    public void testCreateResourceCount_N05()
+    {
+        int count = -10;
+
+        SimulatorResourceServer[] simulatorResourceServers = createResources(count);
+
+        assertTrue(simulatorResourceServers == null  );
+    }
+
     public void testDeleteResource_P01()
     {
         boolean result = true;
@@ -396,7 +402,42 @@ public class SimulatorManagerTest extends TestCase
      */
     public void testSetDeviceInfo_N01()
     {
-        SimulatorManager.setDeviceInfo("");
+        try
+        {
+            SimulatorManager.setDeviceInfo("");
+        }
+        catch(Exception e)
+        {
+            System.out.println("Exception hit");
+        }
+    }
+
+    /**
+    *  checking for crash
+    * pass null
+    */
+    public void testSetDeviceInfo_N02()
+    {
+        try
+        {
+            SimulatorManager.setDeviceInfo(null);
+        }
+        catch(Exception e)
+        {
+            System.out.println("Exception hit");
+        }
+    }
+
+    public void testGetDeviceInfo_N01()
+    {
+        try
+        {
+            SimulatorManager.getDeviceInfo(null);
+        }
+        catch(Exception e)
+        {
+            System.out.println(" Exception hit");
+        }
     }
 
     /**
@@ -419,4 +460,31 @@ public class SimulatorManagerTest extends TestCase
 
         SimulatorManager.setPlatformInfo(platformInfo);
     }
+
+    /**
+     * Checking for crash
+     */
+    public void testSetPlatformInfo_N01()
+    {
+        try
+        {
+            SimulatorManager.setPlatformInfo(null);
+        }
+        catch(Exception e)
+        {
+          System.out.println("Exception Hit");
+        }
+    }
+
+    public void testGetPlatformInfo_N01()
+    {
+        try
+        {
+            SimulatorManager.getPlatformInfo(null);
+        }
+        catch (Exception e)
+        {
+            System.out.println("Exception Hit");
+        }
+    }
 }
index 23448e4..2748e09 100644 (file)
@@ -203,6 +203,23 @@ public class SimulatorResourceModelTest extends TestCase
         assertTrue(result);
     }
 
+   public void testAddAttributeString_N02() {
+        String val = null;
+
+        boolean result = false;
+        try {
+
+            simulatorResourceModel.addAttributeString(KEY, val);
+
+            result = result && simulatorResourceModel.getAttribute(KEY).getValue().toString().equals(val);
+
+        } catch(Exception e) {
+            result = true;
+        }
+
+        assertTrue(result);
+    }
+
     public void testAddAttributeString_N03()
     {
         String val = "@#$$&^*^(*^&";
@@ -225,19 +242,20 @@ public class SimulatorResourceModelTest extends TestCase
     {
         boolean result = true;
 
-        boolean val = true;
+        boolean val;
 
         try
         {
+            val=Boolean.parseBoolean("true");
             simulatorResourceModel.addAttributeBoolean(KEY, val);
 
-            result = result && ((Boolean.parseBoolean(simulatorResourceModel.getAttribute(KEY).getValue() + "")));
+            result = result && ((Boolean.parseBoolean(simulatorResourceModel.getAttribute(KEY).getValue().toString()+"")));
 
-            val = false;
+            val = Boolean.parseBoolean("false");
 
             simulatorResourceModel.addAttributeBoolean(KEY, val);
 
-            result = result && !((Boolean.parseBoolean(simulatorResourceModel.getAttribute(KEY).getValue() + "")));
+            result = result && !((Boolean.parseBoolean(simulatorResourceModel.getAttribute(KEY).getValue().toString()+"")));
         }
         catch (Exception e)
         {
@@ -258,7 +276,7 @@ public class SimulatorResourceModelTest extends TestCase
             result = result && (simulatorResourceModel.size() == 1);
 
             simulatorResourceModel.addAttributeString("test2", "asdf");
-            simulatorResourceModel.addAttributeBoolean("test3", true);
+            simulatorResourceModel.addAttributeBoolean("test3", Boolean.parseBoolean("true"));
             simulatorResourceModel.addAttributeDouble("test4", 22.435234);
 
             result = result && (simulatorResourceModel.size() == 4);
@@ -278,14 +296,14 @@ public class SimulatorResourceModelTest extends TestCase
         {
             simulatorResourceModel.addAttributeInt("test1", 1234);
             simulatorResourceModel.addAttributeString("test2", "asdf");
-            simulatorResourceModel.addAttributeBoolean("test3", true);
+            simulatorResourceModel.addAttributeBoolean("test3", Boolean.parseBoolean("true"));
             simulatorResourceModel.addAttributeDouble("test4", 22.435234);
 
             Map<String, ResourceAttribute> attributes = simulatorResourceModel.getAttributes();
 
             result = result && (((Integer)attributes.get("test1").getValue()) == 1234) &&
                      (((String)attributes.get("test2").getValue()).equals("asdf")) &&
-                     ((Boolean.parseBoolean(attributes.get("test3").getValue() + "")==true)) &&
+                     ((Boolean.parseBoolean(attributes.get("test3").getValue().toString() + "")==true)) &&
                      (((Double)attributes.get("test4").getValue()) == 22.435234);
         }
         catch(Exception e)