From fa479aa651057e5e487fda9939c05e9a189a2a54 Mon Sep 17 00:00:00 2001 From: Jakub Jedlicka Date: Thu, 1 Feb 2024 02:27:31 +0100 Subject: [PATCH 1/2] Add tests coverage for REST client reactive using HTTP2 and update README --- README.md | 6 + .../reactive/HttpVersionClient.java | 23 +++ .../HttpVersionClientWithConfigKey.java | 7 + .../HttpsVersionClientWithConfigKey.java | 7 + .../resources/HttpVersionBaseResource.java | 29 +++ .../resources/HttpVersionClientResource.java | 165 ++++++++++++++++++ .../src/main/resources/application.properties | 3 + .../src/main/resources/httpVersion.properties | 2 + .../reactive/HttpVersionAlpnIT.java | 59 +++++++ .../HttpVersionAlpnWithConfigKeyIT.java | 61 +++++++ .../restclient/reactive/HttpVersionIT.java | 95 ++++++++++ .../reactive/HttpVersionWithConfigKeyIT.java | 97 ++++++++++ 12 files changed, 554 insertions(+) create mode 100644 http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/HttpVersionClient.java create mode 100644 http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/HttpVersionClientWithConfigKey.java create mode 100644 http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/HttpsVersionClientWithConfigKey.java create mode 100644 http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/resources/HttpVersionBaseResource.java create mode 100644 http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/resources/HttpVersionClientResource.java create mode 100644 http/rest-client-reactive/src/main/resources/application.properties create mode 100644 http/rest-client-reactive/src/main/resources/httpVersion.properties create mode 100644 http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/HttpVersionAlpnIT.java create mode 100644 http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/HttpVersionAlpnWithConfigKeyIT.java create mode 100644 http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/HttpVersionIT.java create mode 100644 http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/HttpVersionWithConfigKeyIT.java diff --git a/README.md b/README.md index 07c4620ae..6634c6621 100644 --- a/README.md +++ b/README.md @@ -371,6 +371,12 @@ This module will setup a very minimal configuration (only `quarkus-resteasy`) an Reactive equivalent of the http/rest-client module. Exclusions: XML test. Reason: https://quarkus.io/blog/resteasy-reactive/#what-jax-rs-features-are-missing +Additionally, it's include endpoints to check usage of HTTP/2 using REST client over the http and https. +HTTP/2 REST client tests check sync and async response by: +- Two endpoint used by client +- Eight endpoints used for validation of client request + + ### `http/rest-client-reactive-vanilla` Verifies Rest Client usage, while no request are going only internally on the server. This module requires to not have any resteasy dependency, for an issue to be reproducible. diff --git a/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/HttpVersionClient.java b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/HttpVersionClient.java new file mode 100644 index 000000000..db1726713 --- /dev/null +++ b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/HttpVersionClient.java @@ -0,0 +1,23 @@ +package io.quarkus.ts.http.restclient.reactive; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.Response; + +import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; + +import io.smallrye.mutiny.Uni; + +@RegisterRestClient +@Path("/http-version") +public interface HttpVersionClient { + + @GET + @Path("synchronous") + Response getClientHttpVersion(@QueryParam("name") String name); + + @GET + @Path("asynchronous") + Uni getClientHttpVersionAsync(@QueryParam("name") String name); +} diff --git a/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/HttpVersionClientWithConfigKey.java b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/HttpVersionClientWithConfigKey.java new file mode 100644 index 000000000..5052c273c --- /dev/null +++ b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/HttpVersionClientWithConfigKey.java @@ -0,0 +1,7 @@ +package io.quarkus.ts.http.restclient.reactive; + +import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; + +@RegisterRestClient(configKey = "http-client-with-config-key") +public interface HttpVersionClientWithConfigKey extends HttpVersionClient { +} diff --git a/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/HttpsVersionClientWithConfigKey.java b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/HttpsVersionClientWithConfigKey.java new file mode 100644 index 000000000..6a947d26d --- /dev/null +++ b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/HttpsVersionClientWithConfigKey.java @@ -0,0 +1,7 @@ +package io.quarkus.ts.http.restclient.reactive; + +import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; + +@RegisterRestClient(configKey = "https-client-with-config-key") +public interface HttpsVersionClientWithConfigKey extends HttpVersionClient { +} diff --git a/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/resources/HttpVersionBaseResource.java b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/resources/HttpVersionBaseResource.java new file mode 100644 index 000000000..8088eabce --- /dev/null +++ b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/resources/HttpVersionBaseResource.java @@ -0,0 +1,29 @@ +package io.quarkus.ts.http.restclient.reactive.resources; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.QueryParam; +import jakarta.ws.rs.core.Response; + +import io.smallrye.mutiny.Uni; +import io.vertx.ext.web.RoutingContext; + +@ApplicationScoped +@Path("/http-version") +public class HttpVersionBaseResource { + + @GET + @Path("synchronous") + public Response sayHello(@QueryParam("name") String name, RoutingContext context) { + return Response.ok("Hello " + name + " and your using http protocol in version " + context.request().version().name()) + .build(); + } + + @GET + @Path("asynchronous") + public Uni sayHelloAsync(@QueryParam("name") String name, RoutingContext context) { + return Uni.createFrom().item(Response.ok( + "Hello " + name + " and your using http protocol in version " + context.request().version().name()).build()); + } +} diff --git a/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/resources/HttpVersionClientResource.java b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/resources/HttpVersionClientResource.java new file mode 100644 index 000000000..dd2b801bd --- /dev/null +++ b/http/rest-client-reactive/src/main/java/io/quarkus/ts/http/restclient/reactive/resources/HttpVersionClientResource.java @@ -0,0 +1,165 @@ +package io.quarkus.ts.http.restclient.reactive.resources; + +import java.net.MalformedURLException; +import java.net.URI; + +import jakarta.inject.Inject; +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.Response; + +import org.eclipse.microprofile.config.inject.ConfigProperty; +import org.eclipse.microprofile.rest.client.RestClientBuilder; +import org.eclipse.microprofile.rest.client.inject.RestClient; +import org.jboss.resteasy.reactive.client.impl.ClientResponseImpl; + +import io.quarkus.ts.http.restclient.reactive.HttpVersionClient; +import io.quarkus.ts.http.restclient.reactive.HttpVersionClientWithConfigKey; +import io.quarkus.ts.http.restclient.reactive.HttpsVersionClientWithConfigKey; +import io.smallrye.mutiny.Uni; +import io.vertx.core.http.HttpVersion; + +@Path("/http2") +public class HttpVersionClientResource { + + public static final String WRONG_HTTP_VERSION = "The HTTP version should be HTTP_2 but is "; + public static final String NAME = "Rest Client"; + private static final int TIMEOUT_SECONDS = 10; + private final URI baseUri; + private final URI securedBaseUri; + + @Inject + @RestClient + HttpVersionClientWithConfigKey httpVersionClientWithConfigKey; + + @Inject + @RestClient + HttpsVersionClientWithConfigKey httpsVersionClientWithConfigKey; + + public HttpVersionClientResource(@ConfigProperty(name = "quarkus.http.port") int httpPort, + @ConfigProperty(name = "quarkus.http.ssl-port") int sslHttpPort, + @ConfigProperty(name = "quarkus.http.host") String baseHost) { + this.baseUri = URI.create("http://" + baseHost + ":" + httpPort); + this.securedBaseUri = URI.create("https://" + baseHost + ":" + sslHttpPort); + } + + @GET + @Path("https-synchronous") + public Response httpsSynchronous() throws MalformedURLException { + return createSynchronousResponseForClient(securedBaseUri); + } + + @GET + @Path("http-synchronous") + public Response httpSynchronous() throws MalformedURLException { + return createSynchronousResponseForClient(baseUri); + } + + @GET + @Path("https-asynchronous") + public Uni httpsAsynchronous() throws MalformedURLException { + return createAsynchronousResponseForClient(securedBaseUri); + } + + @GET + @Path("http-asynchronous") + public Uni httpAsynchronous() throws MalformedURLException { + return createAsynchronousResponseForClient(baseUri); + } + + @GET + @Path("https-synchronous-for-client-with-key") + public Response httpsSynchronousForClientWithKey() { + Response response = httpsVersionClientWithConfigKey.getClientHttpVersion(NAME); + return checkHttpVersion(response); + } + + @GET + @Path("http-synchronous-for-client-with-key") + public Response httpSynchronousForClientWithKey() { + Response response = httpVersionClientWithConfigKey.getClientHttpVersion(NAME); + return checkHttpVersion(response); + } + + @GET + @Path("https-asynchronous-for-client-with-key") + public Uni httpsAsynchronousForClientWithKey() { + Uni response = httpsVersionClientWithConfigKey.getClientHttpVersionAsync(NAME); + + return checkHttpVersionAsync(response); + } + + @GET + @Path("http-asynchronous-for-client-with-key") + public Uni httpAsynchronousForClientWithKey() { + Uni response = httpVersionClientWithConfigKey.getClientHttpVersionAsync(NAME); + + return checkHttpVersionAsync(response); + } + + /** + * Create HttpVersionClient and make REST client synchronous request to `httpVersion/synchronous endpoint` + * Response from the client is checked if HTTP/2 was used + * + * @param uri base url for client to use + * @return Response contain original response from endpoint or error message containing actual http version used + */ + private Response createSynchronousResponseForClient(URI uri) throws MalformedURLException { + HttpVersionClient httpVersionClient = RestClientBuilder.newBuilder() + .baseUrl(uri.toURL()) + .build(HttpVersionClient.class); + + Response response = httpVersionClient.getClientHttpVersion(NAME); + return checkHttpVersion(response); + } + + /** + * Create HttpVersionClient and make REST client asynchronous request to `httpVersion/asynchronous endpoint` + * Response from the client is checked if HTTP/2 was used + * + * @param uri base url for client to use + * @return Response contain original response from endpoint or error message containing actual http version used + */ + private Uni createAsynchronousResponseForClient(URI uri) throws MalformedURLException { + HttpVersionClient httpVersionClient = RestClientBuilder.newBuilder() + .baseUrl(uri.toURL()) + .build(HttpVersionClient.class); + + Uni response = httpVersionClient.getClientHttpVersionAsync(NAME); + return checkHttpVersionAsync(response); + } + + /** + * Check response from the REST client if HTTP/2 is used, and it's body contain HTTP/2 version string + * + * @param response response of REST client + * @return Response contains original response from endpoint or error message containing actual http version used + */ + private Response checkHttpVersion(Response response) { + String httpVersion = ((ClientResponseImpl) response).getHttpVersion(); + response.bufferEntity(); + String responseText = response.readEntity(String.class); + if (httpVersion.equals(HttpVersion.HTTP_2.name()) && responseText.contains(HttpVersion.HTTP_2.name())) { + return response; + } + + return Response.ok(WRONG_HTTP_VERSION + httpVersion).build(); + } + + /** + * Check response from the REST client if HTTP/2 is used, and it's body contain HTTP/2 version string + * + * @param response uni response of REST client + * @return Uni contains original response from endpoint or error message containing actual http version used + */ + private Uni checkHttpVersionAsync(Uni response) { + return response.onItem().transformToUni(r -> { + String httpVersion = ((ClientResponseImpl) r).getHttpVersion(); + String responseText = r.readEntity(String.class); + if (httpVersion.equals(HttpVersion.HTTP_2.name()) && responseText.contains(HttpVersion.HTTP_2.name())) { + return response; + } + return Uni.createFrom().item(Response.ok(WRONG_HTTP_VERSION + httpVersion).build()); + }); + } +} diff --git a/http/rest-client-reactive/src/main/resources/application.properties b/http/rest-client-reactive/src/main/resources/application.properties new file mode 100644 index 000000000..4adf05639 --- /dev/null +++ b/http/rest-client-reactive/src/main/resources/application.properties @@ -0,0 +1,3 @@ +quarkus.tls.trust-all=true +quarkus.http.ssl.certificate.key-store-file=META-INF/keystore.jks +quarkus.http.ssl.certificate.key-store-password=password \ No newline at end of file diff --git a/http/rest-client-reactive/src/main/resources/httpVersion.properties b/http/rest-client-reactive/src/main/resources/httpVersion.properties new file mode 100644 index 000000000..a31c4edd1 --- /dev/null +++ b/http/rest-client-reactive/src/main/resources/httpVersion.properties @@ -0,0 +1,2 @@ +quarkus.rest-client.http-client-with-config-key.url=http://${quarkus.http.host}:${quarkus.http.port} +quarkus.rest-client.https-client-with-config-key.url=https://${quarkus.http.host}:${quarkus.http.ssl-port} \ No newline at end of file diff --git a/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/HttpVersionAlpnIT.java b/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/HttpVersionAlpnIT.java new file mode 100644 index 000000000..38bb99e9f --- /dev/null +++ b/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/HttpVersionAlpnIT.java @@ -0,0 +1,59 @@ +package io.quarkus.ts.http.restclient.reactive; + +import static io.quarkus.ts.http.restclient.reactive.resources.HttpVersionClientResource.NAME; +import static org.hamcrest.Matchers.containsString; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.bootstrap.RestService; +import io.quarkus.test.scenarios.QuarkusScenario; +import io.quarkus.test.services.QuarkusApplication; +import io.vertx.core.http.HttpVersion; + +@QuarkusScenario +public class HttpVersionAlpnIT { + + private static final String SUCCESSFUL_RESPONSE_STRING = "Hello " + NAME + " and your using http protocol in version " + + HttpVersion.HTTP_2.name(); + + @QuarkusApplication(ssl = true) + static RestService app = new RestService() + .withProperties("httpVersion.properties") + .withProperty("quarkus.rest-client.alpn", "true"); + + @Test + public void testSyncResponseWithSingleClientOnGlobalClient() { + app.given() + .get("/http2/https-synchronous") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } + + @Test + public void testAsyncResponseWithSingleClientOnGlobalClient() { + app.given() + .get("/http2/https-asynchronous") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } + + @Test + public void testSyncResponseWithSingleClientOnSingleClient() { + app.given() + .get("/http2/https-synchronous-for-client-with-key") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } + + @Test + public void testAsyncResponseWithSingleClientOnSingleClient() { + app.given() + .get("/http2/https-asynchronous-for-client-with-key") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } +} diff --git a/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/HttpVersionAlpnWithConfigKeyIT.java b/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/HttpVersionAlpnWithConfigKeyIT.java new file mode 100644 index 000000000..19f4064bf --- /dev/null +++ b/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/HttpVersionAlpnWithConfigKeyIT.java @@ -0,0 +1,61 @@ +package io.quarkus.ts.http.restclient.reactive; + +import static io.quarkus.ts.http.restclient.reactive.resources.HttpVersionClientResource.NAME; +import static io.quarkus.ts.http.restclient.reactive.resources.HttpVersionClientResource.WRONG_HTTP_VERSION; +import static org.hamcrest.Matchers.containsString; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.bootstrap.RestService; +import io.quarkus.test.scenarios.QuarkusScenario; +import io.quarkus.test.services.QuarkusApplication; +import io.vertx.core.http.HttpVersion; + +@QuarkusScenario +public class HttpVersionAlpnWithConfigKeyIT { + + private static final String SUCCESSFUL_RESPONSE_STRING = "Hello " + NAME + " and your using http protocol in version " + + HttpVersion.HTTP_2.name(); + + @QuarkusApplication(ssl = true) + static RestService app = new RestService() + .withProperties("httpVersion.properties") + .withProperty("quarkus.rest-client.http-client-with-config-key.alpn", "true") + .withProperty("quarkus.rest-client.https-client-with-config-key.alpn", "true"); + + @Test + public void testSyncResponseWithSingleClientOnGlobalClient() { + app.given() + .get("/http2/https-synchronous") + .then() + .statusCode(200) + .body(containsString(WRONG_HTTP_VERSION)); + } + + @Test + public void testAsyncResponseWithSingleClientOnGlobalClient() { + app.given() + .get("/http2/https-asynchronous") + .then() + .statusCode(200) + .body(containsString(WRONG_HTTP_VERSION)); + } + + @Test + public void testSyncResponseWithSingleClientOnSingleClient() { + app.given() + .get("/http2/https-synchronous-for-client-with-key") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } + + @Test + public void testAsyncResponseWithSingleClientOnSingleClient() { + app.given() + .get("/http2/https-asynchronous-for-client-with-key") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } +} diff --git a/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/HttpVersionIT.java b/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/HttpVersionIT.java new file mode 100644 index 000000000..ee70458c6 --- /dev/null +++ b/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/HttpVersionIT.java @@ -0,0 +1,95 @@ +package io.quarkus.ts.http.restclient.reactive; + +import static io.quarkus.ts.http.restclient.reactive.resources.HttpVersionClientResource.NAME; +import static org.hamcrest.Matchers.containsString; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.bootstrap.RestService; +import io.quarkus.test.scenarios.QuarkusScenario; +import io.quarkus.test.services.QuarkusApplication; +import io.vertx.core.http.HttpVersion; + +@QuarkusScenario +public class HttpVersionIT { + + private static final String SUCCESSFUL_RESPONSE_STRING = "Hello " + NAME + " and your using http protocol in version " + + HttpVersion.HTTP_2.name(); + + @QuarkusApplication(ssl = true) + static RestService app = new RestService() + .withProperties("httpVersion.properties") + .withProperty("quarkus.rest-client.http2", "true"); + + @Test + public void testHttpSyncResponseWithSingleClientOnGlobalClient() { + app.given() + .get("/http2/http-synchronous") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } + + @Test + public void testHttpsSyncResponseWithSingleClientOnGlobalClient() { + app.given() + .get("/http2/https-synchronous") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } + + @Test + public void testHttpsAsyncResponseWithSingleClientOnGlobalClient() { + app.given() + .get("/http2/http-asynchronous") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } + + @Test + public void testHttpAsyncResponseWithSingleClientOnGlobalClient() { + app.given() + .get("/http2/https-asynchronous") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } + + @Test + public void testHttpSyncResponseWithSingleClientOnSingleClient() { + app.given() + .get("/http2/http-synchronous-for-client-with-key") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } + + @Test + public void testHttpsSyncResponseWithSingleClientOnSingleClient() { + app.given() + .get("/http2/https-synchronous-for-client-with-key") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } + + @Test + public void testHttpAsyncResponseWithSingleClientOnSingleClient() { + app.given() + .get("/http2/http-asynchronous-for-client-with-key") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } + + @Test + public void testHttpsAsyncResponseWithSingleClientOnSingleClient() { + app.given() + .get("/http2/https-asynchronous-for-client-with-key") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } +} diff --git a/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/HttpVersionWithConfigKeyIT.java b/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/HttpVersionWithConfigKeyIT.java new file mode 100644 index 000000000..e147f290e --- /dev/null +++ b/http/rest-client-reactive/src/test/java/io/quarkus/ts/http/restclient/reactive/HttpVersionWithConfigKeyIT.java @@ -0,0 +1,97 @@ +package io.quarkus.ts.http.restclient.reactive; + +import static io.quarkus.ts.http.restclient.reactive.resources.HttpVersionClientResource.NAME; +import static io.quarkus.ts.http.restclient.reactive.resources.HttpVersionClientResource.WRONG_HTTP_VERSION; +import static org.hamcrest.Matchers.containsString; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.bootstrap.RestService; +import io.quarkus.test.scenarios.QuarkusScenario; +import io.quarkus.test.services.QuarkusApplication; +import io.vertx.core.http.HttpVersion; + +@QuarkusScenario +public class HttpVersionWithConfigKeyIT { + + private static final String SUCCESSFUL_RESPONSE_STRING = "Hello " + NAME + " and your using http protocol in version " + + HttpVersion.HTTP_2.name(); + + @QuarkusApplication(ssl = true) + static RestService app = new RestService() + .withProperties("httpVersion.properties") + .withProperty("quarkus.rest-client.http-client-with-config-key.http2", "true") + .withProperty("quarkus.rest-client.https-client-with-config-key.http2", "true"); + + @Test + public void testHttpSyncResponseWithSingleClientOnGlobalClient() { + app.given() + .get("/http2/http-synchronous") + .then() + .statusCode(200) + .body(containsString(WRONG_HTTP_VERSION)); + } + + @Test + public void testHttpsSyncResponseWithSingleClientOnGlobalClient() { + app.given() + .get("/http2/https-synchronous") + .then() + .statusCode(200) + .body(containsString(WRONG_HTTP_VERSION)); + } + + @Test + public void testHttpsAsyncResponseWithSingleClientOnGlobalClient() { + app.given() + .get("/http2/http-asynchronous") + .then() + .statusCode(200) + .body(containsString(WRONG_HTTP_VERSION)); + } + + @Test + public void testHttpAsyncResponseWithSingleClientOnGlobalClient() { + app.given() + .get("/http2/https-asynchronous") + .then() + .statusCode(200) + .body(containsString(WRONG_HTTP_VERSION)); + } + + @Test + public void testHttpSyncResponseWithSingleClientOnSingleClient() { + app.given() + .get("/http2/http-synchronous-for-client-with-key") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } + + @Test + public void testHttpsSyncResponseWithSingleClientOnSingleClient() { + app.given() + .get("/http2/https-synchronous-for-client-with-key") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } + + @Test + public void testHttpAsyncResponseWithSingleClientOnSingleClient() { + app.given() + .get("/http2/http-asynchronous-for-client-with-key") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } + + @Test + public void testHttpsAsyncResponseWithSingleClientOnSingleClient() { + app.given() + .get("/http2/https-asynchronous-for-client-with-key") + .then() + .statusCode(200) + .body(containsString(SUCCESSFUL_RESPONSE_STRING)); + } +} From de3936d4d56a4901fe3824f9274c7fe583cae350 Mon Sep 17 00:00:00 2001 From: Jakub Jedlicka Date: Thu, 1 Feb 2024 10:59:12 +0100 Subject: [PATCH 2/2] Remove REST client tests as they adapted and moved to rest-client-reactive --- .../reactive/HttpClientVersionResource.java | 20 ------- .../src/main/resources/application.properties | 12 ---- .../reactive/BaseHttpAdvancedReactiveIT.java | 32 ---------- .../clients/HttpVersionClientService.java | 15 ----- .../HttpVersionClientServiceAsync.java | 17 ------ .../clients/RestClientServiceBuilder.java | 60 ------------------- .../advanced/HttpClientVersionResource.java | 20 ------- .../src/main/resources/application.properties | 12 ---- .../ts/http/advanced/BaseHttpAdvancedIT.java | 32 ---------- .../clients/HttpVersionClientService.java | 15 ----- .../HttpVersionClientServiceAsync.java | 17 ------ .../clients/RestClientServiceBuilder.java | 60 ------------------- 12 files changed, 312 deletions(-) delete mode 100644 http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/HttpClientVersionResource.java delete mode 100644 http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/clients/HttpVersionClientService.java delete mode 100644 http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/clients/HttpVersionClientServiceAsync.java delete mode 100644 http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/clients/RestClientServiceBuilder.java delete mode 100644 http/http-advanced/src/main/java/io/quarkus/ts/http/advanced/HttpClientVersionResource.java delete mode 100644 http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/clients/HttpVersionClientService.java delete mode 100644 http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/clients/HttpVersionClientServiceAsync.java delete mode 100644 http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/clients/RestClientServiceBuilder.java diff --git a/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/HttpClientVersionResource.java b/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/HttpClientVersionResource.java deleted file mode 100644 index 91f64ab4c..000000000 --- a/http/http-advanced-reactive/src/main/java/io/quarkus/ts/http/advanced/reactive/HttpClientVersionResource.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.quarkus.ts.http.advanced.reactive; - -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.ws.rs.core.Response; - -import io.quarkus.vertx.web.Route; -import io.vertx.ext.web.RoutingContext; - -@ApplicationScoped -public class HttpClientVersionResource { - - protected static final String HTTP_VERSION = "x-http-version"; - - @Route(methods = Route.HttpMethod.GET, path = "/httpVersion") - public void clientHttpVersion(RoutingContext rc) { - String httpClientVersion = rc.request().version().name(); - rc.response().headers().add(HTTP_VERSION, httpClientVersion); - rc.response().setStatusCode(Response.Status.OK.getStatusCode()).end(); - } -} diff --git a/http/http-advanced-reactive/src/main/resources/application.properties b/http/http-advanced-reactive/src/main/resources/application.properties index 1578c23de..484471f6c 100644 --- a/http/http-advanced-reactive/src/main/resources/application.properties +++ b/http/http-advanced-reactive/src/main/resources/application.properties @@ -13,16 +13,6 @@ HealthClientService/mp-rest/url=http://localhost:${quarkus.http.port} HealthClientService/mp-rest/scope=jakarta.inject.Singleton # FollowRedirect not supported QUARKUS-781 # HealthClientService/mp-rest/followRedirects=true -HttpVersionClientService/mp-rest/url=https://localhost:${quarkus.http.ssl-port} -HttpVersionClientService/mp-rest/scope=jakarta.inject.Singleton -HttpVersionClientService/mp-rest/hostnameVerifier=io.quarkus.restclient.NoopHostnameVerifier -HttpVersionClientService/mp-rest/trustStore=classpath:/META-INF/resources/server.truststore -HttpVersionClientService/mp-rest/trustStorePassword=password -HttpVersionClientServiceAsync/mp-rest/url=https://localhost:${quarkus.http.ssl-port} -HttpVersionClientServiceAsync/mp-rest/scope=jakarta.inject.Singleton -HttpVersionClientServiceAsync/mp-rest/hostnameVerifier=io.quarkus.restclient.NoopHostnameVerifier -HttpVersionClientServiceAsync/mp-rest/trustStore=classpath:/META-INF/resources/server.truststore -HttpVersionClientServiceAsync/mp-rest/trustStorePassword=password # gRPC quarkus.grpc.clients.hello.host=localhost quarkus.grpc.clients.hello.port=${quarkus.http.port} @@ -43,8 +33,6 @@ quarkus.keycloak.policy-enforcer.paths.swagger-ui.path=/api/swagger-ui/* quarkus.keycloak.policy-enforcer.paths.swagger-ui.enforcement-mode=DISABLED quarkus.keycloak.policy-enforcer.paths.health.path=/api/health/* quarkus.keycloak.policy-enforcer.paths.health.enforcement-mode=DISABLED -quarkus.keycloak.policy-enforcer.paths.version.path=/api/httpVersion/* -quarkus.keycloak.policy-enforcer.paths.version.enforcement-mode=DISABLED # Application endpoints quarkus.keycloak.policy-enforcer.paths.99-bottles-of-beer.path=/api/99-bottles-of-beer/* quarkus.keycloak.policy-enforcer.paths.99-bottles-of-beer.enforcement-mode=DISABLED diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/BaseHttpAdvancedReactiveIT.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/BaseHttpAdvancedReactiveIT.java index 57a6559d6..35bc98dd3 100644 --- a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/BaseHttpAdvancedReactiveIT.java +++ b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/BaseHttpAdvancedReactiveIT.java @@ -53,7 +53,6 @@ import org.apache.http.HttpStatus; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -74,9 +73,6 @@ import io.quarkus.test.bootstrap.RestService; import io.quarkus.test.scenarios.annotations.DisabledOnNative; import io.quarkus.test.scenarios.annotations.EnabledOnQuarkusVersion; -import io.quarkus.ts.http.advanced.reactive.clients.HttpVersionClientService; -import io.quarkus.ts.http.advanced.reactive.clients.HttpVersionClientServiceAsync; -import io.quarkus.ts.http.advanced.reactive.clients.RestClientServiceBuilder; import io.restassured.http.Header; import io.restassured.response.ValidatableResponse; import io.smallrye.mutiny.Uni; @@ -96,7 +92,6 @@ public abstract class BaseHttpAdvancedReactiveIT { private static final int RETRY = 3; private static final String PASSWORD = "password"; private static final String KEY_STORE_PATH = "META-INF/resources/server.keystore"; - private static final int ASSERT_TIMEOUT_SECONDS = 10; private static final String UTF_8_CHARSET = ";charset=UTF-8"; private static final String CONTENT = "content"; @@ -235,33 +230,6 @@ public void http2Server() throws InterruptedException, URISyntaxException { assertThat(done.getCount(), equalTo(0L)); } - @Test - @DisplayName("Http/2 Client Sync test") - @Disabled("blocked by: https://issues.redhat.com/browse/QUARKUS-658") - public void http2ClientSync() throws Exception { - HttpVersionClientService versionHttpClient = new RestClientServiceBuilder( - getAppEndpoint()).withHostVerified(true).withPassword(PASSWORD).withKeyStorePath(KEY_STORE_PATH) - .build(HttpVersionClientService.class); - - Response resp = versionHttpClient.getClientHttpVersion(); - assertEquals(SC_OK, resp.getStatus()); - assertEquals(HttpVersion.HTTP_2.name(), resp.getHeaderString(HttpClientVersionResource.HTTP_VERSION)); - } - - @Test - @DisplayName("Http/2 Client Async test") - @Disabled("blocked by: https://issues.redhat.com/browse/QUARKUS-658") - public void http2ClientAsync() throws Exception { - HttpVersionClientServiceAsync clientServiceAsync = new RestClientServiceBuilder( - getAppEndpoint()).withHostVerified(true).withPassword(PASSWORD).withKeyStorePath(KEY_STORE_PATH) - .build(HttpVersionClientServiceAsync.class); - - Response resp = clientServiceAsync.getClientHttpVersion().await().atMost(Duration.ofSeconds(ASSERT_TIMEOUT_SECONDS)); - - assertEquals(SC_OK, resp.getStatus()); - assertEquals(HttpVersion.HTTP_2.name(), resp.getHeaderString(HttpClientVersionResource.HTTP_VERSION)); - } - @Test @DisplayName("Non-application endpoint move to /q/") @EnabledOnQuarkusVersion(version = "1\\..*", reason = "Redirection is no longer supported in 2.x") diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/clients/HttpVersionClientService.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/clients/HttpVersionClientService.java deleted file mode 100644 index 0e925c7d0..000000000 --- a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/clients/HttpVersionClientService.java +++ /dev/null @@ -1,15 +0,0 @@ -package io.quarkus.ts.http.advanced.reactive.clients; - -import jakarta.ws.rs.GET; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.core.Response; - -import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; - -@RegisterRestClient -public interface HttpVersionClientService { - - @GET - @Path("/httpVersion") - Response getClientHttpVersion(); -} diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/clients/HttpVersionClientServiceAsync.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/clients/HttpVersionClientServiceAsync.java deleted file mode 100644 index 26a62d09d..000000000 --- a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/clients/HttpVersionClientServiceAsync.java +++ /dev/null @@ -1,17 +0,0 @@ -package io.quarkus.ts.http.advanced.reactive.clients; - -import jakarta.ws.rs.GET; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.core.Response; - -import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; - -import io.smallrye.mutiny.Uni; - -@RegisterRestClient -public interface HttpVersionClientServiceAsync { - - @GET - @Path("/httpVersion") - Uni getClientHttpVersion(); -} diff --git a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/clients/RestClientServiceBuilder.java b/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/clients/RestClientServiceBuilder.java deleted file mode 100644 index ddadb9db8..000000000 --- a/http/http-advanced-reactive/src/test/java/io/quarkus/ts/http/advanced/reactive/clients/RestClientServiceBuilder.java +++ /dev/null @@ -1,60 +0,0 @@ -package io.quarkus.ts.http.advanced.reactive.clients; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.net.URI; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.CertificateException; - -import org.apache.commons.lang3.StringUtils; -import org.eclipse.microprofile.rest.client.RestClientBuilder; - -public class RestClientServiceBuilder { - - protected String uri; - protected String password; - protected boolean hostVerified; - protected String keyStorePath; - - public RestClientServiceBuilder(String uri) { - this.uri = uri; - } - - public RestClientServiceBuilder withPassword(String password) { - this.password = password; - return this; - } - - public RestClientServiceBuilder withHostVerified(Boolean verified) { - this.hostVerified = verified; - return this; - } - - public RestClientServiceBuilder withKeyStorePath(String keyStorePath) { - this.keyStorePath = keyStorePath; - return this; - } - - public T build(Class clazz) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException { - RestClientBuilder builder = RestClientBuilder.newBuilder().baseUri(URI.create(this.uri)); - builder.hostnameVerifier((s, sslSession) -> this.hostVerified); - if (!StringUtils.isEmpty(this.keyStorePath)) { - builder.trustStore(loadKeystore()); - } - - return builder.build(clazz); - } - - protected KeyStore loadKeystore() throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException { - KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); - ClassLoader classLoader = getClass().getClassLoader(); - File keyStore = new File(classLoader.getResource(this.keyStorePath).getFile()); - try (FileInputStream fis = new FileInputStream(keyStore)) { - ks.load(fis, this.password.toCharArray()); - } - return ks; - } -} diff --git a/http/http-advanced/src/main/java/io/quarkus/ts/http/advanced/HttpClientVersionResource.java b/http/http-advanced/src/main/java/io/quarkus/ts/http/advanced/HttpClientVersionResource.java deleted file mode 100644 index 5b93b1a74..000000000 --- a/http/http-advanced/src/main/java/io/quarkus/ts/http/advanced/HttpClientVersionResource.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.quarkus.ts.http.advanced; - -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.ws.rs.core.Response; - -import io.quarkus.vertx.web.Route; -import io.vertx.ext.web.RoutingContext; - -@ApplicationScoped -public class HttpClientVersionResource { - - protected static final String HTTP_VERSION = "x-http-version"; - - @Route(methods = Route.HttpMethod.GET, path = "/httpVersion") - public void clientHttpVersion(RoutingContext rc) { - String httpClientVersion = rc.request().version().name(); - rc.response().headers().add(HTTP_VERSION, httpClientVersion); - rc.response().setStatusCode(Response.Status.OK.getStatusCode()).end(); - } -} diff --git a/http/http-advanced/src/main/resources/application.properties b/http/http-advanced/src/main/resources/application.properties index da1dfa3e3..a3dab67ae 100644 --- a/http/http-advanced/src/main/resources/application.properties +++ b/http/http-advanced/src/main/resources/application.properties @@ -13,16 +13,6 @@ HealthClientService/mp-rest/url=http://localhost:${quarkus.http.port} HealthClientService/mp-rest/scope=jakarta.inject.Singleton # FollowRedirect not supported QUARKUS-781 # HealthClientService/mp-rest/followRedirects=true -HttpVersionClientService/mp-rest/url=https://localhost:${quarkus.http.ssl-port} -HttpVersionClientService/mp-rest/scope=jakarta.inject.Singleton -HttpVersionClientService/mp-rest/hostnameVerifier=io.quarkus.restclient.NoopHostnameVerifier -HttpVersionClientService/mp-rest/trustStore=classpath:/META-INF/resources/server.truststore -HttpVersionClientService/mp-rest/trustStorePassword=password -HttpVersionClientServiceAsync/mp-rest/url=https://localhost:${quarkus.http.ssl-port} -HttpVersionClientServiceAsync/mp-rest/scope=jakarta.inject.Singleton -HttpVersionClientServiceAsync/mp-rest/hostnameVerifier=io.quarkus.restclient.NoopHostnameVerifier -HttpVersionClientServiceAsync/mp-rest/trustStore=classpath:/META-INF/resources/server.truststore -HttpVersionClientServiceAsync/mp-rest/trustStorePassword=password # gRPC quarkus.grpc.clients.hello.host=localhost quarkus.grpc.clients.hello.port=${quarkus.http.port} @@ -40,8 +30,6 @@ quarkus.keycloak.policy-enforcer.paths.swagger-ui.path=/api/swagger-ui/* quarkus.keycloak.policy-enforcer.paths.swagger-ui.enforcement-mode=DISABLED quarkus.keycloak.policy-enforcer.paths.health.path=/api/health/* quarkus.keycloak.policy-enforcer.paths.health.enforcement-mode=DISABLED -quarkus.keycloak.policy-enforcer.paths.version.path=/api/httpVersion/* -quarkus.keycloak.policy-enforcer.paths.version.enforcement-mode=DISABLED # Application endpoints quarkus.keycloak.policy-enforcer.paths.hello.path=/api/hello/* quarkus.keycloak.policy-enforcer.paths.hello.enforcement-mode=DISABLED diff --git a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/BaseHttpAdvancedIT.java b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/BaseHttpAdvancedIT.java index 35382df97..5d72ff038 100644 --- a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/BaseHttpAdvancedIT.java +++ b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/BaseHttpAdvancedIT.java @@ -25,7 +25,6 @@ import org.apache.http.HttpStatus; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -41,9 +40,6 @@ import io.quarkus.test.scenarios.OpenShiftScenario; import io.quarkus.test.scenarios.QuarkusScenario; import io.quarkus.test.scenarios.annotations.EnabledOnQuarkusVersion; -import io.quarkus.ts.http.advanced.clients.HttpVersionClientService; -import io.quarkus.ts.http.advanced.clients.HttpVersionClientServiceAsync; -import io.quarkus.ts.http.advanced.clients.RestClientServiceBuilder; import io.smallrye.mutiny.Uni; import io.vertx.core.http.HttpVersion; import io.vertx.core.json.JsonObject; @@ -60,7 +56,6 @@ public abstract class BaseHttpAdvancedIT { private static final int RETRY = 3; private static final String PASSWORD = "password"; private static final String KEY_STORE_PATH = "META-INF/resources/server.keystore"; - private static final int ASSERT_TIMEOUT_SECONDS = 10; private static final String SSE_ERROR_MESSAGE = "java.lang.ClassNotFoundException: Provider for jakarta.ws.rs.sse.SseEventSource.Builder cannot be found"; protected abstract RestService getApp(); @@ -151,33 +146,6 @@ public void http2Server() throws InterruptedException, URISyntaxException { assertThat(done.getCount(), equalTo(0L)); } - @Test - @DisplayName("Http/2 Client Sync test") - @Disabled("blocked by: https://issues.redhat.com/browse/QUARKUS-658") - public void http2ClientSync() throws Exception { - HttpVersionClientService versionHttpClient = new RestClientServiceBuilder( - getAppEndpoint()).withHostVerified(true).withPassword(PASSWORD).withKeyStorePath(KEY_STORE_PATH) - .build(HttpVersionClientService.class); - - Response resp = versionHttpClient.getClientHttpVersion(); - assertEquals(HttpStatus.SC_OK, resp.getStatus()); - assertEquals(HttpVersion.HTTP_2.name(), resp.getHeaderString(HttpClientVersionResource.HTTP_VERSION)); - } - - @Test - @DisplayName("Http/2 Client Async test") - @Disabled("blocked by: https://issues.redhat.com/browse/QUARKUS-658") - public void http2ClientAsync() throws Exception { - HttpVersionClientServiceAsync clientServiceAsync = new RestClientServiceBuilder( - getAppEndpoint()).withHostVerified(true).withPassword(PASSWORD).withKeyStorePath(KEY_STORE_PATH) - .build(HttpVersionClientServiceAsync.class); - - Response resp = clientServiceAsync.getClientHttpVersion().await().atMost(Duration.ofSeconds(ASSERT_TIMEOUT_SECONDS)); - - assertEquals(HttpStatus.SC_OK, resp.getStatus()); - assertEquals(HttpVersion.HTTP_2.name(), resp.getHeaderString(HttpClientVersionResource.HTTP_VERSION)); - } - @Test @DisplayName("Non-application endpoint move to /q/") @EnabledOnQuarkusVersion(version = "1\\..*", reason = "Redirection is no longer supported in 2.x") diff --git a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/clients/HttpVersionClientService.java b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/clients/HttpVersionClientService.java deleted file mode 100644 index 99eda5179..000000000 --- a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/clients/HttpVersionClientService.java +++ /dev/null @@ -1,15 +0,0 @@ -package io.quarkus.ts.http.advanced.clients; - -import jakarta.ws.rs.GET; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.core.Response; - -import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; - -@RegisterRestClient -public interface HttpVersionClientService { - - @GET - @Path("/httpVersion") - Response getClientHttpVersion(); -} diff --git a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/clients/HttpVersionClientServiceAsync.java b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/clients/HttpVersionClientServiceAsync.java deleted file mode 100644 index 2ace750af..000000000 --- a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/clients/HttpVersionClientServiceAsync.java +++ /dev/null @@ -1,17 +0,0 @@ -package io.quarkus.ts.http.advanced.clients; - -import jakarta.ws.rs.GET; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.core.Response; - -import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; - -import io.smallrye.mutiny.Uni; - -@RegisterRestClient -public interface HttpVersionClientServiceAsync { - - @GET - @Path("/httpVersion") - Uni getClientHttpVersion(); -} diff --git a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/clients/RestClientServiceBuilder.java b/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/clients/RestClientServiceBuilder.java deleted file mode 100644 index 5d2034860..000000000 --- a/http/http-advanced/src/test/java/io/quarkus/ts/http/advanced/clients/RestClientServiceBuilder.java +++ /dev/null @@ -1,60 +0,0 @@ -package io.quarkus.ts.http.advanced.clients; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.net.URI; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.CertificateException; - -import org.apache.commons.lang3.StringUtils; -import org.eclipse.microprofile.rest.client.RestClientBuilder; - -public class RestClientServiceBuilder { - - protected String uri; - protected String password; - protected boolean hostVerified; - protected String keyStorePath; - - public RestClientServiceBuilder(String uri) { - this.uri = uri; - } - - public RestClientServiceBuilder withPassword(String password) { - this.password = password; - return this; - } - - public RestClientServiceBuilder withHostVerified(Boolean verified) { - this.hostVerified = verified; - return this; - } - - public RestClientServiceBuilder withKeyStorePath(String keyStorePath) { - this.keyStorePath = keyStorePath; - return this; - } - - public T build(Class clazz) throws CertificateException, NoSuchAlgorithmException, KeyStoreException, IOException { - RestClientBuilder builder = RestClientBuilder.newBuilder().baseUri(URI.create(this.uri)); - builder.hostnameVerifier((s, sslSession) -> this.hostVerified); - if (!StringUtils.isEmpty(this.keyStorePath)) { - builder.trustStore(loadKeystore()); - } - - return builder.build(clazz); - } - - protected KeyStore loadKeystore() throws KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException { - KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); - ClassLoader classLoader = getClass().getClassLoader(); - File keyStore = new File(classLoader.getResource(this.keyStorePath).getFile()); - try (FileInputStream fis = new FileInputStream(keyStore)) { - ks.load(fis, this.password.toCharArray()); - } - return ks; - } -}