You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2022/10/21 20:15:08 UTC
[camel-quarkus] branch main updated: Use official azure-core-http-vertx client in Azure extensions
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 465d146334 Use official azure-core-http-vertx client in Azure extensions
465d146334 is described below
commit 465d1463344ba122d00855b11d72e501480b2cac
Author: James Netherton <ja...@gmail.com>
AuthorDate: Fri Oct 21 14:01:16 2022 +0100
Use official azure-core-http-vertx client in Azure extensions
Fixes #4180
---
.../deployment/pom.xml | 59 ---
.../vertx/AzureCoreHttpClientVertxProcessor.java | 7 +-
.../azure/core/http/vertx/DeadlockTests.java | 92 ----
.../http/vertx/SimpleBasicAuthHttpProxyServer.java | 132 ------
.../http/vertx/VertxAsyncClientTestHelper.java | 47 ---
.../VertxAsyncHttpClientAsyncHttpClientTests.java | 70 ----
.../vertx/VertxAsyncHttpClientBuilderTests.java | 464 ---------------------
.../vertx/VertxAsyncHttpClientProviderTests.java | 213 ----------
.../VertxAsyncHttpClientResponseTransformer.java | 56 ---
.../vertx/VertxAsyncHttpClientRestProxyTests.java | 145 -------
...HttpClientRestProxyWithAsyncHttpProxyTests.java | 192 ---------
.../vertx/VertxAsyncHttpClientSingletonTests.java | 83 ----
.../core/http/vertx/VertxAsyncHttpClientTests.java | 371 ----------------
.../http/vertx/VertxHttpClientTestResource.java | 73 ----
.../deployment/src/test/resources/upload.txt | 1 -
.../azure-core-http-client-vertx/runtime/pom.xml | 4 +
.../core/http/vertx/QuarkusVertxProvider.java | 1 +
.../core/http/vertx/VertxAsyncHttpClient.java | 139 ------
.../http/vertx/VertxAsyncHttpClientBuilder.java | 288 -------------
.../http/vertx/VertxAsyncHttpClientProvider.java | 82 ----
.../azure/core/http/vertx/VertxProvider.java | 34 --
.../implementation/BufferedVertxHttpResponse.java | 66 ---
.../implementation/VertxHttpAsyncResponse.java | 61 ---
.../implementation/VertxHttpResponseBase.java | 74 ----
.../com.azure.core.http.HttpClientProvider | 1 -
...der => com.azure.core.http.vertx.VertxProvider} | 0
.../src/main/resources/application.properties | 2 +-
pom.xml | 1 +
poms/bom/pom.xml | 6 +
poms/bom/src/main/generated/flattened-full-pom.xml | 5 +
.../src/main/generated/flattened-reduced-pom.xml | 5 +
.../generated/flattened-reduced-verbose-pom.xml | 5 +
32 files changed, 32 insertions(+), 2747 deletions(-)
diff --git a/extensions-support/azure-core-http-client-vertx/deployment/pom.xml b/extensions-support/azure-core-http-client-vertx/deployment/pom.xml
index d9b245b462..cf20d1f738 100644
--- a/extensions-support/azure-core-http-client-vertx/deployment/pom.xml
+++ b/extensions-support/azure-core-http-client-vertx/deployment/pom.xml
@@ -58,65 +58,6 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-support-azure-core-http-client-vertx</artifactId>
</dependency>
-
-
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-junit5-internal</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.testcontainers</groupId>
- <artifactId>testcontainers</artifactId>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>io.quarkus</groupId>
- <artifactId>quarkus-junit4-mock</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-integration-wiremock-support</artifactId>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-core</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
-
- <!-- Azure core test support -->
- <dependency>
- <groupId>com.azure</groupId>
- <artifactId>azure-core</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.azure</groupId>
- <artifactId>azure-core-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.azure</groupId>
- <artifactId>azure-core-test</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-inline</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
<build>
diff --git a/extensions-support/azure-core-http-client-vertx/deployment/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/AzureCoreHttpClientVertxProcessor.java b/extensions-support/azure-core-http-client-vertx/deployment/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/AzureCoreHttpClientVertxProcessor.java
index 45af42f898..15289f55c9 100644
--- a/extensions-support/azure-core-http-client-vertx/deployment/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/AzureCoreHttpClientVertxProcessor.java
+++ b/extensions-support/azure-core-http-client-vertx/deployment/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/AzureCoreHttpClientVertxProcessor.java
@@ -16,7 +16,7 @@
*/
package org.apache.camel.quarkus.support.azure.core.http.vertx;
-import com.azure.core.http.HttpClientProvider;
+import com.azure.core.http.vertx.VertxProvider;
import io.netty.handler.ssl.OpenSsl;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
@@ -30,12 +30,13 @@ public class AzureCoreHttpClientVertxProcessor {
runtimeInitializedClasses.produce(new RuntimeInitializedClassBuildItem(OpenSsl.class.getName()));
runtimeInitializedClasses.produce(new RuntimeInitializedClassBuildItem("io.netty.internal.tcnative.SSL"));
runtimeInitializedClasses.produce(new RuntimeInitializedClassBuildItem(
- "org.apache.camel.quarkus.support.azure.core.http.vertx.VertxAsyncHttpClientProvider$GlobalVertxHttpClient"));
+ "com.azure.core.http.vertx.VertxAsyncHttpClientProvider$GlobalVertxHttpClient"));
+ runtimeInitializedClasses.produce(
+ new RuntimeInitializedClassBuildItem("com.azure.core.http.vertx.VertxAsyncHttpClientBuilder$DefaultVertx"));
}
@BuildStep
void registerServiceProviders(BuildProducer<ServiceProviderBuildItem> serviceProvider) {
- serviceProvider.produce(ServiceProviderBuildItem.allProvidersFromClassPath(HttpClientProvider.class.getName()));
serviceProvider.produce(ServiceProviderBuildItem.allProvidersFromClassPath(VertxProvider.class.getName()));
}
}
diff --git a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/DeadlockTests.java b/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/DeadlockTests.java
deleted file mode 100644
index 14d0fc1060..0000000000
--- a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/DeadlockTests.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx;
-
-import java.security.SecureRandom;
-
-import com.azure.core.http.HttpClient;
-import com.azure.core.http.HttpMethod;
-import com.azure.core.http.HttpRequest;
-import com.azure.core.util.FluxUtil;
-import com.github.tomakehurst.wiremock.WireMockServer;
-import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
-import io.quarkus.test.QuarkusUnitTest;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
-import reactor.core.publisher.Mono;
-import reactor.test.StepVerifier;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-public class DeadlockTests {
-
- private static final String GET_ENDPOINT = "/get";
-
- private WireMockServer server;
- private byte[] expectedGetBytes;
-
- @RegisterExtension
- static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
- .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class));
-
- @BeforeEach
- public void configureWireMockServer() {
- expectedGetBytes = new byte[10 * 1024 * 1024];
- new SecureRandom().nextBytes(expectedGetBytes);
-
- server = new WireMockServer(WireMockConfiguration.options()
- .dynamicPort()
- .disableRequestJournal()
- .gzipDisabled(true));
-
- server.stubFor(get(GET_ENDPOINT).willReturn(aResponse().withBody(expectedGetBytes)));
-
- server.start();
- }
-
- @AfterEach
- public void shutdownWireMockServer() {
- if (server != null) {
- server.shutdown();
- }
- }
-
- @Test
- public void attemptToDeadlock() {
- HttpClient httpClient = new VertxAsyncHttpClientProvider().createInstance();
-
- String endpoint = server.baseUrl() + GET_ENDPOINT;
-
- for (int i = 0; i < 100; i++) {
- StepVerifier.create(httpClient.send(new HttpRequest(HttpMethod.GET, endpoint))
- .flatMap(response -> FluxUtil.collectBytesInByteBufferStream(response.getBody())
- .zipWith(Mono.just(response.getStatusCode()))))
- .assertNext(responseTuple -> {
- assertEquals(200, responseTuple.getT2());
- assertArrayEquals(expectedGetBytes, responseTuple.getT1());
- })
- .verifyComplete();
- }
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/SimpleBasicAuthHttpProxyServer.java b/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/SimpleBasicAuthHttpProxyServer.java
deleted file mode 100644
index 3e1cfb9738..0000000000
--- a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/SimpleBasicAuthHttpProxyServer.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx;
-
-import java.util.Base64;
-
-import com.github.tomakehurst.wiremock.WireMockServer;
-import com.github.tomakehurst.wiremock.client.WireMock;
-import com.github.tomakehurst.wiremock.common.FileSource;
-import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
-import com.github.tomakehurst.wiremock.extension.Parameters;
-import com.github.tomakehurst.wiremock.extension.ResponseTransformer;
-import com.github.tomakehurst.wiremock.http.HttpHeader;
-import com.github.tomakehurst.wiremock.http.HttpHeaders;
-import com.github.tomakehurst.wiremock.http.Request;
-import com.github.tomakehurst.wiremock.http.Response;
-
-/**
- * A simple Http proxy server that enforce basic proxy authentication, once authenticated
- * any request matching {@code serviceEndpoints} will be responded with an empty Http 200.
- */
-final class SimpleBasicAuthHttpProxyServer {
- private final String userName;
- private final String password;
- private final String[] serviceEndpoints;
- private WireMockServer proxyService;
-
- /**
- * Creates SimpleBasicAuthHttpProxyServer.
- *
- * @param userName the proxy user name for basic authentication
- * @param password the proxy password for basic authentication
- * @param serviceEndpoints the whitelisted mock endpoints targeting the service behind proxy
- */
- SimpleBasicAuthHttpProxyServer(String userName, String password, String[] serviceEndpoints) {
- this.userName = userName;
- this.password = password;
- this.serviceEndpoints = serviceEndpoints;
- }
-
- public ProxyEndpoint start() {
- this.proxyService = new WireMockServer(WireMockConfiguration
- .options()
- .dynamicPort()
- .extensions(new ResponseTransformer() {
- @Override
- public Response transform(Request request,
- Response response,
- FileSource fileSource,
- Parameters parameters) {
- String proxyAuthorization = request.getHeader("Proxy-Authorization");
- if (proxyAuthorization == null) {
- HttpHeader proxyAuthenticateHeader = new HttpHeader("Proxy-Authenticate", "Basic");
- return new Response.Builder()
- .status(407)
- .headers(new HttpHeaders(proxyAuthenticateHeader))
- .build();
- } else {
- if (!proxyAuthorization.startsWith("Basic")) {
- return new Response.Builder()
- .status(401)
- .build();
- }
- String encodedCred = proxyAuthorization.substring("Basic".length());
- encodedCred = encodedCred.trim();
- final Base64.Decoder decoder = Base64.getDecoder();
- final byte[] decodedCred = decoder.decode(encodedCred);
- if (new String(decodedCred).equals(userName + ":" + password)) {
- return new Response.Builder()
- .status(200)
- .build();
- } else {
- return new Response.Builder()
- .status(401)
- .build();
- }
- }
- }
-
- @Override
- public String getName() {
- return "ProxyServer";
- }
- })
- .disableRequestJournal());
- for (String endpoint : this.serviceEndpoints) {
- proxyService.stubFor(WireMock.any(WireMock.urlEqualTo(endpoint))
- .willReturn(WireMock.aResponse()));
- }
- this.proxyService.start();
- return new ProxyEndpoint("localhost", this.proxyService.port());
- }
-
- public void shutdown() {
- if (this.proxyService != null && this.proxyService.isRunning()) {
- this.proxyService.shutdown();
-
- }
- }
-
- static class ProxyEndpoint {
- private final String host;
- private final int port;
-
- ProxyEndpoint(String host, int port) {
- this.host = host;
- this.port = port;
- }
-
- String getHost() {
- return this.host;
- }
-
- int getPort() {
- return this.port;
- }
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncClientTestHelper.java b/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncClientTestHelper.java
deleted file mode 100644
index c3708513f2..0000000000
--- a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncClientTestHelper.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx;
-
-import java.lang.reflect.Field;
-import java.util.function.Predicate;
-
-import io.vertx.core.http.impl.HttpClientImpl;
-import io.vertx.core.net.SocketAddress;
-
-/**
- * Utility class to reflectively retrieve configuration settings from the Vert.x HTTP Client that are
- * not exposed by default.
- *
- * Avoids having to implement workarounds in the client code to make them available just for testing purposes.
- */
-final class VertxAsyncClientTestHelper {
-
- private VertxAsyncClientTestHelper() {
- // Utility class
- }
-
- @SuppressWarnings("unchecked")
- static Predicate<SocketAddress> getVertxInternalProxyFilter(HttpClientImpl client) {
- try {
- Field field = HttpClientImpl.class.getDeclaredField("proxyFilter");
- field.setAccessible(true);
- return (Predicate<SocketAddress>) field.get(client);
- } catch (NoSuchFieldException | IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientAsyncHttpClientTests.java b/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientAsyncHttpClientTests.java
deleted file mode 100644
index db5606d26c..0000000000
--- a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientAsyncHttpClientTests.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import com.azure.core.http.HttpClient;
-import com.azure.core.test.HttpClientTestsWireMockServer;
-import com.azure.core.test.http.HttpClientTests;
-import com.github.tomakehurst.wiremock.WireMockServer;
-import io.vertx.core.AsyncResult;
-import io.vertx.core.Handler;
-import io.vertx.core.Vertx;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-
-public class VertxAsyncHttpClientAsyncHttpClientTests extends HttpClientTests {
- private static WireMockServer server;
- private static Vertx vertx;
-
- @BeforeAll
- public static void beforeAll() {
- server = HttpClientTestsWireMockServer.getHttpClientTestsServer();
- server.start();
- vertx = Vertx.vertx();
- }
-
- @AfterAll
- public static void afterAll() throws Exception {
- if (server != null) {
- server.shutdown();
- }
-
- if (vertx != null) {
- CountDownLatch latch = new CountDownLatch(1);
- vertx.close(new Handler<AsyncResult<Void>>() {
- @Override
- public void handle(AsyncResult<Void> event) {
- latch.countDown();
- }
- });
- latch.await(5, TimeUnit.SECONDS);
- }
- }
-
- @Override
- protected int getWireMockPort() {
- return server.port();
- }
-
- @Override
- protected HttpClient createHttpClient() {
- return new VertxAsyncHttpClientBuilder().vertx(vertx).build();
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientBuilderTests.java b/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientBuilderTests.java
deleted file mode 100644
index 0e43054761..0000000000
--- a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientBuilderTests.java
+++ /dev/null
@@ -1,464 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx;
-
-import java.net.ConnectException;
-import java.net.InetSocketAddress;
-import java.time.Duration;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.function.Predicate;
-
-import com.azure.core.http.HttpClient;
-import com.azure.core.http.HttpMethod;
-import com.azure.core.http.HttpRequest;
-import com.azure.core.http.ProxyOptions;
-import com.azure.core.test.utils.TestConfigurationSource;
-import com.azure.core.util.Configuration;
-import com.azure.core.util.ConfigurationBuilder;
-import com.azure.core.util.ConfigurationSource;
-import com.github.tomakehurst.wiremock.WireMockServer;
-import com.github.tomakehurst.wiremock.client.WireMock;
-import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
-import io.vertx.core.AsyncResult;
-import io.vertx.core.Handler;
-import io.vertx.core.Vertx;
-import io.vertx.core.http.HttpClientOptions;
-import io.vertx.core.http.impl.HttpClientImpl;
-import io.vertx.core.net.SocketAddress;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
-import reactor.test.StepVerifier;
-
-import static io.vertx.core.net.SocketAddress.inetSocketAddress;
-import static org.apache.camel.quarkus.support.azure.core.http.vertx.VertxAsyncClientTestHelper.getVertxInternalProxyFilter;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-/**
- * Tests {@link VertxAsyncHttpClientBuilder}.
- */
-public class VertxAsyncHttpClientBuilderTests {
- private static final String PROXY_USERNAME = "foo";
- private static final String PROXY_PASSWORD = "bar";
- private static final String PROXY_USER_INFO = PROXY_USERNAME + ":" + PROXY_PASSWORD + "@";
- private static final String SERVICE_ENDPOINT = "/default";
- private static final ConfigurationSource EMPTY_SOURCE = new TestConfigurationSource();
- private static Vertx vertx;
-
- @BeforeAll
- public static void beforeAll() {
- vertx = Vertx.vertx();
- }
-
- @AfterAll
- public static void afterAll() {
- if (vertx != null) {
- CountDownLatch latch = new CountDownLatch(1);
- vertx.close(new Handler<AsyncResult<Void>>() {
- @Override
- public void handle(AsyncResult<Void> event) {
- latch.countDown();
- }
- });
- try {
- latch.await(5, TimeUnit.SECONDS);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- }
- }
-
- @Test
- public void buildWithConfigurationNone() {
- HttpClient httpClient = new VertxAsyncHttpClientBuilder()
- .configuration(Configuration.NONE)
- .vertx(vertx)
- .build();
-
- String defaultPath = "/default";
- WireMockServer server = new WireMockServer(WireMockConfiguration.options().dynamicPort().disableRequestJournal());
- server.stubFor(WireMock.get(defaultPath).willReturn(WireMock.aResponse().withStatus(200)));
- server.start();
- String defaultUrl = "http://localhost:" + server.port() + defaultPath;
- try {
- StepVerifier.create(httpClient.send(new HttpRequest(HttpMethod.GET, defaultUrl)))
- .assertNext(response -> assertEquals(200, response.getStatusCode()))
- .verifyComplete();
- } finally {
- if (server.isRunning()) {
- server.shutdown();
- }
- }
- }
-
- @Test
- public void buildWithDefaultConnectionOptions() {
- VertxAsyncHttpClientBuilder builder = new VertxAsyncHttpClientBuilder().vertx(vertx);
- HttpClient httpClient = builder.build();
-
- io.vertx.core.http.HttpClient client = ((VertxAsyncHttpClient) httpClient).client;
- io.vertx.core.http.HttpClientOptions options = ((HttpClientImpl) client).options();
-
- String defaultPath = "/default";
- WireMockServer server = new WireMockServer(WireMockConfiguration.options().dynamicPort().disableRequestJournal());
- server.stubFor(WireMock.get(defaultPath).willReturn(WireMock.aResponse().withStatus(200)));
- server.start();
- String defaultUrl = "http://localhost:" + server.port() + defaultPath;
- try {
- StepVerifier.create(httpClient.send(new HttpRequest(HttpMethod.GET, defaultUrl)))
- .assertNext(response -> assertEquals(200, response.getStatusCode()))
- .verifyComplete();
-
- assertEquals(10000, options.getConnectTimeout());
- assertEquals(60, options.getIdleTimeout());
- assertEquals(60, options.getReadIdleTimeout());
- assertEquals(60, options.getWriteIdleTimeout());
- } finally {
- if (server.isRunning()) {
- server.shutdown();
- }
- }
- }
-
- @Test
- public void buildWithConnectionOptions() {
- VertxAsyncHttpClientBuilder builder = new VertxAsyncHttpClientBuilder().vertx(vertx);
- VertxAsyncHttpClient httpClient = (VertxAsyncHttpClient) builder.connectTimeout(Duration.ofSeconds(10))
- .idleTimeout(Duration.ofSeconds(20))
- .readIdleTimeout(Duration.ofSeconds(30))
- .writeIdleTimeout(Duration.ofSeconds(40))
- .build();
-
- io.vertx.core.http.HttpClientOptions options = ((HttpClientImpl) httpClient.client).options();
-
- String defaultPath = "/default";
- WireMockServer server = new WireMockServer(WireMockConfiguration.options().dynamicPort().disableRequestJournal());
- server.stubFor(WireMock.get(defaultPath).willReturn(WireMock.aResponse().withStatus(200)));
- server.start();
- String defaultUrl = "http://localhost:" + server.port() + defaultPath;
- try {
- StepVerifier.create(httpClient.send(new HttpRequest(HttpMethod.GET, defaultUrl)))
- .assertNext(response -> assertEquals(200, response.getStatusCode()))
- .verifyComplete();
-
- assertEquals(10000, options.getConnectTimeout());
- assertEquals(20, options.getIdleTimeout());
- assertEquals(30, options.getReadIdleTimeout());
- assertEquals(40, options.getWriteIdleTimeout());
- } finally {
- if (server.isRunning()) {
- server.shutdown();
- }
- }
- }
-
- @Test
- public void buildWithAllProxyTypes() throws Exception {
- for (ProxyOptions.Type type : ProxyOptions.Type.values()) {
- if (type.equals(ProxyOptions.Type.SOCKS5)) {
- return;
- }
-
- String proxyUser = "user";
- String proxyPassword = "secret";
-
- InetSocketAddress address = new InetSocketAddress("localhost", 8888);
- ProxyOptions proxyOptions = new ProxyOptions(type, address);
- proxyOptions.setCredentials("user", "secret");
- proxyOptions.setNonProxyHosts("foo.*|*bar.com|microsoft.com");
-
- VertxAsyncHttpClient httpClient = (VertxAsyncHttpClient) new VertxAsyncHttpClientBuilder()
- .proxy(proxyOptions)
- .vertx(vertx)
- .build();
-
- HttpClientImpl vertxHttpClientImpl = (HttpClientImpl) httpClient.client;
- io.vertx.core.http.HttpClientOptions options = vertxHttpClientImpl.options();
-
- io.vertx.core.net.ProxyOptions vertxProxyOptions = options.getProxyOptions();
- assertNotNull(vertxProxyOptions);
- assertEquals(address.getHostName(), vertxProxyOptions.getHost());
- assertEquals(address.getPort(), vertxProxyOptions.getPort());
- assertEquals(type.name(), vertxProxyOptions.getType().name());
- assertEquals(proxyUser, vertxProxyOptions.getUsername());
- assertEquals(proxyPassword, vertxProxyOptions.getPassword());
-
- Predicate<SocketAddress> proxyFilter = getVertxInternalProxyFilter(vertxHttpClientImpl);
- assertFalse(proxyFilter.test(inetSocketAddress(80, "foo.com")));
- assertFalse(proxyFilter.test(inetSocketAddress(80, "foo.bar.com")));
- assertFalse(proxyFilter.test(inetSocketAddress(80, "test.bar.com")));
- assertFalse(proxyFilter.test(inetSocketAddress(80, "microsoft.com")));
- assertTrue(proxyFilter.test(inetSocketAddress(80, "allowed.host.com")));
- }
-
- }
-
- @Test
- public void buildWithHttpProxy() {
- SimpleBasicAuthHttpProxyServer proxyServer = new SimpleBasicAuthHttpProxyServer(PROXY_USERNAME,
- PROXY_PASSWORD,
- new String[] { SERVICE_ENDPOINT });
-
- try {
- SimpleBasicAuthHttpProxyServer.ProxyEndpoint proxyEndpoint = proxyServer.start();
-
- ProxyOptions clientProxyOptions = new ProxyOptions(ProxyOptions.Type.HTTP,
- new InetSocketAddress(proxyEndpoint.getHost(), proxyEndpoint.getPort()))
- .setCredentials(PROXY_USERNAME, PROXY_PASSWORD);
-
- HttpClient httpClient = new VertxAsyncHttpClientBuilder()
- .proxy(clientProxyOptions)
- .vertx(vertx)
- .build();
-
- final String serviceUrl = "http://localhost:80" + SERVICE_ENDPOINT;
- StepVerifier.create(httpClient.send(new HttpRequest(HttpMethod.GET, serviceUrl)))
- .expectNextCount(1)
- .verifyComplete();
- } finally {
- proxyServer.shutdown();
- }
- }
-
- @Test
- public void buildWithHttpProxyFromEnvConfiguration() {
- SimpleBasicAuthHttpProxyServer proxyServer = new SimpleBasicAuthHttpProxyServer(PROXY_USERNAME,
- PROXY_PASSWORD,
- new String[] { SERVICE_ENDPOINT });
-
- try {
- SimpleBasicAuthHttpProxyServer.ProxyEndpoint proxyEndpoint = proxyServer.start();
-
- Configuration configuration = new ConfigurationBuilder(EMPTY_SOURCE, EMPTY_SOURCE,
- new TestConfigurationSource()
- .put(Configuration.PROPERTY_HTTP_PROXY,
- "http://" + PROXY_USER_INFO + proxyEndpoint.getHost() + ":" + proxyEndpoint.getPort())
- .put("java.net.useSystemProxies", "true"))
- .build();
-
- HttpClient httpClient = new VertxAsyncHttpClientBuilder()
- .configuration(configuration)
- .vertx(vertx)
- .build();
-
- final String serviceUrl = "http://localhost:80" + SERVICE_ENDPOINT;
- StepVerifier.create(httpClient.send(new HttpRequest(HttpMethod.GET, serviceUrl)))
- .expectNextCount(1)
- .verifyComplete();
- } finally {
- proxyServer.shutdown();
- }
- }
-
- @Test
- public void buildWithHttpProxyFromExplicitConfiguration() {
- SimpleBasicAuthHttpProxyServer proxyServer = new SimpleBasicAuthHttpProxyServer(PROXY_USERNAME,
- PROXY_PASSWORD,
- new String[] { SERVICE_ENDPOINT });
-
- try {
- SimpleBasicAuthHttpProxyServer.ProxyEndpoint proxyEndpoint = proxyServer.start();
-
- Configuration configuration = new ConfigurationBuilder()
- .putProperty("http.proxy.hostname", proxyEndpoint.getHost())
- .putProperty("http.proxy.port", String.valueOf(proxyEndpoint.getPort()))
- .build();
-
- HttpClient httpClient = new VertxAsyncHttpClientBuilder()
- .configuration(configuration)
- .vertx(vertx)
- .build();
-
- final String serviceUrl = "http://localhost:80" + SERVICE_ENDPOINT;
- StepVerifier.create(httpClient.send(new HttpRequest(HttpMethod.GET, serviceUrl)))
- .expectNextCount(1)
- .verifyComplete();
- } finally {
- proxyServer.shutdown();
- }
- }
-
- @Test
- public void buildWithCustomVertx() throws Exception {
- Vertx vertx = Vertx.vertx();
-
- HttpClient httpClient = new VertxAsyncHttpClientBuilder()
- .configuration(Configuration.NONE)
- .vertx(vertx)
- .build();
-
- String defaultPath = "/default";
- WireMockServer server = new WireMockServer(WireMockConfiguration.options().dynamicPort().disableRequestJournal());
- server.stubFor(WireMock.get(defaultPath).willReturn(WireMock.aResponse().withStatus(200)));
- server.start();
- String defaultUrl = "http://localhost:" + server.port() + defaultPath;
- try {
- StepVerifier.create(httpClient.send(new HttpRequest(HttpMethod.GET, defaultUrl)))
- .assertNext(response -> assertEquals(200, response.getStatusCode()))
- .verifyComplete();
- } finally {
- if (server.isRunning()) {
- server.shutdown();
- }
-
- CountDownLatch latch = new CountDownLatch(1);
- vertx.close(event -> latch.countDown());
- assertTrue(latch.await(5, TimeUnit.SECONDS));
- }
- }
-
- @Test
- public void buildWithCustomHttpClientOptions() {
- HttpClientOptions options = new HttpClientOptions();
- options.setConnectTimeout(30000);
- options.setIdleTimeout(50);
- options.setReadIdleTimeout(60);
- options.setWriteIdleTimeout(70);
-
- HttpClient httpClient = new VertxAsyncHttpClientBuilder()
- .connectTimeout(Duration.ofSeconds(10))
- .idleTimeout(Duration.ofSeconds(20))
- .readIdleTimeout(Duration.ofSeconds(30))
- .writeIdleTimeout(Duration.ofSeconds(40))
- .httpClientOptions(options)
- .vertx(vertx)
- .build();
-
- // Verify the original configuration was preserved and not overwritten
- assertEquals(30000, options.getConnectTimeout());
- assertEquals(50, options.getIdleTimeout());
- assertEquals(60, options.getReadIdleTimeout());
- assertEquals(70, options.getWriteIdleTimeout());
-
- String defaultPath = "/default";
- WireMockServer server = new WireMockServer(WireMockConfiguration.options().dynamicPort().disableRequestJournal());
- server.stubFor(WireMock.get(defaultPath).willReturn(WireMock.aResponse().withStatus(200)));
- server.start();
- String defaultUrl = "http://localhost:" + server.port() + defaultPath;
- try {
- StepVerifier.create(httpClient.send(new HttpRequest(HttpMethod.GET, defaultUrl)))
- .assertNext(response -> assertEquals(200, response.getStatusCode()))
- .verifyComplete();
- } finally {
- if (server.isRunning()) {
- server.shutdown();
- }
- }
- }
-
- @Test
- public void buildWithNullProxyAddress() {
- SimpleBasicAuthHttpProxyServer proxyServer = new SimpleBasicAuthHttpProxyServer(PROXY_USERNAME,
- PROXY_PASSWORD,
- new String[] { SERVICE_ENDPOINT });
-
- try {
- proxyServer.start();
-
- ProxyOptions mockPoxyOptions = Mockito.mock(ProxyOptions.class);
- Mockito.when(mockPoxyOptions.getType()).thenReturn(ProxyOptions.Type.HTTP);
- Mockito.when(mockPoxyOptions.getAddress()).thenReturn(null);
-
- HttpClient httpClient = new VertxAsyncHttpClientBuilder()
- .proxy(mockPoxyOptions)
- .vertx(vertx)
- .build();
-
- final String serviceUrl = "http://localhost:80" + SERVICE_ENDPOINT;
- StepVerifier.create(httpClient.send(new HttpRequest(HttpMethod.GET, serviceUrl)))
- .verifyError(ConnectException.class);
- } finally {
- proxyServer.shutdown();
- }
- }
-
- @Test
- public void buildWithInvalidProxyType() {
- ProxyOptions.Type mockProxyType = Mockito.mock(ProxyOptions.Type.class);
- Mockito.when(mockProxyType.name()).thenReturn("INVALID");
-
- ProxyOptions clientProxyOptions = new ProxyOptions(mockProxyType,
- new InetSocketAddress("test.com", 8080));
-
- assertThrows(IllegalArgumentException.class, () -> {
- new VertxAsyncHttpClientBuilder()
- .proxy(clientProxyOptions)
- .vertx(vertx)
- .build();
- });
- }
-
- @Test
- public void buildWithNullProxyType() {
- SimpleBasicAuthHttpProxyServer proxyServer = new SimpleBasicAuthHttpProxyServer(PROXY_USERNAME,
- PROXY_PASSWORD,
- new String[] { SERVICE_ENDPOINT });
-
- try {
- SimpleBasicAuthHttpProxyServer.ProxyEndpoint proxyEndpoint = proxyServer.start();
-
- ProxyOptions mockPoxyOptions = Mockito.mock(ProxyOptions.class);
- Mockito.when(mockPoxyOptions.getType()).thenReturn(null);
- Mockito.when(mockPoxyOptions.getAddress())
- .thenReturn(new InetSocketAddress(proxyEndpoint.getHost(), proxyEndpoint.getPort()));
-
- HttpClient httpClient = new VertxAsyncHttpClientBuilder()
- .proxy(mockPoxyOptions)
- .vertx(vertx)
- .build();
-
- final String serviceUrl = "http://localhost:80" + SERVICE_ENDPOINT;
- StepVerifier.create(httpClient.send(new HttpRequest(HttpMethod.GET, serviceUrl)))
- .expectNextCount(1)
- .verifyComplete();
- } finally {
- proxyServer.shutdown();
- }
- }
-
- @Test
- public void buildWithoutProxyAuthentication() {
- SimpleBasicAuthHttpProxyServer proxyServer = new SimpleBasicAuthHttpProxyServer(PROXY_USERNAME,
- PROXY_PASSWORD,
- new String[] { SERVICE_ENDPOINT });
-
- try {
- SimpleBasicAuthHttpProxyServer.ProxyEndpoint proxyEndpoint = proxyServer.start();
-
- ProxyOptions clientProxyOptions = new ProxyOptions(ProxyOptions.Type.HTTP,
- new InetSocketAddress(proxyEndpoint.getHost(), proxyEndpoint.getPort()));
-
- HttpClient httpClient = new VertxAsyncHttpClientBuilder()
- .proxy(clientProxyOptions)
- .vertx(vertx)
- .build();
-
- final String serviceUrl = "http://localhost:80" + SERVICE_ENDPOINT;
- StepVerifier.create(httpClient.send(new HttpRequest(HttpMethod.GET, serviceUrl)))
- .expectNextCount(1)
- .verifyComplete();
- } finally {
- proxyServer.shutdown();
- }
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientProviderTests.java b/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientProviderTests.java
deleted file mode 100644
index ccd22bc6e9..0000000000
--- a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientProviderTests.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx;
-
-import java.net.InetSocketAddress;
-import java.time.Duration;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.ServiceLoader;
-import java.util.Set;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.function.Predicate;
-
-import com.azure.core.http.HttpClient;
-import com.azure.core.http.ProxyOptions;
-import com.azure.core.util.Configuration;
-import com.azure.core.util.HttpClientOptions;
-import io.quarkus.test.QuarkusUnitTest;
-import io.vertx.core.Vertx;
-import io.vertx.core.http.impl.HttpClientImpl;
-import io.vertx.core.net.SocketAddress;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
-import org.mockito.MockedStatic;
-import org.mockito.Mockito;
-
-import static io.vertx.core.net.SocketAddress.inetSocketAddress;
-import static org.apache.camel.quarkus.support.azure.core.http.vertx.VertxAsyncClientTestHelper.getVertxInternalProxyFilter;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.mockStatic;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-/**
- * Tests {@link VertxAsyncHttpClientProvider}.
- */
-public class VertxAsyncHttpClientProviderTests {
-
- @RegisterExtension
- static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
- .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
- .addAsServiceProvider(VertxProvider.class, QuarkusVertxProvider.class)
- .addPackage(VertxAsyncHttpClient.class.getPackage()));
-
- @Test
- public void nullOptionsReturnsBaseClient() {
- VertxAsyncHttpClient httpClient = (VertxAsyncHttpClient) new VertxAsyncHttpClientProvider()
- .createInstance(null);
-
- ProxyOptions environmentProxy = ProxyOptions.fromConfiguration(Configuration.getGlobalConfiguration());
- io.vertx.core.http.HttpClientOptions options = ((HttpClientImpl) httpClient.client).options();
- io.vertx.core.net.ProxyOptions proxyOptions = options.getProxyOptions();
- if (environmentProxy == null) {
- assertNull(proxyOptions);
- } else {
- assertNotNull(proxyOptions);
- assertEquals(environmentProxy.getAddress().getHostName(), proxyOptions.getHost());
- }
- }
-
- @Test
- public void defaultOptionsReturnsBaseClient() {
- VertxAsyncHttpClient httpClient = (VertxAsyncHttpClient) new VertxAsyncHttpClientProvider()
- .createInstance(new HttpClientOptions());
-
- ProxyOptions environmentProxy = ProxyOptions.fromConfiguration(Configuration.getGlobalConfiguration());
- io.vertx.core.http.HttpClientOptions options = ((HttpClientImpl) httpClient.client).options();
- io.vertx.core.net.ProxyOptions proxyOptions = options.getProxyOptions();
- if (environmentProxy == null) {
- assertNull(proxyOptions);
- } else {
- assertNotNull(proxyOptions);
- assertEquals(environmentProxy.getAddress().getHostName(), proxyOptions.getHost());
- }
- }
-
- @Test
- public void optionsWithAProxy() {
- ProxyOptions proxyOptions = new ProxyOptions(ProxyOptions.Type.HTTP, new InetSocketAddress("localhost", 8888));
- proxyOptions.setNonProxyHosts("foo.*|bar.*|cheese.com|wine.org");
-
- HttpClientOptions clientOptions = new HttpClientOptions().setProxyOptions(proxyOptions);
-
- VertxAsyncHttpClient httpClient = (VertxAsyncHttpClient) new VertxAsyncHttpClientProvider()
- .createInstance(clientOptions);
-
- io.vertx.core.http.HttpClientOptions options = ((HttpClientImpl) httpClient.client).options();
-
- io.vertx.core.net.ProxyOptions vertxProxyOptions = options.getProxyOptions();
- assertNotNull(vertxProxyOptions);
- assertEquals(proxyOptions.getAddress().getHostName(), vertxProxyOptions.getHost());
- assertEquals(proxyOptions.getAddress().getPort(), vertxProxyOptions.getPort());
- assertEquals(proxyOptions.getType().name(), vertxProxyOptions.getType().name());
-
- Predicate<SocketAddress> proxyFilter = getVertxInternalProxyFilter((HttpClientImpl) httpClient.client);
- assertFalse(proxyFilter.test(inetSocketAddress(80, "foo.com")));
- assertFalse(proxyFilter.test(inetSocketAddress(80, "foo.bar.com")));
- assertFalse(proxyFilter.test(inetSocketAddress(80, "bar.com")));
- assertFalse(proxyFilter.test(inetSocketAddress(80, "cheese.com")));
- assertFalse(proxyFilter.test(inetSocketAddress(80, "wine.org")));
- assertTrue(proxyFilter.test(inetSocketAddress(80, "allowed.host.com")));
- }
-
- @Test
- public void optionsWithTimeouts() {
- Duration timeout = Duration.ofMillis(15000);
- HttpClientOptions clientOptions = new HttpClientOptions()
- .setConnectTimeout(timeout)
- .setConnectionIdleTimeout(timeout)
- .setReadTimeout(timeout)
- .setWriteTimeout(timeout);
-
- HttpClient httpClient = new VertxAsyncHttpClientProvider().createInstance(clientOptions);
- VertxAsyncHttpClient cast = VertxAsyncHttpClient.class.cast(httpClient);
-
- io.vertx.core.http.HttpClientOptions options = ((HttpClientImpl) cast.client).options();
-
- assertEquals(timeout.toMillis(), options.getConnectTimeout());
- assertEquals(timeout.getSeconds(), options.getIdleTimeout());
- assertEquals(timeout.getSeconds(), options.getReadIdleTimeout());
- assertEquals(timeout.getSeconds(), options.getWriteIdleTimeout());
- }
-
- @SuppressWarnings("rawtypes")
- @Test
- public void vertxProvider() throws Exception {
- Vertx vertx = Vertx.vertx();
-
- ServiceLoader mockServiceLoader = mock(ServiceLoader.class);
- VertxProvider mockVertxProvider = mock(VertxProvider.class);
-
- try (MockedStatic<ServiceLoader> serviceLoader = mockStatic(ServiceLoader.class)) {
- Set<VertxProvider> providers = new HashSet<>();
- providers.add(mockVertxProvider);
-
- Class<?> providerClass = VertxProvider.class;
- serviceLoader.when(() -> ServiceLoader.load(providerClass, providerClass.getClassLoader()))
- .thenReturn(mockServiceLoader);
-
- Mockito.when(mockServiceLoader.iterator()).thenReturn(providers.iterator());
- Mockito.when(mockVertxProvider.createVertx()).thenReturn(vertx);
-
- HttpClient httpClient = new VertxAsyncHttpClientProvider().createInstance();
- assertNotNull(httpClient);
-
- verify(mockServiceLoader, times(1)).iterator();
- verify(mockVertxProvider, times(1)).createVertx();
- } finally {
- CountDownLatch latch = new CountDownLatch(1);
- vertx.close(event -> latch.countDown());
- latch.await(5, TimeUnit.SECONDS);
- }
- }
-
- @SuppressWarnings("rawtypes")
- @Test
- public void multipleVertxProviders() throws Exception {
- Vertx vertx = Vertx.vertx();
-
- ServiceLoader mockServiceLoader = mock(ServiceLoader.class);
- VertxProvider mockVertxProviderA = mock(VertxProvider.class);
- VertxProvider mockVertxProviderB = mock(VertxProvider.class);
-
- try (MockedStatic<ServiceLoader> serviceLoader = mockStatic(ServiceLoader.class)) {
- Set<VertxProvider> providers = new LinkedHashSet<>();
- providers.add(mockVertxProviderA);
- providers.add(mockVertxProviderB);
-
- Class<?> providerClass = VertxProvider.class;
- serviceLoader.when(() -> ServiceLoader.load(providerClass, providerClass.getClassLoader()))
- .thenReturn(mockServiceLoader);
-
- Mockito.when(mockServiceLoader.iterator()).thenReturn(providers.iterator());
- Mockito.when(mockVertxProviderA.createVertx()).thenReturn(vertx);
-
- HttpClient httpClient = new VertxAsyncHttpClientProvider().createInstance();
- assertNotNull(httpClient);
-
- verify(mockServiceLoader, times(1)).iterator();
- verify(mockVertxProviderA, times(1)).createVertx();
-
- // Only the first provider should have been invoked
- verify(mockVertxProviderB, never()).createVertx();
- } finally {
- CountDownLatch latch = new CountDownLatch(1);
- vertx.close(event -> latch.countDown());
- latch.await(5, TimeUnit.SECONDS);
- }
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientResponseTransformer.java b/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientResponseTransformer.java
deleted file mode 100644
index 8ea2fa589e..0000000000
--- a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientResponseTransformer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx;
-
-import com.github.tomakehurst.wiremock.common.FileSource;
-import com.github.tomakehurst.wiremock.extension.Parameters;
-import com.github.tomakehurst.wiremock.extension.ResponseTransformer;
-import com.github.tomakehurst.wiremock.http.Request;
-import com.github.tomakehurst.wiremock.http.Response;
-
-import static org.apache.camel.quarkus.support.azure.core.http.vertx.VertxAsyncHttpClientTests.RETURN_HEADERS_AS_IS_PATH;
-
-/**
- * Mock response transformer used to test {@link VertxAsyncHttpClient}.
- */
-public class VertxAsyncHttpClientResponseTransformer extends ResponseTransformer {
- public static final String NAME = "vertx-http-client-response-transformer";
-
- @Override
- public Response transform(Request request, Response response, FileSource fileSource, Parameters parameters) {
- String url = request.getUrl();
-
- if (RETURN_HEADERS_AS_IS_PATH.equalsIgnoreCase(url)) {
- return Response.response()
- .status(200)
- .headers(request.getHeaders())
- .build();
- }
-
- return response;
- }
-
- @Override
- public String getName() {
- return NAME;
- }
-
- @Override
- public boolean applyGlobally() {
- return false;
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientRestProxyTests.java b/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientRestProxyTests.java
deleted file mode 100644
index bf11603981..0000000000
--- a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientRestProxyTests.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx;
-
-import java.io.IOException;
-
-import com.azure.core.http.HttpClient;
-import com.azure.core.test.RestProxyTestsWireMockServer;
-import com.azure.core.test.implementation.RestProxyTests;
-import com.azure.core.util.Context;
-import com.github.tomakehurst.wiremock.WireMockServer;
-import io.quarkus.test.QuarkusUnitTest;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Named;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
-
-public class VertxAsyncHttpClientRestProxyTests extends RestProxyTests {
- private static WireMockServer server;
-
- @RegisterExtension
- static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
- .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
- .addAsResource("upload.txt", "upload.txt"));
-
- @BeforeAll
- public static void beforeAll() {
- server = RestProxyTestsWireMockServer.getRestProxyTestsServer();
- server.start();
- }
-
- @AfterAll
- public static void afterAll() throws Exception {
- if (server != null) {
- server.shutdown();
- }
- }
-
- @Override
- protected int getWireMockPort() {
- return server.port();
- }
-
- @Override
- protected HttpClient createHttpClient() {
- return new VertxAsyncHttpClientBuilder().build();
- }
-
- /*
- * The following methods are overridden and reimplemented to work around issues with
- * parameterized tests not working properly with QuarkusUnitTest.
- */
-
- @Override
- @ParameterizedTest
- @MethodSource("downloadTestArgumentProvider")
- @Disabled
- public void simpleDownloadTest(Context context) {
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void simpleDownloadTest() {
- downloadTestArgumentProvider().forEach(arguments -> {
- Named<Context> named = (Named<Context>) arguments.get()[0];
- super.simpleDownloadTest(named.getPayload());
- });
- }
-
- @Override
- @ParameterizedTest
- @MethodSource("downloadTestArgumentProvider")
- @Disabled
- public void simpleDownloadTestAsync(Context context) {
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void simpleDownloadTestAsync() {
- downloadTestArgumentProvider().forEach(arguments -> {
- Named<Context> named = (Named<Context>) arguments.get()[0];
- super.simpleDownloadTestAsync(named.getPayload());
- });
- }
-
- @Override
- @ParameterizedTest
- @MethodSource("downloadTestArgumentProvider")
- @Disabled
- public void streamResponseCanTransferBody(Context context) throws IOException {
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void streamResponseCanTransferBody() {
- downloadTestArgumentProvider().forEach(arguments -> {
- Named<Context> named = (Named<Context>) arguments.get()[0];
- try {
- super.streamResponseCanTransferBody(named.getPayload());
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- });
- }
-
- @Override
- @ParameterizedTest
- @MethodSource("downloadTestArgumentProvider")
- @Disabled
- public void streamResponseCanTransferBodyAsync(Context context) throws IOException {
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void streamResponseCanTransferBodyAsync() {
- downloadTestArgumentProvider().forEach(arguments -> {
- Named<Context> named = (Named<Context>) arguments.get()[0];
- try {
- super.streamResponseCanTransferBodyAsync(named.getPayload());
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- });
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientRestProxyWithAsyncHttpProxyTests.java b/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientRestProxyWithAsyncHttpProxyTests.java
deleted file mode 100644
index 2c35e71c34..0000000000
--- a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientRestProxyWithAsyncHttpProxyTests.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-
-import com.azure.core.http.HttpClient;
-import com.azure.core.http.ProxyOptions;
-import com.azure.core.test.RestProxyTestsWireMockServer;
-import com.azure.core.test.implementation.RestProxyTests;
-import com.azure.core.util.Context;
-import com.github.tomakehurst.wiremock.WireMockServer;
-import io.quarkus.test.QuarkusUnitTest;
-import io.quarkus.test.common.QuarkusTestResource;
-import org.eclipse.microprofile.config.Config;
-import org.eclipse.microprofile.config.ConfigProvider;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Named;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.MethodSource;
-
-import static org.apache.camel.quarkus.support.azure.core.http.vertx.VertxHttpClientTestResource.PROXY_PASSWORD;
-import static org.apache.camel.quarkus.support.azure.core.http.vertx.VertxHttpClientTestResource.PROXY_USER;
-
-@QuarkusTestResource(VertxHttpClientTestResource.class)
-public class VertxAsyncHttpClientRestProxyWithAsyncHttpProxyTests extends RestProxyTests {
- private static WireMockServer server;
-
- @RegisterExtension
- static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
- .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
- .addAsResource("upload.txt", "upload.txt"));
-
- @BeforeAll
- public static void beforeAll() {
- server = RestProxyTestsWireMockServer.getRestProxyTestsServer();
- server.start();
- }
-
- @AfterAll
- public static void afterAll() throws Exception {
- if (server != null) {
- server.shutdown();
- }
- }
-
- @Override
- protected int getWireMockPort() {
- return server.port();
- }
-
- @Override
- protected HttpClient createHttpClient() {
- Config config = ConfigProvider.getConfig();
- String proxyHost = config.getValue("tiny.proxy.host", String.class);
- int proxyPort = config.getValue("tiny.proxy.port", int.class);
-
- InetSocketAddress address = new InetSocketAddress(proxyHost, proxyPort);
- ProxyOptions proxyOptions = new ProxyOptions(ProxyOptions.Type.HTTP, address);
- proxyOptions.setCredentials(PROXY_USER, PROXY_PASSWORD);
-
- return new VertxAsyncHttpClientBuilder()
- .proxy(proxyOptions)
- .build();
- }
-
- /*
- * The following methods are overridden and reimplemented to work around issues with
- * parameterized tests not working properly with QuarkusUnitTest.
- */
-
- @Override
- @ParameterizedTest
- @MethodSource("downloadTestArgumentProvider")
- @Disabled
- public void simpleDownloadTest(Context context) {
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void simpleDownloadTest() {
- downloadTestArgumentProvider().forEach(arguments -> {
- Named<Context> named = (Named<Context>) arguments.get()[0];
- super.simpleDownloadTest(named.getPayload());
- });
- }
-
- @Override
- @ParameterizedTest
- @MethodSource("downloadTestArgumentProvider")
- @Disabled
- public void simpleDownloadTestAsync(Context context) {
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void simpleDownloadTestAsync() {
- downloadTestArgumentProvider().forEach(arguments -> {
- Named<Context> named = (Named<Context>) arguments.get()[0];
- super.simpleDownloadTestAsync(named.getPayload());
- });
- }
-
- @Override
- @ParameterizedTest
- @MethodSource("downloadTestArgumentProvider")
- @Disabled
- public void streamResponseCanTransferBody(Context context) throws IOException {
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void streamResponseCanTransferBody() {
- downloadTestArgumentProvider().forEach(arguments -> {
- Named<Context> named = (Named<Context>) arguments.get()[0];
- try {
- super.streamResponseCanTransferBody(named.getPayload());
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- });
- }
-
- @Override
- @ParameterizedTest
- @MethodSource("downloadTestArgumentProvider")
- @Disabled
- public void streamResponseCanTransferBodyAsync(Context context) throws IOException {
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void streamResponseCanTransferBodyAsync() {
- downloadTestArgumentProvider().forEach(arguments -> {
- Named<Context> named = (Named<Context>) arguments.get()[0];
- try {
- super.streamResponseCanTransferBodyAsync(named.getPayload());
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- });
- }
-
- @Override
- @Test
- @Disabled
- public void service19PutWithBodyParamApplicationOctetStreamContentTypeAndStringBodyWithEmptyBody() {
- super.service19PutWithBodyParamApplicationOctetStreamContentTypeAndStringBodyWithEmptyBody();
- }
-
- @Override
- @Test
- @Disabled
- public void service19PutWithHeaderApplicationJsonContentTypeAndCharsetAndStringBodyWithEmptyBody() {
- super.service19PutWithHeaderApplicationJsonContentTypeAndCharsetAndStringBodyWithEmptyBody();
- }
-
- @Override
- @Test
- @Disabled
- public void service19PutWithHeaderApplicationOctetStreamContentTypeAndStringBodyWithEmptyBody() {
- super.service19PutWithHeaderApplicationOctetStreamContentTypeAndStringBodyWithEmptyBody();
- }
-
- @Override
- @Test
- @Disabled
- public void service19PutWithNoContentTypeAndStringBodyWithEmptyBody() {
- super.service19PutWithNoContentTypeAndStringBodyWithEmptyBody();
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientSingletonTests.java b/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientSingletonTests.java
deleted file mode 100644
index acb5cca6b9..0000000000
--- a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientSingletonTests.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx;
-
-import com.azure.core.http.HttpClient;
-import com.azure.core.test.utils.TestConfigurationSource;
-import com.azure.core.util.Configuration;
-import com.azure.core.util.ConfigurationBuilder;
-import com.azure.core.util.ConfigurationSource;
-import com.azure.core.util.HttpClientOptions;
-import io.quarkus.test.QuarkusUnitTest;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
-import org.junit.jupiter.api.parallel.Execution;
-import org.junit.jupiter.api.parallel.ExecutionMode;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
-
-@Execution(ExecutionMode.SAME_THREAD)
-public class VertxAsyncHttpClientSingletonTests {
- private static final ConfigurationSource EMPTY_SOURCE = new TestConfigurationSource();
-
- @RegisterExtension
- static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
- .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
- .addClasses(VertxAsyncHttpClientProvider.class));
-
- @Test
- public void testSingletonClientInstanceCreation() {
- Configuration configuration = getConfiguration(true);
- HttpClient client1 = new VertxAsyncHttpClientProvider(configuration).createInstance();
- HttpClient client2 = new VertxAsyncHttpClientProvider(configuration).createInstance();
- assertEquals(client1, client2);
- }
-
- @Test
- public void testNonDefaultClientInstanceCreation() {
- Configuration configuration = getConfiguration(false);
- HttpClient client1 = new VertxAsyncHttpClientProvider(configuration).createInstance();
- HttpClient client2 = new VertxAsyncHttpClientProvider(configuration).createInstance();
- assertNotEquals(client1, client2);
- }
-
- @Test
- public void testCustomizedClientInstanceCreationNotShared() {
- Configuration configuration = getConfiguration(false);
- HttpClientOptions clientOptions = new HttpClientOptions().setMaximumConnectionPoolSize(500);
- HttpClient client1 = new VertxAsyncHttpClientProvider(configuration).createInstance(clientOptions);
- HttpClient client2 = new VertxAsyncHttpClientProvider(configuration).createInstance(clientOptions);
- assertNotEquals(client1, client2);
- }
-
- @Test
- public void testNullHttpClientOptionsInstanceCreation() {
- Configuration configuration = getConfiguration(true);
- HttpClient client1 = new VertxAsyncHttpClientProvider(configuration).createInstance(null);
- HttpClient client2 = new VertxAsyncHttpClientProvider(configuration).createInstance(null);
- assertEquals(client1, client2);
- }
-
- private static Configuration getConfiguration(boolean enableSharing) {
- return new ConfigurationBuilder(EMPTY_SOURCE, EMPTY_SOURCE, new TestConfigurationSource()
- .put("AZURE_ENABLE_HTTP_CLIENT_SHARING", Boolean.toString(enableSharing)))
- .build();
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientTests.java b/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientTests.java
deleted file mode 100644
index dd06d9b864..0000000000
--- a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientTests.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx;
-
-import java.io.OutputStream;
-import java.net.MalformedURLException;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.URL;
-import java.nio.ByteBuffer;
-import java.nio.charset.StandardCharsets;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.time.Duration;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-
-import com.azure.core.http.HttpClient;
-import com.azure.core.http.HttpHeader;
-import com.azure.core.http.HttpHeaders;
-import com.azure.core.http.HttpMethod;
-import com.azure.core.http.HttpRequest;
-import com.azure.core.http.HttpResponse;
-import com.azure.core.util.Context;
-import com.azure.core.util.FluxUtil;
-import com.github.tomakehurst.wiremock.WireMockServer;
-import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
-import io.quarkus.test.QuarkusUnitTest;
-import io.vertx.core.http.HttpClosedException;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
-import reactor.core.scheduler.Schedulers;
-import reactor.test.StepVerifier;
-import reactor.test.StepVerifierOptions;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static org.junit.jupiter.api.Assertions.assertArrayEquals;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertLinesMatch;
-
-public class VertxAsyncHttpClientTests {
- static final String RETURN_HEADERS_AS_IS_PATH = "/returnHeadersAsIs";
- private static final String SHORT_BODY = "hi there";
- private static final String LONG_BODY = createLongBody();
- private static WireMockServer server;
-
- @RegisterExtension
- static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
- .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
- .addClasses(VertxAsyncHttpClientResponseTransformer.class));
-
- @BeforeAll
- public static void beforeAll() {
- server = new WireMockServer(WireMockConfiguration.options()
- .extensions(new VertxAsyncHttpClientResponseTransformer())
- .dynamicPort()
- .disableRequestJournal()
- .gzipDisabled(true));
-
- server.stubFor(get("/short").willReturn(aResponse().withBody(SHORT_BODY)));
- server.stubFor(get("/long").willReturn(aResponse().withBody(LONG_BODY)));
- server.stubFor(get("/error").willReturn(aResponse().withBody("error").withStatus(500)));
- server.stubFor(post("/shortPost").willReturn(aResponse().withBody(SHORT_BODY)));
- server.stubFor(get(RETURN_HEADERS_AS_IS_PATH).willReturn(aResponse()
- .withTransformers(VertxAsyncHttpClientResponseTransformer.NAME)));
- server.stubFor(get("/empty").willReturn(aResponse().withBody(new byte[0])));
- server.start();
- }
-
- @AfterAll
- public static void afterAll() throws Exception {
- if (server != null) {
- server.shutdown();
- }
- }
-
- @Test
- public void testFlowableResponseShortBodyAsByteArrayAsync() {
- checkBodyReceived(SHORT_BODY, "/short");
- }
-
- @Test
- public void testFlowableResponseLongBodyAsByteArrayAsync() {
- checkBodyReceived(LONG_BODY, "/long");
- }
-
- @Test
- public void responseBodyAsStringAsyncWithCharset() {
- HttpClient client = new VertxAsyncHttpClientBuilder().build();
- StepVerifier.create(doRequest(client, "/short").getBodyAsString(StandardCharsets.UTF_8))
- .assertNext(result -> assertEquals(SHORT_BODY, result))
- .verifyComplete();
- }
-
- @Test
- public void testFlowableWhenServerReturnsBodyAndNoErrorsWhenHttp500Returned() {
- HttpResponse response = getResponse("/error");
- assertEquals(500, response.getStatusCode());
- StepVerifier.create(response.getBodyAsString())
- .expectNext("error")
- .expectComplete()
- .verify(Duration.ofSeconds(20));
- }
-
- @Test
- public void testFlowableBackpressure() {
- HttpResponse response = getResponse("/long");
-
- StepVerifierOptions stepVerifierOptions = StepVerifierOptions.create();
- stepVerifierOptions.initialRequest(0);
-
- StepVerifier.create(response.getBody(), stepVerifierOptions)
- .expectNextCount(0)
- .thenRequest(1)
- .expectNextCount(1)
- .thenRequest(3)
- .expectNextCount(3)
- .thenRequest(Long.MAX_VALUE)
- .thenConsumeWhile(ByteBuffer::hasRemaining)
- .verifyComplete();
- }
-
- @Test
- public void testRequestBodyIsErrorShouldPropagateToResponse() {
- HttpClient client = new VertxAsyncHttpClientProvider().createInstance();
- HttpRequest request = new HttpRequest(HttpMethod.POST, url(server, "/shortPost"))
- .setHeader("Content-Length", "123")
- .setBody(Flux.error(new RuntimeException("boo")));
-
- StepVerifier.create(client.send(request))
- .expectErrorMessage("boo")
- .verify();
- }
-
- @Test
- public void testRequestBodyEndsInErrorShouldPropagateToResponse() {
- HttpClient client = new VertxAsyncHttpClientProvider().createInstance();
- String contentChunk = "abcdefgh";
- int repetitions = 1000;
- HttpRequest request = new HttpRequest(HttpMethod.POST, url(server, "/shortPost"))
- .setHeader("Content-Length", String.valueOf(contentChunk.length() * (repetitions + 1)))
- .setBody(Flux.just(contentChunk)
- .repeat(repetitions)
- .map(s -> ByteBuffer.wrap(s.getBytes(StandardCharsets.UTF_8)))
- .concatWith(Flux.error(new RuntimeException("boo"))));
-
- try {
- StepVerifier.create(client.send(request))
- .expectErrorMessage("boo")
- .verify(Duration.ofSeconds(10));
- } catch (Exception ex) {
- assertEquals("boo", ex.getMessage());
- }
- }
-
- @Test
- public void testServerShutsDownSocketShouldPushErrorToContentFlowable() {
- Assertions.assertTimeout(Duration.ofMillis(5000), () -> {
- CountDownLatch latch = new CountDownLatch(1);
- try (ServerSocket ss = new ServerSocket(0)) {
- Mono.fromCallable(() -> {
- latch.countDown();
- Socket socket = ss.accept();
- // give the client time to get request across
- Thread.sleep(500);
- // respond but don't send the complete response
- byte[] bytes = new byte[1024];
- int n = socket.getInputStream().read(bytes);
- String response = "HTTP/1.1 200 OK\r\n"
- + "Content-Type: text/plain\r\n"
- + "Content-Length: 10\r\n"
- + "\r\n" //
- + "zi";
- OutputStream out = socket.getOutputStream();
- out.write(response.getBytes());
- out.flush();
- // kill the socket with HTTP response body incomplete
- socket.close();
- return 1;
- }).subscribeOn(Schedulers.boundedElastic()).subscribe();
- //
- latch.await();
- HttpClient client = new VertxAsyncHttpClientBuilder().build();
- HttpRequest request = new HttpRequest(HttpMethod.GET,
- new URL("http://localhost:" + ss.getLocalPort() + "/ioException"));
-
- StepVerifier.create(client.send(request)
- .flatMap(response -> FluxUtil.collectBytesInByteBufferStream(response.getBody())
- .zipWith(Mono.just(response.getStatusCode()))))
- .expectError(HttpClosedException.class)
- .verify(Duration.ofSeconds(5));
- }
- });
- }
-
- @Test
- public void testConcurrentRequests() throws NoSuchAlgorithmException {
- int numRequests = 100; // 100 = 1GB of data read
- HttpClient client = new VertxAsyncHttpClientProvider().createInstance();
- byte[] expectedDigest = digest(LONG_BODY);
- long expectedByteCount = (long) numRequests * LONG_BODY.getBytes(StandardCharsets.UTF_8).length;
-
- Mono<Long> numBytesMono = Flux.range(1, numRequests)
- .parallel(10)
- .runOn(Schedulers.boundedElastic())
- .flatMap(n -> Mono.fromCallable(() -> getResponse(client, "/long", Context.NONE)).flatMapMany(response -> {
- MessageDigest md = md5Digest();
- return response.getBody()
- .doOnNext(buffer -> md.update(buffer.duplicate()))
- .doOnComplete(() -> assertArrayEquals(expectedDigest, md.digest(), "wrong digest!"));
- }))
- .sequential()
- .map(buffer -> (long) buffer.remaining())
- .reduce(Long::sum);
-
- StepVerifier.create(numBytesMono)
- .expectNext(expectedByteCount)
- .expectComplete()
- .verify(Duration.ofSeconds(60));
- }
-
- @Test
- public void validateHeadersReturnAsIs() {
- HttpClient client = new VertxAsyncHttpClientProvider().createInstance();
-
- final String singleValueHeaderName = "singleValue";
- final String singleValueHeaderValue = "value";
-
- final String multiValueHeaderName = "Multi-value";
- final List<String> multiValueHeaderValue = Arrays.asList("value1", "value2");
-
- HttpHeaders headers = new HttpHeaders()
- .set(singleValueHeaderName, singleValueHeaderValue)
- .set(multiValueHeaderName, multiValueHeaderValue);
-
- StepVerifier.create(client.send(new HttpRequest(HttpMethod.GET, url(server, RETURN_HEADERS_AS_IS_PATH),
- headers, Flux.empty())))
- .assertNext(response -> {
- assertEquals(200, response.getStatusCode());
-
- HttpHeaders responseHeaders = response.getHeaders();
- HttpHeader singleValueHeader = responseHeaders.get(singleValueHeaderName);
- assertEquals(singleValueHeaderName, singleValueHeader.getName());
- assertEquals(singleValueHeaderValue, singleValueHeader.getValue());
-
- HttpHeader multiValueHeader = responseHeaders.get("Multi-value");
- assertEquals(multiValueHeaderName, multiValueHeader.getName());
- assertLinesMatch(multiValueHeaderValue, multiValueHeader.getValuesList());
- })
- .expectComplete()
- .verify(Duration.ofSeconds(10));
- }
-
- @Test
- public void testBufferedResponse() {
- Context context = new Context("azure-eagerly-read-response", true);
- HttpClient client = new VertxAsyncHttpClientBuilder().build();
- HttpResponse response = getResponse(client, "/short", context);
-
- StepVerifier.create(response.getBody())
- .assertNext(buffer -> {
- assertEquals(SHORT_BODY, new String(buffer.array()));
- })
- .verifyComplete();
- }
-
- @Test
- public void testEmptyBufferResponse() {
- HttpResponse response = getResponse("/empty");
-
- StepVerifierOptions stepVerifierOptions = StepVerifierOptions.create();
- stepVerifierOptions.initialRequest(0);
-
- StepVerifier.create(response.getBody(), stepVerifierOptions)
- .expectNextCount(0)
- .thenRequest(1)
- .verifyComplete();
- }
-
- @Test
- public void testEmptyBufferedResponse() {
- Context context = new Context("azure-eagerly-read-response", true);
- HttpClient client = new VertxAsyncHttpClientBuilder().build();
- HttpResponse response = getResponse(client, "/empty", context);
-
- StepVerifierOptions stepVerifierOptions = StepVerifierOptions.create();
- stepVerifierOptions.initialRequest(0);
-
- StepVerifier.create(response.getBody(), stepVerifierOptions)
- .expectNextCount(0)
- .thenRequest(1)
- .verifyComplete();
- }
-
- private static MessageDigest md5Digest() {
- try {
- return MessageDigest.getInstance("MD5");
- } catch (NoSuchAlgorithmException e) {
- throw new RuntimeException(e);
- }
- }
-
- private static byte[] digest(String s) throws NoSuchAlgorithmException {
- MessageDigest md = MessageDigest.getInstance("MD5");
- md.update(s.getBytes(StandardCharsets.UTF_8));
- return md.digest();
- }
-
- private static HttpResponse getResponse(String path) {
- HttpClient client = new VertxAsyncHttpClientBuilder().build();
- return getResponse(client, path, Context.NONE);
- }
-
- private static HttpResponse getResponse(HttpClient client, String path, Context context) {
- HttpRequest request = new HttpRequest(HttpMethod.GET, url(server, path));
- return client.send(request, context).block();
- }
-
- static URL url(WireMockServer server, String path) {
- try {
- return new URL("http://localhost:" + server.port() + path);
- } catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
- }
-
- private static String createLongBody() {
- StringBuilder builder = new StringBuilder("abcdefghijk".length() * 1000000);
- for (int i = 0; i < 1000000; i++) {
- builder.append("abcdefghijk");
- }
-
- return builder.toString();
- }
-
- private void checkBodyReceived(String expectedBody, String path) {
- HttpClient client = new VertxAsyncHttpClientBuilder().build();
- StepVerifier.create(doRequest(client, path).getBodyAsByteArray())
- .assertNext(bytes -> assertEquals(expectedBody, new String(bytes, StandardCharsets.UTF_8)))
- .verifyComplete();
- }
-
- private HttpResponse doRequest(HttpClient client, String path) {
- HttpRequest request = new HttpRequest(HttpMethod.GET, url(server, path));
- return client.send(request).block();
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxHttpClientTestResource.java b/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxHttpClientTestResource.java
deleted file mode 100644
index 2a54ab7783..0000000000
--- a/extensions-support/azure-core-http-client-vertx/deployment/src/test/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxHttpClientTestResource.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
-import org.apache.commons.lang3.SystemUtils;
-import org.testcontainers.containers.GenericContainer;
-import org.testcontainers.containers.wait.strategy.Wait;
-import org.testcontainers.utility.DockerImageName;
-
-public class VertxHttpClientTestResource implements QuarkusTestResourceLifecycleManager {
-
- public static final String PROXY_USER = "admin";
- public static final String PROXY_PASSWORD = "p4ssw0rd";
-
- private static final DockerImageName TINY_PROXY_IMAGE_NAME = DockerImageName.parse("monokal/tinyproxy");
- private static final Integer TINY_PROXY_PORT = 8888;
- private GenericContainer container;
-
- @Override
- public Map<String, String> start() {
- String host;
- int port;
-
- container = new GenericContainer(TINY_PROXY_IMAGE_NAME)
- .withEnv("BASIC_AUTH_USER", PROXY_USER)
- .withEnv("BASIC_AUTH_PASSWORD", PROXY_PASSWORD)
- .withCommand("ANY")
- .waitingFor(Wait.forListeningPort());
-
- if (SystemUtils.IS_OS_LINUX) {
- container.withNetworkMode("host");
- port = TINY_PROXY_PORT;
- host = "localhost";
- } else {
- container.withNetworkMode("bridge")
- .withExposedPorts(TINY_PROXY_PORT);
- port = container.getMappedPort(TINY_PROXY_PORT);
- host = "host.docker.internal";
- }
-
- container.start();
-
- Map<String, String> options = new HashMap<>();
- options.put("tiny.proxy.host", host);
- options.put("tiny.proxy.port", String.valueOf(port));
- return options;
- }
-
- @Override
- public void stop() {
- if (container != null) {
- container.stop();
- }
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/deployment/src/test/resources/upload.txt b/extensions-support/azure-core-http-client-vertx/deployment/src/test/resources/upload.txt
deleted file mode 100644
index ff3bb63948..0000000000
--- a/extensions-support/azure-core-http-client-vertx/deployment/src/test/resources/upload.txt
+++ /dev/null
@@ -1 +0,0 @@
-The quick brown fox jumps over the lazy dog
\ No newline at end of file
diff --git a/extensions-support/azure-core-http-client-vertx/runtime/pom.xml b/extensions-support/azure-core-http-client-vertx/runtime/pom.xml
index 4f3ca842db..1feb279e48 100644
--- a/extensions-support/azure-core-http-client-vertx/runtime/pom.xml
+++ b/extensions-support/azure-core-http-client-vertx/runtime/pom.xml
@@ -47,6 +47,10 @@
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.azure</groupId>
+ <artifactId>azure-core-http-vertx</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-support-azure-core</artifactId>
diff --git a/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/QuarkusVertxProvider.java b/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/QuarkusVertxProvider.java
index e02df4957c..a1225dfa3a 100644
--- a/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/QuarkusVertxProvider.java
+++ b/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/QuarkusVertxProvider.java
@@ -22,6 +22,7 @@ import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.CDI;
+import com.azure.core.http.vertx.VertxProvider;
import io.vertx.core.Vertx;
public class QuarkusVertxProvider implements VertxProvider {
diff --git a/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClient.java b/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClient.java
deleted file mode 100644
index 82e8737aa6..0000000000
--- a/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClient.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx;
-
-import java.nio.ByteBuffer;
-import java.util.Objects;
-
-import com.azure.core.http.HttpClient;
-import com.azure.core.http.HttpHeaders;
-import com.azure.core.http.HttpMethod;
-import com.azure.core.http.HttpRequest;
-import com.azure.core.http.HttpResponse;
-import com.azure.core.util.Context;
-import com.azure.core.util.Contexts;
-import com.azure.core.util.ProgressReporter;
-import io.netty.buffer.Unpooled;
-import io.vertx.core.Vertx;
-import io.vertx.core.buffer.Buffer;
-import io.vertx.core.http.HttpClientRequest;
-import io.vertx.core.http.HttpClientResponse;
-import io.vertx.core.http.RequestOptions;
-import org.apache.camel.quarkus.support.azure.core.http.vertx.implementation.BufferedVertxHttpResponse;
-import org.apache.camel.quarkus.support.azure.core.http.vertx.implementation.VertxHttpAsyncResponse;
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
-import reactor.core.scheduler.Scheduler;
-import reactor.core.scheduler.Schedulers;
-
-/**
- * {@link HttpClient} implementation for the Vert.x {@link io.vertx.core.http.HttpClient}.
- */
-class VertxAsyncHttpClient implements HttpClient {
- private final Scheduler scheduler;
- final io.vertx.core.http.HttpClient client;
-
- /**
- * Constructs a {@link VertxAsyncHttpClient}.
- *
- * @param client The Vert.x {@link io.vertx.core.http.HttpClient}
- */
- VertxAsyncHttpClient(io.vertx.core.http.HttpClient client, Vertx vertx) {
- Objects.requireNonNull(client, "client cannot be null");
- Objects.requireNonNull(vertx, "vertx cannot be null");
- this.client = client;
- this.scheduler = Schedulers.fromExecutor(vertx.nettyEventLoopGroup());
- }
-
- @Override
- public Mono<HttpResponse> send(HttpRequest request) {
- return send(request, Context.NONE);
- }
-
- @Override
- public Mono<HttpResponse> send(HttpRequest request, Context context) {
- boolean eagerlyReadResponse = (boolean) context.getData("azure-eagerly-read-response").orElse(false);
- ProgressReporter progressReporter = Contexts.with(context).getHttpRequestProgressReporter();
- return Mono.create(sink -> toVertxHttpRequest(request).subscribe(vertxHttpRequest -> {
- vertxHttpRequest.exceptionHandler(sink::error);
-
- HttpHeaders requestHeaders = request.getHeaders();
- if (requestHeaders != null) {
- requestHeaders.stream().forEach(header -> vertxHttpRequest.putHeader(header.getName(), header.getValuesList()));
- if (request.getHeaders().get("Content-Length") == null) {
- vertxHttpRequest.setChunked(true);
- }
- } else {
- vertxHttpRequest.setChunked(true);
- }
-
- vertxHttpRequest.response(event -> {
- if (event.succeeded()) {
- HttpClientResponse vertxHttpResponse = event.result();
- vertxHttpResponse.exceptionHandler(sink::error);
-
- if (eagerlyReadResponse) {
- vertxHttpResponse.body(bodyEvent -> {
- if (bodyEvent.succeeded()) {
- sink.success(new BufferedVertxHttpResponse(request, vertxHttpResponse,
- bodyEvent.result()));
- } else {
- sink.error(bodyEvent.cause());
- }
- });
- } else {
- sink.success(new VertxHttpAsyncResponse(request, vertxHttpResponse));
- }
- } else {
- sink.error(event.cause());
- }
- });
-
- getRequestBody(request, progressReporter)
- .subscribeOn(scheduler)
- .map(Unpooled::wrappedBuffer)
- .map(Buffer::buffer)
- .subscribe(vertxHttpRequest::write, sink::error, vertxHttpRequest::end);
- }, sink::error));
- }
-
- private Mono<HttpClientRequest> toVertxHttpRequest(HttpRequest request) {
- HttpMethod httpMethod = request.getHttpMethod();
- io.vertx.core.http.HttpMethod requestMethod = io.vertx.core.http.HttpMethod.valueOf(httpMethod.name());
-
- RequestOptions options = new RequestOptions();
- options.setMethod(requestMethod);
- options.setAbsoluteURI(request.getUrl());
- return Mono.fromCompletionStage(client.request(options).toCompletionStage());
- }
-
- private Flux<ByteBuffer> getRequestBody(HttpRequest request, ProgressReporter progressReporter) {
- Flux<ByteBuffer> body = request.getBody();
- if (body == null) {
- return Flux.empty();
- }
-
- if (progressReporter != null) {
- body = body.map(buffer -> {
- progressReporter.reportProgress(buffer.remaining());
- return buffer;
- });
- }
-
- return body;
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientBuilder.java b/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientBuilder.java
deleted file mode 100644
index 3ec5a59642..0000000000
--- a/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientBuilder.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx;
-
-import java.net.InetSocketAddress;
-import java.time.Duration;
-import java.util.Iterator;
-import java.util.ServiceLoader;
-import java.util.regex.Pattern;
-
-import com.azure.core.http.HttpClient;
-import com.azure.core.http.ProxyOptions;
-import com.azure.core.util.Configuration;
-import com.azure.core.util.CoreUtils;
-import com.azure.core.util.logging.ClientLogger;
-import io.vertx.core.Vertx;
-import io.vertx.core.http.HttpClientOptions;
-import io.vertx.core.net.ProxyType;
-
-import static com.azure.core.util.Configuration.PROPERTY_AZURE_REQUEST_CONNECT_TIMEOUT;
-import static com.azure.core.util.Configuration.PROPERTY_AZURE_REQUEST_READ_TIMEOUT;
-import static com.azure.core.util.Configuration.PROPERTY_AZURE_REQUEST_WRITE_TIMEOUT;
-import static com.azure.core.util.CoreUtils.getDefaultTimeoutFromEnvironment;
-
-/**
- * Builds a {@link VertxAsyncHttpClient}.
- */
-public class VertxAsyncHttpClientBuilder {
- private static final ClientLogger LOGGER = new ClientLogger(VertxAsyncHttpClientBuilder.class);
- private static final Pattern NON_PROXY_HOSTS_SPLIT = Pattern.compile("(?<!\\\\)\\|");
- private static final Pattern NON_PROXY_HOST_DESANITIZE = Pattern.compile("(\\?|\\\\|\\(|\\)|\\\\E|\\\\Q|\\.\\.)");
- private static final Pattern NON_PROXY_HOST_DOT_STAR = Pattern.compile("(\\.\\*)");
- private static final long DEFAULT_CONNECT_TIMEOUT;
- private static final long DEFAULT_WRITE_TIMEOUT;
- private static final long DEFAULT_READ_TIMEOUT;
-
- static {
- Configuration configuration = Configuration.getGlobalConfiguration();
- DEFAULT_CONNECT_TIMEOUT = getDefaultTimeoutFromEnvironment(configuration,
- PROPERTY_AZURE_REQUEST_CONNECT_TIMEOUT, Duration.ofSeconds(10), LOGGER).toMillis();
- DEFAULT_WRITE_TIMEOUT = getDefaultTimeoutFromEnvironment(configuration, PROPERTY_AZURE_REQUEST_WRITE_TIMEOUT,
- Duration.ofSeconds(60), LOGGER).getSeconds();
- DEFAULT_READ_TIMEOUT = getDefaultTimeoutFromEnvironment(configuration, PROPERTY_AZURE_REQUEST_READ_TIMEOUT,
- Duration.ofSeconds(60), LOGGER).getSeconds();
- }
-
- private Duration readIdleTimeout;
- private Duration writeIdleTimeout;
- private Duration connectTimeout;
- private Duration idleTimeout = Duration.ofSeconds(60);
- private ProxyOptions proxyOptions;
- private Configuration configuration;
- private HttpClientOptions httpClientOptions;
- private Vertx vertx;
-
- /**
- * Sets the read idle timeout.
- *
- * The default read idle timeout is 60 seconds.
- *
- * @param readIdleTimeout the read idle timeout
- * @return the updated VertxAsyncHttpClientBuilder object
- */
- public VertxAsyncHttpClientBuilder readIdleTimeout(Duration readIdleTimeout) {
- this.readIdleTimeout = readIdleTimeout;
- return this;
- }
-
- /**
- * Sets the write idle timeout.
- *
- * The default read idle timeout is 60 seconds.
- *
- * @param writeIdleTimeout the write idle timeout
- * @return the updated VertxAsyncHttpClientBuilder object
- */
- public VertxAsyncHttpClientBuilder writeIdleTimeout(Duration writeIdleTimeout) {
- this.writeIdleTimeout = writeIdleTimeout;
- return this;
- }
-
- /**
- * Sets the connect timeout.
- *
- * The default connect timeout is 10 seconds.
- *
- * @param connectTimeout the connection timeout
- * @return the updated VertxAsyncHttpClientBuilder object
- */
- public VertxAsyncHttpClientBuilder connectTimeout(Duration connectTimeout) {
- this.connectTimeout = connectTimeout;
- return this;
- }
-
- /**
- * Sets the connection idle timeout.
- *
- * The default connect timeout is 60 seconds.
- *
- * @param idleTimeout the connection idle timeout
- * @return the updated VertxAsyncHttpClientBuilder object
- */
- public VertxAsyncHttpClientBuilder idleTimeout(Duration idleTimeout) {
- this.idleTimeout = idleTimeout;
- return this;
- }
-
- /**
- * Sets proxy configuration.
- *
- * @param proxyOptions The proxy configuration to use.
- * @return The updated VertxAsyncHttpClientBuilder object.
- */
- public VertxAsyncHttpClientBuilder proxy(ProxyOptions proxyOptions) {
- this.proxyOptions = proxyOptions;
- return this;
- }
-
- /**
- * Sets the configuration store that is used during construction of the HTTP client.
- * <p>
- * The default configuration store is a clone of the
- * {@link Configuration#getGlobalConfiguration() global configuration store}, use {@link Configuration#NONE} to
- * bypass using configuration settings during construction.
- *
- * @param configuration The configuration store.
- * @return The updated VertxAsyncHttpClientBuilder object.
- */
- public VertxAsyncHttpClientBuilder configuration(Configuration configuration) {
- this.configuration = configuration;
- return this;
- }
-
- /**
- * Sets custom {@link HttpClientOptions} for the constructed {@link io.vertx.core.http.HttpClient}.
- *
- * @param httpClientOptions The options of the web client.
- * @return The updated VertxAsyncHttpClientBuilder object
- */
- public VertxAsyncHttpClientBuilder httpClientOptions(HttpClientOptions httpClientOptions) {
- this.httpClientOptions = httpClientOptions;
- return this;
- }
-
- /**
- * Sets a custom {@link Vertx} instance that the constructed {@link io.vertx.core.http.HttpClient} will be created
- * with.
- *
- * @param vertx The vertx instance.
- * @return The updated VertxAsyncHttpClientBuilder object
- */
- public VertxAsyncHttpClientBuilder vertx(Vertx vertx) {
- this.vertx = vertx;
- return this;
- }
-
- /**
- * Creates a new Vert.x {@link HttpClient} instance on every call, using the configuration set in the builder at the
- * time of the build method call.
- *
- * @return A new Vert.x backed {@link HttpClient} instance.
- */
- public HttpClient build() {
- Vertx configuredVertx = this.vertx;
- if (configuredVertx == null) {
- ServiceLoader<VertxProvider> vertxProviders = ServiceLoader.load(VertxProvider.class,
- VertxProvider.class.getClassLoader());
- Iterator<VertxProvider> iterator = vertxProviders.iterator();
- if (iterator.hasNext()) {
- VertxProvider provider = iterator.next();
- configuredVertx = provider.createVertx();
- LOGGER.verbose("Using {} as the VertxProvider.", provider.getClass().getName());
-
- while (iterator.hasNext()) {
- VertxProvider ignoredProvider = iterator.next();
- LOGGER.warning("Multiple VertxProviders were found on the classpath, ignoring {}.",
- ignoredProvider.getClass().getName());
- }
- } else {
- throw new RuntimeException("Unable to find usable Vertx instance");
- }
- }
-
- if (this.httpClientOptions == null) {
- this.httpClientOptions = new HttpClientOptions();
-
- if (this.connectTimeout != null) {
- this.httpClientOptions.setConnectTimeout((int) this.connectTimeout.toMillis());
- } else {
- this.httpClientOptions.setConnectTimeout((int) DEFAULT_CONNECT_TIMEOUT);
- }
-
- if (this.readIdleTimeout != null) {
- this.httpClientOptions.setReadIdleTimeout((int) this.readIdleTimeout.getSeconds());
- } else {
- this.httpClientOptions.setReadIdleTimeout((int) DEFAULT_READ_TIMEOUT);
- }
-
- if (this.writeIdleTimeout != null) {
- this.httpClientOptions.setWriteIdleTimeout((int) this.writeIdleTimeout.getSeconds());
- } else {
- this.httpClientOptions.setWriteIdleTimeout((int) DEFAULT_WRITE_TIMEOUT);
- }
-
- this.httpClientOptions.setIdleTimeout((int) this.idleTimeout.getSeconds());
-
- Configuration buildConfiguration = (this.configuration == null)
- ? Configuration.getGlobalConfiguration()
- : configuration;
-
- ProxyOptions buildProxyOptions = (this.proxyOptions == null)
- ? ProxyOptions.fromConfiguration(buildConfiguration, true)
- : this.proxyOptions;
-
- if (buildProxyOptions != null) {
- io.vertx.core.net.ProxyOptions vertxProxyOptions = new io.vertx.core.net.ProxyOptions();
- InetSocketAddress proxyAddress = buildProxyOptions.getAddress();
-
- if (proxyAddress != null) {
- vertxProxyOptions.setHost(proxyAddress.getHostName());
- vertxProxyOptions.setPort(proxyAddress.getPort());
- }
-
- String proxyUsername = buildProxyOptions.getUsername();
- String proxyPassword = buildProxyOptions.getPassword();
- if (!CoreUtils.isNullOrEmpty(proxyUsername) && !CoreUtils.isNullOrEmpty(proxyPassword)) {
- vertxProxyOptions.setUsername(proxyUsername);
- vertxProxyOptions.setPassword(proxyPassword);
- }
-
- ProxyOptions.Type type = buildProxyOptions.getType();
- if (type != null) {
- try {
- ProxyType proxyType = ProxyType.valueOf(type.name());
- vertxProxyOptions.setType(proxyType);
- } catch (IllegalArgumentException e) {
- throw LOGGER.logExceptionAsError(
- new IllegalArgumentException("Unknown Vert.x proxy type: " + type.name(), e));
- }
- }
-
- String nonProxyHosts = buildProxyOptions.getNonProxyHosts();
- if (!CoreUtils.isNullOrEmpty(nonProxyHosts)) {
- for (String nonProxyHost : desanitizedNonProxyHosts(nonProxyHosts)) {
- this.httpClientOptions.addNonProxyHost(nonProxyHost);
- }
- }
-
- this.httpClientOptions.setProxyOptions(vertxProxyOptions);
- }
- }
-
- io.vertx.core.http.HttpClient client = configuredVertx.createHttpClient(this.httpClientOptions);
- return new VertxAsyncHttpClient(client, configuredVertx);
- }
-
- /**
- * Reverses non proxy host string sanitization applied by {@link ProxyOptions}.
- *
- * This is necessary as Vert.x will apply its own sanitization logic.
- *
- * @param nonProxyHosts The list of non proxy hosts
- * @return String array of desanitized proxy host strings
- */
- private String[] desanitizedNonProxyHosts(String nonProxyHosts) {
- String desanitzedNonProxyHosts = NON_PROXY_HOST_DESANITIZE.matcher(nonProxyHosts)
- .replaceAll("");
-
- desanitzedNonProxyHosts = NON_PROXY_HOST_DOT_STAR.matcher(desanitzedNonProxyHosts)
- .replaceAll("*");
-
- return NON_PROXY_HOSTS_SPLIT.split(desanitzedNonProxyHosts);
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientProvider.java b/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientProvider.java
deleted file mode 100644
index 83a3fd5d79..0000000000
--- a/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxAsyncHttpClientProvider.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx;
-
-import com.azure.core.http.HttpClient;
-import com.azure.core.http.HttpClientProvider;
-import com.azure.core.util.Configuration;
-import com.azure.core.util.HttpClientOptions;
-
-/**
- * {@link HttpClientProvider} backed by the Vert.x {@link io.vertx.core.http.HttpClient}
- */
-public class VertxAsyncHttpClientProvider implements HttpClientProvider {
- private static final boolean AZURE_ENABLE_HTTP_CLIENT_SHARING = Configuration.getGlobalConfiguration()
- .get("AZURE_ENABLE_HTTP_CLIENT_SHARING", Boolean.FALSE);
- private final boolean enableHttpClientSharing;
-
- // Enum Singleton Pattern
- private enum GlobalVertxHttpClient {
- HTTP_CLIENT(new VertxAsyncHttpClientBuilder().build());
-
- private final HttpClient httpClient;
-
- GlobalVertxHttpClient(HttpClient httpClient) {
- this.httpClient = httpClient;
- }
-
- private HttpClient getHttpClient() {
- return httpClient;
- }
- }
-
- /**
- * For testing purpose only, assigning 'AZURE_ENABLE_HTTP_CLIENT_SHARING' to 'enableHttpClientSharing' for
- * 'final' modifier.
- */
- public VertxAsyncHttpClientProvider() {
- enableHttpClientSharing = AZURE_ENABLE_HTTP_CLIENT_SHARING;
- }
-
- VertxAsyncHttpClientProvider(Configuration configuration) {
- enableHttpClientSharing = configuration.get("AZURE_ENABLE_HTTP_CLIENT_SHARING", Boolean.FALSE);
- }
-
- @Override
- public HttpClient createInstance() {
- if (enableHttpClientSharing) {
- return GlobalVertxHttpClient.HTTP_CLIENT.getHttpClient();
- }
- return new VertxAsyncHttpClientBuilder().build();
- }
-
- @Override
- public HttpClient createInstance(HttpClientOptions clientOptions) {
- if (clientOptions == null) {
- return createInstance();
- }
-
- return new VertxAsyncHttpClientBuilder()
- .proxy(clientOptions.getProxyOptions())
- .configuration(clientOptions.getConfiguration())
- .connectTimeout(clientOptions.getConnectTimeout())
- .idleTimeout(clientOptions.getConnectionIdleTimeout())
- .writeIdleTimeout(clientOptions.getWriteTimeout())
- .readIdleTimeout(clientOptions.getReadTimeout())
- .build();
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxProvider.java b/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxProvider.java
deleted file mode 100644
index f7f881e832..0000000000
--- a/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/VertxProvider.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx;
-
-import io.vertx.core.Vertx;
-
-/**
- * Service provider interface providing platforms and applications the means to have their own managed
- * {@link Vertx} be resolved by the {@link VertxAsyncHttpClientBuilder}.
- */
-public interface VertxProvider {
-
- /**
- * Creates a {@link Vertx}. Could either be the result of returning {@code Vertx.vertx()},
- * or returning a {@link Vertx} that was resolved from a dependency injection framework like Spring or CDI.
- *
- * @return The created {@link Vertx}.
- */
- Vertx createVertx();
-}
diff --git a/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/implementation/BufferedVertxHttpResponse.java b/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/implementation/BufferedVertxHttpResponse.java
deleted file mode 100644
index bb26009d6e..0000000000
--- a/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/implementation/BufferedVertxHttpResponse.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx.implementation;
-
-import java.nio.ByteBuffer;
-
-import com.azure.core.http.HttpRequest;
-import com.azure.core.http.HttpResponse;
-import com.azure.core.util.BinaryData;
-import io.vertx.core.buffer.Buffer;
-import io.vertx.core.http.HttpClientResponse;
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
-
-public final class BufferedVertxHttpResponse extends VertxHttpAsyncResponse {
- private final Buffer body;
-
- public BufferedVertxHttpResponse(HttpRequest azureHttpRequest, HttpClientResponse vertxHttpResponse, Buffer body) {
- super(azureHttpRequest, vertxHttpResponse);
- this.body = body;
- }
-
- @Override
- public BinaryData getBodyAsBinaryData() {
- return BinaryData.fromBytes(body.getBytes());
- }
-
- @Override
- public Flux<ByteBuffer> getBody() {
- return Flux.defer(() -> {
- if (this.body.length() == 0) {
- return Flux.empty();
- }
- return Flux.just(ByteBuffer.wrap(this.body.getBytes()));
- });
- }
-
- @Override
- public Mono<byte[]> getBodyAsByteArray() {
- return Mono.defer(() -> {
- if (this.body.length() == 0) {
- return Mono.empty();
- }
- return Mono.just(this.body.getBytes());
- });
- }
-
- @Override
- public HttpResponse buffer() {
- return this;
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/implementation/VertxHttpAsyncResponse.java b/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/implementation/VertxHttpAsyncResponse.java
deleted file mode 100644
index e872b0826f..0000000000
--- a/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/implementation/VertxHttpAsyncResponse.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx.implementation;
-
-import java.nio.ByteBuffer;
-
-import com.azure.core.http.HttpRequest;
-import com.azure.core.util.FluxUtil;
-import io.vertx.core.http.HttpClientResponse;
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
-
-/**
- * Default HTTP response for Vert.x.
- */
-public class VertxHttpAsyncResponse extends VertxHttpResponseBase {
- public VertxHttpAsyncResponse(HttpRequest azureHttpRequest, HttpClientResponse vertxHttpResponse) {
- super(azureHttpRequest, vertxHttpResponse);
- vertxHttpResponse.pause();
- }
-
- @Override
- public Flux<ByteBuffer> getBody() {
- return streamResponseBody();
- }
-
- @Override
- public Mono<byte[]> getBodyAsByteArray() {
- return FluxUtil.collectBytesFromNetworkResponse(streamResponseBody(), getHeaders())
- .flatMap(bytes -> (bytes == null || bytes.length == 0)
- ? Mono.empty()
- : Mono.just(bytes));
- }
-
- private Flux<ByteBuffer> streamResponseBody() {
- HttpClientResponse vertxHttpResponse = getVertxHttpResponse();
- return Flux.create(sink -> {
- vertxHttpResponse.handler(buffer -> {
- sink.next(buffer.getByteBuf().nioBuffer());
- }).endHandler(event -> {
- sink.complete();
- }).exceptionHandler(sink::error);
-
- vertxHttpResponse.resume();
- });
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/implementation/VertxHttpResponseBase.java b/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/implementation/VertxHttpResponseBase.java
deleted file mode 100644
index a6b5938156..0000000000
--- a/extensions-support/azure-core-http-client-vertx/runtime/src/main/java/org/apache/camel/quarkus/support/azure/core/http/vertx/implementation/VertxHttpResponseBase.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.support.azure.core.http.vertx.implementation;
-
-import java.nio.charset.Charset;
-
-import com.azure.core.http.HttpHeaders;
-import com.azure.core.http.HttpRequest;
-import com.azure.core.http.HttpResponse;
-import com.azure.core.util.CoreUtils;
-import io.vertx.core.MultiMap;
-import io.vertx.core.http.HttpClientResponse;
-import reactor.core.publisher.Mono;
-
-abstract class VertxHttpResponseBase extends HttpResponse {
-
- private final HttpClientResponse vertxHttpResponse;
- private final HttpHeaders headers;
-
- VertxHttpResponseBase(HttpRequest azureHttpRequest, HttpClientResponse vertxHttpResponse) {
- super(azureHttpRequest);
- this.vertxHttpResponse = vertxHttpResponse;
- this.headers = fromVertxHttpHeaders(vertxHttpResponse.headers());
- }
-
- private HttpHeaders fromVertxHttpHeaders(MultiMap headers) {
- HttpHeaders azureHeaders = new HttpHeaders();
- headers.names().forEach(name -> azureHeaders.set(name, headers.getAll(name)));
- return azureHeaders;
- }
-
- protected HttpClientResponse getVertxHttpResponse() {
- return this.vertxHttpResponse;
- }
-
- @Override
- public int getStatusCode() {
- return this.vertxHttpResponse.statusCode();
- }
-
- @Override
- public String getHeaderValue(String name) {
- return this.headers.getValue(name);
- }
-
- @Override
- public HttpHeaders getHeaders() {
- return this.headers;
- }
-
- @Override
- public final Mono<String> getBodyAsString() {
- return getBodyAsByteArray().map(bytes -> CoreUtils.bomAwareToString(bytes, getHeaderValue("Content-Type")));
- }
-
- @Override
- public final Mono<String> getBodyAsString(Charset charset) {
- return getBodyAsByteArray().map(bytes -> CoreUtils.bomAwareToString(bytes, charset.toString()));
- }
-}
diff --git a/extensions-support/azure-core-http-client-vertx/runtime/src/main/resources/META-INF/services/com.azure.core.http.HttpClientProvider b/extensions-support/azure-core-http-client-vertx/runtime/src/main/resources/META-INF/services/com.azure.core.http.HttpClientProvider
deleted file mode 100644
index 98565fba0c..0000000000
--- a/extensions-support/azure-core-http-client-vertx/runtime/src/main/resources/META-INF/services/com.azure.core.http.HttpClientProvider
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.camel.quarkus.support.azure.core.http.vertx.VertxAsyncHttpClientProvider
\ No newline at end of file
diff --git a/extensions-support/azure-core-http-client-vertx/runtime/src/main/resources/META-INF/services/org.apache.camel.quarkus.support.azure.core.http.vertx.VertxProvider b/extensions-support/azure-core-http-client-vertx/runtime/src/main/resources/META-INF/services/com.azure.core.http.vertx.VertxProvider
similarity index 100%
rename from extensions-support/azure-core-http-client-vertx/runtime/src/main/resources/META-INF/services/org.apache.camel.quarkus.support.azure.core.http.vertx.VertxProvider
rename to extensions-support/azure-core-http-client-vertx/runtime/src/main/resources/META-INF/services/com.azure.core.http.vertx.VertxProvider
diff --git a/integration-test-groups/azure/azure-storage-blob/src/main/resources/application.properties b/integration-test-groups/azure/azure-storage-blob/src/main/resources/application.properties
index 23c1c40c23..128423dca1 100644
--- a/integration-test-groups/azure/azure-storage-blob/src/main/resources/application.properties
+++ b/integration-test-groups/azure/azure-storage-blob/src/main/resources/application.properties
@@ -22,4 +22,4 @@ azurite.storage.account.name = devstoreaccount1
azurite.storage.account.key = Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
azure.storage.account-name = ${AZURE_STORAGE_ACCOUNT_NAME:${azurite.storage.account.name}}
-azure.storage.account-key = ${AZURE_STORAGE_ACCOUNT_KEY:${azurite.storage.account.key}}
+azure.storage.account-key = ${AZURE_STORAGE_ACCOUNT_KEY:${azurite.storage.account.key}}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 1de47d046d..a4bb58fe54 100644
--- a/pom.xml
+++ b/pom.xml
@@ -75,6 +75,7 @@
<azure-core.version>1.32.0</azure-core.version><!-- @sync com.azure:azure-sdk-bom:${azure-sdk-bom.version} dep:com.azure:azure-core -->
<azure-core-test.version>1.11.0</azure-core-test.version>
<azure-identity.version>1.6.0</azure-identity.version><!-- @sync com.azure:azure-sdk-bom:${azure-sdk-bom.version} dep:com.azure:azure-identity -->
+ <azure-core-http-vertx.version>1.0.0-beta.1</azure-core-http-vertx.version> <!-- TODO: https://github.com/apache/camel-quarkus/issues/4181 -->
<cassandra-driver-test.version>3.7.1</cassandra-driver-test.version><!-- Keep in sync with testcontainers instead of Debezium bom -->
<bouncycastle.version>1.70</bouncycastle.version><!-- @sync io.quarkus:quarkus-bom:${quarkus.version} dep:org.bouncycastle:bcprov-jdk15on -->
<caffeine.version>2.9.3</caffeine.version><!-- @sync io.quarkus:quarkus-bom:${quarkus.version} dep:com.github.ben-manes.caffeine:caffeine -->
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index 11b70d43c7..92324f0cd0 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -9858,6 +9858,12 @@
</exclusion>
</exclusions>
</dependency>
+ <!-- TODO: Remove this when azure-core-http-vertx is part of azure-sdk-bom https://github.com/apache/camel-quarkus/issues/4181 -->
+ <dependency>
+ <groupId>com.azure</groupId>
+ <artifactId>azure-core-http-vertx</artifactId>
+ <version>${azure-core-http-vertx.version}</version>
+ </dependency>
<dependency>
<groupId>com.esotericsoftware.kryo</groupId>
<artifactId>kryo</artifactId>
diff --git a/poms/bom/src/main/generated/flattened-full-pom.xml b/poms/bom/src/main/generated/flattened-full-pom.xml
index 352dbb2966..e9f57f63cd 100644
--- a/poms/bom/src/main/generated/flattened-full-pom.xml
+++ b/poms/bom/src/main/generated/flattened-full-pom.xml
@@ -9793,6 +9793,11 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>com.azure</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <artifactId>azure-core-http-vertx</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <version>1.0.0-beta.1</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ </dependency>
<dependency>
<groupId>com.esotericsoftware.kryo</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<artifactId>kryo</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
diff --git a/poms/bom/src/main/generated/flattened-reduced-pom.xml b/poms/bom/src/main/generated/flattened-reduced-pom.xml
index ee72a49e7e..be094bd327 100644
--- a/poms/bom/src/main/generated/flattened-reduced-pom.xml
+++ b/poms/bom/src/main/generated/flattened-reduced-pom.xml
@@ -9793,6 +9793,11 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>com.azure</groupId>
+ <artifactId>azure-core-http-vertx</artifactId>
+ <version>1.0.0-beta.1</version>
+ </dependency>
<dependency>
<groupId>com.esotericsoftware.kryo</groupId>
<artifactId>kryo</artifactId>
diff --git a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
index 80a54b1afb..f21313e1a9 100644
--- a/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
+++ b/poms/bom/src/main/generated/flattened-reduced-verbose-pom.xml
@@ -9793,6 +9793,11 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>com.azure</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <artifactId>azure-core-http-vertx</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ <version>1.0.0-beta.1</version><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
+ </dependency>
<dependency>
<groupId>com.esotericsoftware.kryo</groupId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->
<artifactId>kryo</artifactId><!-- org.apache.camel.quarkus:camel-quarkus-bom:${project.version} -->