vmassol     02/04/28 13:19:17

  Modified:    framework/src/java/j2ee13/org/apache/cactus
                        FilterTestCase.java
               framework/src/java/share/org/apache/cactus
                        AbstractTestCase.java ServletTestCase.java
               framework/src/test/share/org/apache/cactus
                        TestAbstractTestCaseInterceptorTestCase.java
  Added:       framework/src/java/share/org/apache/cactus
                        AbstractWebTestCase.java
  Log:
  refactoring to prepare the way for support of protocols other than HTTP (JMS for 
example)
  
  Revision  Changes    Path
  1.3       +2 -2      
jakarta-cactus/framework/src/java/j2ee13/org/apache/cactus/FilterTestCase.java
  
  Index: FilterTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/framework/src/java/j2ee13/org/apache/cactus/FilterTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FilterTestCase.java       14 Apr 2002 10:17:16 -0000      1.2
  +++ FilterTestCase.java       28 Apr 2002 20:19:17 -0000      1.3
  @@ -69,9 +69,9 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Vincent Massol</a>
    *
  - * @version $Id: FilterTestCase.java,v 1.2 2002/04/14 10:17:16 vmassol Exp $
  + * @version $Id: FilterTestCase.java,v 1.3 2002/04/28 20:19:17 vmassol Exp $
    */
  -public class FilterTestCase extends AbstractTestCase
  +public class FilterTestCase extends AbstractWebTestCase
   {
       /**
        * Valid <code>HttpServletRequest</code> object that you can access from
  
  
  
  1.4       +6 -255    
jakarta-cactus/framework/src/java/share/org/apache/cactus/AbstractTestCase.java
  
  Index: AbstractTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/AbstractTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractTestCase.java     16 Apr 2002 21:16:13 -0000      1.3
  +++ AbstractTestCase.java     28 Apr 2002 20:19:17 -0000      1.4
  @@ -59,26 +59,20 @@
   import java.lang.reflect.InvocationTargetException;
   import java.lang.reflect.Method;
   import java.lang.reflect.Modifier;
  -import java.net.HttpURLConnection;
  -import java.net.URLConnection;
   
   import junit.framework.TestCase;
   
  -import org.apache.cactus.client.AbstractHttpClient;
  -import org.apache.cactus.client.ClientConfigurationChecker;
  -import org.apache.cactus.util.ChainedRuntimeException;
   import org.apache.cactus.util.JUnitVersionHelper;
   import org.apache.cactus.util.log.Log;
   import org.apache.cactus.util.log.LogService;
   
   /**
  - * Abstract class that specific test cases (<code>ServletTestCase</code>,
  - * <code>FilterTestCase</code>, ...) must extend. Provides generally useful
  - * methods fro writing a specific test case.
  + * Abstract class that is a thin layer on top of JUnit and that knows about
  + * test cases that are executed on the server side.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Vincent Massol</a>
    *
  - * @version $Id: AbstractTestCase.java,v 1.3 2002/04/16 21:16:13 vmassol Exp $
  + * @version $Id: AbstractTestCase.java,v 1.4 2002/04/28 20:19:17 vmassol Exp $
    */
   public abstract class AbstractTestCase extends TestCase
   {
  @@ -174,201 +168,9 @@
       }
   
       /**
  -     * Call the test case begin method
  -     *
  -     * @param theRequest the <code>WebRequest</code> object to
  -     *                   pass to the begin method.
  -     * @exception Throwable any error that occurred when calling the begin
  -     *            method for the current test case.
  -     */
  -    protected void callBeginMethod(WebRequest theRequest)
  -        throws Throwable
  -    {
  -        // First, verify if a begin method exist. If one is found, verify if
  -        // it has the correct signature. If not, send a warning.
  -        Method[] methods = getClass().getMethods();
  -        for (int i = 0; i < methods.length; i++) {
  -            if (methods[i].getName().equals(getBeginMethodName())) {
  -
  -                // Check return type
  -                if (!methods[i].getReturnType().getName().equals("void")) {
  -                    fail("The begin method [" + methods[i].getName() +
  -                        "] should return void and not [" +
  -                        methods[i].getReturnType().getName() + "]");
  -                }
  -
  -                // Check if method is public
  -                if (!Modifier.isPublic(methods[i].getModifiers())) {
  -                    fail("Method [" + methods[i].getName() +
  -                        "] should be declared public");
  -                }
  -
  -                // Check parameters
  -                Class[] parameters = methods[i].getParameterTypes();
  -                if (parameters.length != 1) {
  -
  -                    fail("The begin method [" + methods[i].getName() +
  -                        "] must accept a single parameter derived from " +
  -                        "class [" + WebRequest.class.getName() + "], " +
  -                        "but " + parameters.length + " parameters were found");
  -
  -                } else if (
  -                    !WebRequest.class.isAssignableFrom(parameters[0])) {
  -
  -                    fail("The begin method [" + methods[i].getName() +
  -                        "] must accept a single parameter derived from " +
  -                        "class [" + WebRequest.class.getName() + "], " +
  -                        "but found a [" + parameters[0].getName() + "] " +
  -                        "parameter instead");
  -                }
  -
  -                try {
  -
  -                    methods[i].invoke(this, new Object[]{theRequest});
  -
  -                } catch (InvocationTargetException e) {
  -                    e.fillInStackTrace();
  -                    throw e.getTargetException();
  -                } catch (IllegalAccessException e) {
  -                    e.fillInStackTrace();
  -                    throw e;
  -                }
  -
  -            }
  -        }
  -    }
  -
  -    /**
  -     * Call the test case end method
  -     *
  -     * @param theRequest the request data that were used to open the
  -     *                   connection.
  -     * @param theConnection the <code>HttpURLConnection</code> that was used
  -     *        to open the connection to the redirection servlet. The response
  -     *        codes, headers, cookies can be checked using the get methods of
  -     *        this object.
  -     * @exception Throwable any error that occurred when calling the end method
  -     *         for the current test case.
  +     * Check client side configuration.
        */
  -    protected void callEndMethod(WebRequest theRequest,
  -        HttpURLConnection theConnection) throws Throwable
  -    {
  -        // First, verify if an end method exist. If one is found, verify if
  -        // it has the correct signature. If not, send a warning. Also
  -        // verify that only one end method is defined for a given test.
  -        Method methodToCall = null;
  -        Object paramObject = null;
  -
  -        Method[] methods = getClass().getMethods();
  -        for (int i = 0; i < methods.length; i++) {
  -            if (methods[i].getName().equals(getEndMethodName())) {
  -
  -                // Check return type
  -                if (!methods[i].getReturnType().getName().equals("void")) {
  -                    fail("The end method [" + methods[i].getName() +
  -                        "] should return void and not [" +
  -                        methods[i].getReturnType().getName() + "]");
  -                }
  -
  -                // Check if method is public
  -                if (!Modifier.isPublic(methods[i].getModifiers())) {
  -                    fail("Method [" + methods[i].getName() +
  -                        "] should be declared public");
  -                }
  -
  -                // Check parameters
  -                Class[] parameters = methods[i].getParameterTypes();
  -
  -                // Verify only one parameter is defined
  -                if (parameters.length != 1) {
  -                    fail("The end method [" + methods[i].getName() +
  -                        "] must only have a single parameter");
  -                }
  -
  -                // Is it a Http Unit WebResponse ?
  -                if (parameters[0].getName().
  -                    equals("com.meterware.httpunit.WebResponse")) {
  -
  -                    paramObject = createHttpUnitWebResponse(theConnection);
  -
  -                    // Is it a Cactus WebResponse ?
  -                } else if (parameters[0].getName().
  -                    equals("org.apache.cactus.WebResponse")) {
  -
  -                    paramObject = new WebResponse(theRequest, theConnection);
  -
  -                    // Is it an old HttpURLConnection (deprecated) ?
  -                } else if (parameters[0].getName().
  -                    equals("java.net.HttpURLConnection")) {
  -
  -                    paramObject = theConnection;
  -
  -                    // Else it is an error ...
  -                } else {
  -                    fail("The end method [" + methods[i].getName() +
  -                        "] has a bad parameter of type [" +
  -                        parameters[0].getName() + "]");
  -                }
  -
  -                // Has a method to call already been found ?
  -                if (methodToCall != null) {
  -                    fail("There can only be one end method per test case. " +
  -                        "Test case [" + this.getCurrentTestMethod() +
  -                        "] has two at least !");
  -                }
  -
  -                methodToCall = methods[i];
  -
  -            }
  -        }
  -
  -        if (methodToCall != null) {
  -
  -            try {
  -
  -                methodToCall.invoke(this, new Object[]{paramObject});
  -
  -            } catch (InvocationTargetException e) {
  -                e.fillInStackTrace();
  -                throw e.getTargetException();
  -            } catch (IllegalAccessException e) {
  -                e.fillInStackTrace();
  -                throw e;
  -            }
  -        }
  -
  -    }
  -
  -    /**
  -     * Create a HttpUnit <code>WebResponse</code> object by reflection (so
  -     * that we don't need the HttpUnit jar for users who are not using
  -     * the HttpUnit endXXX() signature).
  -     *
  -     * @param theConnection the HTTP connection that was used when connecting
  -     *        to the server side and which now contains the returned HTTP
  -     *        response that we will pass to HttpUnit so that it can construt
  -     *        a <code>com.meterware.httpunit.WebResponse</code> object.
  -     * @return a HttpUnit <code>WebResponse</code> object
  -     */
  -    private Object createHttpUnitWebResponse(HttpURLConnection theConnection)
  -    {
  -        Object webResponse;
  -
  -        try {
  -            Class responseClass =
  -                Class.forName("com.meterware.httpunit.WebResponse");
  -            Method method = responseClass.getMethod("newResponse",
  -                new Class[]{URLConnection.class});
  -            webResponse = method.invoke(null, new Object[]{theConnection});
  -        } catch (Exception e) {
  -            throw new ChainedRuntimeException("Error calling " +
  -                "[public static com.meterware.httpunit.WebResponse " +
  -                "com.meterware.httpunit.WebResponse.newResponse(" +
  -                "java.net.URLConnection) throws java.io.IOException]", e);
  -        }
  -
  -        return webResponse;
  -    }
  +    protected abstract void checkConfiguration();
   
       /**
        * Runs the bare test sequence. This method is overridden from the
  @@ -383,9 +185,7 @@
       public void runBare() throws Throwable
       {
           // Run some configuration checks
  -        ClientConfigurationChecker.getInstance().checkCactusProperties();
  -        ClientConfigurationChecker.getInstance().checkHttpClient();
  -        ClientConfigurationChecker.getInstance().checkLog4j();
  +        checkConfiguration();
   
           // We make sure we reinitialize The logger with the name of the
           // current class (that's why the logged instance is not static).
  @@ -414,55 +214,6 @@
        *            for the current test case.
        */
       protected abstract void runTest() throws Throwable;
  -
  -    /**
  -     * Execute the test case begin method, then connect to the server proxy
  -     * redirector (where the test case test method is executed) and then
  -     * executes the test case end method.
  -     *
  -     * @param theHttpClient the HTTP client class to use to connect to the
  -     *                      proxy redirector.
  -     * @exception Throwable any error that occurred when calling the test method
  -     *         for the current test case.
  -     */
  -    protected void runGenericTest(AbstractHttpClient theHttpClient)
  -        throws Throwable
  -    {
  -        // Call the begin method to fill the request object
  -        WebRequest request = new WebRequest();
  -        callBeginMethod(request);
  -
  -        // Add the class name, the method name, the URL to simulate and
  -        // automatic session creation flag to the request
  -
  -        // Note: All these pareameters are passed in the URL. This is to allow
  -        // the user to send whatever he wants in the request body. For example
  -        // a file, ...
  -        request.addParameter(ServiceDefinition.CLASS_NAME_PARAM,
  -            this.getClass().getName(), WebRequest.GET_METHOD);
  -        request.addParameter(ServiceDefinition.METHOD_NAME_PARAM,
  -            this.getCurrentTestMethod(), WebRequest.GET_METHOD);
  -        request.addParameter(ServiceDefinition.AUTOSESSION_NAME_PARAM,
  -            new Boolean(request.getAutomaticSession()).toString(),
  -            WebRequest.GET_METHOD);
  -
  -        // Add the simulated URL (if one has been defined)
  -        if (request.getURL() != null) {
  -            request.getURL().saveToRequest(request);
  -        }
  -
  -        // Open the HTTP connection to the servlet redirector
  -        // and manage errors that could be returned in the
  -        // HTTP response.
  -        HttpURLConnection connection = theHttpClient.doTest(request);
  -
  -        // Call the end method
  -        callEndMethod(request, connection);
  -
  -        // Close the input stream (just in the case the user has not done it
  -        // in it's endXXX method (or if he has no endXXX method) ....
  -        connection.getInputStream().close();
  -    }
   
       // Methods below are only called by the Cactus redirector on the server
       // side
  
  
  
  1.2       +2 -2      
jakarta-cactus/framework/src/java/share/org/apache/cactus/ServletTestCase.java
  
  Index: ServletTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/ServletTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServletTestCase.java      1 Mar 2002 00:43:45 -0000       1.1
  +++ ServletTestCase.java      28 Apr 2002 20:19:17 -0000      1.2
  @@ -69,9 +69,9 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Vincent Massol</a>
    *
  - * @version $Id: ServletTestCase.java,v 1.1 2002/03/01 00:43:45 vmassol Exp $
  + * @version $Id: ServletTestCase.java,v 1.2 2002/04/28 20:19:17 vmassol Exp $
    */
  -public class ServletTestCase extends AbstractTestCase
  +public class ServletTestCase extends AbstractWebTestCase
   {
       /**
        * Valid <code>HttpServletRequest</code> object that you can access from
  
  
  
  1.1                  
jakarta-cactus/framework/src/java/share/org/apache/cactus/AbstractWebTestCase.java
  
  Index: AbstractWebTestCase.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Cactus" and "Apache Software
   *    Foundation" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact [EMAIL PROTECTED]
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.cactus;
  
  import java.lang.reflect.InvocationTargetException;
  import java.lang.reflect.Method;
  import java.lang.reflect.Modifier;
  import java.net.HttpURLConnection;
  import java.net.URLConnection;
  
  import org.apache.cactus.client.AbstractHttpClient;
  import org.apache.cactus.client.ClientConfigurationChecker;
  import org.apache.cactus.util.ChainedRuntimeException;
  
  /**
   * Abstract class for Web Test Cases (i.e. HTTP connection to the server) that
   * (<code>ServletTestCase</code>, <code>FilterTestCase</code>, ...) must
   * extend.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]";>Vincent Massol</a>
   *
   * @version $Id: AbstractWebTestCase.java,v 1.1 2002/04/28 20:19:17 vmassol Exp $
   */
  public abstract class AbstractWebTestCase extends AbstractTestCase
  {
      /**
       * Constructs a JUnit test case with the given name.
       *
       * @param theName the name of the test case
       */
      public AbstractWebTestCase(String theName)
      {
          super(theName);
      }
  
      /**
       * Call the test case begin method
       *
       * @param theRequest the <code>WebRequest</code> object to
       *                   pass to the begin method.
       * @exception Throwable any error that occurred when calling the begin
       *            method for the current test case.
       */
      protected void callBeginMethod(WebRequest theRequest)
          throws Throwable
      {
          // First, verify if a begin method exist. If one is found, verify if
          // it has the correct signature. If not, send a warning.
          Method[] methods = getClass().getMethods();
          for (int i = 0; i < methods.length; i++) {
              if (methods[i].getName().equals(getBeginMethodName())) {
  
                  // Check return type
                  if (!methods[i].getReturnType().getName().equals("void")) {
                      fail("The begin method [" + methods[i].getName() +
                          "] should return void and not [" +
                          methods[i].getReturnType().getName() + "]");
                  }
  
                  // Check if method is public
                  if (!Modifier.isPublic(methods[i].getModifiers())) {
                      fail("Method [" + methods[i].getName() +
                          "] should be declared public");
                  }
  
                  // Check parameters
                  Class[] parameters = methods[i].getParameterTypes();
                  if (parameters.length != 1) {
  
                      fail("The begin method [" + methods[i].getName() +
                          "] must accept a single parameter derived from " +
                          "class [" + WebRequest.class.getName() + "], " +
                          "but " + parameters.length + " parameters were found");
  
                  } else if (
                      !WebRequest.class.isAssignableFrom(parameters[0])) {
  
                      fail("The begin method [" + methods[i].getName() +
                          "] must accept a single parameter derived from " +
                          "class [" + WebRequest.class.getName() + "], " +
                          "but found a [" + parameters[0].getName() + "] " +
                          "parameter instead");
                  }
  
                  try {
  
                      methods[i].invoke(this, new Object[]{theRequest});
  
                  } catch (InvocationTargetException e) {
                      e.fillInStackTrace();
                      throw e.getTargetException();
                  } catch (IllegalAccessException e) {
                      e.fillInStackTrace();
                      throw e;
                  }
  
              }
          }
      }
  
      /**
       * Call the test case end method
       *
       * @param theRequest the request data that were used to open the
       *                   connection.
       * @param theConnection the <code>HttpURLConnection</code> that was used
       *        to open the connection to the redirection servlet. The response
       *        codes, headers, cookies can be checked using the get methods of
       *        this object.
       * @exception Throwable any error that occurred when calling the end method
       *         for the current test case.
       */
      protected void callEndMethod(WebRequest theRequest,
          HttpURLConnection theConnection) throws Throwable
      {
          // First, verify if an end method exist. If one is found, verify if
          // it has the correct signature. If not, send a warning. Also
          // verify that only one end method is defined for a given test.
          Method methodToCall = null;
          Object paramObject = null;
  
          Method[] methods = getClass().getMethods();
          for (int i = 0; i < methods.length; i++) {
              if (methods[i].getName().equals(getEndMethodName())) {
  
                  // Check return type
                  if (!methods[i].getReturnType().getName().equals("void")) {
                      fail("The end method [" + methods[i].getName() +
                          "] should return void and not [" +
                          methods[i].getReturnType().getName() + "]");
                  }
  
                  // Check if method is public
                  if (!Modifier.isPublic(methods[i].getModifiers())) {
                      fail("Method [" + methods[i].getName() +
                          "] should be declared public");
                  }
  
                  // Check parameters
                  Class[] parameters = methods[i].getParameterTypes();
  
                  // Verify only one parameter is defined
                  if (parameters.length != 1) {
                      fail("The end method [" + methods[i].getName() +
                          "] must only have a single parameter");
                  }
  
                  // Is it a Http Unit WebResponse ?
                  if (parameters[0].getName().
                      equals("com.meterware.httpunit.WebResponse")) {
  
                      paramObject = createHttpUnitWebResponse(theConnection);
  
                      // Is it a Cactus WebResponse ?
                  } else if (parameters[0].getName().
                      equals("org.apache.cactus.WebResponse")) {
  
                      paramObject = new WebResponse(theRequest, theConnection);
  
                      // Is it an old HttpURLConnection (deprecated) ?
                  } else if (parameters[0].getName().
                      equals("java.net.HttpURLConnection")) {
  
                      paramObject = theConnection;
  
                      // Else it is an error ...
                  } else {
                      fail("The end method [" + methods[i].getName() +
                          "] has a bad parameter of type [" +
                          parameters[0].getName() + "]");
                  }
  
                  // Has a method to call already been found ?
                  if (methodToCall != null) {
                      fail("There can only be one end method per test case. " +
                          "Test case [" + this.getCurrentTestMethod() +
                          "] has two at least !");
                  }
  
                  methodToCall = methods[i];
  
              }
          }
  
          if (methodToCall != null) {
  
              try {
  
                  methodToCall.invoke(this, new Object[]{paramObject});
  
              } catch (InvocationTargetException e) {
                  e.fillInStackTrace();
                  throw e.getTargetException();
              } catch (IllegalAccessException e) {
                  e.fillInStackTrace();
                  throw e;
              }
          }
  
      }
  
      /**
       * Create a HttpUnit <code>WebResponse</code> object by reflection (so
       * that we don't need the HttpUnit jar for users who are not using
       * the HttpUnit endXXX() signature).
       *
       * @param theConnection the HTTP connection that was used when connecting
       *        to the server side and which now contains the returned HTTP
       *        response that we will pass to HttpUnit so that it can construt
       *        a <code>com.meterware.httpunit.WebResponse</code> object.
       * @return a HttpUnit <code>WebResponse</code> object
       */
      private Object createHttpUnitWebResponse(HttpURLConnection theConnection)
      {
          Object webResponse;
  
          try {
              Class responseClass =
                  Class.forName("com.meterware.httpunit.WebResponse");
              Method method = responseClass.getMethod("newResponse",
                  new Class[]{URLConnection.class});
              webResponse = method.invoke(null, new Object[]{theConnection});
          } catch (Exception e) {
              throw new ChainedRuntimeException("Error calling " +
                  "[public static com.meterware.httpunit.WebResponse " +
                  "com.meterware.httpunit.WebResponse.newResponse(" +
                  "java.net.URLConnection) throws java.io.IOException]", e);
          }
  
          return webResponse;
      }
  
      /**
       * @see AbstractTestCase#checkConfiguration()
       */
      protected void checkConfiguration()
      {
          ClientConfigurationChecker.getInstance().checkCactusProperties();
          ClientConfigurationChecker.getInstance().checkHttpClient();
          ClientConfigurationChecker.getInstance().checkLog4j();
      }
  
      /**
       * Execute the test case begin method, then connect to the server proxy
       * redirector (where the test case test method is executed) and then
       * executes the test case end method.
       *
       * @param theHttpClient the HTTP client class to use to connect to the
       *                      proxy redirector.
       * @exception Throwable any error that occurred when calling the test method
       *         for the current test case.
       */
      protected void runGenericTest(AbstractHttpClient theHttpClient)
          throws Throwable
      {
          // Call the begin method to fill the request object
          WebRequest request = new WebRequest();
          callBeginMethod(request);
  
          // Add the class name, the method name, the URL to simulate and
          // automatic session creation flag to the request
  
          // Note: All these pareameters are passed in the URL. This is to allow
          // the user to send whatever he wants in the request body. For example
          // a file, ...
          request.addParameter(ServiceDefinition.CLASS_NAME_PARAM,
              this.getClass().getName(), WebRequest.GET_METHOD);
          request.addParameter(ServiceDefinition.METHOD_NAME_PARAM,
              this.getCurrentTestMethod(), WebRequest.GET_METHOD);
          request.addParameter(ServiceDefinition.AUTOSESSION_NAME_PARAM,
              new Boolean(request.getAutomaticSession()).toString(),
              WebRequest.GET_METHOD);
  
          // Add the simulated URL (if one has been defined)
          if (request.getURL() != null) {
              request.getURL().saveToRequest(request);
          }
  
          // Open the HTTP connection to the servlet redirector
          // and manage errors that could be returned in the
          // HTTP response.
          HttpURLConnection connection = theHttpClient.doTest(request);
  
          // Call the end method
          callEndMethod(request, connection);
  
          // Close the input stream (just in the case the user has not done it
          // in it's endXXX method (or if he has no endXXX method) ....
          connection.getInputStream().close();
      }
  
  }
  
  
  
  1.3       +2 -2      
jakarta-cactus/framework/src/test/share/org/apache/cactus/TestAbstractTestCaseInterceptorTestCase.java
  
  Index: TestAbstractTestCaseInterceptorTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/framework/src/test/share/org/apache/cactus/TestAbstractTestCaseInterceptorTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestAbstractTestCaseInterceptorTestCase.java      14 Apr 2002 11:15:30 -0000     
 1.2
  +++ TestAbstractTestCaseInterceptorTestCase.java      28 Apr 2002 20:19:17 -0000     
 1.3
  @@ -70,10 +70,10 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Vincent Massol</a>
    *
  - * @version $Id: TestAbstractTestCaseInterceptorTestCase.java,v 1.2 2002/04/14 
11:15:30 vmassol Exp $
  + * @version $Id: TestAbstractTestCaseInterceptorTestCase.java,v 1.3 2002/04/28 
20:19:17 vmassol Exp $
    */
   public class TestAbstractTestCaseInterceptorTestCase
  -    extends AbstractTestCase
  +    extends AbstractWebTestCase
   {
       /**
        * Constructs a test case with the given name.
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to