Junit fixes and review comment fixes for Simulator.
authorspurthi.segu <spurthi.segu@samsung.com>
Wed, 7 Oct 2015 12:37:34 +0000 (18:07 +0530)
committerMadan Lanka <lanka.madan@samsung.com>
Wed, 7 Oct 2015 13:59:44 +0000 (13:59 +0000)
Change-Id: I215a83ef94b8b503018cf983bf36fc14bbe66c77
Signed-off-by: spurthi.segu <spurthi.segu@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3727
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Madan Lanka <lanka.madan@samsung.com>
service/simulator/inc/simulator_error_codes.h
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/ResourceManager.java
service/simulator/java/jni/simulator_resource_server_jni.cpp
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/service-provider/resource_update_automation_mngr.cpp

index fe2b6e1..76092a2 100644 (file)
@@ -75,7 +75,7 @@ typedef enum
     SIMULATOR_TYPE_MISMATCH,
     SIMULATOR_BAD_VALUE,
     SIMULATOR_BAD_OBJECT,
-    /** Simulator specific error codes - START */
+    /** Simulator specific error codes - END */
 
     SIMULATOR_ERROR = 255
 } SimulatorResult;
index d7b5feb..ebc34e0 100644 (file)
@@ -1384,17 +1384,7 @@ public class ResourceManager {
             if (null != resourceServerN) {
                 try {
                     resourceServerN.stopAutomation(autoId);
-                } catch (InvalidArgsException e) {
-                    Activator
-                    .getDefault()
-                    .getLogManager()
-                    .log(Level.ERROR.ordinal(),
-                            new Date(),
-                            "[" + e.getClass().getSimpleName() + "]"
-                                    + e.code().toString() + "-"
-                                    + e.message());
-                    return;
-               }catch (SimulatorException e) {
+                } catch (SimulatorException e) {
                     Activator
                             .getDefault()
                             .getLogManager()
@@ -1533,16 +1523,6 @@ public class ResourceManager {
         // Call native method
         try {
             resourceServer.stopAutomation(autoId);
-        } catch (InvalidArgsException e) {
-            Activator
-            .getDefault()
-            .getLogManager()
-            .log(Level.ERROR.ordinal(),
-                    new Date(),
-                    "[" + e.getClass().getSimpleName() + "]"
-                            + e.code().toString() + "-"
-                            + e.message());
-            return false;
         } catch (SimulatorException e) {
             Activator
                     .getDefault()
index 50affa6..c9b08c9 100644 (file)
@@ -603,20 +603,20 @@ Java_org_oic_simulator_serviceprovider_SimulatorResourceServer_stopAutomation
         throwSimulatorException(env, SIMULATOR_BAD_OBJECT, "No resource!");
         return;
     }
-    
-       try
+
+    try
     {
         resource->stopUpdateAutomation(automationId);
     }
-    catch (InvalidArgsException &e)
+    catch (SimulatorException &e)
     {
-        throwInvalidArgsException(env, e.code(), e.what());
+        throwSimulatorException(env, e.code(), e.what());
     }
     catch (...)
     {
         throwSimulatorException(env, SIMULATOR_ERROR, "Unknown Exception");
-    }  
-    
+    }
+
     SIM_LOG(ILogger::INFO, "Automation has been forcibly stopped.")
 }
 
index daed3b7..096e65e 100644 (file)
@@ -161,7 +161,7 @@ public class SimulatorRemoteResource {
             throw new InvalidArgsException(
                     SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
                     "Parameter passed in invalid");
-        this.get(null, queryParamsMap, onGetListener);
+        this.nativeGet(null, queryParamsMap, onGetListener);
     }
 
     /**
@@ -188,11 +188,11 @@ public class SimulatorRemoteResource {
     public void get(String resourceInterface,
             Map<String, String> queryParamsMap, IGetListener onGetListener)
             throws InvalidArgsException, NoSupportException, SimulatorException {
-        if (resourceInterface.isEmpty() || null == onGetListener)
+        if (null == resourceInterface || resourceInterface.isEmpty() || null == onGetListener)
             throw new InvalidArgsException(
                     SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
                     "Parameter passed in invalid");
-        this.get(resourceInterface, queryParamsMap, onGetListener);
+        this.nativeGet(resourceInterface, queryParamsMap, onGetListener);
     }
 
     private native void nativeGet(String resourceInterface,
@@ -228,7 +228,7 @@ public class SimulatorRemoteResource {
             throw new InvalidArgsException(
                     SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
                     "Parameter passed in invalid");
-        this.put(null, representation, queryParamsMap, onPutListener);
+        this.nativePut(null, representation, queryParamsMap, onPutListener);
     }
 
     /**
@@ -259,11 +259,12 @@ public class SimulatorRemoteResource {
             SimulatorResourceModel representation,
             Map<String, String> queryParamsMap, IPutListener onPutListener)
             throws InvalidArgsException, NoSupportException, SimulatorException {
-        if (resourceInterface.isEmpty() || null == representation || null == onPutListener)
+        if (null == resourceInterface || resourceInterface.isEmpty() ||
+            null == representation || null == onPutListener)
             throw new InvalidArgsException(
                     SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
                     "Parameter passed in invalid");
-        this.put(resourceInterface, representation, queryParamsMap, onPutListener);
+        this.nativePut(resourceInterface, representation, queryParamsMap, onPutListener);
     }
 
     private native void nativePut(String resourceInterface,
@@ -300,7 +301,7 @@ public class SimulatorRemoteResource {
             throw new InvalidArgsException(
                     SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
                     "Parameter passed in invalid");
-        this.post(null, representation, queryParamsMap, onPostListener);
+        this.nativePost(null, representation, queryParamsMap, onPostListener);
     }
 
     /**
@@ -331,11 +332,12 @@ public class SimulatorRemoteResource {
             SimulatorResourceModel representation,
             Map<String, String> queryParamsMap, IPostListener onPostListener)
             throws InvalidArgsException, NoSupportException, SimulatorException {
-        if (resourceInterface.isEmpty() || null == representation || null == onPostListener)
+        if (null == resourceInterface || resourceInterface.isEmpty() ||
+            null == representation || null == onPostListener)
             throw new InvalidArgsException(
                 SimulatorResult.SIMULATOR_INVALID_PARAM.ordinal(),
                 "Parameter passed in invalid");
-        this.post(resourceInterface, representation, queryParamsMap, onPostListener);
+        this.nativePost(resourceInterface, representation, queryParamsMap, onPostListener);
     }
 
     private native void nativePost(String resourceInterface,
index a42a12f..0d9accd 100644 (file)
@@ -389,7 +389,7 @@ public class SimulatorResourceServer {
      *             This exception will be thrown for other errors.
      */
     public native void stopAutomation(int automationId)
-            throws InvalidArgsException, SimulatorException;
+            throws SimulatorException;
 
     /**
      * API to remove an attribute from the simulated resource.
index c5ec75e..94eb2c5 100644 (file)
@@ -114,8 +114,8 @@ void UpdateAutomationMngr::stop(int id)
         return;
     }
 
-    //Throw InvalidArgsException
-    throw InvalidArgsException(SIMULATOR_INVALID_PARAM, "Invalid Automation Id!");
+    //Throw SimulatorException
+    throw SimulatorException(SIMULATOR_ERROR, "No automation is currently in progress for the given automation Id!");
 }
 
 void UpdateAutomationMngr::stopAll()