Package net.officefloor.server.http
Class AbstractHttpClientJUnit<T>
java.lang.Object
net.officefloor.server.http.AbstractHttpClientJUnit<T>
- Direct Known Subclasses:
HttpClientExtension,HttpClientRule
Abstract
HttpClient to HttpServer.- Author:
- Daniel Sagenschneider
-
Constructor Summary
ConstructorsConstructorDescriptionInstantiate for non-secure (HTTP) connection toHttpServer.AbstractHttpClientJUnit(boolean isSecure) Instantiate with flagging if secure (HTTPS) connection toHttpServer.AbstractHttpClientJUnit(boolean isSecure, int port) Instantiate indicating the server port. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCloses theHttpClient.org.apache.http.HttpResponseexecute(org.apache.http.client.methods.HttpUriRequest request) Convenience method to execute theHttpUriRequest.followRedirects(boolean isFollowRedirects) Flags whether to follow redirects.org.apache.http.client.HttpClientObtains theHttpClient.protected voidOpens theCloseableHttpClient.timeout(int timeout) Specifies the request timeout in milliseconds.Creates URL to the server.
-
Constructor Details
-
AbstractHttpClientJUnit
public AbstractHttpClientJUnit()Instantiate for non-secure (HTTP) connection toHttpServer. -
AbstractHttpClientJUnit
public AbstractHttpClientJUnit(boolean isSecure) Instantiate with flagging if secure (HTTPS) connection toHttpServer.- Parameters:
isSecure- Indicates if secure (HTTPS).
-
AbstractHttpClientJUnit
public AbstractHttpClientJUnit(boolean isSecure, int port) Instantiate indicating the server port.- Parameters:
isSecure- Indicates if secure (HTTPS).port- Server port to connect.
-
-
Method Details
-
followRedirects
Flags whether to follow redirects.- Parameters:
isFollowRedirects- Indicates if follow redirects.- Returns:
this.
-
timeout
Specifies the request timeout in milliseconds.- Parameters:
timeout- Time out.- Returns:
this.
-
getHttpClient
public org.apache.http.client.HttpClient getHttpClient()Obtains theHttpClient.- Returns:
HttpClient.
-
url
Creates URL to the server.- Parameters:
path- Path on the server.- Returns:
- URL to the server.
-
execute
public org.apache.http.HttpResponse execute(org.apache.http.client.methods.HttpUriRequest request) throws IOException, org.apache.http.client.ClientProtocolException Convenience method to execute theHttpUriRequest.- Parameters:
request-HttpUriRequest.- Returns:
HttpResponse.- Throws:
IOException- If failure in communication with server.org.apache.http.client.ClientProtocolException- If client protocol issue.
-
openHttpClient
protected void openHttpClient()Opens theCloseableHttpClient. -
closeHttpClient
Closes theHttpClient.- Throws:
IOException- If fails to close theHttpClient.
-