|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.github.kristofa.test.http.SimpleHttpResponseProvider
public class SimpleHttpResponseProvider
HttpResponseProvider that keeps expected request/responses in memory. Its purpose is to match simple requests that
can be easily programmatically defined in code. It supports matching:
MockHttpServer| Constructor Summary | |
|---|---|
SimpleHttpResponseProvider()
|
|
| Method Summary | |
|---|---|
SimpleHttpResponseProvider |
expect(Method method,
String path)
Provide an expected request without content. |
SimpleHttpResponseProvider |
expect(Method method,
String path,
String contentType,
String requestEntity)
Provide an expected request with content. |
HttpResponse |
getResponse(HttpRequest request)
Gets expected response for given request. |
void |
reset()
Reset the response provider to its original state |
SimpleHttpResponseProvider |
respondWith(int httpCode,
String contentType,
String requestEntity)
Provide expected response for latest given request. |
void |
verify()
Should be executed when all requests have been submitted. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public SimpleHttpResponseProvider()
| Method Detail |
|---|
public SimpleHttpResponseProvider expect(Method method,
String path,
String contentType,
String requestEntity)
method - HTTP method.path - Path. Path can contain query parameters, eg: path?a=b&b=ccontentType - Content type.requestEntity - Request entity as string.
SimpleHttpResponseProvider. Allows chaining calls.
public SimpleHttpResponseProvider expect(Method method,
String path)
method - HTTP method.path - Path. Path can contain query parameters, eg: path?a=b&b=c
SimpleHttpResponseProvider. Allows chaining calls.
public SimpleHttpResponseProvider respondWith(int httpCode,
String contentType,
String requestEntity)
httpCode - Http response code.contentType - Content type.requestEntity - Data.
SimpleHttpResponseProvider. Allows chaining calls.public HttpResponse getResponse(HttpRequest request)
getResponse in interface HttpResponseProviderrequest - HttpRequest.
null in case we don't know given request.
public void verify()
throws UnsatisfiedExpectationException
verify in interface HttpResponseProviderUnsatisfiedExpectationException - In case expectation were not as expected. See
UnsatisfiedExpectationException.getMissingHttpRequests() and
UnsatisfiedExpectationException.getUnexpectedHttpRequests() to get missing and unexpected
requests.public void reset()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||