public class ClientTestingAdapter extends Object
Modifier and Type | Field and Description |
---|---|
protected ClientPOJOAdapter |
adapter
This adapter will perform the HTTP request and return the response in the
expected format.
|
protected boolean |
callAssertNothingThrown |
Constructor and Description |
---|
ClientTestingAdapter() |
ClientTestingAdapter(ClientPOJOAdapter adapter) |
Modifier and Type | Method and Description |
---|---|
Map<String,Object> |
execute(String defaultURI,
Map<String,Object> request,
TestingFrameworkRequestHandler requestHandler,
Map<String,Object> responseExpectations)
See the documentation for the same method in
ClientPOJOAdapter . |
ClientPOJOAdapter |
getClientPOJOAdapter()
Getter for the
ClientPOJOAdapter that is actually used to make the
HTTP request. |
boolean |
isRequestSupported(Map<String,Object> request)
See the documentation for the same method in
ClientPOJOAdapter . |
Map<String,Object> |
modifyRequest(Map<String,Object> request)
See the documentation for the same method in
ClientPOJOAdapter . |
Map<String,Object> |
modifyResponseExpectations(Map<String,Object> request,
Map<String,Object> responseExpectations)
Generally a test's response expectations should not need to be modified, but
if a particular HTTP client (such as Groovy's RESTClient which uses HttpClient)
needs to modify the response expectations, it should do so here.
|
protected ClientPOJOAdapter adapter
protected boolean callAssertNothingThrown
public ClientTestingAdapter()
public ClientTestingAdapter(ClientPOJOAdapter adapter)
public Map<String,Object> execute(String defaultURI, Map<String,Object> request, TestingFrameworkRequestHandler requestHandler, Map<String,Object> responseExpectations) throws TestingFrameworkException
ClientPOJOAdapter
. This
method will typically call it. However, this method also has access to the
test's response expectations if that is needed for some reason. Furthermore,
this method also has access to the TestingFrameworkRequestHandler
so
it can optionally call assertNothingThrown() before checking the response
further. It is optional because the test framework will call it later.defaultURI
- See execute method of ClientPOJOAdapter
.request
- See execute method of ClientPOJOAdapter
.requestHandler
- The request handler that checks the received HTTP request
with the request that was intended. If there is a
mismatch of expectations, then the requestHandler will
throw an exception. If this execute method does not want
to make further checks of the response in the case
the responseHandler threw, then the assertNothingThrown()
method should be called before doing further checks.responseExpectations
- The response expectations of the test.ClientPOJOAdapter
.TestingFrameworkException
- in the case of a problem.public boolean isRequestSupported(Map<String,Object> request)
ClientPOJOAdapter
.public Map<String,Object> modifyRequest(Map<String,Object> request)
ClientPOJOAdapter
.public Map<String,Object> modifyResponseExpectations(Map<String,Object> request, Map<String,Object> responseExpectations)
TestingFrameworkRequestHandler
is sent the
expectations so the request handler will return a response that matches the
expectations. When the HTTP response is obtained, the received response
is matched against the expectations.request
- for the format, see the documentation for ClientPOJOAdapter
.responseExpectations
- for the format, see the documentation for ClientPOJOAdapter
.public ClientPOJOAdapter getClientPOJOAdapter()
ClientPOJOAdapter
that is actually used to make the
HTTP request.ClientPOJOAdapter
.Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.