Author: sebb
Date: Mon Apr 2 14:49:30 2012
New Revision: 1308367
URL: http://svn.apache.org/viewvc?rev=1308367&view=rev
Log:
Adjust loop count and timing
Modified:
commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
Modified:
commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java?rev=1308367&r1=1308366&r2=1308367&view=diff
==============================================================================
---
commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
(original)
+++
commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
Mon Apr 2 14:49:30 2012
@@ -1072,21 +1072,24 @@ public class DefaultExecutorTest extends
CommandLine cmdLine = new CommandLine(pingScript);
cmdLine.addArgument(Integer.toString(seconds + 1)); // need to add "1"
to wait the requested number of seconds
- for (int offset = start; offset <= 20; offset += 1) {
+ for (int offset = start; offset <= 50; offset++) {
// wait progressively longer for process to complete
- ExecuteWatchdog watchdog = new ExecuteWatchdog(seconds * 1000 +
offset * 10);
+ // tricky to get this test right. We want to try and catch the
process while it is terminating,
+ // so we increase the timeout gradually until the test terminates
normally.
+ // However if the increase is too gradual, we never wait long
enough for any test to exit normally
+ ExecuteWatchdog watchdog = new ExecuteWatchdog(seconds * 1000 +
offset * 5);
exec.setWatchdog(watchdog);
try {
exec.execute(cmdLine);
processTerminatedCounter++;
- System.out.println(offset + ": process has terminated: " +
watchdog.killedProcess());
+// System.out.println(offset + ": process has terminated: " +
watchdog.killedProcess());
if(processTerminatedCounter > 5) {
break;
}
} catch (ExecuteException ex) {
- System.out.println(offset + ": process was killed: " +
watchdog.killedProcess());
+// System.out.println(offset + ": process was killed: " +
watchdog.killedProcess());
assertTrue("Watchdog killed the process",
watchdog.killedProcess());
- watchdogKilledProcessCounter++;;
+ watchdogKilledProcessCounter++;
}
}