Class TestingFrameworkRequestHandler
java.lang.Object
org.apache.hc.core5.testing.framework.TestingFrameworkRequestHandler
- All Implemented Interfaces:
HttpRequestHandler
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAfter the handler returns the response, any exception or failed assertion will be in the member called "thrown".voidhandle(ClassicHttpRequest request, ClassicHttpResponse response, HttpContext context) Checks the HTTP request against the requestExpectations that it was previously given.voidsetDesiredResponse(Map<String, Object> desiredResponse) Sets the desired response.voidsetRequestExpectations(Map<String, Object> requestExpectations) Sets the request expectations.
-
Field Details
-
thrown
-
requestExpectations
-
desiredResponse
-
-
Constructor Details
-
TestingFrameworkRequestHandler
public TestingFrameworkRequestHandler()
-
-
Method Details
-
setRequestExpectations
public void setRequestExpectations(Map<String, Object> requestExpectations) throws TestingFrameworkExceptionSets the request expectations.- Parameters:
requestExpectations- the expected values of the request.- Throws:
TestingFrameworkException
-
setDesiredResponse
Sets the desired response. The handler will return a response that matches this.- Parameters:
desiredResponse- the desired response.- Throws:
TestingFrameworkException
-
assertNothingThrown
After the handler returns the response, any exception or failed assertion will be in the member called "thrown". A testing framework can later call this method which will rethrow the exception that was thrown before.- Throws:
TestingFrameworkException
-
handle
public void handle(ClassicHttpRequest request, ClassicHttpResponse response, HttpContext context) throws HttpException, IOException Checks the HTTP request against the requestExpectations that it was previously given. If there is a mismatch, an exception will be saved in the "thrown" member.
Also, a response will be returned that matches the desiredResponse.
- Specified by:
handlein interfaceHttpRequestHandler- Parameters:
request- the HTTP request.response- the HTTP response.context- the HTTP execution context.- Throws:
HttpException- in case of HTTP protocol violation or a processing problem.IOException- in case of an I/O error.
-