Class ClientTestingAdapter
- java.lang.Object
-
- org.apache.hc.core5.testing.framework.ClientTestingAdapter
-
- Direct Known Subclasses:
ClassicTestClientTestingAdapter
public class ClientTestingAdapter extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected ClientPOJOAdapter
adapter
This adapter will perform the HTTP request and return the response in the expected format.protected boolean
callAssertNothingThrown
-
Constructor Summary
Constructors Constructor Description ClientTestingAdapter()
ClientTestingAdapter(ClientPOJOAdapter adapter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.Object>
execute(java.lang.String defaultURI, java.util.Map<java.lang.String,java.lang.Object> request, TestingFrameworkRequestHandler requestHandler, java.util.Map<java.lang.String,java.lang.Object> responseExpectations)
See the documentation for the same method inClientPOJOAdapter
.ClientPOJOAdapter
getClientPOJOAdapter()
Getter for theClientPOJOAdapter
that is actually used to make the HTTP request.boolean
isRequestSupported(java.util.Map<java.lang.String,java.lang.Object> request)
See the documentation for the same method inClientPOJOAdapter
.java.util.Map<java.lang.String,java.lang.Object>
modifyRequest(java.util.Map<java.lang.String,java.lang.Object> request)
See the documentation for the same method inClientPOJOAdapter
.java.util.Map<java.lang.String,java.lang.Object>
modifyResponseExpectations(java.util.Map<java.lang.String,java.lang.Object> request, java.util.Map<java.lang.String,java.lang.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.
-
-
-
Field Detail
-
adapter
protected ClientPOJOAdapter adapter
This adapter will perform the HTTP request and return the response in the expected format.
-
callAssertNothingThrown
protected boolean callAssertNothingThrown
-
-
Constructor Detail
-
ClientTestingAdapter
public ClientTestingAdapter()
-
ClientTestingAdapter
public ClientTestingAdapter(ClientPOJOAdapter adapter)
-
-
Method Detail
-
execute
public java.util.Map<java.lang.String,java.lang.Object> execute(java.lang.String defaultURI, java.util.Map<java.lang.String,java.lang.Object> request, TestingFrameworkRequestHandler requestHandler, java.util.Map<java.lang.String,java.lang.Object> responseExpectations) throws TestingFrameworkException
See the documentation for the same method inClientPOJOAdapter
. 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 theTestingFrameworkRequestHandler
so it can optionally call assertNothingThrown() before checking the response further. It is optional because the test framework will call it later.- Parameters:
defaultURI
- See execute method ofClientPOJOAdapter
.request
- See execute method ofClientPOJOAdapter
.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.- Returns:
- See return of the execute method of
ClientPOJOAdapter
. - Throws:
TestingFrameworkException
- in the case of a problem.
-
isRequestSupported
public boolean isRequestSupported(java.util.Map<java.lang.String,java.lang.Object> request)
See the documentation for the same method inClientPOJOAdapter
.
-
modifyRequest
public java.util.Map<java.lang.String,java.lang.Object> modifyRequest(java.util.Map<java.lang.String,java.lang.Object> request)
See the documentation for the same method inClientPOJOAdapter
.
-
modifyResponseExpectations
public java.util.Map<java.lang.String,java.lang.Object> modifyResponseExpectations(java.util.Map<java.lang.String,java.lang.Object> request, java.util.Map<java.lang.String,java.lang.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. After this method returns, theTestingFrameworkRequestHandler
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.- Parameters:
request
- for the format, see the documentation forClientPOJOAdapter
.responseExpectations
- for the format, see the documentation forClientPOJOAdapter
.- Returns:
- the same or modified response expectations.
-
getClientPOJOAdapter
public ClientPOJOAdapter getClientPOJOAdapter()
Getter for theClientPOJOAdapter
that is actually used to make the HTTP request.- Returns:
- the
ClientPOJOAdapter
.
-
-