public class FakeHttp extends Object
Constructor | Description |
---|---|
FakeHttp() |
Modifier and Type | Method | Description |
---|---|---|
static void |
addHttpResponseRule(String uri,
String response) |
Adds an HTTP response rule.
|
static void |
addHttpResponseRule(String method,
String uri,
org.apache.http.HttpResponse response) |
Adds an HTTP response rule.
|
static void |
addHttpResponseRule(String uri,
org.apache.http.HttpResponse response) |
Adds an HTTP response rule with a default method of GET.
|
static void |
addHttpResponseRule(RequestMatcher requestMatcher,
List<? extends org.apache.http.HttpResponse> responses) |
Adds an HTTP response rule.
|
static void |
addHttpResponseRule(RequestMatcher requestMatcher,
org.apache.http.HttpResponse response) |
Adds an HTTP response rule.
|
static void |
addPendingHttpResponse(int statusCode,
String responseBody,
org.apache.http.Header... headers) |
Sets up an HTTP response to be returned by calls to Apache's
HttpClient implementers. |
static void |
addPendingHttpResponse(org.apache.http.HttpResponse httpResponse) |
Sets up an HTTP response to be returned by calls to Apache's
HttpClient implementers. |
static void |
addPendingHttpResponse(HttpResponseGenerator httpResponseGenerator) |
Sets up an HTTP response to be returned by calls to Apache's
HttpClient implementers. |
static void |
addPendingHttpResponseWithContentType(int statusCode,
String responseBody,
org.apache.http.Header contentType) |
Deprecated.
|
static void |
clearHttpResponseRules() |
|
static void |
clearPendingHttpResponses() |
|
static FakeHttpLayer |
getFakeHttpLayer() |
|
static org.apache.http.HttpRequest |
getLatestSentHttpRequest() |
|
static org.apache.http.HttpRequest |
getNextSentHttpRequest() |
Accessor to obtain HTTP requests made during the current test in the order in which they were made.
|
static HttpRequestInfo |
getNextSentHttpRequestInfo() |
Accessor to obtain metadata for an HTTP request made during the current test in the order in which they were made.
|
static org.apache.http.HttpRequest |
getSentHttpRequest(int index) |
Accessor to obtain HTTP requests made during the current test in the order in which they were made.
|
static HttpRequestInfo |
getSentHttpRequestInfo(int index) |
Accessor to obtain metadata for an HTTP request made during the current test in the order in which they were made.
|
static boolean |
httpRequestWasMade() |
Accessor to find out if HTTP requests were made during the current test.
|
static boolean |
httpRequestWasMade(String uri) |
|
static void |
reset() |
|
static void |
setDefaultHttpResponse(int statusCode,
String responseBody) |
|
static void |
setDefaultHttpResponse(org.apache.http.HttpResponse defaultHttpResponse) |
public static void addPendingHttpResponse(int statusCode, String responseBody, org.apache.http.Header... headers)
HttpClient
implementers.statusCode
- the status code of the responseresponseBody
- the body of the responseheaders
- optional headers for the request@Deprecated public static void addPendingHttpResponseWithContentType(int statusCode, String responseBody, org.apache.http.Header contentType)
addPendingHttpResponse(int, String, org.apache.http.Header...)
insteadHttpClient
implementers.statusCode
- the status code of the responseresponseBody
- the body of the responsecontentType
- the contentType of the responsepublic static void addPendingHttpResponse(org.apache.http.HttpResponse httpResponse)
HttpClient
implementers.httpResponse
- the responsepublic static void addPendingHttpResponse(HttpResponseGenerator httpResponseGenerator)
HttpClient
implementers.httpResponseGenerator
- an HttpResponseGenerator that will provide responsespublic static org.apache.http.HttpRequest getSentHttpRequest(int index)
index
- index of the request to retrieve.public static org.apache.http.HttpRequest getLatestSentHttpRequest()
public static boolean httpRequestWasMade()
public static boolean httpRequestWasMade(String uri)
public static HttpRequestInfo getSentHttpRequestInfo(int index)
index
- index of the request to retrieve.public static org.apache.http.HttpRequest getNextSentHttpRequest()
public static HttpRequestInfo getNextSentHttpRequestInfo()
public static void addHttpResponseRule(String method, String uri, org.apache.http.HttpResponse response)
method
- method to match.uri
- uri to match.response
- response to return when a match is found.public static void addHttpResponseRule(String uri, org.apache.http.HttpResponse response)
uri
- uri to match.response
- response to return when a match is found.public static void addHttpResponseRule(String uri, String response)
uri
- uri to match.response
- response to return when a match is found.public static void addHttpResponseRule(RequestMatcher requestMatcher, org.apache.http.HttpResponse response)
requestMatcher
- custom RequestMatcher
.response
- response to return when a match is found.public static void addHttpResponseRule(RequestMatcher requestMatcher, List<? extends org.apache.http.HttpResponse> responses)
requestMatcher
- custom RequestMatcher
.responses
- responses to return in order when a match is found.public static FakeHttpLayer getFakeHttpLayer()
public static void setDefaultHttpResponse(int statusCode, String responseBody)
public static void setDefaultHttpResponse(org.apache.http.HttpResponse defaultHttpResponse)
public static void clearHttpResponseRules()
public static void clearPendingHttpResponses()
public static void reset()