You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by cm...@apache.org on 2003/05/07 18:30:37 UTC
cvs commit: jakarta-cactus/integration/ant/src/test/org/apache/cactus/integration/ant/container TestContainerRunner.java
cmlenz 2003/05/07 09:30:36
Modified: integration/ant/src/java/org/apache/cactus/integration/ant/container
Tag: CACTUS_14_ANT_BRANCH ContainerRunner.java
integration/ant/src/test/org/apache/cactus/integration/ant/container
Tag: CACTUS_14_ANT_BRANCH TestContainerRunner.java
Log:
Make the timing of the ContainerRunner configurable, and use short times for the test (still takes too long)
Revision Changes Path
No revision
No revision
1.1.2.3 +67 -25 jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/Attic/ContainerRunner.java
Index: ContainerRunner.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/Attic/ContainerRunner.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- ContainerRunner.java 7 May 2003 15:52:00 -0000 1.1.2.2
+++ ContainerRunner.java 7 May 2003 16:30:35 -0000 1.1.2.3
@@ -94,6 +94,21 @@
private long timeout = 180000;
/**
+ * The time interval in milliseconds to sleep between polling the container.
+ */
+ private long checkInterval = 500;
+
+ /**
+ * The time to sleep after the container has started up.
+ */
+ private long startUpWait = 1000;
+
+ /**
+ * The time to sleep after the container has shut down.
+ */
+ private long shutDownWait = 2000;
+
+ /**
* Whether the container had already been running before.
*/
private boolean alreadyRunning;
@@ -172,32 +187,23 @@
}
});
thread.start();
- // Wait a few ms more (just to make sure the servlet engine is
- // ready to accept connections)
- sleep(1000);
// 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)
+ do
{
if ((System.currentTimeMillis() - startTime) > this.timeout)
{
throw new BuildException("Failed to start the container after "
+ "more than [" + this.timeout + "] ms.");
}
+ sleep(checkInterval);
this.log.debug("Checking if server is up ...");
- if (!isAvailable(this.url))
- {
- sleep(500);
- continue;
- }
- this.log.debug("Checking if server is up ...");
- break;
- }
+ } while (!isAvailable(this.url));
// Wait a few ms more (just to be sure !)
- sleep(500);
+ sleep(startUpWait);
this.serverName = retrieveServerName(this.url);
this.log.trace("Server '" + this.serverName + "' started");
@@ -238,28 +244,49 @@
// Continuously try calling the test URL until it fails
do
{
- sleep(500);
+ sleep(checkInterval);
} while (isAvailable(this.url));
// sleep a bit longer to be sure the container has terminated
- sleep(2000);
+ sleep(shutDownWait);
this.log.debug("Server stopped!");
}
/**
- * Sets the HTTP URL that will be continuously pinged to check if the
- * container is running.
+ * Sets the time interval to sleep between polling the container.
*
- * @param theUrl The URL to set
+ * The default interval is 500 milliseconds.
+ *
+ * @param theCheckInterval The interval in milliseconds
*/
- public void setUrl(URL theUrl)
+ public void setCheckInterval(long theCheckInterval)
{
- if (!theUrl.getProtocol().equals("http"))
- {
- throw new IllegalArgumentException("Not a HTTP URL");
- }
- this.url = theUrl;
+ this.checkInterval = theCheckInterval;
+ }
+
+ /**
+ * Sets the time to wait after the container has been shut down.
+ *
+ * The default time is 2 seconds.
+ *
+ * @param theShutDownWait The time to wait in milliseconds
+ */
+ public void setShutDownWait(long theShutDownWait)
+ {
+ this.shutDownWait = theShutDownWait;
+ }
+
+ /**
+ * Sets the time to wait after the container has been started up.
+ *
+ * The default time is 1 second.
+ *
+ * @param theStartUpWait The time to wait in milliseconds
+ */
+ public void setStartUpWait(long theStartUpWait)
+ {
+ this.startUpWait = theStartUpWait;
}
/**
@@ -272,6 +299,21 @@
public void setTimeout(long theTimeout)
{
this.timeout = theTimeout;
+ }
+
+ /**
+ * Sets the HTTP URL that will be continuously pinged to check if the
+ * container is running.
+ *
+ * @param theUrl The URL to set
+ */
+ public void setUrl(URL theUrl)
+ {
+ if (!theUrl.getProtocol().equals("http"))
+ {
+ throw new IllegalArgumentException("Not a HTTP URL");
+ }
+ this.url = theUrl;
}
// Private Methods ---------------------------------------------------------
No revision
No revision
1.1.2.3 +10 -1 jakarta-cactus/integration/ant/src/test/org/apache/cactus/integration/ant/container/Attic/TestContainerRunner.java
Index: TestContainerRunner.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/integration/ant/src/test/org/apache/cactus/integration/ant/container/Attic/TestContainerRunner.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- TestContainerRunner.java 7 May 2003 15:52:01 -0000 1.1.2.2
+++ TestContainerRunner.java 7 May 2003 16:30:36 -0000 1.1.2.3
@@ -126,6 +126,9 @@
runner.setUrl(new URL("http", "localhost", this.server.getPort(),
"/test/ServletRedirector"));
runner.setTimeout(0);
+ runner.setCheckInterval(250);
+ runner.setStartUpWait(0);
+ runner.setShutDownWait(0);
runner.startUpContainer();
runner.shutDownContainer();
@@ -148,6 +151,9 @@
runner.setUrl(new URL("http", "localhost", this.server.getPort(),
"/test/ServletRedirector"));
runner.setTimeout(0);
+ runner.setCheckInterval(250);
+ runner.setStartUpWait(0);
+ runner.setShutDownWait(0);
try
{
runner.startUpContainer();
@@ -179,6 +185,9 @@
runner.setUrl(new URL("http", "localhost", this.server.getPort(),
"/test/ServletRedirector"));
runner.setTimeout(5000);
+ runner.setCheckInterval(250);
+ runner.setStartUpWait(0);
+ runner.setShutDownWait(0);
long startTime = System.currentTimeMillis();
try
{
---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org