From 965ad833c2652bd34f4259eb4235c6af9dc4ee68 Mon Sep 17 00:00:00 2001 From: Jakub Jedlicka Date: Thu, 1 Feb 2024 10:59:12 +0100 Subject: [PATCH] Remove REST client tests as they adapted and moved to rest-client-reactive --- .../src/main/resources/application.properties | 10 ---- .../reactive/BaseHttpAdvancedReactiveIT.java | 32 ---------- .../clients/HttpVersionClientService.java | 15 ----- .../HttpVersionClientServiceAsync.java | 17 ------ .../clients/RestClientServiceBuilder.java | 60 ------------------- .../src/main/resources/application.properties | 10 ---- .../ts/http/advanced/BaseHttpAdvancedIT.java | 32 ---------- .../clients/HttpVersionClientService.java | 15 ----- .../HttpVersionClientServiceAsync.java | 17 ------ .../clients/RestClientServiceBuilder.java | 60 ------------------- 10 files changed, 268 deletions(-) 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/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/resources/application.properties b/http/http-advanced-reactive/src/main/resources/application.properties index 1578c23de0..97ae89d8df 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} 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 57a6559d60..35bc98dd38 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 0e925c7d07..0000000000 --- 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 26a62d09de..0000000000 --- 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 ddadb9db87..0000000000 --- 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/resources/application.properties b/http/http-advanced/src/main/resources/application.properties index da1dfa3e3f..5b31abaa04 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} 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 35382df97c..5d72ff038b 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 99eda51797..0000000000 --- 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 2ace750af3..0000000000 --- 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 5d2034860b..0000000000 --- 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; - } -}