Code cleanup, Junit fixes and updated Junit test cases for Simulator.
authorspurthi.segu <spurthi.segu@samsung.com>
Tue, 13 Oct 2015 08:18:28 +0000 (13:48 +0530)
committerUze Choi <uzchoi@samsung.com>
Wed, 14 Oct 2015 05:51:07 +0000 (05:51 +0000)
Change-Id: I08587ff08fdc58dbe245f13298c514562722bef5
Signed-off-by: spurthi.segu <spurthi.segu@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3847
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
17 files changed:
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/ResourceManager.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/AutomationSettingDialog.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/src/service-provider/simulator_resource_server_impl.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 ebc34e0..c065bc2 100644 (file)
@@ -44,7 +44,6 @@ import oic.simulator.serviceprovider.utils.Utility;
 import org.eclipse.swt.graphics.Image;
 import org.oic.simulator.IAutomation;
 import org.oic.simulator.ILogger.Level;
-import org.oic.simulator.InvalidArgsException;
 import org.oic.simulator.ResourceAttribute;
 import org.oic.simulator.ResourceAttribute.Range;
 import org.oic.simulator.ResourceAttribute.Type;
index e2bb48f..c2a6925 100644 (file)
@@ -41,7 +41,6 @@ import org.eclipse.swt.widgets.Shell;
 public class AutomationSettingDialog extends TitleAreaDialog {
 
     private CCombo                        autoTypeCmb;
-    private CCombo                        updateFreqCmb;
 
     private String                        automationType;
     private String                        updateFrequencyInMillis;
@@ -81,15 +80,6 @@ public class AutomationSettingDialog extends TitleAreaDialog {
         gd.grabExcessHorizontalSpace = true;
         autoTypeCmb.setLayoutData(gd);
 
-        Label updateFreqLbl = new Label(container, SWT.NONE);
-        updateFreqLbl.setText("Update Frequency(ms)");
-
-        updateFreqCmb = new CCombo(container, SWT.READ_ONLY | SWT.BORDER);
-        gd = new GridData();
-        gd.horizontalAlignment = SWT.FILL;
-        gd.grabExcessHorizontalSpace = true;
-        updateFreqCmb.setLayoutData(gd);
-
         populateSettingsData();
 
         addUIListeners();
@@ -119,13 +109,6 @@ public class AutomationSettingDialog extends TitleAreaDialog {
                 }
                 // Select the default value
                 autoTypeCmb.select(autoTypeCmb.indexOf(value));
-            } else if (settingId.equals(Constants.UPDATE_INTERVAL_IN_MS)) {
-                itr = allowedValues.iterator();
-                while (itr.hasNext()) {
-                    updateFreqCmb.add(itr.next());
-                }
-                // Select the default value
-                updateFreqCmb.select(updateFreqCmb.indexOf(value));
             }
         }
     }
@@ -137,18 +120,10 @@ public class AutomationSettingDialog extends TitleAreaDialog {
                 automationType = autoTypeCmb.getText();
             }
         });
-
-        updateFreqCmb.addSelectionListener(new SelectionAdapter() {
-            @Override
-            public void widgetSelected(SelectionEvent e) {
-                updateFrequencyInMillis = updateFreqCmb.getText();
-            }
-        });
     }
 
     public void setInitialSettings() {
         automationType = autoTypeCmb.getText();
-        updateFrequencyInMillis = updateFreqCmb.getText();
     }
 
     public String getAutomationType() {
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 c9b08c9..8a4a735 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..691fd5d 100644 (file)
@@ -157,9 +157,8 @@ public class SimulatorResourceModel {
     protected void finalize() throws Throwable {
         try {
             dispose();
-        } catch(Throwable t){
-            throw t;
-        } finally{
+        }
+        finally {
             super.finalize();
         }
     }
index 096e65e..a8aa3a3 100644 (file)
@@ -417,9 +417,8 @@ public class SimulatorRemoteResource {
     protected void finalize() throws Throwable {
         try {
             dispose();
-        } catch(Throwable t){
-            throw t;
-        } finally{
+        }
+        finally {
             super.finalize();
         }
     }
index 0d9accd..acc6cd1 100644 (file)
@@ -474,9 +474,8 @@ public class SimulatorResourceServer {
     protected void finalize() throws Throwable {
         try {
             dispose();
-        } catch(Throwable t){
-            throw t;
-        } finally{
+        }
+        finally {
             super.finalize();
         }
     }
index d4472f8..5523ab0 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 dcd7988..c26fa19 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>
@@ -311,9 +313,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 083e67f..426ee9d 100644 (file)
@@ -80,7 +80,8 @@ int SimulatorResourceServerImpl::startUpdateAutomation(AutomationType type,
         throw SimulatorException(SIMULATOR_NO_RESOURCE, "Invalid resource!");
     }
 
-    return m_updateAutomationMgr.startResourceAutomation(this, type, -1, callback);
+    // This fix is temporarily to give 500 ms default delay in automation until the new UI change is merged.
+    return m_updateAutomationMgr.startResourceAutomation(this, type, 500, callback);
 }
 
 int SimulatorResourceServerImpl::startUpdateAutomation(const std::string &attrName,
@@ -99,7 +100,8 @@ int SimulatorResourceServerImpl::startUpdateAutomation(const std::string &attrNa
         throw SimulatorException(SIMULATOR_NO_RESOURCE, "Invalid resource!");
     }
 
-    return m_updateAutomationMgr.startAttributeAutomation(this, attrName, type, -1, callback);
+    // This fix is temporarily to give 500 ms default delay in automation until the new UI change is merged.
+    return m_updateAutomationMgr.startAttributeAutomation(this, attrName, type, 500, callback);
 }
 
 std::vector<int> SimulatorResourceServerImpl::getResourceAutomationIds()
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)