summaryrefslogtreecommitdiff
path: root/qadevOOo
diff options
context:
space:
mode:
authorRüdiger Timm <rt@openoffice.org>2008-06-13 11:45:24 +0000
committerRüdiger Timm <rt@openoffice.org>2008-06-13 11:45:24 +0000
commit374fbe7575f8d6e596a5cb9449f78801d0bae858 (patch)
tree90f1ee3adef566de3d141734ad5dcaa9086e958e /qadevOOo
parent037edf4ebeddfaaf9c7ae492cee33e20e6b3e917 (diff)
INTEGRATION: CWS qadev32 (1.7.2); FILE MERGED
2008/05/28 12:14:16 cn 1.7.2.7: #i87389# enhance logging 2008/05/13 19:07:44 cn 1.7.2.6: #i87389# update logging 2008/05/07 07:47:26 cn 1.7.2.5: #i85370# enhance logging 2008/05/05 09:39:20 cn 1.7.2.4: #i85370# enhance logging, change command 'runCommand' to executeSynchronously' to run killoffice command 2008/04/17 11:40:34 cn 1.7.2.3: RESYNC: (1.7-1.8); FILE MERGED 2008/04/03 07:57:15 cn 1.7.2.2: #i87389# enhance logging 2008/01/22 11:45:51 cn 1.7.2.1: #i85370#: calling the sKillCommand via ProcessHandler
Diffstat (limited to 'qadevOOo')
-rw-r--r--qadevOOo/runner/helper/OfficeWatcher.java57
1 files changed, 36 insertions, 21 deletions
diff --git a/qadevOOo/runner/helper/OfficeWatcher.java b/qadevOOo/runner/helper/OfficeWatcher.java
index 300aab0739df..1196283df4bd 100644
--- a/qadevOOo/runner/helper/OfficeWatcher.java
+++ b/qadevOOo/runner/helper/OfficeWatcher.java
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: OfficeWatcher.java,v $
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
* This file is part of OpenOffice.org.
*
@@ -27,17 +27,18 @@
* for a copy of the LGPLv3 License.
*
************************************************************************/
-
package helper;
import lib.TestParameters;
import java.util.StringTokenizer;
+import util.utils;
public class OfficeWatcher extends Thread implements share.Watcher {
public boolean finish;
- TestParameters params;
- int StoredPing = 0;
+ private TestParameters params;
+ private int StoredPing = 0;
+ private boolean debug = false;
/** Creates new OfficeWatcher
* @param param
@@ -45,6 +46,7 @@ public class OfficeWatcher extends Thread implements share.Watcher {
public OfficeWatcher(TestParameters param) {
finish = false;
this.params = param;
+ debug = params.getBool(util.PropertyName.DEBUG_IS_ACTIVE);
}
/**
@@ -67,15 +69,16 @@ public class OfficeWatcher extends Thread implements share.Watcher {
}
public void run() {
+ dbg("started");
boolean isDone = false;
- ProcessHandler ph = (ProcessHandler) params.get("AppProvider");
+ final ProcessHandler ph = (ProcessHandler) params.get("AppProvider");
int timeOut = params.getInt("TimeOut");
if (ph == null) {
isDone = true;
}
while (!isDone) {
timeOut = params.getInt("TimeOut");
- int previous = StoredPing;
+ final int previous = StoredPing;
shortWait(timeOut == 0 ? 30000 : timeOut);
// a timeout with value 0 lets watcher not react.
if ((StoredPing == previous) && timeOut != 0) {
@@ -87,28 +90,34 @@ public class OfficeWatcher extends Thread implements share.Watcher {
}
}
if (ph != null) {
- System.out.println("OfficeWatcher: the Office is idle for " + timeOut / 1000 + " seconds, it probably hangs and is killed NOW.");
- String AppKillCommand = (String) params.get ("AppKillCommand");
+ dbg("the Office is idle for " + timeOut / 1000 +
+ " seconds, it probably hangs and is killed NOW.");
+ final String AppKillCommand = (String) params.get("AppKillCommand");
if (AppKillCommand != null) {
- StringTokenizer aKillCommandToken = new StringTokenizer(AppKillCommand, ";");
+ final StringTokenizer aKillCommandToken = new StringTokenizer(AppKillCommand, ";");
while (aKillCommandToken.hasMoreTokens()) {
- String sKillCommand = aKillCommandToken.nextToken();
+ final String sKillCommand = aKillCommandToken.nextToken();
+
+ dbg("User defined an application to destroy the started process.");
+ dbg("Trying to execute: " + sKillCommand);
+
+ final ProcessHandler pHdl = new ProcessHandler(sKillCommand);
+ pHdl.executeSynchronously();
+// dbg("---> Output of killoffice:");
+// dbg(pHdl.getOutputText());
+// dbg("<--- Output of killoffice");
+// dbg("---> Error output of killoffice:");
+// dbg(pHdl.getErrorText());
+// dbg("<--- Error output of killoffice");
- System.out.println("User defined an application to destroy the started process.");
- System.out.println("Trying to execute: " + sKillCommand);
- try {
- Process myprc = Runtime.getRuntime().exec(sKillCommand);
- myprc.waitFor();
- } catch (InterruptedException ex) {
- ex.printStackTrace();
- } catch (java.io.IOException e) {
- e.printStackTrace();
- }
}
}
ph.kill();
+ } else {
+ dbg("reaeched timeout but ProcessHandler is NULL");
}
shortWait(timeOut == 0 ? 30000 : timeOut);
+ dbg("finished");
}
protected void shortWait(int timeOut) {
@@ -117,4 +126,10 @@ public class OfficeWatcher extends Thread implements share.Watcher {
} catch (java.lang.InterruptedException ie) {
}
}
-} \ No newline at end of file
+
+ protected void dbg(String message) {
+ if (debug) {
+ System.out.println(utils.getDateTime() + "OfficeWatcher: " + message);
+ }
+ }
+}