This is an automated email from the ASF dual-hosted git repository.
etudenhoefner pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/master by this push:
new d5ec74306e AWS: Switch tests to JUnit5 (#7957)
d5ec74306e is described below
commit d5ec74306e6013a45ad2485eaa764f4b6f9d44cd
Author: Song Minseok <[email protected]>
AuthorDate: Mon Jul 3 19:06:52 2023 +0900
AWS: Switch tests to JUnit5 (#7957)
---
.../apache/iceberg/aws/TestAwsClientFactories.java | 24 +++--
.../org/apache/iceberg/aws/TestAwsProperties.java | 92 +++++++++----------
.../iceberg/aws/TestHttpClientConfigurations.java | 2 +-
.../apache/iceberg/aws/TestRESTSigV4Signer.java | 14 +--
.../iceberg/aws/dynamodb/TestDynamoDbCatalog.java | 6 +-
.../apache/iceberg/aws/glue/TestGlueCatalog.java | 82 ++++++++---------
.../aws/glue/TestGlueToIcebergConverter.java | 7 +-
.../aws/glue/TestIcebergToGlueConverter.java | 100 +++++++++++----------
.../apache/iceberg/aws/s3/TestS3RequestUtil.java | 44 ++++-----
.../java/org/apache/iceberg/aws/s3/TestS3URI.java | 2 +-
.../aws/s3/signer/TestS3SignRequestParser.java | 2 +-
.../aws/s3/signer/TestS3SignResponseParser.java | 2 +-
.../apache/iceberg/aws/util/TestRetryDetector.java | 56 +++++++-----
13 files changed, 218 insertions(+), 215 deletions(-)
diff --git
a/aws/src/test/java/org/apache/iceberg/aws/TestAwsClientFactories.java
b/aws/src/test/java/org/apache/iceberg/aws/TestAwsClientFactories.java
index 8b4f46a23a..8b19d339a7 100644
--- a/aws/src/test/java/org/apache/iceberg/aws/TestAwsClientFactories.java
+++ b/aws/src/test/java/org/apache/iceberg/aws/TestAwsClientFactories.java
@@ -29,8 +29,7 @@ import
org.apache.iceberg.relocated.com.google.common.collect.Maps;
import org.apache.iceberg.util.SerializationUtil;
import org.assertj.core.api.Assertions;
import org.assertj.core.api.ThrowableAssert;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentials;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
@@ -45,23 +44,22 @@ public class TestAwsClientFactories {
@Test
public void testLoadDefault() {
- Assert.assertEquals(
- "default client should be singleton",
- AwsClientFactories.defaultFactory(),
- AwsClientFactories.defaultFactory());
-
- Assert.assertTrue(
- "should load default when not configured",
- AwsClientFactories.from(Maps.newHashMap())
- instanceof AwsClientFactories.DefaultAwsClientFactory);
+ Assertions.assertThat(AwsClientFactories.defaultFactory())
+ .as("default client should be singleton")
+ .isSameAs(AwsClientFactories.defaultFactory());
+
+ Assertions.assertThat(AwsClientFactories.from(Maps.newHashMap()))
+ .as("should load default when not configured")
+ .isInstanceOf(AwsClientFactories.DefaultAwsClientFactory.class);
}
@Test
public void testLoadCustom() {
Map<String, String> properties = Maps.newHashMap();
properties.put(AwsProperties.CLIENT_FACTORY,
CustomFactory.class.getName());
- Assert.assertTrue(
- "should load custom class", AwsClientFactories.from(properties)
instanceof CustomFactory);
+ Assertions.assertThat(AwsClientFactories.from(properties))
+ .as("should load custom class")
+ .isInstanceOf(CustomFactory.class);
}
@Test
diff --git a/aws/src/test/java/org/apache/iceberg/aws/TestAwsProperties.java
b/aws/src/test/java/org/apache/iceberg/aws/TestAwsProperties.java
index 0ea57a4663..556968ec22 100644
--- a/aws/src/test/java/org/apache/iceberg/aws/TestAwsProperties.java
+++ b/aws/src/test/java/org/apache/iceberg/aws/TestAwsProperties.java
@@ -28,8 +28,7 @@ import org.apache.iceberg.aws.s3.signer.S3V4RestSignerClient;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
import org.assertj.core.api.Assertions;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
@@ -72,7 +71,7 @@ public class TestAwsProperties {
Map<String, String> map = Maps.newHashMap();
map.put(AwsProperties.S3FILEIO_ACL,
ObjectCannedACL.AUTHENTICATED_READ.toString());
AwsProperties properties = new AwsProperties(map);
- Assert.assertEquals(ObjectCannedACL.AUTHENTICATED_READ,
properties.s3FileIoAcl());
+
Assertions.assertThat(properties.s3FileIoAcl()).isEqualTo(ObjectCannedACL.AUTHENTICATED_READ);
}
@Test
@@ -148,9 +147,9 @@ public class TestAwsProperties {
Mockito.verify(mockS3ClientBuilder).credentialsProvider(awsCredentialsProviderCaptor.capture());
AwsCredentialsProvider capturedAwsCredentialsProvider =
awsCredentialsProviderCaptor.getValue();
- Assert.assertTrue(
- "Should use default credentials if nothing is set",
- capturedAwsCredentialsProvider instanceof DefaultCredentialsProvider);
+ Assertions.assertThat(capturedAwsCredentialsProvider)
+ .as("Should use default credentials if nothing is set")
+ .isInstanceOf(DefaultCredentialsProvider.class);
}
@Test
@@ -168,17 +167,16 @@ public class TestAwsProperties {
Mockito.verify(mockS3ClientBuilder).credentialsProvider(awsCredentialsProviderCaptor.capture());
AwsCredentialsProvider capturedAwsCredentialsProvider =
awsCredentialsProviderCaptor.getValue();
- Assert.assertTrue(
- "Should use basic credentials if access key ID and secret access key
are set",
- capturedAwsCredentialsProvider.resolveCredentials() instanceof
AwsBasicCredentials);
- Assert.assertEquals(
- "The access key id should be the same as the one set by tag
S3FILEIO_ACCESS_KEY_ID",
- "key",
- capturedAwsCredentialsProvider.resolveCredentials().accessKeyId());
- Assert.assertEquals(
- "The secret access key should be the same as the one set by tag
S3FILEIO_SECRET_ACCESS_KEY",
- "secret",
- capturedAwsCredentialsProvider.resolveCredentials().secretAccessKey());
+ Assertions.assertThat(capturedAwsCredentialsProvider.resolveCredentials())
+ .as("Should use basic credentials if access key ID and secret access
key are set")
+ .isInstanceOf(AwsBasicCredentials.class);
+
Assertions.assertThat(capturedAwsCredentialsProvider.resolveCredentials().accessKeyId())
+ .as("The access key id should be the same as the one set by tag
S3FILEIO_ACCESS_KEY_ID")
+ .isEqualTo("key");
+
Assertions.assertThat(capturedAwsCredentialsProvider.resolveCredentials().secretAccessKey())
+ .as(
+ "The secret access key should be the same as the one set by tag
S3FILEIO_SECRET_ACCESS_KEY")
+ .isEqualTo("secret");
}
@Test
@@ -197,17 +195,16 @@ public class TestAwsProperties {
Mockito.verify(mockS3ClientBuilder).credentialsProvider(awsCredentialsProviderCaptor.capture());
AwsCredentialsProvider capturedAwsCredentialsProvider =
awsCredentialsProviderCaptor.getValue();
- Assert.assertTrue(
- "Should use session credentials if session token is set",
- capturedAwsCredentialsProvider.resolveCredentials() instanceof
AwsSessionCredentials);
- Assert.assertEquals(
- "The access key id should be the same as the one set by tag
S3FILEIO_ACCESS_KEY_ID",
- "key",
- capturedAwsCredentialsProvider.resolveCredentials().accessKeyId());
- Assert.assertEquals(
- "The secret access key should be the same as the one set by tag
S3FILEIO_SECRET_ACCESS_KEY",
- "secret",
- capturedAwsCredentialsProvider.resolveCredentials().secretAccessKey());
+ Assertions.assertThat(capturedAwsCredentialsProvider.resolveCredentials())
+ .as("Should use session credentials if session token is set")
+ .isInstanceOf(AwsSessionCredentials.class);
+
Assertions.assertThat(capturedAwsCredentialsProvider.resolveCredentials().accessKeyId())
+ .as("The access key id should be the same as the one set by tag
S3FILEIO_ACCESS_KEY_ID")
+ .isEqualTo("key");
+
Assertions.assertThat(capturedAwsCredentialsProvider.resolveCredentials().secretAccessKey())
+ .as(
+ "The secret access key should be the same as the one set by tag
S3FILEIO_SECRET_ACCESS_KEY")
+ .isEqualTo("secret");
}
@Test
@@ -223,9 +220,9 @@ public class TestAwsProperties {
Mockito.verify(mockS3ClientBuilder).httpClientBuilder(httpClientBuilderCaptor.capture());
SdkHttpClient.Builder capturedHttpClientBuilder =
httpClientBuilderCaptor.getValue();
- Assert.assertTrue(
- "Should use url connection http client",
- capturedHttpClientBuilder instanceof UrlConnectionHttpClient.Builder);
+ Assertions.assertThat(capturedHttpClientBuilder)
+ .as("Should use url connection http client")
+ .isInstanceOf(UrlConnectionHttpClient.Builder.class);
}
@Test
@@ -240,9 +237,9 @@ public class TestAwsProperties {
awsProperties.applyHttpClientConfigurations(mockS3ClientBuilder);
Mockito.verify(mockS3ClientBuilder).httpClientBuilder(httpClientBuilderCaptor.capture());
SdkHttpClient.Builder capturedHttpClientBuilder =
httpClientBuilderCaptor.getValue();
- Assert.assertTrue(
- "Should use apache http client",
- capturedHttpClientBuilder instanceof ApacheHttpClient.Builder);
+ Assertions.assertThat(capturedHttpClientBuilder)
+ .as("Should use apache http client")
+ .isInstanceOf(ApacheHttpClient.Builder.class);
}
@Test
@@ -263,29 +260,26 @@ public class TestAwsProperties {
AwsProperties awsProperties = new AwsProperties();
AwsProperties deSerializedAwsProperties =
TestHelpers.KryoHelpers.roundTripSerialize(awsProperties);
- Assert.assertEquals(
- awsProperties.s3BucketToAccessPointMapping(),
- deSerializedAwsProperties.s3BucketToAccessPointMapping());
- Assert.assertEquals(
- awsProperties.httpClientProperties(),
deSerializedAwsProperties.httpClientProperties());
+
Assertions.assertThat(deSerializedAwsProperties.s3BucketToAccessPointMapping())
+ .isEqualTo(awsProperties.s3BucketToAccessPointMapping());
+ Assertions.assertThat(deSerializedAwsProperties.httpClientProperties())
+ .isEqualTo(awsProperties.httpClientProperties());
AwsProperties awsPropertiesWithProps = new
AwsProperties(ImmutableMap.of("a", "b"));
AwsProperties deSerializedAwsPropertiesWithProps =
TestHelpers.KryoHelpers.roundTripSerialize(awsPropertiesWithProps);
- Assert.assertEquals(
- awsPropertiesWithProps.s3BucketToAccessPointMapping(),
- deSerializedAwsPropertiesWithProps.s3BucketToAccessPointMapping());
- Assert.assertEquals(
- awsProperties.httpClientProperties(),
deSerializedAwsProperties.httpClientProperties());
+
Assertions.assertThat(deSerializedAwsPropertiesWithProps.s3BucketToAccessPointMapping())
+ .isEqualTo(awsPropertiesWithProps.s3BucketToAccessPointMapping());
+
Assertions.assertThat(deSerializedAwsPropertiesWithProps.httpClientProperties())
+ .isEqualTo(awsProperties.httpClientProperties());
AwsProperties awsPropertiesWithEmptyProps = new
AwsProperties(Collections.emptyMap());
AwsProperties deSerializedAwsPropertiesWithEmptyProps =
TestHelpers.KryoHelpers.roundTripSerialize(awsPropertiesWithProps);
- Assert.assertEquals(
- awsPropertiesWithEmptyProps.s3BucketToAccessPointMapping(),
-
deSerializedAwsPropertiesWithEmptyProps.s3BucketToAccessPointMapping());
- Assert.assertEquals(
- awsProperties.httpClientProperties(),
deSerializedAwsProperties.httpClientProperties());
+
Assertions.assertThat(deSerializedAwsPropertiesWithEmptyProps.s3BucketToAccessPointMapping())
+ .isEqualTo(awsPropertiesWithEmptyProps.s3BucketToAccessPointMapping());
+
Assertions.assertThat(deSerializedAwsPropertiesWithEmptyProps.httpClientProperties())
+ .isEqualTo(awsProperties.httpClientProperties());
}
@Test
diff --git
a/aws/src/test/java/org/apache/iceberg/aws/TestHttpClientConfigurations.java
b/aws/src/test/java/org/apache/iceberg/aws/TestHttpClientConfigurations.java
index 7e380861ce..2c6f35c3a0 100644
--- a/aws/src/test/java/org/apache/iceberg/aws/TestHttpClientConfigurations.java
+++ b/aws/src/test/java/org/apache/iceberg/aws/TestHttpClientConfigurations.java
@@ -21,7 +21,7 @@ package org.apache.iceberg.aws;
import java.time.Duration;
import java.util.Map;
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import software.amazon.awssdk.http.apache.ApacheHttpClient;
import software.amazon.awssdk.http.urlconnection.UrlConnectionHttpClient;
diff --git a/aws/src/test/java/org/apache/iceberg/aws/TestRESTSigV4Signer.java
b/aws/src/test/java/org/apache/iceberg/aws/TestRESTSigV4Signer.java
index 188d488db2..b353635029 100644
--- a/aws/src/test/java/org/apache/iceberg/aws/TestRESTSigV4Signer.java
+++ b/aws/src/test/java/org/apache/iceberg/aws/TestRESTSigV4Signer.java
@@ -29,10 +29,10 @@ import org.apache.iceberg.rest.auth.OAuth2Util;
import org.apache.iceberg.rest.responses.ConfigResponse;
import org.apache.iceberg.rest.responses.OAuthTokenResponse;
import org.assertj.core.api.Assertions;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockserver.integration.ClientAndServer;
import org.mockserver.model.Header;
import org.mockserver.model.HttpRequest;
@@ -44,7 +44,7 @@ public class TestRESTSigV4Signer {
private static ClientAndServer mockServer;
private static HTTPClient client;
- @BeforeClass
+ @BeforeAll
public static void beforeClass() {
mockServer = ClientAndServer.startClientAndServer();
@@ -66,13 +66,13 @@ public class TestRESTSigV4Signer {
.build();
}
- @AfterClass
+ @AfterAll
public static void afterClass() throws IOException {
mockServer.stop();
client.close();
}
- @Before
+ @BeforeEach
public void before() {
mockServer.reset();
}
diff --git
a/aws/src/test/java/org/apache/iceberg/aws/dynamodb/TestDynamoDbCatalog.java
b/aws/src/test/java/org/apache/iceberg/aws/dynamodb/TestDynamoDbCatalog.java
index 9e6e948408..5b5941c9a6 100644
--- a/aws/src/test/java/org/apache/iceberg/aws/dynamodb/TestDynamoDbCatalog.java
+++ b/aws/src/test/java/org/apache/iceberg/aws/dynamodb/TestDynamoDbCatalog.java
@@ -27,8 +27,8 @@ import org.apache.iceberg.exceptions.NoSuchNamespaceException;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.apache.iceberg.relocated.com.google.common.collect.Maps;
import org.assertj.core.api.Assertions;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
@@ -44,7 +44,7 @@ public class TestDynamoDbCatalog {
private DynamoDbClient dynamo;
private DynamoDbCatalog dynamoCatalog;
- @Before
+ @BeforeEach
public void before() {
dynamo = Mockito.mock(DynamoDbClient.class);
dynamoCatalog = new DynamoDbCatalog();
diff --git a/aws/src/test/java/org/apache/iceberg/aws/glue/TestGlueCatalog.java
b/aws/src/test/java/org/apache/iceberg/aws/glue/TestGlueCatalog.java
index a915a97d0e..1dded0ccad 100644
--- a/aws/src/test/java/org/apache/iceberg/aws/glue/TestGlueCatalog.java
+++ b/aws/src/test/java/org/apache/iceberg/aws/glue/TestGlueCatalog.java
@@ -35,9 +35,8 @@ import
org.apache.iceberg.relocated.com.google.common.collect.Maps;
import org.apache.iceberg.relocated.com.google.common.collect.Sets;
import org.apache.iceberg.util.LockManagers;
import org.assertj.core.api.Assertions;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -72,7 +71,7 @@ public class TestGlueCatalog {
private GlueClient glue;
private GlueCatalog glueCatalog;
- @Before
+ @BeforeEach
public void before() {
glue = Mockito.mock(GlueClient.class);
glueCatalog = new GlueCatalog();
@@ -127,7 +126,7 @@ public class TestGlueCatalog {
.when(glue)
.getDatabase(Mockito.any(GetDatabaseRequest.class));
String location =
catalogWithSlash.defaultWarehouseLocation(TableIdentifier.of("db", "table"));
- Assert.assertEquals(WAREHOUSE_PATH + "/db.db/table", location);
+ Assertions.assertThat(location).isEqualTo(WAREHOUSE_PATH + "/db.db/table");
}
@Test
@@ -137,7 +136,7 @@ public class TestGlueCatalog {
.when(glue)
.getDatabase(Mockito.any(GetDatabaseRequest.class));
String location =
glueCatalog.defaultWarehouseLocation(TableIdentifier.of("db", "table"));
- Assert.assertEquals(WAREHOUSE_PATH + "/db.db/table", location);
+ Assertions.assertThat(location).isEqualTo(WAREHOUSE_PATH + "/db.db/table");
}
@Test
@@ -149,7 +148,7 @@ public class TestGlueCatalog {
.when(glue)
.getDatabase(Mockito.any(GetDatabaseRequest.class));
String location =
glueCatalog.defaultWarehouseLocation(TableIdentifier.of("db", "table"));
- Assert.assertEquals("s3://bucket2/db/table", location);
+ Assertions.assertThat(location).isEqualTo("s3://bucket2/db/table");
}
@Test
@@ -225,9 +224,9 @@ public class TestGlueCatalog {
.build())
.when(glue)
.getTables(Mockito.any(GetTablesRequest.class));
- Assert.assertEquals(
- Lists.newArrayList(TableIdentifier.of("db1", "t1"),
TableIdentifier.of("db1", "t2")),
- glueCatalog.listTables(Namespace.of("db1")));
+ Assertions.assertThat(glueCatalog.listTables(Namespace.of("db1")))
+ .isEqualTo(
+ Lists.newArrayList(TableIdentifier.of("db1", "t1"),
TableIdentifier.of("db1", "t2")));
}
@Test
@@ -271,7 +270,7 @@ public class TestGlueCatalog {
})
.when(glue)
.getTables(Mockito.any(GetTablesRequest.class));
- Assert.assertEquals(10,
glueCatalog.listTables(Namespace.of("db1")).size());
+
Assertions.assertThat(glueCatalog.listTables(Namespace.of("db1"))).hasSize(10);
}
@Test
@@ -329,7 +328,7 @@ public class TestGlueCatalog {
.when(glue)
.deleteTable(Mockito.any(DeleteTableRequest.class));
glueCatalog.dropTable(TableIdentifier.of("db1", "t1"));
- Assert.assertEquals(0, counter.get());
+ Assertions.assertThat(counter.get()).isEqualTo(0);
}
@Test
@@ -383,7 +382,7 @@ public class TestGlueCatalog {
.createTable(Mockito.any(CreateTableRequest.class));
glueCatalog.renameTable(TableIdentifier.of("db", "t"),
TableIdentifier.of("db", "x_renamed"));
- Assert.assertEquals(0, counter.get());
+ Assertions.assertThat(counter.get()).isEqualTo(0);
}
@Test
@@ -421,8 +420,8 @@ public class TestGlueCatalog {
.build())
.when(glue)
.getDatabases(Mockito.any(GetDatabasesRequest.class));
- Assert.assertEquals(
- Lists.newArrayList(Namespace.of("db1"), Namespace.of("db2")),
glueCatalog.listNamespaces());
+ Assertions.assertThat(glueCatalog.listNamespaces())
+ .isEqualTo(Lists.newArrayList(Namespace.of("db1"),
Namespace.of("db2")));
}
@Test
@@ -449,7 +448,7 @@ public class TestGlueCatalog {
})
.when(glue)
.getDatabases(Mockito.any(GetDatabasesRequest.class));
- Assert.assertEquals(10, glueCatalog.listNamespaces().size());
+ Assertions.assertThat(glueCatalog.listNamespaces()).hasSize(10);
}
@Test
@@ -458,10 +457,9 @@ public class TestGlueCatalog {
GetDatabaseResponse.builder().database(Database.builder().name("db1").build()).build())
.when(glue)
.getDatabase(Mockito.any(GetDatabaseRequest.class));
- Assert.assertEquals(
- "list self should return empty list",
- Lists.newArrayList(),
- glueCatalog.listNamespaces(Namespace.of("db1")));
+ Assertions.assertThat(glueCatalog.listNamespaces(Namespace.of("db1")))
+ .as("list self should return empty list")
+ .isEmpty();
}
@Test
@@ -484,7 +482,8 @@ public class TestGlueCatalog {
.build())
.when(glue)
.getDatabase(Mockito.any(GetDatabaseRequest.class));
- Assert.assertEquals(parameters,
glueCatalog.loadNamespaceMetadata(Namespace.of("db1")));
+
Assertions.assertThat(glueCatalog.loadNamespaceMetadata(Namespace.of("db1")))
+ .isEqualTo(parameters);
}
@Test
@@ -602,17 +601,13 @@ public class TestGlueCatalog {
null,
catalogProps);
Map<String, String> properties = glueCatalog.properties();
- Assert.assertFalse(properties.isEmpty());
- Assert.assertTrue(properties.containsKey("table-default.key1"));
- Assert.assertEquals("catalog-default-key1",
properties.get("table-default.key1"));
- Assert.assertTrue(properties.containsKey("table-default.key2"));
- Assert.assertEquals("catalog-default-key2",
properties.get("table-default.key2"));
- Assert.assertTrue(properties.containsKey("table-default.key3"));
- Assert.assertEquals("catalog-default-key3",
properties.get("table-default.key3"));
- Assert.assertTrue(properties.containsKey("table-override.key3"));
- Assert.assertEquals("catalog-override-key3",
properties.get("table-override.key3"));
- Assert.assertTrue(properties.containsKey("table-override.key4"));
- Assert.assertEquals("catalog-override-key4",
properties.get("table-override.key4"));
+ Assertions.assertThat(properties)
+ .isNotEmpty()
+ .containsEntry("table-default.key1", "catalog-default-key1")
+ .containsEntry("table-default.key2", "catalog-default-key2")
+ .containsEntry("table-default.key3", "catalog-default-key3")
+ .containsEntry("table-override.key3", "catalog-override-key3")
+ .containsEntry("table-override.key4", "catalog-override-key4");
}
@Test
@@ -627,7 +622,8 @@ public class TestGlueCatalog {
LockManagers.defaultLockManager(),
null,
ImmutableMap.of());
-
Assert.assertEquals(glueCatalog.isValidIdentifier(TableIdentifier.parse("db-1.a-1")),
true);
+
Assertions.assertThat(glueCatalog.isValidIdentifier(TableIdentifier.parse("db-1.a-1")))
+ .isEqualTo(true);
}
@Test
@@ -652,19 +648,11 @@ public class TestGlueCatalog {
glueCatalog.newTableOps(TableIdentifier.of(Namespace.of("db"),
"table"));
Map<String, String> tableCatalogProperties =
glueTableOperations.tableCatalogProperties();
- Assert.assertTrue(
- tableCatalogProperties.containsKey(
-
AwsProperties.S3_WRITE_TAGS_PREFIX.concat(AwsProperties.S3_TAG_ICEBERG_TABLE)));
- Assert.assertEquals(
- "table",
- tableCatalogProperties.get(
-
AwsProperties.S3_WRITE_TAGS_PREFIX.concat(AwsProperties.S3_TAG_ICEBERG_TABLE)));
- Assert.assertTrue(
- tableCatalogProperties.containsKey(
-
AwsProperties.S3_WRITE_TAGS_PREFIX.concat(AwsProperties.S3_TAG_ICEBERG_NAMESPACE)));
- Assert.assertEquals(
- "db",
- tableCatalogProperties.get(
-
AwsProperties.S3_WRITE_TAGS_PREFIX.concat(AwsProperties.S3_TAG_ICEBERG_NAMESPACE)));
+ Assertions.assertThat(tableCatalogProperties)
+ .containsEntry(
+
AwsProperties.S3_WRITE_TAGS_PREFIX.concat(AwsProperties.S3_TAG_ICEBERG_TABLE),
"table")
+ .containsEntry(
+
AwsProperties.S3_WRITE_TAGS_PREFIX.concat(AwsProperties.S3_TAG_ICEBERG_NAMESPACE),
+ "db");
}
}
diff --git
a/aws/src/test/java/org/apache/iceberg/aws/glue/TestGlueToIcebergConverter.java
b/aws/src/test/java/org/apache/iceberg/aws/glue/TestGlueToIcebergConverter.java
index e76f6c5ae0..0d2c3d825c 100644
---
a/aws/src/test/java/org/apache/iceberg/aws/glue/TestGlueToIcebergConverter.java
+++
b/aws/src/test/java/org/apache/iceberg/aws/glue/TestGlueToIcebergConverter.java
@@ -25,8 +25,7 @@ import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.exceptions.NoSuchIcebergTableException;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.assertj.core.api.Assertions;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import software.amazon.awssdk.services.glue.model.Database;
import software.amazon.awssdk.services.glue.model.Table;
@@ -36,14 +35,14 @@ public class TestGlueToIcebergConverter {
public void testToNamespace() {
Database database = Database.builder().name("db").build();
Namespace namespace = Namespace.of("db");
- Assert.assertEquals(namespace,
GlueToIcebergConverter.toNamespace(database));
+
Assertions.assertThat(GlueToIcebergConverter.toNamespace(database)).isEqualTo(namespace);
}
@Test
public void testToTableId() {
Table table = Table.builder().databaseName("db").name("name").build();
TableIdentifier icebergId = TableIdentifier.of("db", "name");
- Assert.assertEquals(icebergId, GlueToIcebergConverter.toTableId(table));
+
Assertions.assertThat(GlueToIcebergConverter.toTableId(table)).isEqualTo(icebergId);
}
@Test
diff --git
a/aws/src/test/java/org/apache/iceberg/aws/glue/TestIcebergToGlueConverter.java
b/aws/src/test/java/org/apache/iceberg/aws/glue/TestIcebergToGlueConverter.java
index b29247af65..04e58e8537 100644
---
a/aws/src/test/java/org/apache/iceberg/aws/glue/TestIcebergToGlueConverter.java
+++
b/aws/src/test/java/org/apache/iceberg/aws/glue/TestIcebergToGlueConverter.java
@@ -33,8 +33,7 @@ import
org.apache.iceberg.relocated.com.google.common.collect.Lists;
import org.apache.iceberg.relocated.com.google.common.collect.Sets;
import org.apache.iceberg.types.Types;
import org.assertj.core.api.Assertions;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import software.amazon.awssdk.services.glue.model.Column;
import software.amazon.awssdk.services.glue.model.DatabaseInput;
import software.amazon.awssdk.services.glue.model.StorageDescriptor;
@@ -50,7 +49,8 @@ public class TestIcebergToGlueConverter {
@Test
public void testToDatabaseName() {
- Assert.assertEquals("db",
IcebergToGlueConverter.toDatabaseName(Namespace.of("db"), false));
+
Assertions.assertThat(IcebergToGlueConverter.toDatabaseName(Namespace.of("db"),
false))
+ .isEqualTo("db");
}
@Test
@@ -78,7 +78,8 @@ public class TestIcebergToGlueConverter {
List<Namespace> acceptableNames =
Lists.newArrayList(Namespace.of("db-1"), Namespace.of("db-1-1-1"));
for (Namespace name : acceptableNames) {
- Assert.assertEquals(name.toString(),
IcebergToGlueConverter.toDatabaseName(name, true));
+ Assertions.assertThat(IcebergToGlueConverter.toDatabaseName(name, true))
+ .isEqualTo(name.toString());
}
}
@@ -90,7 +91,8 @@ public class TestIcebergToGlueConverter {
TableIdentifier.parse("db.a-1-1"),
TableIdentifier.parse("db.a#1"));
for (TableIdentifier identifier : acceptableIdentifiers) {
- Assert.assertEquals(identifier.name(),
IcebergToGlueConverter.getTableName(identifier, true));
+ Assertions.assertThat(IcebergToGlueConverter.getTableName(identifier,
true))
+ .isEqualTo(identifier.name());
}
}
@@ -106,19 +108,25 @@ public class TestIcebergToGlueConverter {
"val");
DatabaseInput databaseInput =
IcebergToGlueConverter.toDatabaseInput(Namespace.of("ns"), properties,
false);
- Assert.assertEquals("Location should be set", "s3://location",
databaseInput.locationUri());
- Assert.assertEquals("Description should be set", "description",
databaseInput.description());
- Assert.assertEquals(
- "Parameters should be set", ImmutableMap.of("key", "val"),
databaseInput.parameters());
- Assert.assertEquals("Database name should be set", "ns",
databaseInput.name());
+ Assertions.assertThat(databaseInput.locationUri())
+ .as("Location should be set")
+ .isEqualTo("s3://location");
+ Assertions.assertThat(databaseInput.description())
+ .as("Description should be set")
+ .isEqualTo("description");
+ Assertions.assertThat(databaseInput.parameters())
+ .as("Parameters should be set")
+ .isEqualTo(ImmutableMap.of("key", "val"));
+ Assertions.assertThat(databaseInput.name()).as("Database name should be
set").isEqualTo("ns");
}
@Test
public void testToDatabaseInputNoParameter() {
DatabaseInput input =
DatabaseInput.builder().name("db").parameters(ImmutableMap.of()).build();
Namespace namespace = Namespace.of("db");
- Assert.assertEquals(
- input, IcebergToGlueConverter.toDatabaseInput(namespace,
ImmutableMap.of(), false));
+ Assertions.assertThat(
+ IcebergToGlueConverter.toDatabaseInput(namespace,
ImmutableMap.of(), false))
+ .isEqualTo(input);
}
@Test
@@ -128,11 +136,14 @@ public class TestIcebergToGlueConverter {
IcebergToGlueConverter.GLUE_DB_DESCRIPTION_KEY, "description",
"key", "val");
DatabaseInput databaseInput =
IcebergToGlueConverter.toDatabaseInput(Namespace.of("ns"), properties,
false);
- Assert.assertNull("Location should not be set",
databaseInput.locationUri());
- Assert.assertEquals("Description should be set", "description",
databaseInput.description());
- Assert.assertEquals(
- "Parameters should be set", ImmutableMap.of("key", "val"),
databaseInput.parameters());
- Assert.assertEquals("Database name should be set", "ns",
databaseInput.name());
+ Assertions.assertThat(databaseInput.locationUri()).as("Location should not
be set").isNull();
+ Assertions.assertThat(databaseInput.description())
+ .as("Description should be set")
+ .isEqualTo("description");
+ Assertions.assertThat(databaseInput.parameters())
+ .as("Parameters should be set")
+ .isEqualTo(ImmutableMap.of("key", "val"));
+ Assertions.assertThat(databaseInput.name()).as("Database name should be
set").isEqualTo("ns");
}
@Test
@@ -141,11 +152,14 @@ public class TestIcebergToGlueConverter {
ImmutableMap.of(IcebergToGlueConverter.GLUE_DB_LOCATION_KEY,
"s3://location", "key", "val");
DatabaseInput databaseInput =
IcebergToGlueConverter.toDatabaseInput(Namespace.of("ns"), properties,
false);
- Assert.assertEquals("Location should be set", "s3://location",
databaseInput.locationUri());
- Assert.assertNull("Description should not be set",
databaseInput.description());
- Assert.assertEquals(
- "Parameters should be set", ImmutableMap.of("key", "val"),
databaseInput.parameters());
- Assert.assertEquals("Database name should be set", "ns",
databaseInput.name());
+ Assertions.assertThat(databaseInput.locationUri())
+ .as("Location should be set")
+ .isEqualTo("s3://location");
+ Assertions.assertThat(databaseInput.description()).as("Description should
not be set").isNull();
+ Assertions.assertThat(databaseInput.parameters())
+ .as("Parameters should be set")
+ .isEqualTo(ImmutableMap.of("key", "val"));
+ Assertions.assertThat(databaseInput.name()).as("Database name should be
set").isEqualTo("ns");
}
@Test
@@ -199,18 +213,15 @@ public class TestIcebergToGlueConverter {
.build())
.build();
- Assert.assertEquals(
- "additionalLocations should match",
- expectedTableInput.storageDescriptor().additionalLocations(),
- actualTableInput.storageDescriptor().additionalLocations());
- Assert.assertEquals(
- "Location should match",
- expectedTableInput.storageDescriptor().location(),
- actualTableInput.storageDescriptor().location());
- Assert.assertEquals(
- "Columns should match",
- expectedTableInput.storageDescriptor().columns(),
- actualTableInput.storageDescriptor().columns());
+
Assertions.assertThat(actualTableInput.storageDescriptor().additionalLocations())
+ .as("additionalLocations should match")
+
.isEqualTo(expectedTableInput.storageDescriptor().additionalLocations());
+ Assertions.assertThat(actualTableInput.storageDescriptor().location())
+ .as("Location should match")
+ .isEqualTo(expectedTableInput.storageDescriptor().location());
+ Assertions.assertThat(actualTableInput.storageDescriptor().columns())
+ .as("Columns should match")
+ .isEqualTo(expectedTableInput.storageDescriptor().columns());
}
@Test
@@ -268,17 +279,14 @@ public class TestIcebergToGlueConverter {
.build())
.build();
- Assert.assertEquals(
- "additionalLocations should match",
- expectedTableInput.storageDescriptor().additionalLocations(),
- actualTableInput.storageDescriptor().additionalLocations());
- Assert.assertEquals(
- "Location should match",
- expectedTableInput.storageDescriptor().location(),
- actualTableInput.storageDescriptor().location());
- Assert.assertEquals(
- "Columns should match",
- expectedTableInput.storageDescriptor().columns(),
- actualTableInput.storageDescriptor().columns());
+
Assertions.assertThat(actualTableInput.storageDescriptor().additionalLocations())
+ .as("additionalLocations should match")
+
.isEqualTo(expectedTableInput.storageDescriptor().additionalLocations());
+ Assertions.assertThat(actualTableInput.storageDescriptor().location())
+ .as("Location should match")
+ .isEqualTo(expectedTableInput.storageDescriptor().location());
+ Assertions.assertThat(actualTableInput.storageDescriptor().columns())
+ .as("Columns should match")
+ .isEqualTo(expectedTableInput.storageDescriptor().columns());
}
}
diff --git a/aws/src/test/java/org/apache/iceberg/aws/s3/TestS3RequestUtil.java
b/aws/src/test/java/org/apache/iceberg/aws/s3/TestS3RequestUtil.java
index 816ca4799a..17e3e238e0 100644
--- a/aws/src/test/java/org/apache/iceberg/aws/s3/TestS3RequestUtil.java
+++ b/aws/src/test/java/org/apache/iceberg/aws/s3/TestS3RequestUtil.java
@@ -18,8 +18,8 @@
*/
package org.apache.iceberg.aws.s3;
-import org.junit.Assert;
-import org.junit.Test;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
import software.amazon.awssdk.services.s3.model.S3Request;
import software.amazon.awssdk.services.s3.model.ServerSideEncryption;
@@ -44,11 +44,11 @@ public class TestS3RequestUtil {
this::setCustomAlgorithm,
this::setCustomKey,
this::setCustomMd5);
- Assert.assertNull(serverSideEncryption);
- Assert.assertNull(kmsKeyId);
- Assert.assertEquals(ServerSideEncryption.AES256.name(), customAlgorithm);
- Assert.assertEquals("key", customKey);
- Assert.assertEquals("md5", customMd5);
+ Assertions.assertThat(serverSideEncryption).isNull();
+ Assertions.assertThat(kmsKeyId).isNull();
+
Assertions.assertThat(customAlgorithm).isEqualTo(ServerSideEncryption.AES256.name());
+ Assertions.assertThat(customKey).isEqualTo("key");
+ Assertions.assertThat(customMd5).isEqualTo("md5");
}
@Test
@@ -62,11 +62,11 @@ public class TestS3RequestUtil {
this::setCustomAlgorithm,
this::setCustomKey,
this::setCustomMd5);
- Assert.assertEquals(ServerSideEncryption.AES256, serverSideEncryption);
- Assert.assertNull(kmsKeyId);
- Assert.assertNull(customAlgorithm);
- Assert.assertNull(customKey);
- Assert.assertNull(customMd5);
+
Assertions.assertThat(serverSideEncryption).isEqualTo(ServerSideEncryption.AES256);
+ Assertions.assertThat(kmsKeyId).isNull();
+ Assertions.assertThat(customAlgorithm).isNull();
+ Assertions.assertThat(customKey).isNull();
+ Assertions.assertThat(customMd5).isNull();
}
@Test
@@ -81,11 +81,11 @@ public class TestS3RequestUtil {
this::setCustomAlgorithm,
this::setCustomKey,
this::setCustomMd5);
- Assert.assertEquals(ServerSideEncryption.AWS_KMS, serverSideEncryption);
- Assert.assertEquals("key", kmsKeyId);
- Assert.assertNull(customAlgorithm);
- Assert.assertNull(customKey);
- Assert.assertNull(customMd5);
+
Assertions.assertThat(serverSideEncryption).isEqualTo(ServerSideEncryption.AWS_KMS);
+ Assertions.assertThat(kmsKeyId).isEqualTo("key");
+ Assertions.assertThat(customAlgorithm).isNull();
+ Assertions.assertThat(customKey).isNull();
+ Assertions.assertThat(customMd5).isNull();
}
@Test
@@ -100,11 +100,11 @@ public class TestS3RequestUtil {
this::setCustomAlgorithm,
this::setCustomKey,
this::setCustomMd5);
- Assert.assertNull(serverSideEncryption);
- Assert.assertNull(kmsKeyId);
- Assert.assertNull(customAlgorithm);
- Assert.assertNull(customKey);
- Assert.assertNull(customMd5);
+ Assertions.assertThat(serverSideEncryption).isNull();
+ Assertions.assertThat(kmsKeyId).isNull();
+ Assertions.assertThat(customAlgorithm).isNull();
+ Assertions.assertThat(customKey).isNull();
+ Assertions.assertThat(customMd5).isNull();
}
public S3Request.Builder setCustomAlgorithm(String algorithm) {
diff --git a/aws/src/test/java/org/apache/iceberg/aws/s3/TestS3URI.java
b/aws/src/test/java/org/apache/iceberg/aws/s3/TestS3URI.java
index e1916dbd06..f352d46b50 100644
--- a/aws/src/test/java/org/apache/iceberg/aws/s3/TestS3URI.java
+++ b/aws/src/test/java/org/apache/iceberg/aws/s3/TestS3URI.java
@@ -25,7 +25,7 @@ import org.apache.iceberg.exceptions.ValidationException;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.apache.iceberg.relocated.com.google.common.collect.Lists;
import org.assertj.core.api.Assertions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TestS3URI {
diff --git
a/aws/src/test/java/org/apache/iceberg/aws/s3/signer/TestS3SignRequestParser.java
b/aws/src/test/java/org/apache/iceberg/aws/s3/signer/TestS3SignRequestParser.java
index 7348d8f20e..753d2078c4 100644
---
a/aws/src/test/java/org/apache/iceberg/aws/s3/signer/TestS3SignRequestParser.java
+++
b/aws/src/test/java/org/apache/iceberg/aws/s3/signer/TestS3SignRequestParser.java
@@ -23,7 +23,7 @@ import java.net.URI;
import java.util.Arrays;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.assertj.core.api.Assertions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TestS3SignRequestParser {
diff --git
a/aws/src/test/java/org/apache/iceberg/aws/s3/signer/TestS3SignResponseParser.java
b/aws/src/test/java/org/apache/iceberg/aws/s3/signer/TestS3SignResponseParser.java
index 7b43135395..d7337b1b17 100644
---
a/aws/src/test/java/org/apache/iceberg/aws/s3/signer/TestS3SignResponseParser.java
+++
b/aws/src/test/java/org/apache/iceberg/aws/s3/signer/TestS3SignResponseParser.java
@@ -23,7 +23,7 @@ import java.net.URI;
import java.util.Arrays;
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
import org.assertj.core.api.Assertions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TestS3SignResponseParser {
diff --git
a/aws/src/test/java/org/apache/iceberg/aws/util/TestRetryDetector.java
b/aws/src/test/java/org/apache/iceberg/aws/util/TestRetryDetector.java
index 7403d2557c..72cc2f91ec 100644
--- a/aws/src/test/java/org/apache/iceberg/aws/util/TestRetryDetector.java
+++ b/aws/src/test/java/org/apache/iceberg/aws/util/TestRetryDetector.java
@@ -18,8 +18,8 @@
*/
package org.apache.iceberg.aws.util;
-import org.junit.Assert;
-import org.junit.Test;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import software.amazon.awssdk.core.metrics.CoreMetric;
import software.amazon.awssdk.metrics.MetricCollection;
@@ -31,7 +31,7 @@ public class TestRetryDetector {
@Test
public void testNoMetrics() {
RetryDetector detector = new RetryDetector();
- Assert.assertFalse("Should default to false", detector.retried());
+ Assertions.assertThat(detector.retried()).as("Should default to
false").isFalse();
}
@Test
@@ -40,8 +40,9 @@ public class TestRetryDetector {
RetryDetector detector = new RetryDetector();
detector.publish(metrics.collect());
- Assert.assertFalse(
- "Should not detect retries if RETRY_COUNT metric is not reported",
detector.retried());
+ Assertions.assertThat(detector.retried())
+ .as("Should not detect retries if RETRY_COUNT metric is not reported")
+ .isFalse();
}
@Test
@@ -51,7 +52,9 @@ public class TestRetryDetector {
RetryDetector detector = new RetryDetector();
detector.publish(metrics.collect());
- Assert.assertFalse("Should not detect retries if RETRY_COUNT is zero",
detector.retried());
+ Assertions.assertThat(detector.retried())
+ .as("Should not detect retries if RETRY_COUNT is zero")
+ .isFalse();
}
@Test
@@ -61,7 +64,9 @@ public class TestRetryDetector {
RetryDetector detector = new RetryDetector();
detector.publish(metrics.collect());
- Assert.assertTrue("Should detect retries if RETRY_COUNT is non-zero",
detector.retried());
+ Assertions.assertThat(detector.retried())
+ .as("Should detect retries if RETRY_COUNT is non-zero")
+ .isTrue();
}
@Test
@@ -72,8 +77,9 @@ public class TestRetryDetector {
RetryDetector detector = new RetryDetector();
detector.publish(metrics.collect());
- Assert.assertTrue(
- "Should detect retries if even one RETRY_COUNT is non-zero",
detector.retried());
+ Assertions.assertThat(detector.retried())
+ .as("Should detect retries if even one RETRY_COUNT is non-zero")
+ .isTrue();
}
@Test
@@ -85,8 +91,9 @@ public class TestRetryDetector {
RetryDetector detector = new RetryDetector();
detector.publish(metrics.collect());
- Assert.assertFalse(
- "Should not detect retries if nested RETRY_COUNT is zero",
detector.retried());
+ Assertions.assertThat(detector.retried())
+ .as("Should not detect retries if nested RETRY_COUNT is zero")
+ .isFalse();
}
@Test
@@ -98,8 +105,9 @@ public class TestRetryDetector {
RetryDetector detector = new RetryDetector();
detector.publish(metrics.collect());
- Assert.assertTrue(
- "Should detect retries if nested RETRY_COUNT is non-zero",
detector.retried());
+ Assertions.assertThat(detector.retried())
+ .as("Should detect retries if nested RETRY_COUNT is non-zero")
+ .isTrue();
}
@Test
@@ -116,8 +124,9 @@ public class TestRetryDetector {
RetryDetector detector = new RetryDetector();
detector.publish(metrics.collect());
- Assert.assertTrue(
- "Should detect retries if even one nested RETRY_COUNT is non-zero",
detector.retried());
+ Assertions.assertThat(detector.retried())
+ .as("Should detect retries if even one nested RETRY_COUNT is non-zero")
+ .isTrue();
}
@Test
@@ -129,10 +138,13 @@ public class TestRetryDetector {
RetryDetector detector = new RetryDetector();
detector.publish(metrics1.collect());
- Assert.assertFalse("Should not detect retries if RETRY_COUNT is zero",
detector.retried());
+ Assertions.assertThat(detector.retried())
+ .as("Should not detect retries if RETRY_COUNT is zero")
+ .isFalse();
detector.publish(metrics2.collect());
- Assert.assertTrue(
- "Should continue detecting retries in additional metrics",
detector.retried());
+ Assertions.assertThat(detector.retried())
+ .as("Should continue detecting retries in additional metrics")
+ .isTrue();
}
@Test
@@ -146,9 +158,13 @@ public class TestRetryDetector {
RetryDetector detector = new RetryDetector();
detector.publish(metrics1Spy);
- Assert.assertTrue("Should detect retries if RETRY_COUNT is zero",
detector.retried());
+ Assertions.assertThat(detector.retried())
+ .as("Should detect retries if RETRY_COUNT is zero")
+ .isTrue();
detector.publish(metrics2Spy);
- Assert.assertTrue("Should remain true once a retry is detected",
detector.retried());
+ Assertions.assertThat(detector.retried())
+ .as("Should remain true once a retry is detected")
+ .isTrue();
Mockito.verify(metrics1Spy).metricValues(Mockito.eq(CoreMetric.RETRY_COUNT));
Mockito.verifyNoMoreInteractions(metrics1Spy, metrics2Spy);