public abstract class RESTCall<M extends org.apache.http.client.methods.HttpRequestBase> extends Object implements AutoCloseable
Modifier | Constructor and Description |
---|---|
protected |
RESTCall(org.apache.http.client.HttpClient client,
M method) |
protected |
RESTCall(M method) |
Modifier and Type | Method and Description |
---|---|
void |
addRequestHeader(String key,
String value) |
protected void |
assertExecuted() |
protected void |
assertNotExecuted() |
protected void |
beforeExecute() |
void |
close() |
void |
execute() |
static org.apache.http.client.HttpClient |
getHttpClientWithTimeout(String scheme) |
M |
getMethod() |
InputStream |
getResponseAsStream() |
String |
getResponseAsString() |
byte[] |
getResponseBody()
Returns the response body as a byte array.
|
com.google.common.collect.Multimap<String,String> |
getResponseHeaders() |
int |
getStatusCode() |
org.apache.http.StatusLine |
getStatusLine() |
URI |
getURI() |
protected void |
marshal(Object obj,
OutputStream out) |
void |
release()
Releases the resources held by the underlying HTTP request.
|
void |
setBasicCredentials(String username,
String password)
Configured this call to use Basic HTTP Authentication using the specified username and password.
|
void |
setClientProxy() |
void |
setMarshalledClasses(Class... classes) |
String |
toString() |
<T> T |
unmarshal(Class<T> responseType) |
protected Object |
unmarshal(InputStream in) |
protected RESTCall(org.apache.http.client.HttpClient client, M method)
protected RESTCall(M method)
public static org.apache.http.client.HttpClient getHttpClientWithTimeout(String scheme)
scheme
- target scheme for the REST call, e.g. 'http' or 'https', required to properly set up proxy settingspublic void setMarshalledClasses(Class... classes) throws JAXBException
JAXBException
protected void marshal(Object obj, OutputStream out) throws JAXBException
JAXBException
protected Object unmarshal(InputStream in) throws JAXBException
JAXBException
public <T> T unmarshal(Class<T> responseType) throws IOException, JAXBException
IOException
JAXBException
public void setBasicCredentials(String username, String password)
username
- password
- public void setClientProxy()
public void execute()
protected void beforeExecute()
public int getStatusCode()
public org.apache.http.StatusLine getStatusLine()
public byte[] getResponseBody()
This assertion must be called after the call has been executed successfully, or it will fail the test.
public InputStream getResponseAsStream()
public String getResponseAsString()
public URI getURI()
public void release()
protected void assertExecuted()
protected void assertNotExecuted()
public M getMethod()
public void close()
close
in interface AutoCloseable
Copyright © 2019 Atlassian Software Systems Pty Ltd. All rights reserved.