Methods Summary |
---|
public static org.apache.commons.httpclient.HttpMethodBase | accessURL(java.net.URL url)Perform a get on the indicated URL and assert an HTTP_OK response code
return accessURL(url, "JBossTest Servlets", HttpURLConnection.HTTP_OK);
|
public static org.apache.commons.httpclient.HttpMethodBase | accessURL(java.net.URL url, java.lang.String realm, int expectedHttpCode)Perform a get on the indicated URL and assert that the response code
matches the expectedHttpCode argument.
return accessURL(url, realm, expectedHttpCode, null);
|
public static org.apache.commons.httpclient.HttpMethodBase | accessURL(java.net.URL url, java.lang.String realm, int expectedHttpCode, int type)
return accessURL(url, realm, expectedHttpCode, null, type);
|
public static org.apache.commons.httpclient.HttpMethodBase | accessURL(java.net.URL url, java.lang.String realm, int expectedHttpCode, org.apache.commons.httpclient.Header[] hdrs)
return accessURL(url, realm, expectedHttpCode, hdrs, GET);
|
public static org.apache.commons.httpclient.HttpMethodBase | accessURL(java.net.URL url, java.lang.String realm, int expectedHttpCode, org.apache.commons.httpclient.Header[] hdrs, int type)
HttpClient httpConn = new HttpClient();
HttpMethodBase request = createMethod(url, type);
int hdrCount = hdrs != null ? hdrs.length : 0;
for(int n = 0; n < hdrCount; n ++)
request.addRequestHeader(hdrs[n]);
try
{
log.debug("Connecting to: "+url);
String userInfo = url.getUserInfo();
if( userInfo != null )
{
UsernamePasswordCredentials auth = new UsernamePasswordCredentials(userInfo);
httpConn.getState().setCredentials(realm, url.getHost(), auth);
}
log.debug("RequestURI: "+request.getURI());
int responseCode = httpConn.executeMethod(request);
String response = request.getStatusText();
log.debug("responseCode="+responseCode+", response="+response);
String content = request.getResponseBodyAsString();
log.debug(content);
// Validate that we are seeing the requested response code
if( responseCode != expectedHttpCode )
{
throw new IOException("Expected reply code:"+expectedHttpCode
+", actual="+responseCode);
}
}
catch(IOException e)
{
throw e;
}
return request;
|
public static org.apache.commons.httpclient.HttpMethodBase | createMethod(java.net.URL url, int type)
HttpMethodBase request = null;
switch( type )
{
case GET:
request = new GetMethod(url.toString());
break;
case POST:
request = new PostMethod(url.toString());
break;
case HEAD:
request = new HeadMethod(url.toString());
break;
case OPTIONS:
request = new OptionsMethod(url.toString());
break;
case PUT:
request = new PutMethod(url.toString());
break;
case DELETE:
request = new DeleteMethod(url.toString());
break;
case TRACE:
request = new TraceMethod(url.toString());
break;
}
return request;
|
public static java.lang.String | getBaseURL()
return baseURL;
|
public static java.lang.String | getBaseURL(java.lang.String username, java.lang.String password)
String url = "http://"+username+":"+password+"@"+ System.getProperty("jboss.bind.address") + ":"
+ Integer.getInteger("web.port", 8080) + "/";
return url;
|
public static java.lang.String | getBaseURLNoAuth()
return baseURLNoAuth;
|