[Libreoffice-commits] core.git: framework/qa qadevOOo/runner qadevOOo/tests

Caolán McNamara caolanm at redhat.com
Thu Oct 5 07:51:25 UTC 2017


 framework/qa/complex/api_internal/CheckAPI.java           |    9 ++++++--
 qadevOOo/runner/base/java_complex.java                    |    5 ++++
 qadevOOo/runner/base/java_fat.java                        |    3 +-
 qadevOOo/runner/helper/AppProvider.java                   |    4 ++-
 qadevOOo/runner/helper/OfficeProvider.java                |    3 +-
 qadevOOo/runner/helper/ProcessHandler.java                |    8 ++++---
 qadevOOo/runner/util/dbg.java                             |    6 +++--
 qadevOOo/tests/java/ifc/form/component/_DatabaseForm.java |    5 ++--
 qadevOOo/tests/java/mod/_dbaccess/ORowSet.java            |    9 +++++++-
 qadevOOo/tests/java/mod/_forms/ODatabaseForm.java         |   15 ++++++++++++--
 10 files changed, 52 insertions(+), 15 deletions(-)

New commits:
commit a25868231adba6a3be30f9aedb71315de0c79acd
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Oct 4 13:04:25 2017 +0100

    coverity#1399440 Dm: Dubious method used
    
    Change-Id: Ied0a5218b4f95a300d09483315d577b5bdf01bae
    Reviewed-on: https://gerrit.libreoffice.org/43135
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/framework/qa/complex/api_internal/CheckAPI.java b/framework/qa/complex/api_internal/CheckAPI.java
index bdeb2173dc10..8ee5b1f06c05 100644
--- a/framework/qa/complex/api_internal/CheckAPI.java
+++ b/framework/qa/complex/api_internal/CheckAPI.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.fail;
 import helper.OfficeProvider;
 import helper.ProcessHandler;
 
+import java.io.UnsupportedEncodingException;
 import java.util.StringTokenizer;
 import lib.TestParameters;
 
@@ -110,14 +111,18 @@ public class CheckAPI  {
                 handler.kill();
                 util.utils.pause(10000);
                 OfficeProvider op = new OfficeProvider();
-                xMSF = (XMultiServiceFactory)op.getManager(param);
-                param.put("ServiceFactory",xMSF);
                 try {
+                    xMSF = (XMultiServiceFactory)op.getManager(param);
+                    param.put("ServiceFactory",xMSF);
+
                     oObj = xMSF.createInstance("org.openoffice.RunnerService");
                 }
                 catch(com.sun.star.uno.Exception e) {
                     fail("Could not create Instance of 'org.openoffice.RunnerService'");
                 }
+                catch (UnsupportedEncodingException e) {
+                    fail("Could not get Manager'");
+                }
             }
             System.out.println(erg);
             String processedErg = parseResult(erg);
diff --git a/qadevOOo/runner/base/java_complex.java b/qadevOOo/runner/base/java_complex.java
index 212c9337778f..9e61c5c5f9ae 100644
--- a/qadevOOo/runner/base/java_complex.java
+++ b/qadevOOo/runner/base/java_complex.java
@@ -29,6 +29,7 @@ import share.LogWriter;
 import stats.Summarizer;
 import lib.TestParameters;
 import util.PropertyName;
+import java.io.UnsupportedEncodingException;
 
 /**
  * Test base for executing a java complex test.
@@ -110,6 +111,10 @@ public class java_complex implements TestBase
                 {
                     office = null;
                 }
+                catch (UnsupportedEncodingException e)
+                {
+                    office = null;
+                }
             }
             log.initialize(entries[i], param.getBool(PropertyName.LOGGING_IS_ACTIVE));
             entries[i].Logger = log;
diff --git a/qadevOOo/runner/base/java_fat.java b/qadevOOo/runner/base/java_fat.java
index 4ed28f2c3652..c85103508cbe 100644
--- a/qadevOOo/runner/base/java_fat.java
+++ b/qadevOOo/runner/base/java_fat.java
@@ -24,6 +24,7 @@ import java.io.BufferedReader;
 import java.io.FileInputStream;
 import java.io.InputStreamReader;
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import lib.MultiMethodTest;
 import lib.TestCase;
@@ -446,7 +447,7 @@ public class java_fat implements TestBase {
         return ifc.run(entry, tEnv, param);
     }
 
-    private AppProvider startOffice(lib.TestParameters param) {
+    private AppProvider startOffice(lib.TestParameters param) throws UnsupportedEncodingException {
         if (m_aDynamicClassLoader == null) {
             m_aDynamicClassLoader = new DynamicClassLoader();
         }
diff --git a/qadevOOo/runner/helper/AppProvider.java b/qadevOOo/runner/helper/AppProvider.java
index e8f77d1f059a..a42411ac6589 100644
--- a/qadevOOo/runner/helper/AppProvider.java
+++ b/qadevOOo/runner/helper/AppProvider.java
@@ -18,6 +18,8 @@
 
 package helper;
 
+import java.io.UnsupportedEncodingException;
+
 /**
  *
  * Interface to get a Manager to access the application to check
@@ -27,7 +29,7 @@ public interface AppProvider {
     /**
      * Method to get the desired Manager
      */
