This is an automated email from the ASF dual-hosted git repository.

ayushsaxena pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new d06452c283d HIVE-29105. Migrate iceberg-catalog Tests to JUnit 5. 
(#5996)
d06452c283d is described below

commit d06452c283df741fe51d2411d81f5eb2f8f640b0
Author: slfan1989 <[email protected]>
AuthorDate: Tue Jul 29 15:18:08 2025 +0800

    HIVE-29105. Migrate iceberg-catalog Tests to JUnit 5. (#5996)
---
 .../test/java/org/apache/iceberg/TestHelpers.java  | 76 +++++++++++-----------
 .../apache/iceberg/hive/TestClientPoolImpl.java    | 16 ++---
 .../org/apache/iceberg/hive/TestHiveCatalog.java   |  6 +-
 3 files changed, 50 insertions(+), 48 deletions(-)

diff --git 
a/iceberg/iceberg-catalog/src/test/java/org/apache/iceberg/TestHelpers.java 
b/iceberg/iceberg-catalog/src/test/java/org/apache/iceberg/TestHelpers.java
index d47b0c013b9..f778b3559bf 100644
--- a/iceberg/iceberg-catalog/src/test/java/org/apache/iceberg/TestHelpers.java
+++ b/iceberg/iceberg-catalog/src/test/java/org/apache/iceberg/TestHelpers.java
@@ -34,8 +34,9 @@
 import org.apache.iceberg.expressions.Expression;
 import org.apache.iceberg.expressions.ExpressionVisitors;
 import org.apache.iceberg.expressions.UnboundPredicate;
-import org.assertj.core.api.Assertions;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
+
+import static org.assertj.core.api.Assertions.assertThat;
 
 public class TestHelpers {
 
@@ -43,29 +44,29 @@ private TestHelpers() {
   }
 
   public static <T> T assertAndUnwrap(Expression expr, Class<T> expected) {
-    Assert.assertTrue("Expression should have expected type: " + expected,
-        expected.isInstance(expr));
+    Assertions.assertTrue(
+        expected.isInstance(expr), "Expression should have expected type: " + 
expected);
     return expected.cast(expr);
   }
 
   @SuppressWarnings("unchecked")
   public static <T> BoundPredicate<T> assertAndUnwrap(Expression expr) {
-    Assert.assertTrue("Expression should be a bound predicate: " + expr,
-        expr instanceof BoundPredicate);
+    Assertions.assertTrue(
+        expr instanceof BoundPredicate, "Expression should be a bound 
predicate: " + expr);
     return (BoundPredicate<T>) expr;
   }
 
   @SuppressWarnings("unchecked")
   public static <T> BoundSetPredicate<T> assertAndUnwrapBoundSet(Expression 
expr) {
-    Assert.assertTrue("Expression should be a bound set predicate: " + expr,
-        expr instanceof BoundSetPredicate);
+    Assertions.assertTrue(
+        expr instanceof BoundSetPredicate, "Expression should be a bound set 
predicate: " + expr);
     return (BoundSetPredicate<T>) expr;
   }
 
   @SuppressWarnings("unchecked")
   public static <T> UnboundPredicate<T> assertAndUnwrapUnbound(Expression 
expr) {
-    Assert.assertTrue("Expression should be an unbound predicate: " + expr,
-        expr instanceof UnboundPredicate);
+    Assertions.assertTrue(
+        expr instanceof UnboundPredicate, "Expression should be an unbound 
predicate: " + expr);
     return (UnboundPredicate<T>) expr;
   }
 
@@ -87,7 +88,7 @@ public static <T> T roundTripSerialize(T type) throws 
IOException, ClassNotFound
   }
 
   public static void assertSameSchemaList(List<Schema> list1, List<Schema> 
list2) {
-    Assertions.assertThat(list1)
+    assertThat(list1)
         .as("Should have same number of schemas in both lists")
         .hasSameSizeAs(list2);
 
@@ -96,48 +97,49 @@ public static void assertSameSchemaList(List<Schema> list1, 
List<Schema> list2)
             index -> {
               Schema schema1 = list1.get(index);
               Schema schema2 = list2.get(index);
-              Assert.assertEquals(
-                  "Should have matching schema id", schema1.schemaId(), 
schema2.schemaId());
-              Assert.assertEquals(
-                  "Should have matching schema struct", schema1.asStruct(), 
schema2.asStruct());
+              Assertions.assertEquals(schema1.schemaId(), schema2.schemaId(),
+                  "Should have matching schema id");
+              Assertions.assertEquals(schema1.asStruct(), schema2.asStruct(),
+                  "Should have matching schema struct");
             });
   }
 
   public static void assertSerializedMetadata(Table expected, Table actual) {
-    Assert.assertEquals("Name must match", expected.name(), actual.name());
-    Assert.assertEquals("Location must match", expected.location(), 
actual.location());
-    Assert.assertEquals("Props must match", expected.properties(), 
actual.properties());
-    Assert.assertEquals("Schema must match", expected.schema().asStruct(), 
actual.schema().asStruct());
-    Assert.assertEquals("Spec must match", expected.spec(), actual.spec());
-    Assert.assertEquals("Sort order must match", expected.sortOrder(), 
actual.sortOrder());
+    Assertions.assertEquals(expected.name(), actual.name(), "Name must match");
+    Assertions.assertEquals(expected.location(), actual.location(), "Location 
must match");
+    Assertions.assertEquals(expected.properties(), actual.properties(), "Props 
must match");
+    Assertions.assertEquals(expected.schema().asStruct(), 
actual.schema().asStruct(),
+        "Schema must match");
+    Assertions.assertEquals(expected.spec(), actual.spec(), "Spec must match");
+    Assertions.assertEquals(expected.sortOrder(), actual.sortOrder(), "Sort 
order must match");
   }
 
   public static void assertSerializedAndLoadedMetadata(Table expected, Table 
actual) {
     assertSerializedMetadata(expected, actual);
-    Assert.assertEquals("Specs must match", expected.specs(), actual.specs());
-    Assert.assertEquals("Sort orders must match", expected.sortOrders(), 
actual.sortOrders());
-    Assert.assertEquals("Current snapshot must match", 
expected.currentSnapshot(), actual.currentSnapshot());
-    Assert.assertEquals("Snapshots must match", expected.snapshots(), 
actual.snapshots());
-    Assert.assertEquals("History must match", expected.history(), 
actual.history());
+    Assertions.assertEquals(expected.specs(), actual.specs(), "Specs must 
match");
+    Assertions.assertEquals(expected.sortOrders(), actual.sortOrders(), "Sort 
orders must match");
+    Assertions.assertEquals(expected.currentSnapshot(), 
actual.currentSnapshot(),
+        "Current snapshot must match");
+    Assertions.assertEquals(expected.snapshots(), actual.snapshots(), 
"Snapshots must match");
+    Assertions.assertEquals(expected.history(), actual.history(), "History 
must match");
   }
 
   public static void assertSameSchemaMap(Map<Integer, Schema> map1, 
Map<Integer, Schema> map2) {
-    Assertions.assertThat(map1)
+    assertThat(map1)
         .as("Should have same number of schemas in both maps")
         .hasSameSizeAs(map2);
 
     map1.forEach(
         (schemaId, schema1) -> {
           Schema schema2 = map2.get(schemaId);
-          Assert.assertNotNull(
-              String.format("Schema ID %s does not exist in map: %s", 
schemaId, map2), schema2);
-
-          Assert.assertEquals(
-              "Should have matching schema id", schema1.schemaId(), 
schema2.schemaId());
-          Assert.assertTrue(
-              String.format(
-                  "Should be the same schema. Schema 1: %s, schema 2: %s", 
schema1, schema2),
-              schema1.sameSchema(schema2));
+          Assertions.assertNotNull(
+              schema2, String.format("Schema ID %s does not exist in map: %s", 
schemaId, map2));
+
+          Assertions.assertEquals(schema1.schemaId(), schema2.schemaId(),
+              "Should have matching schema id");
+          Assertions.assertTrue(
+              schema1.sameSchema(schema2), String.format(
+                  "Should be the same schema. Schema 1: %s, schema 2: %s", 
schema1, schema2));
         });
   }
 
@@ -150,7 +152,7 @@ private static class CheckReferencesBound extends 
ExpressionVisitors.ExpressionV
 
     @Override
     public <T> Void predicate(UnboundPredicate<T> pred) {
-      Assert.fail(message + ": Found unbound predicate: " + pred);
+      Assertions.fail(message + ": Found unbound predicate: " + pred);
       return null;
     }
   }
diff --git 
a/iceberg/iceberg-catalog/src/test/java/org/apache/iceberg/hive/TestClientPoolImpl.java
 
b/iceberg/iceberg-catalog/src/test/java/org/apache/iceberg/hive/TestClientPoolImpl.java
index 40eb948c53d..385c67f9009 100644
--- 
a/iceberg/iceberg-catalog/src/test/java/org/apache/iceberg/hive/TestClientPoolImpl.java
+++ 
b/iceberg/iceberg-catalog/src/test/java/org/apache/iceberg/hive/TestClientPoolImpl.java
@@ -30,23 +30,23 @@
 import org.apache.iceberg.AssertHelpers;
 import org.apache.iceberg.relocated.com.google.common.collect.Lists;
 import org.apache.thrift.transport.TTransportException;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 
 public class TestClientPoolImpl {
 
   HiveClientPool clients;
 
-  @Before
+  @BeforeEach
   public void before() {
     HiveClientPool clientPool = new HiveClientPool(2, new Configuration());
     clients = Mockito.spy(clientPool);
   }
 
-  @After
+  @AfterEach
   public void after() {
     clients.close();
     clients = null;
@@ -84,7 +84,7 @@ public void testConnectionFailureRestoreForMetaException() 
throws Exception {
 
     Mockito.doReturn(databases).when(newClient).getAllDatabases();
     // The return is OK when the reconnect method is called.
-    Assert.assertEquals(databases, clients.run(client -> 
client.getAllDatabases(), true));
+    Assertions.assertEquals(databases, clients.run(client -> 
client.getAllDatabases(), true));
 
     // Verify that the method is called.
     Mockito.verify(clients).reconnect(hmsClient);
@@ -104,7 +104,7 @@ public void 
testConnectionFailureRestoreForTTransportException() throws Exceptio
         new Function("concat", "db1", "classname", "root", PrincipalType.USER, 
100, FunctionType.JAVA, null));
     Mockito.doReturn(response).when(newClient).getAllFunctions();
 
-    Assert.assertEquals(response, clients.run(client -> 
client.getAllFunctions(), true));
+    Assertions.assertEquals(response, clients.run(client -> 
client.getAllFunctions(), true));
 
     Mockito.verify(clients).reconnect(hmsClient);
     Mockito.verify(clients, Mockito.never()).reconnect(newClient);
diff --git 
a/iceberg/iceberg-catalog/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
 
b/iceberg/iceberg-catalog/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
index 01616391bd8..b59828466d6 100644
--- 
a/iceberg/iceberg-catalog/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
+++ 
b/iceberg/iceberg-catalog/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
@@ -65,8 +65,8 @@
 import org.apache.iceberg.types.Types;
 import org.apache.iceberg.util.JsonUtil;
 import org.apache.thrift.TException;
-import org.junit.Assert;
 import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
@@ -595,7 +595,7 @@ public void testSetNamespaceProperties() {
     try {
       database = 
HIVE_METASTORE_EXTENSION.metastoreClient().getDatabase(namespace.level(0));
     } catch (TException e) {
-      Assert.fail();
+      Assertions.fail();
     }
     assertThat(database.getParameters()).containsEntry("owner", 
"alter_apache");
     assertThat(database.getParameters()).containsEntry("test", "test");
@@ -799,7 +799,7 @@ public void testRemoveNamespaceProperties() {
     try {
       database = 
HIVE_METASTORE_EXTENSION.metastoreClient().getDatabase(namespace.level(0));
     } catch (TException e) {
-      Assert.fail();
+      Assertions.fail();
     }
     assertThat(database.getParameters()).doesNotContainKey("owner");
     assertThat(database.getParameters()).containsEntry("group", "iceberg");

Reply via email to