[IOT-2745][Simulator] Static Analysis issues fix. 25/22825/2
authorSenthil Kumar G S <senthil.gs@samsung.com>
Fri, 13 Oct 2017 14:37:53 +0000 (20:07 +0530)
committerAshok Babu Channa <ashok.channa@samsung.com>
Mon, 16 Oct 2017 18:27:29 +0000 (18:27 +0000)
1. Added log in exception catch blocks.
2. Merged conditional blocks and removed unnecessary conditions.
3. Incorporated proper usage of access specifiers such as final and static.

Change-Id: I78be7b865a30c1f8e746ed62213fb576d11505f8
Signed-off-by: Senthil Kumar G S <senthil.gs@samsung.com>
30 files changed:
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/Activator.java
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/manager/ResourceManager.java
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/remoteresource/ResourceRepresentation.java
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/utils/AttributeValueBuilder.java
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/utils/Utility.java
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/AttributeEditingSupport.java
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/LogView.java
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/ResourceManagerView.java
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/LoadRAMLDialog.java
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/PostRequestDialog.java
service/simulator/java/eclipse-plugin/ClientControllerPlugin/src/oic/simulator/clientcontroller/view/dialogs/PutRequestDialog.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/Activator.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/LogManager.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/manager/ResourceManager.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/model/AttributeHelper.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/AttributeValueBuilder.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/utils/Utility.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/LogView.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/MetaPropertiesView.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/ResourceManagerView.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/DeleteResourceWizard.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/LoadRamlPage.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/UpdateMultiInstanceCreationPropertiesPage.java
service/simulator/java/eclipse-plugin/ServiceProviderPlugin/src/oic/simulator/serviceprovider/view/dialogs/UpdatePropertiesPage.java
service/simulator/java/sdk/src/org/oic/simulator/ArrayValueValidator.java
service/simulator/java/sdk/src/org/oic/simulator/DoubleProperty.java
service/simulator/java/sdk/src/org/oic/simulator/IntegerProperty.java
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/client/test/SimulatorRemoteResourceTest.java
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/server/test/SimulatorSingleResourceTest.java
service/simulator/unittests/SimulatorTest/src/org/oic/simulator/test/SimulatorManagerTest.java

index 61667c8..8c30763 100644 (file)
@@ -34,11 +34,11 @@ public class Activator extends AbstractUIPlugin {
     // The shared instance
     private static Activator       plugin;
 
-    private static ResourceManager resourceManager;
+    private ResourceManager resourceManager;
 
-    private static LogManager      logManager;
+    private LogManager      logManager;
 
-    private static ImageManager    imageManager;
+    private ImageManager    imageManager;
 
     public Activator() {
     }
@@ -74,16 +74,16 @@ public class Activator extends AbstractUIPlugin {
         return resourceManager;
     }
 
-    private static void setResourceManager(ResourceManager manager) {
-        Activator.resourceManager = manager;
+    private void setResourceManager(ResourceManager manager) {
+        resourceManager = manager;
     }
 
     public LogManager getLogManager() {
         return logManager;
     }
 
-    private static void setLogManager(LogManager logManager) {
-        Activator.logManager = logManager;
+    private void setLogManager(LogManager manager) {
+        logManager = manager;
     }
 
     public ImageManager getImageManager() {
index b8ddf79..0ba8b9d 100755 (executable)
@@ -591,28 +591,28 @@ public class ResourceManager {
         try {
             // Compare URI.
             if (!existingNativeResourceRef.getURI().equals(
-                    existingNativeResourceRef.getURI())) {
+                    newNativeResourceRef.getURI())) {
                 change = true;
             }
 
             // Compare ID.
             if (!change
                     && !existingNativeResourceRef.getId().equals(
-                            existingNativeResourceRef.getId())) {
+                            newNativeResourceRef.getId())) {
                 change = true;
             }
 
             // Compare Host.
             if (!change
                     && !existingNativeResourceRef.getHost().equals(
-                            existingNativeResourceRef.getHost())) {
+                            newNativeResourceRef.getHost())) {
                 change = true;
             }
 
             // Compare Observable flag.
             if (!change
-                    && existingNativeResourceRef.isObservable() != existingNativeResourceRef
-                            .isObservable()) {
+                    && existingNativeResourceRef.isObservable() !=
+                            newNativeResourceRef.isObservable()) {
                 change = true;
             }
 
@@ -658,6 +658,11 @@ public class ResourceManager {
                 }
             }
         } catch (Exception e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             change = true;
         }
 
@@ -730,10 +735,15 @@ public class ResourceManager {
                 try {
                     thread.run();
                 } catch (Exception e) {
+                    e.printStackTrace();
+                    Activator
+                        .getDefault()
+                        .getLogManager()
+                        .log(Level.ERROR.ordinal(), new Date(),
+                                Utility.getSimulatorErrorString(e, null));
                     if (e instanceof InterruptedException) {
                         return;
                     }
-                    e.printStackTrace();
                 }
             }
         }
index 00f76d8..0f275f7 100644 (file)
@@ -16,6 +16,7 @@
 
 package oic.simulator.clientcontroller.remoteresource;
 
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -24,8 +25,12 @@ import org.oic.simulator.InvalidArgsException;
 import org.oic.simulator.ModelProperty;
 import org.oic.simulator.SimulatorResourceAttribute;
 import org.oic.simulator.SimulatorResourceModel;
+import org.oic.simulator.ILogger.Level;
 import org.oic.simulator.client.SimulatorRequestModel;
 
