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,
|
* this method, such an API should be used and the HTTP status code of the response returned,
|
||||||
* for example:
|
* for example:
|
||||||
*
|
*
|
||||||
|
* <pre>
|
||||||
* @Override
|
* @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()
|
* return response.statusCode()
|
||||||
*}*
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
* If there is no synchronous API available at all, for example as in Vert.X, a CompletableFuture
|
* 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:
|
* can be used to block on a result, for example:
|
||||||
*
|
*
|
||||||
|
* <pre>
|
||||||
* @Override
|
* @Override
|
||||||
* int sendRequest(Request request, String method, URI uri, Map<String, String> headers) {* CompletableFuture<Integer> future = new CompletableFuture<>(
|
* int sendRequest(Request request, String method, URI uri, Map<String, String> headers) {
|
||||||
* sendRequestWithCallback(request, method, uri, headers) {* future.complete(it.statusCode())
|
* CompletableFuture<Integer> future = new CompletableFuture<>(
|
||||||
*}* return future.get()
|
* 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)
|
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
|
* such as ApacheHttpClient's response handler callbacks. This method is used in tests to verify
|
||||||
* the context is propagated correctly to such callbacks.
|
* the context is propagated correctly to such callbacks.
|
||||||
*
|
*
|
||||||
|
* <pre>
|
||||||
* @Override
|
* @Override
|
||||||
* void sendRequestWithCallback(Request request, String method, URI uri, Map<String, String> headers, RequestResult requestResult) {* // Hypothetical client accepting a callback
|
* void sendRequestWithCallback(Request request, String method, URI uri, Map<String, String> headers, RequestResult requestResult) {
|
||||||
* client.executeAsync(request) {* void success(Response response) {* requestResult.complete(response.statusCode())
|
* // Hypothetical client accepting a callback
|
||||||
*}* void failure(Throwable throwable) {* requestResult.complete(throwable)
|
* client.executeAsync(request) {
|
||||||
*}*}*
|
* void success(Response response) {
|
||||||
|
* requestResult.complete(response.statusCode())
|
||||||
|
* }
|
||||||
|
* void failure(Throwable throwable) {
|
||||||
|
* requestResult.complete(throwable)
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*
|
||||||
* // Hypothetical client returning a CompletableFuture
|
* // Hypothetical client returning a CompletableFuture
|
||||||
* client.executeAsync(request).whenComplete { response, throwable ->
|
* client.executeAsync(request).whenComplete { response, throwable ->
|
||||||
* requestResult.complete({ response.statusCode() }, throwable)
|
* requestResult.complete({ response.statusCode() }, throwable)
|
||||||
*}*}*
|
* }
|
||||||
|
* }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
* If the client offers no APIs that accept callbacks, then this method should not be implemented
|
* 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.
|
* and instead, {@link #testCallback} should be implemented to return false.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue