vmassol 01/08/21 01:51:04
Modified: cactus/src/framework/share/org/apache/commons/cactus/server
ServletTestCaller.java
Removed: cactus/src/framework/share/org/apache/commons/cactus/server
ResultHolder.java
Log:
removed semaphore (ResultHolder) as it is no longer needed (it was there to prevent
test result to be read before the test was finished and the results written to the
context). However as we use a AutoReadHttpURLConnection on the client side, this
ensures that the test execution will always happen before the second HTTP request to
read the results.
Revision Changes Path
1.7 +14 -24
jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/server/ServletTestCaller.java
Index: ServletTestCaller.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/server/ServletTestCaller.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ServletTestCaller.java 2001/08/19 16:34:10 1.6
+++ ServletTestCaller.java 2001/08/21 08:51:04 1.7
@@ -70,7 +70,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a>
*
- * @version $Id: ServletTestCaller.java,v 1.6 2001/08/19 16:34:10 vmassol Exp $
+ * @version $Id: ServletTestCaller.java,v 1.7 2001/08/21 08:51:04 vmassol Exp $
*/
public class ServletTestCaller
{
@@ -114,18 +114,6 @@
WebTestResult result = null;
- // Reset TEST_RESULTS to a new results holder to prevent premature
- // requests for results from seeing either no results or old results
- ResultHolder holder = new ResultHolder();
- this.servletImplicitObjects.getServletConfig().getServletContext().
- setAttribute(TEST_RESULTS, holder);
-
- this.logger.debug("Result holder semaphore is in place");
-
- // From this point forward, any thread trying to access the result
- // stored in the holder, itself stored in the application scope, will
- // block and wait until a result is set.
-
try {
// Create an instance of the test class
@@ -150,11 +138,9 @@
}
- // Set the test result. This will deactivate the semaphore.
- holder.setResult(result);
-
- this.logger.debug("Result holder semaphore inactive (result set in " +
- "holder)");
+ // Set the test result.
+ this.servletImplicitObjects.getServletConfig().getServletContext().
+ setAttribute(TEST_RESULTS, result);
this.logger.exit("doTest");
}
@@ -168,15 +154,19 @@
{
this.logger.entry("doGetResults()");
- this.logger.debug("Try to read results from Holder ...");
+ // One could think there is a potential risk that the client side of
+ // Cactus will request the result before it has been written to the
+ // context scope as the HTTP request will not block in some containers.
+ // However this will not happend because on the client side, once the
+ // first request is done to execute the test, all the result is read
+ // by the AutoReadHttpURLConnection class, thus ensuring that the
+ // request is fully finished and the resukt has been committed ...
- ResultHolder holder = (ResultHolder)(
- this.servletImplicitObjects.getServletConfig().
+ WebTestResult result =
+ (WebTestResult)(this.servletImplicitObjects.getServletConfig().
getServletContext().getAttribute(TEST_RESULTS));
-
- WebTestResult result = holder.getResult();
- this.logger.debug("... results has been read");
+ this.logger.debug("Test Result = [" + result + "]");
// Write back the results as a serialized object to the outgoing stream.
try {