Correct formatting of HttpClientTest comments (#4654)
* Correct formatting of HttpClientTest comments * add <pre> tags
This commit is contained in:
parent
9e2839cb5a
commit
c57d4e00b6
|
@ -44,18 +44,27 @@ abstract class HttpClientTest<REQUEST> extends InstrumentationSpecification {
|
|||
* this method, such an API should be used and the HTTP status code of the response returned,
|
||||
* for example:
|
||||
*
|
||||
* <pre>
|
||||
* @Override
|
||||
* int sendRequest(Request request, String method, URI uri, Map<String, String headers = [:]) {* HttpResponse response = client.execute(request)
|
||||
* int sendRequest(Request request, String method, URI uri, Map<String, String headers = [:]) {
|
||||
* HttpResponse response = client.execute(request)
|
||||
* return response.statusCode()
|
||||
*}*
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* If there is no synchronous API available at all, for example as in Vert.X, a CompletableFuture
|
||||
* can be used to block on a result, for example:
|
||||
*
|
||||
* <pre>
|
||||
* @Override
|
||||
* int sendRequest(Request request, String method, URI uri, Map<String, String> headers) {* CompletableFuture<Integer> future = new CompletableFuture<>(
|
||||
* sendRequestWithCallback(request, method, uri, headers) {* future.complete(it.statusCode())
|
||||
*}* return future.get()
|
||||
*}
|
||||
* int sendRequest(Request request, String method, URI uri, Map<String, String> headers) {
|
||||
* CompletableFuture<Integer> future = new CompletableFuture<>(
|
||||
* sendRequestWithCallback(request, method, uri, headers) {
|
||||
* future.complete(it.statusCode())
|
||||
* }
|
||||
* return future.get()
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
abstract int sendRequest(REQUEST request, String method, URI uri, Map<String, String> headers)
|
||||
|
||||
|
@ -67,15 +76,26 @@ abstract class HttpClientTest<REQUEST> extends InstrumentationSpecification {
|
|||
* such as ApacheHttpClient's response handler callbacks. This method is used in tests to verify
|
||||
* the context is propagated correctly to such callbacks.
|
||||
*
|
||||
* <pre>
|
||||
* @Override
|
||||
* void sendRequestWithCallback(Request request, String method, URI uri, Map<String, String> headers, RequestResult requestResult) {* // Hypothetical client accepting a callback
|
||||
* client.executeAsync(request) {* void success(Response response) {* requestResult.complete(response.statusCode())
|
||||
*}* void failure(Throwable throwable) {* requestResult.complete(throwable)
|
||||
*}*}*
|
||||
* void sendRequestWithCallback(Request request, String method, URI uri, Map<String, String> headers, RequestResult requestResult) {
|
||||
* // Hypothetical client accepting a callback
|
||||
* client.executeAsync(request) {
|
||||
* void success(Response response) {
|
||||
* requestResult.complete(response.statusCode())
|
||||
* }
|
||||
* void failure(Throwable throwable) {
|
||||
* requestResult.complete(throwable)
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* // Hypothetical client returning a CompletableFuture
|
||||
* client.executeAsync(request).whenComplete { response, throwable ->
|
||||
* requestResult.complete({ response.statusCode() }, throwable)
|
||||
*}*}*
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* If the client offers no APIs that accept callbacks, then this method should not be implemented
|
||||
* and instead, {@link #testCallback} should be implemented to return false.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue