vmassol 01/11/16 10:46:31
Modified: src/framework/share/org/apache/cactus/client
AbstractHttpClient.java
Log:
refactoring and remove explicit logging of entries and exist of methods (which is
now done using aspectj)
Revision Changes Path
1.11 +67 -32
jakarta-cactus/src/framework/share/org/apache/cactus/client/AbstractHttpClient.java
Index: AbstractHttpClient.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/src/framework/share/org/apache/cactus/client/AbstractHttpClient.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- AbstractHttpClient.java 2001/10/20 19:24:27 1.10
+++ AbstractHttpClient.java 2001/11/16 18:46:31 1.11
@@ -67,7 +67,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a>
*
- * @version $Id: AbstractHttpClient.java,v 1.10 2001/10/20 19:24:27 vmassol Exp $
+ * @version $Id: AbstractHttpClient.java,v 1.11 2001/11/16 18:46:31 vmassol Exp $
*/
public abstract class AbstractHttpClient
{
@@ -109,40 +109,12 @@
public HttpURLConnection doTest(WebRequest theRequest)
throws Throwable
{
- logger.entry("doTest(" + theRequest + ")");
-
// Open the first connection to the redirector to execute the test on
// the server side
- HttpClientHelper helper1 =
- new HttpClientHelper(getRedirectorURL());
-
- // Specify the service to call on the redirector side
- theRequest.addParameter(ServiceDefinition.SERVICE_NAME_PARAM,
- ServiceEnumeration.CALL_TEST_SERVICE.toString());
- HttpURLConnection connection = helper1.connect(theRequest);
-
- // Wrap the connection to ensure that all servlet output is read
- // before we ask for results
- connection = new AutoReadHttpURLConnection(connection);
+ HttpURLConnection connection = callRunTest(theRequest);
- // Trigger the transfer of data
- connection.getInputStream();
-
// Open the second connection to get the test results
- HttpClientHelper helper2 =
- new HttpClientHelper(getRedirectorURL());
-
- WebRequest resultsRequest = new WebRequest();
- resultsRequest.addParameter(ServiceDefinition.SERVICE_NAME_PARAM,
- ServiceEnumeration.GET_RESULTS_SERVICE.toString());
- HttpURLConnection resultConnection = helper2.connect(resultsRequest);
-
- // Read the results as a serialized object
- ObjectInputStream ois =
- new ObjectInputStream(resultConnection.getInputStream());
- WebTestResult result = (WebTestResult)ois.readObject();
-
- ois.close();
+ WebTestResult result = callGetResult();
// Check if the returned result object returned contains an error or
// not. If yes, we need to raise an exception so that the JUnit
@@ -180,8 +152,71 @@
}
- logger.exit("doTest");
return connection;
+ }
+
+ /**
+ * Execute the test by calling the redirector.
+ *
+ * @param theRequest the request containing all data to pass to the
+ * redirector servlet.
+ * @return the <code>HttpURLConnection</code> that contains the HTTP
+ * response when the test was called.
+ *
+ * @exception Throwable if an error occured in the test method or in the
+ * redirector servlet.
+ */
+ private HttpURLConnection callRunTest(WebRequest theRequest) throws Throwable
+ {
+ // Open the first connection to the redirector to execute the test on
+ // the server side
+ HttpClientHelper helper =
+ new HttpClientHelper(getRedirectorURL());
+
+ // Specify the service to call on the redirector side
+ theRequest.addParameter(ServiceDefinition.SERVICE_NAME_PARAM,
+ ServiceEnumeration.CALL_TEST_SERVICE.toString(),
+ WebRequest.GET_METHOD);
+ HttpURLConnection connection = helper.connect(theRequest);
+
+ // Wrap the connection to ensure that all servlet output is read
+ // before we ask for results
+ connection = new AutoReadHttpURLConnection(connection);
+
+ // Trigger the transfer of data
+ connection.getInputStream();
+
+ return connection;
+ }
+
+ /**
+ * Get the test result from the redirector.
+ *
+ * @return the result that was returned by the redirector.
+ *
+ * @exception Throwable if an error occured in the test method or in the
+ * redirector servlet.
+ */
+ private WebTestResult callGetResult() throws Throwable
+ {
+ // Open the second connection to get the test results
+ HttpClientHelper helper =
+ new HttpClientHelper(getRedirectorURL());
+
+ WebRequest resultsRequest = new WebRequest();
+ resultsRequest.addParameter(ServiceDefinition.SERVICE_NAME_PARAM,
+ ServiceEnumeration.GET_RESULTS_SERVICE.toString(),
+ WebRequest.GET_METHOD);
+ HttpURLConnection resultConnection = helper.connect(resultsRequest);
+
+ // Read the results as a serialized object
+ ObjectInputStream ois =
+ new ObjectInputStream(resultConnection.getInputStream());
+ WebTestResult result = (WebTestResult)ois.readObject();
+
+ ois.close();
+
+ return result;
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>