Skip to content

Commit

Permalink
Add test for applyClientConfiguration from ADLSFileIO
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcnc committed Dec 19, 2024
1 parent f9e6059 commit b86d376
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.iceberg.azure.adlsv2;

import static org.apache.iceberg.azure.AzureProperties.ADLS_SAS_TOKEN_PREFIX;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
Expand All @@ -32,13 +33,15 @@
import com.azure.core.http.rest.Response;
import com.azure.storage.file.datalake.DataLakeFileClient;
import com.azure.storage.file.datalake.DataLakeFileSystemClient;
import com.azure.storage.file.datalake.DataLakeFileSystemClientBuilder;
import com.azure.storage.file.datalake.models.PathItem;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.time.OffsetDateTime;
import java.util.Iterator;
import org.apache.iceberg.TestHelpers;
import org.apache.iceberg.azure.AzureProperties;
import org.apache.iceberg.io.FileIO;
import org.apache.iceberg.io.FileInfo;
import org.apache.iceberg.io.InputFile;
Expand Down Expand Up @@ -100,6 +103,21 @@ public void testGetClient() {
assertThat(client.exists()).isTrue();
}

@Test
public void testApplyClientConfigurationWithSas() {
AzureProperties props =
spy(
new AzureProperties(
ImmutableMap.of(
ADLS_SAS_TOKEN_PREFIX + "account.dfs.core.windows.net", "sasToken")));
ADLSFileIO io = spy(new ADLSFileIO(props));
String location = AZURITE_CONTAINER.location("path/to/file");
io.client(location);
verify(props)
.applyClientConfiguration(
eq("account.dfs.core.windows.net"), any(DataLakeFileSystemClientBuilder.class));
}

/** Azurite does not support ADLSv2 directory operations yet so use mocks here. */
@SuppressWarnings("unchecked")
@Test
Expand Down

0 comments on commit b86d376

Please sign in to comment.