diff options
author | Noel Grandin <noel@peralex.com> | 2014-12-22 10:02:49 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2015-01-12 08:36:17 +0200 |
commit | 09330056a01a4b5c3d16e3ffb6c1bff36099eb83 (patch) | |
tree | efa793bee83eed4081edd52737e73216a3048b89 /qadevOOo/runner | |
parent | 4bf4e3d40778051f1f886c47dd2b2bef82acf1e5 (diff) |
java: simplify sleeping and waiting in tests
- remove the SHORT_WAIT test parameter, no-one is using it
- inline the various independent shortWait() methods
- use the util.utils.shortWait() utility method everywhere
Change-Id: I93cd4a2580172a1441d2ff3d390f52b9505e2721
Diffstat (limited to 'qadevOOo/runner')
-rw-r--r-- | qadevOOo/runner/base/java_fat.java | 4 | ||||
-rw-r--r-- | qadevOOo/runner/helper/LoggingThread.java | 13 | ||||
-rw-r--r-- | qadevOOo/runner/helper/OfficeProvider.java | 19 | ||||
-rw-r--r-- | qadevOOo/runner/helper/OfficeWatcher.java | 11 | ||||
-rw-r--r-- | qadevOOo/runner/helper/ProcessHandler.java | 17 | ||||
-rw-r--r-- | qadevOOo/runner/helper/UnoProvider.java | 5 | ||||
-rw-r--r-- | qadevOOo/runner/lib/TestParameters.java | 1 | ||||
-rw-r--r-- | qadevOOo/runner/util/DesktopTools.java | 2 | ||||
-rw-r--r-- | qadevOOo/runner/util/PropertyName.java | 5 | ||||
-rw-r--r-- | qadevOOo/runner/util/utils.java | 13 |
10 files changed, 27 insertions, 63 deletions
diff --git a/qadevOOo/runner/base/java_fat.java b/qadevOOo/runner/base/java_fat.java index 78bcc38fb910..bc63f40b4dfb 100644 --- a/qadevOOo/runner/base/java_fat.java +++ b/qadevOOo/runner/base/java_fat.java @@ -133,7 +133,7 @@ public class java_fat implements TestBase continue; } - util.utils.shortWait(2000); + util.utils.pause(2000); System.out.println("Creating: " + entry.entryName); @@ -430,7 +430,7 @@ public class java_fat implements TestBase if (ph != null) { m_aOffice.closeExistingOffice(m_aParams, true); - util.utils.shortWait(5000); + util.utils.pause(5000); } } diff --git a/qadevOOo/runner/helper/LoggingThread.java b/qadevOOo/runner/helper/LoggingThread.java index 590a467a7134..6878fbc8c708 100644 --- a/qadevOOo/runner/helper/LoggingThread.java +++ b/qadevOOo/runner/helper/LoggingThread.java @@ -70,14 +70,11 @@ public class LoggingThread extends Thread { * finished the LoggingThread */ public void finish() { - try { - finished = true; - synchronized (this) { - notify(); - } - if (debug) log.println("TimeOutLogger: " + utils.getDateTime() + " try to finish "); - sleep(1000); - } catch (InterruptedException ex) { + finished = true; + synchronized (this) { + notify(); } + if (debug) log.println("TimeOutLogger: " + utils.getDateTime() + " try to finish "); + util.utils.pause(1000); } } diff --git a/qadevOOo/runner/helper/OfficeProvider.java b/qadevOOo/runner/helper/OfficeProvider.java index 4496fec9d43f..19890e93edcb 100644 --- a/qadevOOo/runner/helper/OfficeProvider.java +++ b/qadevOOo/runner/helper/OfficeProvider.java @@ -262,13 +262,7 @@ public class OfficeProvider implements AppProvider } if (msf == null) { - try - { - Thread.sleep(500L * k); - } - catch (InterruptedException ex) - { - } + util.utils.pause(500 * k); } k++; } @@ -762,15 +756,8 @@ public class OfficeProvider implements AppProvider { System.out.println(utils.getDateTime() + "OfficeProvider:Owp: ping "); ow.ping(); - try - { - System.out.println(utils.getDateTime() + "OfficeProvider:Owp: sleep "); - OfficeWatcherPing.sleep(1000); // 5000 - } - catch (InterruptedException ex) - { - ex.printStackTrace(); - } + System.out.println(utils.getDateTime() + "OfficeProvider:Owp: sleep "); + util.utils.pause(1000); } } diff --git a/qadevOOo/runner/helper/OfficeWatcher.java b/qadevOOo/runner/helper/OfficeWatcher.java index 60900c0052bd..241115e775bd 100644 --- a/qadevOOo/runner/helper/OfficeWatcher.java +++ b/qadevOOo/runner/helper/OfficeWatcher.java @@ -65,7 +65,7 @@ public class OfficeWatcher extends Thread implements share.Watcher { while (!isDone) { timeOut = params.getInt("TimeOut"); final int previous = StoredPing; - shortWait(timeOut == 0 ? 30000 : timeOut); + util.utils.pause(timeOut == 0 ? 30000 : timeOut); // a timeout with value 0 lets watcher not react. if ((StoredPing == previous) && timeOut != 0) { isDone = true; @@ -95,17 +95,10 @@ public class OfficeWatcher extends Thread implements share.Watcher { } else { dbg("reaeched timeout but ProcessHandler is NULL"); } - shortWait(timeOut == 0 ? 30000 : timeOut); + util.utils.pause(timeOut == 0 ? 30000 : timeOut); dbg("finished"); } - private void shortWait(int timeOut) { - try { - OfficeWatcher.sleep(timeOut); - } catch (InterruptedException ie) { - } - } - private void dbg(String message) { if (debug) { System.out.println(utils.getDateTime() + "OfficeWatcher: " + message); diff --git a/qadevOOo/runner/helper/ProcessHandler.java b/qadevOOo/runner/helper/ProcessHandler.java index 1be600d54993..10241a3b9410 100644 --- a/qadevOOo/runner/helper/ProcessHandler.java +++ b/qadevOOo/runner/helper/ProcessHandler.java @@ -329,13 +329,7 @@ public class ProcessHandler { m_aProcess.destroy(); - try - { - Thread.sleep(1000L * counter); // 5000 - } - catch (InterruptedException e) - { - } + util.utils.pause(1000 * counter); try { final int exit_Value = m_aProcess.exitValue(); @@ -664,14 +658,7 @@ public class ProcessHandler while (m_nTimeoutInSec > 0) { m_nTimeoutInSec--; - try - { - sleep(1000); - } - catch(InterruptedException e) - { - // interrupt flag is set back to 'not interrupted' :-( - } + util.utils.pause(1000); if (isInHoldOn()) { break; diff --git a/qadevOOo/runner/helper/UnoProvider.java b/qadevOOo/runner/helper/UnoProvider.java index 78430d195bf3..d5d18c38fb72 100644 --- a/qadevOOo/runner/helper/UnoProvider.java +++ b/qadevOOo/runner/helper/UnoProvider.java @@ -70,10 +70,7 @@ public class UnoProvider implements AppProvider { public boolean disposeManager(TestParameters param) { param.remove("ServiceManager"); System.gc(); - try { - Thread.sleep(1000); - } - catch(InterruptedException e) {} + util.utils.pause(1000); return true; } diff --git a/qadevOOo/runner/lib/TestParameters.java b/qadevOOo/runner/lib/TestParameters.java index 57501c140c06..33fbd301d7e7 100644 --- a/qadevOOo/runner/lib/TestParameters.java +++ b/qadevOOo/runner/lib/TestParameters.java @@ -151,7 +151,6 @@ public class TestParameters extends HashMap<String,Object> { put(PropertyName.LOGGING_IS_ACTIVE, Boolean.TRUE); put(PropertyName.DEBUG_IS_ACTIVE, Boolean.valueOf(DebugIsActive)); put(PropertyName.OUT_PRODUCER, "stats.SimpleOutProducer"); - put(PropertyName.SHORT_WAIT, Integer.valueOf(500)); put(PropertyName.OFFICE_PROVIDER, "helper.OfficeProvider"); put(PropertyName.LOG_WRITER, "stats.SimpleLogWriter"); put(PropertyName.APP_EXECUTION_COMMAND, ""); diff --git a/qadevOOo/runner/util/DesktopTools.java b/qadevOOo/runner/util/DesktopTools.java index d61ba4bc70f8..1f6f6cfeedbc 100644 --- a/qadevOOo/runner/util/DesktopTools.java +++ b/qadevOOo/runner/util/DesktopTools.java @@ -402,7 +402,7 @@ public class DesktopTools oViewProp.setPropertyValue("ZoomType", Short.valueOf(com.sun.star.view.DocumentZoomType.ENTIRE_PAGE)); - utils.shortWait(5000); + utils.pause(5000); } catch (Exception e) { diff --git a/qadevOOo/runner/util/PropertyName.java b/qadevOOo/runner/util/PropertyName.java index 141fee9e305e..4207d4fe1669 100644 --- a/qadevOOo/runner/util/PropertyName.java +++ b/qadevOOo/runner/util/PropertyName.java @@ -67,10 +67,9 @@ public interface PropertyName { */ String OUT_PRODUCER = "OutProducer"; /** - * parameter name: "ShortWait" - * Short wait time for the Office: default is 500 milliseconds + * Default short wait time for the Office */ - String SHORT_WAIT= "ShortWait"; + int DEFAULT_SHORT_WAIT_MS = 500; /** * internal only, no parameter * The OfficeProvider contains the full qualified diff --git a/qadevOOo/runner/util/utils.java b/qadevOOo/runner/util/utils.java index 76d1666f248d..4557cb5484e5 100644 --- a/qadevOOo/runner/util/utils.java +++ b/qadevOOo/runner/util/utils.java @@ -645,10 +645,15 @@ public class utils { } /** Causes the thread to sleep some time. - * It can be used f.e. like: - * util.utils.shortWait(tParam.getInt("ShortWait")); + * This is the default call, which waits for 500ms. */ - public static void shortWait(int milliseconds) { + public static void shortWait() { + pause(PropertyName.DEFAULT_SHORT_WAIT_MS); + } + + /** Causes the thread to sleep some time. + */ + public static void pause(int milliseconds) { try { Thread.sleep(milliseconds); } catch (InterruptedException e) { @@ -827,7 +832,7 @@ public class utils { XDispatch xDispatcher = xDispProv.queryDispatch(aURL, "", 0); xDispatcher.dispatch(aURL, null); - utils.shortWait(3000); + utils.pause(3000); } catch (Exception e) { throw new Exception("ERROR: could not dispatch URL '" + URL + "'", e); |