cmlenz 2003/07/09 07:22:42
Modified: integration/ant/src/java/org/apache/cactus/integration/ant/container
ContainerRunner.java
Log:
Assume that the application is not deployed when connecting to the server is
possible, but requests return non-successful status codes. This fixes a problem with
the tests starting to get executed against a not-yet-initialized application under
JBoss, and thus returning false test failures.
Submitted by: Florin Vancea <fvancea at maxiq.ro>
Revision Changes Path
1.4 +11 -6
jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/ContainerRunner.java
Index: ContainerRunner.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/ContainerRunner.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ContainerRunner.java 14 Jun 2003 08:19:07 -0000 1.3
+++ ContainerRunner.java 9 Jul 2003 14:22:41 -0000 1.4
@@ -334,8 +334,9 @@
// Private Methods ---------------------------------------------------------
/**
- * Tests whether the resource pointed to by the specified HTTP URL is
- * available.
+ * Tests whether we are able to connect to the HTTP server identified by the
+ * specified URL, and whether it responds with a HTTP status code indicating
+ * success (200 up to but excluding 300) for the requested resource.
*
* @param theUrl The URL to check
* @return <code>true</code> if the test URL could be called without error,
@@ -343,7 +344,7 @@
*/
private boolean isAvailable(URL theUrl)
{
- boolean isUrlCallable = false;
+ boolean retVal = false;
try
{
HttpURLConnection connection =
@@ -352,13 +353,17 @@
connection.connect();
readFully(connection);
connection.disconnect();
- isUrlCallable = true;
+ if ((connection.getResponseCode() != -1)
+ && (connection.getResponseCode() < 300))
+ {
+ retVal = true;
+ }
}
catch (IOException e)
{
this.log.debug("Failed to connect to " + theUrl, e);
}
- return isUrlCallable;
+ return retVal;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]