+import oic.simulator.clientcontroller.Activator;
+import oic.simulator.clientcontroller.utils.Utility;
+
 public class ResourceRepresentation {
     private Map<String, AttributeElement> mAttributes = new HashMap<String, AttributeElement>();
 
@@ -119,6 +124,12 @@ public class ResourceRepresentation {
                     model.set(entry.getKey(), attributeElement
                             .getSimulatorResourceAttribute().value());
                 } catch (InvalidArgsException e) {
+                    Activator
+                        .getDefault()
+                        .getLogManager()
+                        .log(Level.ERROR.ordinal(), new Date(),
+                                Utility.getSimulatorErrorString(e, null));
+
                     e.printStackTrace();
                 }
             }
@@ -138,6 +149,12 @@ public class ResourceRepresentation {
                     model.set(entry.getKey(), attributeElement
                             .getSimulatorResourceAttribute().value());
                 } catch (InvalidArgsException e) {
+                    Activator
+                        .getDefault()
+                        .getLogManager()
+                        .log(Level.ERROR.ordinal(), new Date(),
+                                Utility.getSimulatorErrorString(e, null));
+
                     e.printStackTrace();
                 }
             }
index 7816faa..4aaf54a 100644 (file)
 
 package oic.simulator.clientcontroller.utils;
 
+import java.util.Date;
 import java.util.Vector;
 
 import org.oic.simulator.AttributeValue;
