vmassol 01/08/21 01:52:20 Modified: cactus/src/framework/share/org/apache/commons/cactus AbstractTestCase.java ServletTestCase.java Log: moved the runGenericTest() method from ServletTestCase to AbstractTestCase as it is a general behaviour that will also be useful for the FilterTestCase Revision Changes Path 1.5 +52 -1 jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/AbstractTestCase.java Index: AbstractTestCase.java =================================================================== RCS file: /home/cvs/jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/AbstractTestCase.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- AbstractTestCase.java 2001/08/19 16:12:55 1.4 +++ AbstractTestCase.java 2001/08/21 08:52:20 1.5 @@ -72,7 +72,7 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a> * - * @version $Id: AbstractTestCase.java,v 1.4 2001/08/19 16:12:55 vmassol Exp $ + * @version $Id: AbstractTestCase.java,v 1.5 2001/08/21 08:52:20 vmassol Exp $ */ public abstract class AbstractTestCase extends TestCase { @@ -370,6 +370,57 @@ * Cactus redirection servlet. */ 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. + */ + protected void runGenericTest(AbstractHttpClient theHttpClient) + throws Throwable + { + this.logger.entry("runGenericTest(...)"); + + // Log the test name + this.logger.debug("Test case = " + currentTestMethod); + + // Call the begin method to fill the request object + ServletTestRequest request = new ServletTestRequest(); + callBeginMethod(request); + + // Add the class name, the method name, the URL to simulate and + // automatic session creation flag to the request + request.addParameter(ServiceDefinition.CLASS_NAME_PARAM, + this.getClass().getName()); + request.addParameter(ServiceDefinition.METHOD_NAME_PARAM, name()); + request.addParameter(ServiceDefinition.AUTOSESSION_NAME_PARAM, + new Boolean(request.getAutomaticSession()).toString()); + + // 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(connection); + + // Close the intput 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(); + + this.logger.exit("runGenericTest"); + } + + // Methods below are only called by the Cactus redirector on the server + // side /** * Run the test that was specified in the constructor on the server side, 1.6 +1 -50 jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/ServletTestCase.java Index: ServletTestCase.java =================================================================== RCS file: /home/cvs/jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/ServletTestCase.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ServletTestCase.java 2001/08/19 16:12:55 1.5 +++ ServletTestCase.java 2001/08/21 08:52:20 1.6 @@ -70,7 +70,7 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a> * - * @version $Id: ServletTestCase.java,v 1.5 2001/08/19 16:12:55 vmassol Exp $ + * @version $Id: ServletTestCase.java,v 1.6 2001/08/21 08:52:20 vmassol Exp $ */ public class ServletTestCase extends AbstractTestCase { @@ -130,53 +130,4 @@ runGenericTest(new ServletHttpClient()); } - /** - * 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. - */ - protected void runGenericTest(AbstractHttpClient theHttpClient) - throws Throwable - { - this.logger.entry("runGenericTest(...)"); - - // Log the test name - this.logger.debug("Test case = " + currentTestMethod); - - // Call the begin method to fill the request object - ServletTestRequest request = new ServletTestRequest(); - callBeginMethod(request); - - // Add the class name, the method name, the URL to simulate and - // automatic session creation flag to the request - request.addParameter(ServiceDefinition.CLASS_NAME_PARAM, - this.getClass().getName()); - request.addParameter(ServiceDefinition.METHOD_NAME_PARAM, name()); - request.addParameter(ServiceDefinition.AUTOSESSION_NAME_PARAM, - new Boolean(request.getAutomaticSession()).toString()); - - // 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(connection); - - // Close the intput 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(); - //connection.disconnect(); - - this.logger.exit("runGenericTest"); - } - }