dpaani commented on code in PR #7066:
URL: https://github.com/apache/iceberg/pull/7066#discussion_r1136433472


##########
aws/src/test/java/org/apache/iceberg/aws/TestAwsClientFactories.java:
##########
@@ -132,6 +136,41 @@ public void 
testLakeFormationAwsClientFactorySerializable() throws IOException {
         .isInstanceOf(LakeFormationAwsClientFactory.class);
   }
 
+  @Test
+  public void testDefaultAwsClientFactoryWithCredentialsProvider() {
+    Map<String, String> properties = Maps.newHashMap();
+    properties.put(AwsProperties.AWS_REGION, Region.AWS_GLOBAL.toString());
+    properties.put(
+        AwsProperties.S3FILEIO_CREDENTIALS_PROVIDER,
+        SystemPropertyCredentialsProvider.class.getName());
+
+    AwsClientFactory defaultAwsClientFactory = 
AwsClientFactories.from(properties);
+    Assertions.assertThat(defaultAwsClientFactory)
+        .isInstanceOf(AwsClientFactories.DefaultAwsClientFactory.class);
+
+    try (S3Client s3Client = defaultAwsClientFactory.s3()) {
+      Assertions.assertThat(s3Client != null);
+      URL url =
+          s3Client
+              .utilities()
+              
.getUrl(GetUrlRequest.builder().bucket("test-bucket").key("test-key").build());
+      Assert.assertTrue(
+          url != null && 
url.toString().equals("https://test-bucket.s3.amazonaws.com/test-key";));
+    }
+  }
+
+  @Test
+  public void testDefaultAwsClientFactoryWithInvalidCredentialsProvider() {
+    Map<String, String> properties = Maps.newHashMap();
+    properties.put(AwsProperties.AWS_REGION, Region.AWS_GLOBAL.toString());
+    properties.put(AwsProperties.S3FILEIO_CREDENTIALS_PROVIDER, 
"invalidClassName");
+    AssertHelpers.assertThrows(
+        "Should fail if invalid credentials provider set",
+        IllegalArgumentException.class,
+        "The creation of an instance of invalidClassName failed",
+        () -> AwsClientFactories.from(properties).s3().close());

Review Comment:
   Thanks. I replaced it with your suggestion. Please check



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to