+import org.oic.simulator.ILogger.Level;
+
+import oic.simulator.clientcontroller.Activator;
 
 public class AttributeValueBuilder {
     public static AttributeValue build(String valueString,
@@ -85,6 +89,11 @@ public class AttributeValueBuilder {
             } else if (valueType == AttributeValue.ValueType.STRING)
                 return new AttributeValue(valueString);
         } catch (Exception e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             return null;
         }
         return null;
index f3e3cdb..17b737a 100644 (file)
@@ -104,7 +104,7 @@ public class Utility {
         return detail;
     }
 
-    public static Comparator<AttributeElement> attributeComparator = new Comparator<AttributeElement>() {
+    public static final Comparator<AttributeElement> attributeComparator = new Comparator<AttributeElement>() {
                                                                        public int compare(
                                                                                AttributeElement att1,
                                                                                AttributeElement att2) {
index b61469f..0580ff4 100644 (file)
@@ -380,6 +380,11 @@ public class AttributeEditingSupport {
                 try {
                     ((AttributeElement) parent).deepSetChildValue(att);
                 } catch (InvalidArgsException e) {
+                    Activator
+                        .getDefault()
+                        .getLogManager()
+                        .log(Level.ERROR.ordinal(), new Date(),
+                                Utility.getSimulatorErrorString(e, null));
                     e.printStackTrace();
                 }
             }
index c1642d2..05f5f38 100644 (file)
@@ -59,6 +59,7 @@ import java.io.BufferedWriter;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
+import java.io.Writer;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
@@ -430,10 +431,13 @@ public class LogView extends ViewPart {
                     sb.append(entry.toString());
                 }
                 String data = sb.toString();
+                FileOutputStream fos = null;
+                Writer osw = null;
                 BufferedWriter out = null;
                 try {
-                    out = new BufferedWriter(new OutputStreamWriter(
-                            new FileOutputStream(name), "UTF-8"));
+                    fos = new FileOutputStream(name);
+                    osw = new OutputStreamWriter(fos, "UTF-8");
+                    out = new BufferedWriter(osw);
                     out.write(data);
                 } catch (Exception e) {
                     e.printStackTrace();
@@ -456,6 +460,32 @@ public class LogView extends ViewPart {
                                         "[" + e.getClass().getSimpleName()
                                                 + "]" + e.getMessage());
                     }
+                    try {
+                        if (null != osw) {
+                            osw.close();
+                        }
+                    } catch (IOException e) {
+                        Activator
+                                .getDefault()
+                                .getLogManager()
+                                .log(Level.ERROR.ordinal(),
+                                        new Date(),
+                                        "[" + e.getClass().getSimpleName()
+                                                + "]" + e.getMessage());
+                    }
+                    try {
+                        if (null != fos) {
+                            fos.close();
+                        }
+                    } catch (IOException e) {
+                        Activator
+                                .getDefault()
+                                .getLogManager()
+                                .log(Level.ERROR.ordinal(),
+                                        new Date(),
+                                        "[" + e.getClass().getSimpleName()
+                                                + "]" + e.getMessage());
+                    }
                 }
             }
         };
index 1f70ccb..fc3dcca 100644 (file)
@@ -49,10 +49,12 @@ import org.eclipse.ui.dialogs.FilteredTree;
 import org.eclipse.ui.dialogs.PatternFilter;
 import org.eclipse.ui.part.ViewPart;
 
+import java.util.Date;
 import java.util.List;
 import java.util.Set;
 
 import org.oic.simulator.SimulatorException;
+import org.oic.simulator.ILogger.Level;
 
 import oic.simulator.clientcontroller.Activator;
 import oic.simulator.clientcontroller.listener.IFindResourceUIListener;
@@ -60,6 +62,7 @@ import oic.simulator.clientcontroller.manager.ResourceManager;
 import oic.simulator.clientcontroller.manager.UiListenerHandler;
 import oic.simulator.clientcontroller.remoteresource.RemoteResource;
 import oic.simulator.clientcontroller.utils.Constants;
+import oic.simulator.clientcontroller.utils.Utility;
 import oic.simulator.clientcontroller.view.dialogs.FindResourceWizard;
 import oic.simulator.clientcontroller.view.dialogs.LoadRAMLDialog;
 import oic.simulator.clientcontroller.view.dialogs.ResourceWizardDialog;
@@ -436,6 +439,11 @@ public class ResourceManagerView extends ViewPart {
                                                 "Failed to obtain the details from the given RAML.");
                             }
                         } catch (SimulatorException e) {
+                            Activator
+                                .getDefault()
+                                .getLogManager()
+                                .log(Level.ERROR.ordinal(), new Date(),
+                                        Utility.getSimulatorErrorString(e, null));
                             MessageDialog.openInformation(Display.getDefault()
                                     .getActiveShell(), "Invalid RAML",
                                     "Given configuration file is invalid.");
index 8fa457b..dbfa35e 100644 (file)
@@ -135,6 +135,11 @@ public class LoadRAMLDialog extends TitleAreaDialog {
         try {
             fileStream = new FileInputStream(configFilePath);
         } catch (Exception e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             MessageDialog
                     .openError(getShell(), "Invalid File",
                             "File doesn't exist. Either the file path or file name is invalid.");
index 8d694bb..96a0a4b 100644 (file)
@@ -592,6 +592,11 @@ public class PostRequestDialog extends TitleAreaDialog {
             value = Utility.cloneAttributeValue(new AttributeValue(
                     modelValue[0]));
         } catch (Exception e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             return null;
         }
 
index a5ccdb2..5f6c987 100644 (file)
@@ -581,6 +581,11 @@ public class PutRequestDialog extends TitleAreaDialog {
             value = Utility.cloneAttributeValue(new AttributeValue(
                     modelValue[0]));
         } catch (Exception e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             return null;
         }
 
index e49f523..16666c4 100644 (file)
@@ -34,11 +34,11 @@ public class Activator extends AbstractUIPlugin {
     // The shared instance
     private static Activator       plugin;
 
-    private static ResourceManager resourceManager;
+    private ResourceManager resourceManager;
 
-    private static LogManager      logManager;
+    private LogManager      logManager;
 
-    private static ImageManager    imageManager;
+    private ImageManager    imageManager;
 
     public Activator() {
     }
@@ -75,16 +75,16 @@ public class Activator extends AbstractUIPlugin {
         return resourceManager;
     }
 
-    private static void setResourceManager(ResourceManager manager) {
-        Activator.resourceManager = manager;
+    private void setResourceManager(ResourceManager manager) {
+        resourceManager = manager;
     }
 
     public LogManager getLogManager() {
         return logManager;
     }
 
-    private static void setLogManager(LogManager logManager) {
-        Activator.logManager = logManager;
+    private void setLogManager(LogManager manager) {
+        logManager = manager;
     }
 
     public ImageManager getImageManager() {
index 5c35db6..3515551 100644 (file)
@@ -85,10 +85,10 @@ public class LogManager {
                 try {
                     pop.run();
                 } catch (Exception e) {
+                    e.printStackTrace();
                     if (e instanceof InterruptedException) {
                         return;
                     }
-                    e.printStackTrace();
                 }
             }
         }
index c3e0604..38f2c9b 100644 (file)
@@ -330,10 +330,15 @@ public class ResourceManager {
                 try {
                     thread.run();
                 } catch (Exception e) {
+                    e.printStackTrace();
+                    Activator
+                        .getDefault()
+                        .getLogManager()
+                        .log(Level.ERROR.ordinal(), new Date(),
+                                Utility.getSimulatorErrorString(e, null));
                     if (e instanceof InterruptedException) {
                         return;
                     }
-                    e.printStackTrace();
                 }
             }
         }
@@ -1107,6 +1112,11 @@ public class ResourceManager {
                 return false;
             }
         } catch (SimulatorException e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             setResourceType(resource, curResourceType);
         }
 
index 7329569..3d1ca95 100644 (file)
@@ -16,6 +16,7 @@
 
 package oic.simulator.serviceprovider.model;
 
+import java.util.Date;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
@@ -23,12 +24,14 @@ import java.util.Set;
 import org.oic.simulator.AttributeProperty;
 import org.oic.simulator.AttributeValue;
 import org.oic.simulator.AttributeValue.ValueType;
+import org.oic.simulator.ILogger.Level;
 import org.oic.simulator.BooleanProperty;
 import org.oic.simulator.DoubleProperty;
 import org.oic.simulator.IntegerProperty;
 import org.oic.simulator.SimulatorResourceAttribute;
 import org.oic.simulator.StringProperty;
 
+import oic.simulator.serviceprovider.Activator;
 import oic.simulator.serviceprovider.utils.Constants;
 import oic.simulator.serviceprovider.utils.Utility;
 
@@ -178,6 +181,11 @@ public class AttributeHelper {
         try {
             Integer.parseInt(value);
         } catch (Exception e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             isInt = false;
         }
         return isInt;
@@ -188,6 +196,11 @@ public class AttributeHelper {
         try {
             Double.parseDouble(value);
         } catch (Exception e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             isDouble = false;
         }
         return isDouble;
@@ -207,6 +220,11 @@ public class AttributeHelper {
                     result = false;
                 }
             } catch (Exception e) {
+                Activator
+                    .getDefault()
+                    .getLogManager()
+                    .log(Level.ERROR.ordinal(), new Date(),
+                            Utility.getSimulatorErrorString(e, null));
                 result = false;
             }
         } else if (type.equals(Constants.DOUBLE)) {
@@ -253,6 +271,11 @@ public class AttributeHelper {
                             result = false;
                         }
                     } catch (Exception e) {
+                        Activator
+                            .getDefault()
+                            .getLogManager()
+                            .log(Level.ERROR.ordinal(), new Date(),
+                                    Utility.getSimulatorErrorString(e, null));
                         result = false;
                     }
                 } else if (attributeType.equals(Constants.DOUBLE)) {
@@ -272,6 +295,11 @@ public class AttributeHelper {
                             result = false;
                         }
                     } catch (Exception e) {
+                        Activator
+                            .getDefault()
+                            .getLogManager()
+                            .log(Level.ERROR.ordinal(), new Date(),
+                                    Utility.getSimulatorErrorString(e, null));
                         result = false;
                     }
                 }
index 4c640e3..e1ca823 100644 (file)
 
 package oic.simulator.serviceprovider.utils;
 
+import java.util.Date;
 import java.util.Vector;
 
 import org.oic.simulator.AttributeValue;
+import org.oic.simulator.ILogger.Level;
+
+import oic.simulator.serviceprovider.Activator;
 
 public class AttributeValueBuilder {
     public static AttributeValue build(String valueString,
@@ -85,6 +89,11 @@ public class AttributeValueBuilder {
             } else if (valueType == AttributeValue.ValueType.STRING)
                 return new AttributeValue(valueString);
         } catch (Exception e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             return null;
         }
         return null;
index dcf10e4..c6e9914 100644 (file)
@@ -197,6 +197,11 @@ public class Utility {
                 arr[i++] = (int) itr.next();
             }
         } catch (Exception e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             return null;
         }
         return arr;
@@ -214,6 +219,11 @@ public class Utility {
                 arr[i++] = (double) itr.next();
             }
         } catch (Exception e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             return null;
         }
         return arr;
@@ -231,6 +241,11 @@ public class Utility {
                 arr[i++] = (boolean) itr.next();
             }
         } catch (Exception e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             return null;
         }
         return arr;