-    Object getManager(lib.TestParameters param);
+    Object getManager(lib.TestParameters param) throws UnsupportedEncodingException;
 
     /**
      * Method to dispose the desired Manager
diff --git a/qadevOOo/runner/helper/OfficeProvider.java b/qadevOOo/runner/helper/OfficeProvider.java
index 880565896443..01599cd3ff15 100644
--- a/qadevOOo/runner/helper/OfficeProvider.java
+++ b/qadevOOo/runner/helper/OfficeProvider.java
@@ -31,6 +31,7 @@ import com.sun.star.util.XStringSubstitution;
 
 import java.io.File;
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
 
 import lib.TestParameters;
 
@@ -146,7 +147,7 @@ public class OfficeProvider implements AppProvider
     /**
      * Method to get the ServiceManager of an Office
      */
-    public Object getManager(lib.TestParameters param)
+    public Object getManager(lib.TestParameters param) throws UnsupportedEncodingException
     {
         String errorMessage = null;
         boolean bAppExecutionHasWarning = false;
diff --git a/qadevOOo/runner/helper/ProcessHandler.java b/qadevOOo/runner/helper/ProcessHandler.java
index 2b2e94efed38..7098db7d2590 100644
--- a/qadevOOo/runner/helper/ProcessHandler.java
+++ b/qadevOOo/runner/helper/ProcessHandler.java
@@ -19,6 +19,8 @@ package helper;
 
 import java.io.InputStream;
 import java.io.File;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
 import java.io.PrintWriter;
 import java.io.PrintStream;
 import java.io.LineNumberReader;
@@ -128,7 +130,7 @@ public class ProcessHandler
      * log stream where debug info and output
      * of external command is printed out.
      */
-    public ProcessHandler(String cmdLine, PrintWriter log)
+    public ProcessHandler(String cmdLine, PrintWriter log) throws UnsupportedEncodingException
     {
         this(cmdLine, log, null, null);
     }
@@ -157,7 +159,7 @@ public class ProcessHandler
      *                      Waits for the process to end regulary
      *
      */
-    private ProcessHandler(String cmdLine, PrintWriter log, File workDir, String[] envVars)
+    private ProcessHandler(String cmdLine, PrintWriter log, File workDir, String[] envVars) throws UnsupportedEncodingException
     {
         this.cmdLine = cmdLine;
         this.workDir = workDir;
@@ -165,7 +167,7 @@ public class ProcessHandler
         this.envVars = envVars;
         if (log == null)
         {
-            this.log = new PrintWriter(System.out);
+            this.log = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8"));
         }
         else
         {
diff --git a/qadevOOo/runner/util/dbg.java b/qadevOOo/runner/util/dbg.java
index ba06f3c714ff..3a0035cde079 100644
--- a/qadevOOo/runner/util/dbg.java
+++ b/qadevOOo/runner/util/dbg.java
@@ -29,6 +29,8 @@ import com.sun.star.beans.PropertyValue;
 import com.sun.star.lang.XTypeProvider;
 import com.sun.star.lang.XServiceInfo;
 import java.io.PrintWriter;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Method;
 
 /**
@@ -125,8 +127,8 @@ public class dbg {
      * @param name The name of the property.
      * @see com.sun.star.beans.XPropertySet
      */
-    public static void printPropertyInfo(XPropertySet PS, String name) {
-            printPropertyInfo(PS, name, new PrintWriter(System.out)) ;
+    public static void printPropertyInfo(XPropertySet PS, String name) throws UnsupportedEncodingException {
+            printPropertyInfo(PS, name, new PrintWriter(new OutputStreamWriter(System.out, "UTF-8")));
     }
 
     /**
diff --git a/qadevOOo/tests/java/ifc/form/component/_DatabaseForm.java b/qadevOOo/tests/java/ifc/form/component/_DatabaseForm.java
index 17121cb990e8..887c881a2dc9 100644
--- a/qadevOOo/tests/java/ifc/form/component/_DatabaseForm.java
+++ b/qadevOOo/tests/java/ifc/form/component/_DatabaseForm.java
@@ -23,6 +23,7 @@ import util.dbg;
 
 import com.sun.star.form.TabulatorCycle;
 import com.sun.star.uno.Enum;
+import java.io.UnsupportedEncodingException;
 
 /**
 * Testing <code>com.sun.star.form.component.DatabaseForm</code>
@@ -45,7 +46,7 @@ public class _DatabaseForm extends MultiPropertyTest {
     * In this property test only debugging information output
     * is customized.
     */
-    public void _NavigationBarMode() {
+    public void _NavigationBarMode() throws UnsupportedEncodingException {
         dbg.printPropertyInfo(oObj, "NavigationBarMode");
         testProperty("NavigationBarMode", new PropertyTester() {
             @Override
@@ -64,7 +65,7 @@ public class _DatabaseForm extends MultiPropertyTest {
     * This property new value is always fixed and debugging
     * information output is customized.
     */
-    public void _Cycle() {
+    public void _Cycle() throws UnsupportedEncodingException {
         dbg.printPropertyInfo(oObj, "Cycle");
         testProperty("Cycle", new PropertyTester() {
             @Override
diff --git a/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java b/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java
index 40c032a37312..d31bfe1ea029 100644
--- a/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java
+++ b/qadevOOo/tests/java/mod/_dbaccess/ORowSet.java
@@ -20,7 +20,9 @@ package mod._dbaccess;
 
 import ifc.sdb._XCompletedExecution;
 
+import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import lib.StatusException;
 import lib.TestCase;
@@ -535,8 +537,13 @@ public class ORowSet extends TestCase {
      * @see ifc.sdb._XCompletedExecution
      */
     private static class InteractionHandlerImpl implements _XCompletedExecution.CheckInteractionHandler {
+
         private boolean handlerWasUsed = false;
-        private PrintWriter log = new PrintWriter(System.out);
+        private PrintWriter log;
+
+        InteractionHandlerImpl() throws UnsupportedEncodingException {
+            log = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8"));
+        }
 
         public boolean checkInteractionHandler() {
             return handlerWasUsed;
diff --git a/qadevOOo/tests/java/mod/_forms/ODatabaseForm.java b/qadevOOo/tests/java/mod/_forms/ODatabaseForm.java
index d424a1b4f5fb..ac2dd166df73 100644
--- a/qadevOOo/tests/java/mod/_forms/ODatabaseForm.java
+++ b/qadevOOo/tests/java/mod/_forms/ODatabaseForm.java
@@ -20,7 +20,9 @@ package mod._forms;
 import ifc.form._XDatabaseParameterBroadcaster;
 import ifc.sdb._XCompletedExecution;
 
+import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import lib.StatusException;
 import lib.TestCase;
@@ -756,7 +758,12 @@ public class ODatabaseForm extends TestCase {
      */
     private static class ParameterListenerImpl implements _XDatabaseParameterBroadcaster.CheckParameterListener {
         private boolean listenerWasCalled = false;
-        private PrintWriter log = new PrintWriter(System.out);
+
+        private PrintWriter log;
+
+        ParameterListenerImpl() throws UnsupportedEncodingException {
+            log = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8"));
+        }
 
         /**
          * Return true, if the listener was called, false otherwise.
@@ -818,7 +825,11 @@ public class ODatabaseForm extends TestCase {
      */
     private static class InteractionHandlerImpl implements _XCompletedExecution.CheckInteractionHandler {
         private boolean handlerWasUsed = false;
-        private PrintWriter log = new PrintWriter(System.out);
+        private PrintWriter log;
+
+        InteractionHandlerImpl() throws UnsupportedEncodingException {
+            log = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8"));
+        }
 
         public boolean checkInteractionHandler() {
             return handlerWasUsed;


More information about the Libreoffice-commits mailing list