BrokenEvent nanotests

com.brokenevent.nanotests.http
Class TestHeadRequest

java.lang.Object
  extended by com.brokenevent.nanotests.http.TestHeadRequest
All Implemented Interfaces:
TestRequest

public class TestHeadRequest
extends java.lang.Object

HEAD request for http server tests.

Author:
BrokenEvent

Field Summary
protected  HttpClient client
           
protected static HttpHost host
           
protected static java.lang.String hostUrl
           
protected  HttpRequest request
           
protected  HttpResponse response
           
 
Constructor Summary
TestHeadRequest(java.lang.String resource)
          Initializes instance of the GET request for the given resource.
 
Method Summary
 void execute()
          Executes the http request.
 java.lang.String getRequestUrl()
          Gets the fully qualified request URL.
 HttpResponse getResponse()
          Gets the http response object.
 java.lang.String getStringContent()
          Helper method to get content of the response for the http request.
 void removeHeader(java.lang.String name)
          Remove the header from the http request
 void setHeader(java.lang.String name, java.lang.String value)
          Set the header for the http request.
static void setHostUrl(java.lang.String hostUrl)
          Sets the server URL for all the requests.
 void setUserAgent(java.lang.String value)
          Sets the User-Agent http header field to the given value
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

client

protected HttpClient client

request

protected HttpRequest request

response

protected HttpResponse response

hostUrl

protected static java.lang.String hostUrl

host

protected static HttpHost host
Constructor Detail

TestHeadRequest

public TestHeadRequest(java.lang.String resource)
Initializes instance of the GET request for the given resource.

Parameters:
resource - resource name
Method Detail

setHostUrl

public static void setHostUrl(java.lang.String hostUrl)
Sets the server URL for all the requests. Default value is http://localhost

Parameters:
hostUrl - server URL

setHeader

public void setHeader(java.lang.String name,
                      java.lang.String value)
Set the header for the http request. If the header with the such header already exists, it will be overwritten.

Parameters:
name - name of the header to set
value - value for the header

removeHeader

public void removeHeader(java.lang.String name)
Remove the header from the http request

Parameters:
name - name of the header to remove

setUserAgent

public void setUserAgent(java.lang.String value)
Sets the User-Agent http header field to the given value

Parameters:
value - User-Agent new value

execute

public void execute()
Executes the http request.


getRequestUrl

public java.lang.String getRequestUrl()
Gets the fully qualified request URL.

Specified by:
getRequestUrl in interface TestRequest
Returns:
fully qualified request URL

getResponse

public HttpResponse getResponse()
Gets the http response object.

Specified by:
getResponse in interface TestRequest
Returns:
http response object

getStringContent

public java.lang.String getStringContent()
Helper method to get content of the response for the http request.

Returns:
text content of the response

BrokenEvent nanotests