oscerd commented on code in PR #28563:
URL: https://github.com/apache/camel/pull/28563#discussion_r4399345006


##########
components/camel-aws/camel-aws-common/src/test/java/org/apache/camel/component/aws/common/AwsClientBuilderUtilTest.java:
##########
@@ -0,0 +1,162 @@
+/*
+ * 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.component.aws.common;
+
+import java.util.ServiceConfigurationError;
+
+import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
+import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
+import software.amazon.awssdk.core.Protocol;
+import software.amazon.awssdk.core.SdkSystemSetting;
+import software.amazon.awssdk.core.exception.SdkClientException;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.sts.StsAsyncClient;
+import software.amazon.awssdk.services.sts.StsClient;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/**
+ * The test resources register {@link ForeignHttpService} as a sync and an 
async HTTP client implementation of the AWS
+ * SDK, which it is not. The SDK lookup of the HTTP client on the classpath 
then fails, as when a Kafka Connect plugin
+ * sees the registrations of the AWS SDK of the worker.
+ */
+class AwsClientBuilderUtilTest {
+
+    private static final AwsCommonConfiguration CONFIGURATION = new 
StaticCredentialsConfiguration();
+
+    @Test
+    void sdkLookupFailsOnTheForeignRegistration() {
+        StaticCredentialsProvider credentials
+                = 
StaticCredentialsProvider.create(AwsBasicCredentials.create("accessKey", 
"secretKey"));
+
+        assertThatThrownBy(() -> 
StsClient.builder().region(Region.US_EAST_1).credentialsProvider(credentials).build())
+                .isInstanceOf(ServiceConfigurationError.class)
+                .hasMessageContaining("not a subtype");
+        assertThatThrownBy(() -> 
StsAsyncClient.builder().region(Region.US_EAST_1).credentialsProvider(credentials).build())
+                .isInstanceOf(ServiceConfigurationError.class)
+                .hasMessageContaining("not a subtype");
+    }
+
+    @Test
+    void buildClientDoesNotUseTheSdkLookup() {
+        try (StsClient client = 
AwsClientBuilderUtil.buildClient(CONFIGURATION, StsClient::builder)) {
+            assertThat(client).isNotNull();
+        }
+    }
+
+    @Test
+    void buildAsyncClientDoesNotUseTheSdkLookup() {
+        try (StsAsyncClient client = 
AwsClientBuilderUtil.buildAsyncClient(CONFIGURATION, StsAsyncClient::builder)) {
+            assertThat(client).isNotNull();
+        }
+    }
+
+    @Test
+    void sdkSettingLeavesTheChoiceToTheSdk() {
+        // the SDK fails to load the implementation the setting names, so 
Camel did not set its own HTTP client
+        String property = SdkSystemSetting.SYNC_HTTP_SERVICE_IMPL.property();
+        System.setProperty(property, 
"org.apache.camel.component.aws.common.MissingHttpService");

Review Comment:
   Added `sdkAsyncSettingLeavesTheChoiceToTheSdk` in `AwsClientBuilderUtilTest` 
to cover the async override path.
   
   _Claude Code on behalf of oscerd_



##########
docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc:
##########
@@ -307,6 +307,19 @@ closed that client for every other endpoint.
 Camel now closes only the clients it created. A client set with 
`amazonKinesisClient` or `amazonKinesisAsyncClient`, on
 the component or on an endpoint, is no longer closed when Camel stops: close 
it yourself when you no longer need it.
 
+=== camel-aws - the HTTP client is no longer looked up on the classpath
+
+The camel-aws components now set the HTTP client of the AWS SDK clients they 
create: the Apache 5 client

Review Comment:
   Updated the upgrade guide note to specifically state that the configuration 
applies to the AWS SDK clients the components create for their endpoints.
   
   _Claude Code on behalf of oscerd_



##########
components/camel-aws/camel-aws-common/src/test/java/org/apache/camel/component/aws/common/AwsClientBuilderUtilTest.java:
##########
@@ -0,0 +1,162 @@
+/*
+ * 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.component.aws.common;
+
+import java.util.ServiceConfigurationError;
+
+import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
+import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
+import software.amazon.awssdk.core.Protocol;
+import software.amazon.awssdk.core.SdkSystemSetting;
+import software.amazon.awssdk.core.exception.SdkClientException;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.sts.StsAsyncClient;
+import software.amazon.awssdk.services.sts.StsClient;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+/**
+ * The test resources register {@link ForeignHttpService} as a sync and an 
async HTTP client implementation of the AWS
+ * SDK, which it is not. The SDK lookup of the HTTP client on the classpath 
then fails, as when a Kafka Connect plugin
+ * sees the registrations of the AWS SDK of the worker.
+ */
+class AwsClientBuilderUtilTest {
+
+    private static final AwsCommonConfiguration CONFIGURATION = new 
StaticCredentialsConfiguration();
+
+    @Test
+    void sdkLookupFailsOnTheForeignRegistration() {
+        StaticCredentialsProvider credentials
+                = 
StaticCredentialsProvider.create(AwsBasicCredentials.create("accessKey", 
"secretKey"));
+
+        assertThatThrownBy(() -> 
StsClient.builder().region(Region.US_EAST_1).credentialsProvider(credentials).build())
+                .isInstanceOf(ServiceConfigurationError.class)
+                .hasMessageContaining("not a subtype");
+        assertThatThrownBy(() -> 
StsAsyncClient.builder().region(Region.US_EAST_1).credentialsProvider(credentials).build())
+                .isInstanceOf(ServiceConfigurationError.class)
+                .hasMessageContaining("not a subtype");
+    }
+
+    @Test
+    void buildClientDoesNotUseTheSdkLookup() {
+        try (StsClient client = 
AwsClientBuilderUtil.buildClient(CONFIGURATION, StsClient::builder)) {
+            assertThat(client).isNotNull();
+        }
+    }
+
+    @Test
+    void buildAsyncClientDoesNotUseTheSdkLookup() {
+        try (StsAsyncClient client = 
AwsClientBuilderUtil.buildAsyncClient(CONFIGURATION, StsAsyncClient::builder)) {
+            assertThat(client).isNotNull();
+        }
+    }
+
+    @Test
+    void sdkSettingLeavesTheChoiceToTheSdk() {

Review Comment:
   Added the async test counterpart in `AwsClientBuilderUtilTest`.
   
   _Claude Code on behalf of oscerd_



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to