@@ -248,6 +263,11 @@ public class Utility {
                 arr[i++] = (String) itr.next();
             }
         } catch (Exception e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             return null;
         }
         return arr;
@@ -265,6 +285,11 @@ public class Utility {
                 resultVec.add((Integer) itr.next());
             }
         } catch (Exception e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             return null;
         }
         return resultVec;
@@ -282,6 +307,11 @@ public class Utility {
                 resultVec.add((Double) itr.next());
             }
         } catch (Exception e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             return null;
         }
         return resultVec;
@@ -299,6 +329,11 @@ public class Utility {
                 resultVec.add((String) itr.next());
             }
         } catch (Exception e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             return null;
         }
         return resultVec;
@@ -381,7 +416,7 @@ public class Utility {
         return strArr;
     }
 
-    public static Comparator<Resource>         resourceComparator       = new Comparator<Resource>() {
+    public static final Comparator<Resource>         resourceComparator       = new Comparator<Resource>() {
                                                                             public int compare(
                                                                                     Resource res1,
                                                                                     Resource res2) {
@@ -427,7 +462,7 @@ public class Utility {
                                                                             }
                                                                         };
 
-    public static Comparator<SingleResource>   singleResourceComparator = new Comparator<SingleResource>() {
+    public static final Comparator<SingleResource>   singleResourceComparator = new Comparator<SingleResource>() {
                                                                             public int compare(
                                                                                     SingleResource res1,
                                                                                     SingleResource res2) {
@@ -473,7 +508,7 @@ public class Utility {
                                                                             }
                                                                         };
 
-    public static Comparator<AttributeElement> attributeComparator      = new Comparator<AttributeElement>() {
+    public static final Comparator<AttributeElement> attributeComparator      = new Comparator<AttributeElement>() {
                                                                             public int compare(
                                                                                     AttributeElement att1,
                                                                                     AttributeElement att2) {
index 4098cbb..27c6601 100644 (file)
@@ -59,8 +59,10 @@ import java.io.BufferedWriter;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
+import java.io.Writer;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 
@@ -73,6 +75,7 @@ import oic.simulator.serviceprovider.Activator;
 import oic.simulator.serviceprovider.listener.ILogListener;
 import oic.simulator.serviceprovider.manager.LogManager;
 import oic.simulator.serviceprovider.utils.Constants;
+import oic.simulator.serviceprovider.utils.Utility;
 import oic.simulator.serviceprovider.view.dialogs.FilterDialog;
 import oic.simulator.serviceprovider.view.dialogs.LogDetailsDialog;
 
@@ -429,10 +432,13 @@ public class LogView extends ViewPart {
                     sb.append(entry.toString());
                 }
                 String data = sb.toString();
+                FileOutputStream fos = null;
+                Writer osw = null;
                 BufferedWriter out = null;
                 try {
-                    out = new BufferedWriter(new OutputStreamWriter(
-                            new FileOutputStream(name), "UTF-8"));
+                    fos = new FileOutputStream(name);
+                    osw = new OutputStreamWriter(fos, "UTF-8");
+                    out = new BufferedWriter(osw);
                     out.write(data);
                 } catch (Exception e) {
                     e.printStackTrace();
@@ -447,7 +453,33 @@ public class LogView extends ViewPart {
                             out.close();
                         }
                     } catch (IOException e) {
-                        System.out.println("Error occurred during close.");
+                        Activator
+                            .getDefault()
+                            .getLogManager()
+                            .log(Level.ERROR.ordinal(), new Date(),
+                                    Utility.getSimulatorErrorString(e, null));
+                    }
+                    try {
+                        if (null != osw) {
+                            osw.close();
+                        }
+                    } catch (IOException e) {
+                        Activator
+                            .getDefault()
+                            .getLogManager()
+                            .log(Level.ERROR.ordinal(), new Date(),
+                                    Utility.getSimulatorErrorString(e, null));
+                    }
+                    try {
+                        if (null != fos) {
+                            fos.close();
+                        }
+                    } catch (IOException e) {
+                        Activator
+                            .getDefault()
+                            .getLogManager()
+                            .log(Level.ERROR.ordinal(), new Date(),
+                                    Utility.getSimulatorErrorString(e, null));
                     }
                 }
             }
index b362e2e..4f125d5 100644 (file)
@@ -41,6 +41,7 @@ import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.Text;
 import org.eclipse.ui.part.ViewPart;
 
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -48,6 +49,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.oic.simulator.SimulatorException;
+import org.oic.simulator.ILogger.Level;
 
 import oic.simulator.serviceprovider.Activator;
 import oic.simulator.serviceprovider.listener.ISelectionChangedListener;
@@ -225,7 +227,7 @@ public class MetaPropertiesView extends ViewPart {
                                 .getResourceInterfaces();
                         // Adding default interface to local set if removed.
                         updatedIfSet.add(Constants.BASELINE_INTERFACE);
-                        if (null != curIfSet && null != updatedIfSet) {
+                        if (null != curIfSet) {
                             if (curIfSet.size() != updatedIfSet.size()) {
                                 update = true;
                                 interfaceChange = true;
@@ -273,6 +275,11 @@ public class MetaPropertiesView extends ViewPart {
                                                     updatedIfSet);
 
                             } catch (SimulatorException ex) {
+                                Activator
+                                    .getDefault()
+                                    .getLogManager()
+                                    .log(Level.ERROR.ordinal(), new Date(),
+                                            Utility.getSimulatorErrorString(ex, null));
                                 result = false;
                             }
                             if (!result) {
index 225a340..02ab93c 100644 (file)
@@ -306,6 +306,11 @@ public class ResourceManagerView extends ViewPart {
                                             resourceManager
                                                     .resourceSelectionChanged(null);
                                         } catch (SimulatorException e1) {
+                                            Activator
+                                                .getDefault()
+                                                .getLogManager()
+                                                .log(Level.ERROR.ordinal(), new Date(),
+                                                        Utility.getSimulatorErrorString(e1, null));
                                             MessageDialog
                                                     .openInformation(Display
                                                             .getDefault()
index c81078a..b3b4321 100644 (file)
@@ -36,6 +36,7 @@ import oic.simulator.serviceprovider.Activator;
 import oic.simulator.serviceprovider.manager.ResourceManager;
 import oic.simulator.serviceprovider.model.Resource;
 import oic.simulator.serviceprovider.model.SingleResource;
+import oic.simulator.serviceprovider.utils.Utility;
 
 /**
  * This class creates a UI wizard for delete resource operation.
@@ -98,6 +99,11 @@ public class DeleteResourceWizard extends Wizard {
                         monitor.worked(1);
                         success = true;
                     } catch (SimulatorException e) {
+                        Activator
+                            .getDefault()
+                            .getLogManager()
+                            .log(Level.ERROR.ordinal(), new Date(),
+                                    Utility.getSimulatorErrorString(e, null));
                         success = false;
                     } finally {
                         monitor.done();
index 8c0c778..10d9f4b 100644 (file)
@@ -218,6 +218,11 @@ public class LoadRamlPage extends WizardPage {
         try {
             resourceCount = Integer.parseInt(noOfInstancesText.getText());
         } catch (Exception e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             resourceCount = -1;
         }
         if (null != configFilePath && configFilePath.trim().length() > 0) {
@@ -233,6 +238,11 @@ public class LoadRamlPage extends WizardPage {
         try {
             resourceCount = Integer.parseInt(noOfInstancesText.getText());
         } catch (Exception e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             resourceCount = -1;
         }
         if (null != configFilePath && configFilePath.trim().length() > 0) {
@@ -257,6 +267,11 @@ public class LoadRamlPage extends WizardPage {
         try {
             fileStream = new FileInputStream(configFilePath);
         } catch (FileNotFoundException e) {
+            Activator
+                .getDefault()
+                .getLogManager()
+                .log(Level.ERROR.ordinal(), new Date(),
+                        Utility.getSimulatorErrorString(e, null));
             MessageDialog
                     .openError(getShell(), "Invalid File",
                             "File doesn't exist. Either the file path or file name is invalid.");
index 6365916..4e3a103 100644 (file)
@@ -157,7 +157,7 @@ public class UpdateMultiInstanceCreationPropertiesPage extends WizardPage {
         }
 
         this.resName = resName;
-        if (null != resName && !resNameTxt.isDisposed())
+        if (!resNameTxt.isDisposed())
             resNameTxt.setText(resName);
     }
 
@@ -167,7 +167,7 @@ public class UpdateMultiInstanceCreationPropertiesPage extends WizardPage {
         }
 
         this.resType = resType;
-        if (null != resType && !resTypeTxt.isDisposed())
+        if (!resTypeTxt.isDisposed())
             resTypeTxt.setText(resType);
     }
 
index af6b582..66896cf 100644 (file)
@@ -186,7 +186,7 @@ public class UpdatePropertiesPage extends WizardPage {
         }
 
         this.resName = resName;
-        if (null != resName && !resNameTxt.isDisposed())
+        if (!resNameTxt.isDisposed())
             resNameTxt.setText(resName);
     }
 
@@ -196,7 +196,7 @@ public class UpdatePropertiesPage extends WizardPage {
         }
 
         this.resURI = resURI;
-        if (null != resUriTxt && !resUriTxt.isDisposed())
+        if (!resUriTxt.isDisposed())
             resUriTxt.setText(resURI);
     }
 
index d4bbdb3..8c20833 100644 (file)
@@ -64,12 +64,9 @@ class ArrayValueValidator implements
             return false;
 
         // Validating length of array
-        if (mProperty.hasRange()) {
-            if (values.length < mProperty.minItems()
-                    || (values.length > mProperty.maxItems() && !mProperty
-                            .isVariable())) {
-                return false;
-            }
+        if (mProperty.hasRange() && (values.length < mProperty.minItems()
+                    || (values.length > mProperty.maxItems() && !mProperty.isVariable()))) {
+            return false;
         }
 
         // Validating elements of array
@@ -102,12 +99,9 @@ class ArrayValueValidator implements
             return false;
 
         // Validating length of array
-        if (mProperty.hasRange()) {
-            if (values.length < mProperty.minItems()
-                    || (values.length > mProperty.maxItems() && !mProperty
-                            .isVariable())) {
-                return false;
-            }
+        if (mProperty.hasRange() && (values.length < mProperty.minItems()
+                    || (values.length > mProperty.maxItems() && !mProperty.isVariable()))) {
+            return false;
         }
 
         // Validating elements of array
@@ -140,12 +134,9 @@ class ArrayValueValidator implements
             return false;
 
         // Validating length of array
-        if (mProperty.hasRange()) {
-            if (values.length < mProperty.minItems()
-                    || (values.length > mProperty.maxItems() && !mProperty
-                            .isVariable())) {
-                return false;
-            }
+        if (mProperty.hasRange() && (values.length < mProperty.minItems()
+                    || (values.length > mProperty.maxItems() && !mProperty.isVariable()))) {
+            return false;
         }
 
         // Validating elements of array
@@ -178,12 +169,9 @@ class ArrayValueValidator implements
             return false;
 
         // Validating length of array
-        if (mProperty.hasRange()) {
-            if (values.length < mProperty.minItems()
-                    || (values.length > mProperty.maxItems() && !mProperty
-                            .isVariable())) {
-                return false;
-            }
+        if (mProperty.hasRange() && (values.length < mProperty.minItems()
+                    || (values.length > mProperty.maxItems() && !mProperty.isVariable()))) {
+            return false;
         }
 
         // Validating elements of array
@@ -216,12 +204,9 @@ class ArrayValueValidator implements
             return false;
 
         // Validating length of array
-        if (mProperty.hasRange()) {
-            if (values.length < mProperty.minItems()
-                    || (values.length > mProperty.maxItems() && !mProperty
-                            .isVariable())) {
-                return false;
-            }
+        if (mProperty.hasRange() && (values.length < mProperty.minItems()
+                    || (values.length > mProperty.maxItems() && !mProperty.isVariable()))) {
+            return false;
         }
 
         // Validating elements of array
@@ -249,12 +234,9 @@ class ArrayValueValidator implements
             return false;
 
         // Validating length of array
-        if (mProperty.hasRange()) {
-            if (values.length < mProperty.minItems()
-                    || (values.length > mProperty.maxItems() && !mProperty
-                            .isVariable())) {
-                return false;
-            }
+        if (mProperty.hasRange() && (values.length < mProperty.minItems()
+                    || (values.length > mProperty.maxItems() && !mProperty.isVariable()))) {
+            return false;
         }
 
         // Validating elements of array
@@ -279,12 +261,9 @@ class ArrayValueValidator implements
             return false;
 
         // Validating length of array
-        if (mProperty.hasRange()) {
-            if (values.length < mProperty.minItems()
-                    || (values.length > mProperty.maxItems() && !mProperty
-                            .isVariable())) {
-                return false;
-            }
+        if (mProperty.hasRange() && (values.length < mProperty.minItems()
+                    || (values.length > mProperty.maxItems() && !mProperty.isVariable()))) {
+            return false;
         }
 
         // Validating elements of array
@@ -309,12 +288,9 @@ class ArrayValueValidator implements
             return false;
 
         // Validating length of array
-        if (mProperty.hasRange()) {
-            if (values.length < mProperty.minItems()
-                    || (values.length > mProperty.maxItems() && !mProperty
-                            .isVariable())) {
-                return false;
-            }
+        if (mProperty.hasRange() && (values.length < mProperty.minItems()
+                    || (values.length > mProperty.maxItems() && !mProperty.isVariable()))) {
+            return false;
         }
 
         // Validating elements of array
@@ -339,12 +315,9 @@ class ArrayValueValidator implements
             return false;
 
         // Validating length of array
-        if (mProperty.hasRange()) {
-            if (values.length < mProperty.minItems()
-                    || (values.length > mProperty.maxItems() && !mProperty
-                            .isVariable())) {
-                return false;
-            }
+        if (mProperty.hasRange() && (values.length < mProperty.minItems()
+                    || (values.length > mProperty.maxItems() && !mProperty.isVariable()))) {
+            return false;
         }
 
         // Validating elements of array
@@ -369,12 +342,9 @@ class ArrayValueValidator implements
             return false;
 
         // Validating length of array
-        if (mProperty.hasRange()) {
-            if (values.length < mProperty.minItems()
-                    || (values.length > mProperty.maxItems() && !mProperty
-                            .isVariable())) {
-                return false;
-            }
+        if (mProperty.hasRange() && (values.length < mProperty.minItems()
+                    || (values.length > mProperty.maxItems() && !mProperty.isVariable()))) {
+            return false;
         }
 
         // Validating elements of array
@@ -399,12 +369,9 @@ class ArrayValueValidator implements
             return false;
 
         // Validating length of array
-        if (mProperty.hasRange()) {
-            if (values.length < mProperty.minItems()
-                    || (values.length > mProperty.maxItems() && !mProperty
-                            .isVariable())) {
-                return false;
-            }
+        if (mProperty.hasRange() && (values.length < mProperty.minItems()
+                    || (values.length > mProperty.maxItems() && !mProperty.isVariable()))) {
+            return false;
         }
 
         // Validating elements of array
@@ -429,12 +396,9 @@ class ArrayValueValidator implements
             return false;
 
         // Validating length of array
-        if (mProperty.hasRange()) {
-            if (values.length < mProperty.minItems()
-                    || (values.length > mProperty.maxItems() && !mProperty
-                            .isVariable())) {
-                return false;
-            }
+        if (mProperty.hasRange() && (values.length < mProperty.minItems()
+                    || (values.length > mProperty.maxItems() && !mProperty.isVariable()))) {
+            return false;
         }
 
         // Validating elements of array
@@ -459,12 +423,9 @@ class ArrayValueValidator implements
             return false;
 
         // Validating length of array
-        if (mProperty.hasRange()) {
-            if (values.length < mProperty.minItems()
-                    || (values.length > mProperty.maxItems() && !mProperty
-                            .isVariable())) {
-                return false;
-            }
+        if (mProperty.hasRange() && (values.length < mProperty.minItems()
+                    || (values.length > mProperty.maxItems() && !mProperty.isVariable()))) {
+            return false;
         }
 
         // Validating elements of array
@@ -489,12 +450,9 @@ class ArrayValueValidator implements
             return false;
 
         // Validating length of array
-        if (mProperty.hasRange()) {
-            if (values.length < mProperty.minItems()
-                    || (values.length > mProperty.maxItems() && !mProperty
-                            .isVariable())) {
-                return false;
-            }
+        if (mProperty.hasRange() && (values.length < mProperty.minItems()
+                    || (values.length > mProperty.maxItems() && !mProperty.isVariable()))) {
+            return false;
         }
 
         // Validating elements of array
@@ -519,12 +477,9 @@ class ArrayValueValidator implements
             return false;
 
         // Validating length of array
-        if (mProperty.hasRange()) {
-            if (values.length < mProperty.minItems()
-                    || (values.length > mProperty.maxItems() && !mProperty
-                            .isVariable())) {
-                return false;
-            }
+        if (mProperty.hasRange() && (values.length < mProperty.minItems()
+                    || (values.length > mProperty.maxItems() && !mProperty.isVariable()))) {
+            return false;
         }
 
         // Validating elements of array
index 2daff28..3d014c3 100644 (file)
@@ -73,7 +73,7 @@ public class DoubleProperty extends AttributeProperty {
     }
 
     public boolean hasValues() {
-        return (null != mValues && (mValues.length > 0));
+        return (null != mValues && mValues.length > 0);
     }
 
     public double[] getValues() {
index 2448c2e..d411251 100644 (file)
@@ -72,7 +72,7 @@ public class IntegerProperty extends AttributeProperty {
     }
 
     public boolean hasValues() {
-        return (null != mValues && (mValues.length > 0));
+        return (null != mValues && mValues.length > 0);
     }
 
     public int[] getValues() {
index a37f65b..67238a9 100644 (file)
@@ -55,7 +55,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
         }
 
         // Find the created resource for first time
-        if (null != singleResource && null == remoteResource) {
+        if (null == remoteResource) {
             CountDownLatch lockObject = new CountDownLatch(1);
             ObjectHolder<SimulatorRemoteResource> resourceHolder = new ObjectHolder<>();
             FindResourceCallbackListener listener = new FindResourceCallbackListener(
@@ -68,6 +68,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
                 try {
                     lockObject.await(10, TimeUnit.SECONDS);
                 } catch (InterruptedException e) {
+                    e.printStackTrace();
                 }
 
             } catch (InvalidArgsException e) {
@@ -142,6 +143,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
@@ -170,6 +172,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
@@ -198,6 +201,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
@@ -227,6 +231,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
@@ -306,6 +311,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
@@ -336,6 +342,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
@@ -366,6 +373,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
@@ -397,6 +405,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
@@ -426,6 +435,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
@@ -509,6 +519,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
@@ -539,6 +550,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
@@ -569,6 +581,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
@@ -600,6 +613,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
@@ -629,6 +643,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
@@ -715,6 +730,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             remoteResource.stopObserve();
@@ -747,6 +763,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             remoteResource.stopObserve();
@@ -793,6 +810,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             response.set(null);
@@ -804,6 +822,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
@@ -874,6 +893,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
@@ -903,6 +923,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
@@ -932,6 +953,7 @@ public class SimulatorRemoteResourceTest extends TestCase {
             try {
                 lockObject.await(10, TimeUnit.SECONDS);
             } catch (InterruptedException e) {
+                e.printStackTrace();
             }
 
             syncResult = true;
index 842fb72..4282957 100644 (file)
@@ -83,8 +83,10 @@ public class SimulatorSingleResourceTest extends TestCase {
         try {
             singleResource.getAttribute(null);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -233,8 +235,10 @@ public class SimulatorSingleResourceTest extends TestCase {
             assertTrue(singleResource.addAttribute(stringAttribute));
             singleResource.removeAttribute(null);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -246,7 +250,9 @@ public class SimulatorSingleResourceTest extends TestCase {
         try {
             result = singleResource.removeAttribute("");
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
         } catch (SimulatorException e) {
+            e.printStackTrace();
         }
 
         assertFalse(result);
@@ -403,8 +409,10 @@ public class SimulatorSingleResourceTest extends TestCase {
             singleResource.startResourceUpdation(
                     SimulatorResource.AutoUpdateType.ONE_TIME, 500, null);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -474,8 +482,10 @@ public class SimulatorSingleResourceTest extends TestCase {
             singleResource.startAttributeUpdation("intensity",
                     SimulatorResource.AutoUpdateType.ONE_TIME, 1000, null);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
index 1014320..0dacb24 100644 (file)
@@ -93,8 +93,10 @@ public class SimulatorManagerTest extends TestCase {
             String configPath = "";
             SimulatorManager.createResource(configPath);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -107,8 +109,10 @@ public class SimulatorManagerTest extends TestCase {
         try {
             SimulatorManager.createResource(null);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -158,8 +162,10 @@ public class SimulatorManagerTest extends TestCase {
             String configPath = "";
             SimulatorManager.createResource(configPath, 1);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -172,8 +178,10 @@ public class SimulatorManagerTest extends TestCase {
         try {
             SimulatorManager.createResource(null, 1);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -186,8 +194,10 @@ public class SimulatorManagerTest extends TestCase {
         try {
             SimulatorManager.createResource(SINGLE_RES_RAML, 0);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -200,8 +210,10 @@ public class SimulatorManagerTest extends TestCase {
         try {
             SimulatorManager.createResource(SINGLE_RES_RAML, -1);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -263,8 +275,10 @@ public class SimulatorManagerTest extends TestCase {
             SimulatorManager.createResource(SimulatorResource.Type.SINGLE,
                     name, uri, resourceType);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -282,8 +296,10 @@ public class SimulatorManagerTest extends TestCase {
             SimulatorManager.createResource(SimulatorResource.Type.SINGLE,
                     name, uri, resourceType);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -301,8 +317,10 @@ public class SimulatorManagerTest extends TestCase {
             SimulatorManager.createResource(SimulatorResource.Type.SINGLE,
                     name, uri, resourceType);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -320,8 +338,10 @@ public class SimulatorManagerTest extends TestCase {
             SimulatorManager.createResource(SimulatorResource.Type.SINGLE,
                     name, uri, resourceType);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -339,8 +359,10 @@ public class SimulatorManagerTest extends TestCase {
             SimulatorManager.createResource(SimulatorResource.Type.SINGLE,
                     name, uri, resourceType);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -358,8 +380,10 @@ public class SimulatorManagerTest extends TestCase {
             SimulatorManager.createResource(SimulatorResource.Type.SINGLE,
                     name, uri, resourceType);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -397,6 +421,7 @@ public class SimulatorManagerTest extends TestCase {
         try {
             lockObject.await(10, TimeUnit.SECONDS);
         } catch (InterruptedException e) {
+            e.printStackTrace();
         }
 
         testResource.stop();
@@ -410,8 +435,10 @@ public class SimulatorManagerTest extends TestCase {
             String resourceType = "test.singleresource";
             SimulatorManager.findResource(resourceType, null);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -431,8 +458,10 @@ public class SimulatorManagerTest extends TestCase {
                         }
                     });
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -452,8 +481,10 @@ public class SimulatorManagerTest extends TestCase {
                         }
                     });
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -490,6 +521,7 @@ public class SimulatorManagerTest extends TestCase {
         try {
             lockObject.await(10, TimeUnit.SECONDS);
         } catch (InterruptedException e) {
+            e.printStackTrace();
         }
 
         testResource.stop();
@@ -502,8 +534,10 @@ public class SimulatorManagerTest extends TestCase {
         try {
             SimulatorManager.findResource(null);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -533,8 +567,10 @@ public class SimulatorManagerTest extends TestCase {
             String deviceName = "";
             SimulatorManager.setDeviceInfo(deviceName);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -548,8 +584,10 @@ public class SimulatorManagerTest extends TestCase {
             String deviceName = null;
             SimulatorManager.setDeviceInfo(deviceName);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -581,8 +619,10 @@ public class SimulatorManagerTest extends TestCase {
             PlatformInfo platformInfo = null;
             SimulatorManager.setPlatformInfo(platformInfo);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -612,6 +652,7 @@ public class SimulatorManagerTest extends TestCase {
         try {
             lockObject.await(10, TimeUnit.SECONDS);
         } catch (InterruptedException e) {
+            e.printStackTrace();
         }
 
         assertNotNull(infoHolder.get());
@@ -623,8 +664,10 @@ public class SimulatorManagerTest extends TestCase {
         try {
             SimulatorManager.findDevices(null, null);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }
 
@@ -653,6 +696,7 @@ public class SimulatorManagerTest extends TestCase {
         try {
             lockObject.await(10, TimeUnit.SECONDS);
         } catch (InterruptedException e) {
+            e.printStackTrace();
         }
 
         assertNotNull(infoHolder.get());
@@ -664,8 +708,10 @@ public class SimulatorManagerTest extends TestCase {
         try {
             SimulatorManager.getPlatformInformation(null, null);
         } catch (InvalidArgsException e) {
+            e.printStackTrace();
             exType = ExceptionType.INVALID_ARGS;
         } catch (SimulatorException e) {
+            e.printStackTrace();
             exType = ExceptionType.SIMULATOR;
         }