*** ServletTestCaller.java.1.3	Tue May 15 12:16:28 2001
--- ServletTestCaller.java	Tue May 15 12:46:04 2001
***************
*** 154,159 ****
--- 154,164 ----
      {
          ServletTestResult result = null;
  
+         // Reset TEST_RESULTS to a new results holder to prevent premature
+         // requests for results from seeing either no results or old results
+         TestResultHolder holder = new TestResultHolder();
+         theObjects.m_Config.getServletContext().setAttribute(TEST_RESULTS, holder);
+ 
          try {
  
              // Extract from the HTTP request the test class name and method to call.
***************
*** 185,192 ****
  
          }
  
!         // Save the test result.
!         theObjects.m_Config.getServletContext().setAttribute(TEST_RESULTS, result);
  
      }
  
--- 190,197 ----
  
          }
  
!         // Set the test result.
!        holder.setResult(result);
  
      }
  
***************
*** 199,205 ****
       */
      public void doGetResults(ServletImplicitObjects theObjects) throws ServletException
      {
!         ServletTestResult result = (ServletTestResult)theObjects.m_Config.getServletContext().getAttribute(TEST_RESULTS);
          if (result == null) {
              throw new ServletException("No test results found in the application scope");
          }
--- 204,210 ----
       */
      public void doGetResults(ServletImplicitObjects theObjects) throws ServletException
      {
!         ServletTestResult result = ((TestResultHolder)theObjects.m_Config.getServletContext().getAttribute(TEST_RESULTS)).getResult();
          if (result == null) {
              throw new ServletException("No test results found in the application scope");
          }
***************
*** 220,223 ****
          }
      }
  
! }
--- 225,252 ----
          }
      }
  
! 
!     /**
!      * Provides synchronized access to test results to prevent the
!      * request for servlet results being processed before the test
!      * servlet has written the results
!      */
!     static class TestResultHolder {
!         ServletTestResult result;
! 
!         synchronized void setResult(ServletTestResult r) {
!             result = r;
!             notifyAll();
!         }
! 
!         synchronized ServletTestResult getResult() {
!             while( result == null ) {
!                 try {
!                     wait();
!                 } catch(InterruptedException ie) {
!                 }
!             }
!             return result;
!         }
!     }
! }
