You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ju...@apache.org on 2010/01/20 18:08:19 UTC
svn commit: r901284 -
/sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
Author: justin
Date: Wed Jan 20 17:08:19 2010
New Revision: 901284
URL: http://svn.apache.org/viewvc?rev=901284&view=rev
Log:
SLING-1301 - adding HttpMethod return values from assertHttpStatus methods in HttpTestBase
Modified:
sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
Modified: sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java?rev=901284&r1=901283&r2=901284&view=diff
==============================================================================
--- sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java (original)
+++ sling/trunk/bundles/commons/testing/src/main/java/org/apache/sling/commons/testing/integration/HttpTestBase.java Wed Jan 20 17:08:19 2010
@@ -35,6 +35,7 @@
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
@@ -247,24 +248,30 @@
}
/** Verify that given URL returns expectedStatusCode
+ * @return the HttpMethod executed
* @throws IOException */
- protected void assertHttpStatus(String urlString, int expectedStatusCode, String assertMessage) throws IOException {
- final int status = httpClient.executeMethod(new GetMethod(urlString));
+ protected HttpMethod assertHttpStatus(String urlString, int expectedStatusCode, String assertMessage) throws IOException {
+ final GetMethod get = new GetMethod(urlString);
+ final int status = httpClient.executeMethod(get);
if(assertMessage == null) {
assertEquals(urlString,expectedStatusCode, status);
} else {
assertEquals(assertMessage, expectedStatusCode, status);
}
+ return get;
}
/** Verify that given URL returns expectedStatusCode
+ * @return the HttpMethod executed
* @throws IOException */
- protected void assertHttpStatus(String urlString, int expectedStatusCode) throws IOException {
- assertHttpStatus(urlString, expectedStatusCode, null);
+ protected HttpMethod assertHttpStatus(String urlString, int expectedStatusCode) throws IOException {
+ return assertHttpStatus(urlString, expectedStatusCode, null);
}
- /** Execute a POST request and check status */
- protected void assertPostStatus(String url, int expectedStatusCode, List<NameValuePair> postParams, String assertMessage)
+ /** Execute a POST request and check status
+ * @return the HttpMethod executed
+ * @throws IOException */
+ protected HttpMethod assertPostStatus(String url, int expectedStatusCode, List<NameValuePair> postParams, String assertMessage)
throws IOException {
final PostMethod post = new PostMethod(url);
post.setFollowRedirects(false);
@@ -280,6 +287,7 @@
} else {
assertEquals(assertMessage, expectedStatusCode, status);
}
+ return post;
}
/** retrieve the contents of given URL and assert its content type */