Package net.officefloor.server.http
Class AbstractHttpClientJUnit
- java.lang.Object
-
- net.officefloor.server.http.AbstractHttpClientJUnit
-
- Direct Known Subclasses:
HttpClientExtension,HttpClientRule
public abstract class AbstractHttpClientJUnit extends java.lang.ObjectAbstractHttpClienttoHttpServer.- Author:
- Daniel Sagenschneider
-
-
Constructor Summary
Constructors Constructor Description AbstractHttpClientJUnit()Instantiate 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcloseHttpClient()Closes theHttpClient.org.apache.http.HttpResponseexecute(org.apache.http.client.methods.HttpUriRequest request)Convenience method to execute theHttpUriRequest.org.apache.http.client.HttpClientgetHttpClient()Obtains theHttpClient.protected voidopenHttpClient()Opens theCloseableHttpClient.java.lang.Stringurl(java.lang.String path)Creates URL to the server.
-
-
-
Constructor Detail
-
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 Detail
-
getHttpClient
public org.apache.http.client.HttpClient getHttpClient()
Obtains theHttpClient.- Returns:
HttpClient.
-
url
public java.lang.String url(java.lang.String path)
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 java.io.IOException, org.apache.http.client.ClientProtocolExceptionConvenience method to execute theHttpUriRequest.- Parameters:
request-HttpUriRequest.- Returns:
HttpResponse.- Throws:
java.io.IOException- If failure in communication with server.org.apache.http.client.ClientProtocolException- If client protocol issue.
-
openHttpClient
protected void openHttpClient()
Opens theCloseableHttpClient.
-
closeHttpClient
protected void closeHttpClient() throws java.io.IOExceptionCloses theHttpClient.- Throws:
java.io.IOException- If fails to close theHttpClient.
-
-