vmassol 2003/02/07 09:16:59
Modified: integration/ant/src/java/org/apache/cactus/integration/ant
RunServerTestsTask.java StartServerHelper.java
documentation/docs/xdocs changes.xml
Log:
Implemented suggestion by [EMAIL PROTECTED] (
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16869
) for adding a timeout to the runservertests ant task.
Revision Changes Path
1.2 +11 -1
jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/RunServerTestsTask.java
Index: RunServerTestsTask.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/RunServerTestsTask.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RunServerTestsTask.java 3 Feb 2003 10:52:41 -0000 1.1
+++ RunServerTestsTask.java 7 Feb 2003 17:16:58 -0000 1.2
@@ -214,4 +214,14 @@
{
this.testTarget = theTestTarget;
}
+
+ /**
+ * @param theTimeout the timeout after which we stop trying to call the test
+ * URL.
+ */
+ public void setTimeout(long theTimeout)
+ {
+ this.startHelper.setTimeout(theTimeout);
+ }
+
}
1.2 +25 -2
jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/StartServerHelper.java
Index: StartServerHelper.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/StartServerHelper.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StartServerHelper.java 3 Feb 2003 10:52:41 -0000 1.1
+++ StartServerHelper.java 7 Feb 2003 17:16:58 -0000 1.2
@@ -107,6 +107,12 @@
private boolean isServerAlreadyStarted = false;
/**
+ * Timeout after which we stop trying to connect to the test URL (in ms).
+ */
+ private long timeout = 180000;
+
+
+ /**
* @param theTask the Ant task that is calling this helper
*/
public StartServerHelper(Task theTask)
@@ -167,9 +173,17 @@
// ready to accept connections)
sleep(1000);
- // Continuously try calling the test URL until it succeeds
+ // Continuously try calling the test URL until it succeeds or
+ // until a timeout is reached (we then throw a build exception).
+ long startTime = System.currentTimeMillis();
while (true)
{
+ if (System.currentTimeMillis() - startTime > this.timeout)
+ {
+ throw new BuildException("Failed to start the container after "
+ + "more than [" + this.timeout + "] ms.");
+ }
+
this.task.log("Checking if server is up ...", Project.MSG_DEBUG);
if (!isURLCallable())
@@ -313,6 +327,15 @@
}
this.task.log("Test URL = [" + this.testURL + "]", Project.MSG_DEBUG);
+ }
+
+ /**
+ * @param theTimeout the timeout after which we stop trying to call the test
+ * URL
+ */
+ public void setTimeout(long theTimeout)
+ {
+ this.timeout = theTimeout;
}
/**
1.79 +5 -0 jakarta-cactus/documentation/docs/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-cactus/documentation/docs/xdocs/changes.xml,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- changes.xml 6 Feb 2003 09:36:53 -0000 1.78
+++ changes.xml 7 Feb 2003 17:16:58 -0000 1.79
@@ -57,6 +57,11 @@
</devs>
<release version="1.5" date="- in CVS">
+ <action dev="VMA" type="add">
+ Added a timeout for the <code><runservertests></code> Ant task
+ so that the verification that the container is started is stopped if
+ this timeout is reached (a build exception is raised).
+ </action>
<action dev="VMA" type="remove">
Moved some Ant tasks that were previously in the Cactus Ant tasks;
they are now in the Ant Integration project. They are the tasks used
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]