You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by et...@apache.org on 2023/05/15 07:34:31 UTC

[iceberg] branch master updated: Core: Remove deprecated AssertHelpers usage (#7597)

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 00f7babfdc Core: Remove deprecated AssertHelpers usage (#7597)
00f7babfdc is described below

commit 00f7babfdcc2d21694dc50522c201d3bd0050732
Author: Liu Xiao <42...@users.noreply.github.com>
AuthorDate: Mon May 15 15:34:24 2023 +0800

    Core: Remove deprecated AssertHelpers usage (#7597)
---
 .../iceberg/actions/TestBinPackStrategy.java       | 87 +++++++++++---------
 .../apache/iceberg/actions/TestSortStrategy.java   | 38 ++++-----
 .../iceberg/io/TestByteBufferInputStreams.java     | 56 ++++---------
 .../java/org/apache/iceberg/io/TestIOUtil.java     | 21 ++---
 .../org/apache/iceberg/jdbc/TestJdbcCatalog.java   | 96 +++++++++-------------
 .../apache/iceberg/mapping/TestNameMapping.java    | 26 +++---
 .../org/apache/iceberg/rest/TestHTTPClient.java    | 13 ++-
 .../org/apache/iceberg/rest/TestRESTCatalog.java   | 20 ++---
 .../iceberg/util/TestInMemoryLockManager.java      | 12 +--
 .../org/apache/iceberg/util/TestLocationUtil.java  | 10 +--
 .../org/apache/iceberg/util/TestTableScanUtil.java | 11 ++-
 11 files changed, 170 insertions(+), 220 deletions(-)

diff --git a/core/src/test/java/org/apache/iceberg/actions/TestBinPackStrategy.java b/core/src/test/java/org/apache/iceberg/actions/TestBinPackStrategy.java
index 5a0baf9aff..07f0b84439 100644
--- a/core/src/test/java/org/apache/iceberg/actions/TestBinPackStrategy.java
+++ b/core/src/test/java/org/apache/iceberg/actions/TestBinPackStrategy.java
@@ -23,7 +23,6 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 import java.util.stream.Collectors;
-import org.apache.iceberg.AssertHelpers;
 import org.apache.iceberg.DataFile;
 import org.apache.iceberg.FileScanTask;
 import org.apache.iceberg.MockFileScanTask;
@@ -33,6 +32,7 @@ import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
 import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
 import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
 import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -307,46 +307,51 @@ public class TestBinPackStrategy extends TableTestBase {
 
   @Test
   public void testInvalidOptions() {
-    AssertHelpers.assertThrows(
-        "Should not allow max size smaller than target",
-        IllegalArgumentException.class,
-        () -> {
-          defaultBinPack()
-              .options(ImmutableMap.of(BinPackStrategy.MAX_FILE_SIZE_BYTES, Long.toString(1 * MB)));
-        });
-
-    AssertHelpers.assertThrows(
-        "Should not allow min size larger than target",
-        IllegalArgumentException.class,
-        () -> {
-          defaultBinPack()
-              .options(
-                  ImmutableMap.of(BinPackStrategy.MIN_FILE_SIZE_BYTES, Long.toString(1000 * MB)));
-        });
-
-    AssertHelpers.assertThrows(
-        "Should not allow min input size smaller than 1",
-        IllegalArgumentException.class,
-        () -> {
-          defaultBinPack()
-              .options(ImmutableMap.of(BinPackStrategy.MIN_INPUT_FILES, Long.toString(-5)));
-        });
-
-    AssertHelpers.assertThrows(
-        "Should not allow min deletes per file smaller than 1",
-        IllegalArgumentException.class,
-        () -> {
-          defaultBinPack()
-              .options(ImmutableMap.of(BinPackStrategy.DELETE_FILE_THRESHOLD, Long.toString(-5)));
-        });
-
-    AssertHelpers.assertThrows(
-        "Should not allow negative target size",
-        IllegalArgumentException.class,
-        () -> {
-          defaultBinPack()
-              .options(ImmutableMap.of(RewriteDataFiles.TARGET_FILE_SIZE_BYTES, Long.toString(-5)));
-        });
+    Assertions.assertThatThrownBy(
+            () ->
+                defaultBinPack()
+                    .options(
+                        ImmutableMap.of(
+                            BinPackStrategy.MAX_FILE_SIZE_BYTES, Long.toString(1 * MB))))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageStartingWith(
+            "Cannot set min-file-size-bytes greater than or equal to max-file-size-bytes");
+
+    Assertions.assertThatThrownBy(
+            () ->
+                defaultBinPack()
+                    .options(
+                        ImmutableMap.of(
+                            BinPackStrategy.MIN_FILE_SIZE_BYTES, Long.toString(1000 * MB))))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageStartingWith(
+            "Cannot set min-file-size-bytes greater than or equal to max-file-size-bytes");
+
+    Assertions.assertThatThrownBy(
+            () ->
+                defaultBinPack()
+                    .options(ImmutableMap.of(BinPackStrategy.MIN_INPUT_FILES, Long.toString(-5))))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageStartingWith(
+            "Cannot set min-input-files is less than 1. All values less than 1 have the same effect as 1");
+
+    Assertions.assertThatThrownBy(
+            () ->
+                defaultBinPack()
+                    .options(
+                        ImmutableMap.of(BinPackStrategy.DELETE_FILE_THRESHOLD, Long.toString(-5))))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageStartingWith(
+            "Cannot set delete-file-threshold is less than 1. All values less than 1 have the same effect as 1");
+
+    Assertions.assertThatThrownBy(
+            () ->
+                defaultBinPack()
+                    .options(
+                        ImmutableMap.of(
+                            RewriteDataFiles.TARGET_FILE_SIZE_BYTES, Long.toString(-5))))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageStartingWith("Cannot set min-file-size-bytes to a negative number");
   }
 
   @Test
diff --git a/core/src/test/java/org/apache/iceberg/actions/TestSortStrategy.java b/core/src/test/java/org/apache/iceberg/actions/TestSortStrategy.java
index 8d199512be..57c1e066b1 100644
--- a/core/src/test/java/org/apache/iceberg/actions/TestSortStrategy.java
+++ b/core/src/test/java/org/apache/iceberg/actions/TestSortStrategy.java
@@ -22,7 +22,6 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 import java.util.stream.IntStream;
-import org.apache.iceberg.AssertHelpers;
 import org.apache.iceberg.DataFile;
 import org.apache.iceberg.FileScanTask;
 import org.apache.iceberg.MockFileScanTask;
@@ -34,6 +33,7 @@ import org.apache.iceberg.exceptions.ValidationException;
 import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
 import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
 import org.apache.iceberg.types.Types;
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -85,24 +85,24 @@ public class TestSortStrategy extends TableTestBase {
 
   @Test
   public void testInvalidSortOrder() {
-    AssertHelpers.assertThrows(
-        "Should not allow an unsorted Sort order",
-        IllegalArgumentException.class,
-        () -> defaultSort().sortOrder(SortOrder.unsorted()).options(Collections.emptyMap()));
-
-    AssertHelpers.assertThrows(
-        "Should not allow a Sort order with bad columns",
-        ValidationException.class,
-        () -> {
-          Schema badSchema =
-              new Schema(
-                  ImmutableList.of(
-                      Types.NestedField.required(0, "nonexistant", Types.IntegerType.get())));
-
-          defaultSort()
-              .sortOrder(SortOrder.builderFor(badSchema).asc("nonexistant").build())
-              .options(Collections.emptyMap());
-        });
+    Assertions.assertThatThrownBy(
+            () -> defaultSort().sortOrder(SortOrder.unsorted()).options(Collections.emptyMap()))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Cannot set strategy sort order: unsorted");
+
+    Assertions.assertThatThrownBy(
+            () -> {
+              Schema badSchema =
+                  new Schema(
+                      ImmutableList.of(
+                          Types.NestedField.required(0, "nonexistant", Types.IntegerType.get())));
+
+              defaultSort()
+                  .sortOrder(SortOrder.builderFor(badSchema).asc("nonexistant").build())
+                  .options(Collections.emptyMap());
+            })
+        .isInstanceOf(ValidationException.class)
+        .hasMessageStartingWith("Cannot find field 'nonexistant' in struct");
   }
 
   @Test
diff --git a/core/src/test/java/org/apache/iceberg/io/TestByteBufferInputStreams.java b/core/src/test/java/org/apache/iceberg/io/TestByteBufferInputStreams.java
index 59a23865ba..ef6ee9ae54 100644
--- a/core/src/test/java/org/apache/iceberg/io/TestByteBufferInputStreams.java
+++ b/core/src/test/java/org/apache/iceberg/io/TestByteBufferInputStreams.java
@@ -23,9 +23,8 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.Collections;
 import java.util.List;
-import java.util.concurrent.Callable;
-import org.apache.iceberg.AssertHelpers;
 import org.apache.iceberg.relocated.com.google.common.collect.Lists;
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -159,10 +158,7 @@ public abstract class TestByteBufferInputStreams {
       Assert.assertEquals(i, stream.read());
     }
 
-    AssertHelpers.assertThrows(
-        "Should throw EOFException at end of stream",
-        EOFException.class,
-        (Callable<Integer>) stream::read);
+    Assertions.assertThatThrownBy(stream::read).isInstanceOf(EOFException.class).hasMessage(null);
 
     checkOriginalData();
   }
@@ -213,10 +209,9 @@ public abstract class TestByteBufferInputStreams {
 
     Assert.assertEquals("Should consume all buffers", length, stream.getPos());
 
-    AssertHelpers.assertThrows(
-        "Should throw EOFException when empty",
-        EOFException.class,
-        () -> stream.sliceBuffers(length));
+    Assertions.assertThatThrownBy(() -> stream.sliceBuffers(length))
+        .isInstanceOf(EOFException.class)
+        .hasMessage(null);
 
     ByteBufferInputStream copy = ByteBufferInputStream.wrap(buffers);
     for (int i = 0; i < length; i += 1) {
@@ -339,13 +334,10 @@ public abstract class TestByteBufferInputStreams {
     Assert.assertEquals(0, stream2.getPos());
 
     int length = stream2.available();
-    AssertHelpers.assertThrows(
-        "Should throw when out of bytes",
-        EOFException.class,
-        () -> {
-          stream2.skipFully(length + 10);
-          return null;
-        });
+
+    Assertions.assertThatThrownBy(() -> stream2.skipFully(length + 10))
+        .isInstanceOf(EOFException.class)
+        .hasMessageStartingWith("Not enough bytes to skip");
   }
 
   @Test
@@ -464,13 +456,9 @@ public abstract class TestByteBufferInputStreams {
   public void testMarkUnset() {
     ByteBufferInputStream stream = newStream();
 
-    AssertHelpers.assertThrows(
-        "Should throw an error for reset() without mark()",
-        IOException.class,
-        () -> {
-          stream.reset();
-          return null;
-        });
+    Assertions.assertThatThrownBy(stream::reset)
+        .isInstanceOf(IOException.class)
+        .hasMessageStartingWith("No mark defined");
   }
 
   @Test
@@ -508,13 +496,9 @@ public abstract class TestByteBufferInputStreams {
 
     Assert.assertEquals("Should read 6 bytes", 6, stream.read(new byte[6]));
 
-    AssertHelpers.assertThrows(
-        "Should throw an error for reset() after limit",
-        IOException.class,
-        () -> {
-          stream.reset();
-          return null;
-        });
+    Assertions.assertThatThrownBy(stream::reset)
+        .isInstanceOf(IOException.class)
+        .hasMessageStartingWith("No mark defined");
   }
 
   @Test
@@ -526,12 +510,8 @@ public abstract class TestByteBufferInputStreams {
 
     stream.reset();
 
-    AssertHelpers.assertThrows(
-        "Should throw an error for double reset()",
-        IOException.class,
-        () -> {
-          stream.reset();
-          return null;
-        });
+    Assertions.assertThatThrownBy(stream::reset)
+        .isInstanceOf(IOException.class)
+        .hasMessageStartingWith("No mark defined");
   }
 }
diff --git a/core/src/test/java/org/apache/iceberg/io/TestIOUtil.java b/core/src/test/java/org/apache/iceberg/io/TestIOUtil.java
index bccc7cd952..568a5dbe9b 100644
--- a/core/src/test/java/org/apache/iceberg/io/TestIOUtil.java
+++ b/core/src/test/java/org/apache/iceberg/io/TestIOUtil.java
@@ -23,7 +23,6 @@ import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
-import org.apache.iceberg.AssertHelpers;
 import org.apache.iceberg.inmemory.InMemoryOutputFile;
 import org.apache.iceberg.relocated.com.google.common.base.Strings;
 import org.assertj.core.api.Assertions;
@@ -70,13 +69,9 @@ public class TestIOUtil {
         "Byte array contents should match", MockInputStream.TEST_ARRAY, buffer);
     Assert.assertEquals("Stream position should reflect bytes read", 10, stream.getPos());
 
-    AssertHelpers.assertThrows(
-        "Should throw EOFException if no more bytes left",
-        EOFException.class,
-        () -> {
-          IOUtil.readFully(stream, buffer, 0, 1);
-          return null;
-        });
+    Assertions.assertThatThrownBy(() -> IOUtil.readFully(stream, buffer, 0, 1))
+        .isInstanceOf(EOFException.class)
+        .hasMessage("Reached the end of stream with 1 bytes left to read");
   }
 
   @Test
@@ -85,13 +80,9 @@ public class TestIOUtil {
 
     final MockInputStream stream = new MockInputStream(2, 3, 3);
 
-    AssertHelpers.assertThrows(
-        "Should throw EOFException if no more bytes left",
-        EOFException.class,
-        () -> {
-          IOUtil.readFully(stream, buffer, 0, buffer.length);
-          return null;
-        });
+    Assertions.assertThatThrownBy(() -> IOUtil.readFully(stream, buffer, 0, buffer.length))
+        .isInstanceOf(EOFException.class)
+        .hasMessage("Reached the end of stream with 1 bytes left to read");
 
     Assert.assertArrayEquals(
         "Should have consumed bytes",
diff --git a/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java b/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java
index b0fdea458d..644b2ff526 100644
--- a/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java
+++ b/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java
@@ -38,7 +38,6 @@ import java.util.stream.Stream;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
-import org.apache.iceberg.AssertHelpers;
 import org.apache.iceberg.CatalogProperties;
 import org.apache.iceberg.DataFile;
 import org.apache.iceberg.DataFiles;
@@ -277,11 +276,10 @@ public class TestJdbcCatalog extends CatalogTests<JdbcCatalog> {
     FileSystem fs = Util.getFs(new Path(metaLocation), conf);
     Assert.assertTrue(fs.isDirectory(new Path(metaLocation)));
 
-    AssertHelpers.assertThrows(
-        "should throw exception",
-        AlreadyExistsException.class,
-        "already exists",
-        () -> catalog.createTable(testTable, SCHEMA, PartitionSpec.unpartitioned()));
+    Assertions.assertThatThrownBy(
+            () -> catalog.createTable(testTable, SCHEMA, PartitionSpec.unpartitioned()))
+        .isInstanceOf(AlreadyExistsException.class)
+        .hasMessage("Table already exists: db.ns1.ns2.tbl");
 
     catalog.dropTable(testTable);
   }
@@ -337,11 +335,10 @@ public class TestJdbcCatalog extends CatalogTests<JdbcCatalog> {
             .withRecordCount(1)
             .build();
 
-    AssertHelpers.assertThrows(
-        "Should fail",
-        NoSuchTableException.class,
-        "Failed to load table",
-        () -> table.newAppend().appendFile(dataFile2).commit());
+    Assertions.assertThatThrownBy(() -> table.newAppend().appendFile(dataFile2).commit())
+        .isInstanceOf(NoSuchTableException.class)
+        .hasMessage(
+            "Failed to load table db.table from catalog test_jdbc_catalog: dropped by another process");
   }
 
   @Test
@@ -393,11 +390,10 @@ public class TestJdbcCatalog extends CatalogTests<JdbcCatalog> {
     catalog.dropTable(testTable);
     Assert.assertFalse(catalog.listTables(testTable.namespace()).contains(testTable));
     catalog.dropTable(testTable2);
-    AssertHelpers.assertThrows(
-        "should throw exception",
-        NoSuchNamespaceException.class,
-        "not exist",
-        () -> catalog.listTables(testTable2.namespace()));
+
+    Assertions.assertThatThrownBy(() -> catalog.listTables(testTable2.namespace()))
+        .isInstanceOf(NoSuchNamespaceException.class)
+        .hasMessage("Namespace does not exist: db.ns1.ns2");
 
     Assert.assertFalse(catalog.dropTable(TableIdentifier.of("db", "tbl-not-exists")));
   }
@@ -425,20 +421,17 @@ public class TestJdbcCatalog extends CatalogTests<JdbcCatalog> {
     Assert.assertFalse(catalog.listTables(to.namespace()).contains(from));
     Assert.assertTrue(catalog.loadTable(to).name().endsWith(to.name()));
 
-    AssertHelpers.assertThrows(
-        "should throw exception",
-        NoSuchTableException.class,
-        "Table does not exist",
-        () -> catalog.renameTable(TableIdentifier.of("db", "tbl-not-exists"), to));
+    Assertions.assertThatThrownBy(
+            () -> catalog.renameTable(TableIdentifier.of("db", "tbl-not-exists"), to))
+        .isInstanceOf(NoSuchTableException.class)
+        .hasMessage("Table does not exist: db.tbl-not-exists");
 
     // rename table to existing table name!
     TableIdentifier from2 = TableIdentifier.of("db", "tbl2");
     catalog.createTable(from2, SCHEMA, PartitionSpec.unpartitioned());
-    AssertHelpers.assertThrows(
-        "should throw exception",
-        AlreadyExistsException.class,
-        "Table already exists",
-        () -> catalog.renameTable(from2, to));
+    Assertions.assertThatThrownBy(() -> catalog.renameTable(from2, to))
+        .isInstanceOf(AlreadyExistsException.class)
+        .hasMessage("Table already exists: db.tbl2-newtable");
   }
 
   @Test
@@ -462,11 +455,9 @@ public class TestJdbcCatalog extends CatalogTests<JdbcCatalog> {
     Assert.assertEquals(tbls2.size(), 1);
     Assert.assertEquals("tbl3", tbls2.get(0).name());
 
-    AssertHelpers.assertThrows(
-        "should throw exception",
-        NoSuchNamespaceException.class,
-        "does not exist",
-        () -> catalog.listTables(Namespace.of("db", "ns1", "ns2")));
+    Assertions.assertThatThrownBy(() -> catalog.listTables(Namespace.of("db", "ns1", "ns2")))
+        .isInstanceOf(NoSuchNamespaceException.class)
+        .hasMessage("Namespace does not exist: db.ns1.ns2");
   }
 
   @Test
@@ -550,11 +541,9 @@ public class TestJdbcCatalog extends CatalogTests<JdbcCatalog> {
     Assert.assertTrue(tblSet3.contains("db2"));
     Assert.assertTrue(tblSet3.contains(""));
 
-    AssertHelpers.assertThrows(
-        "Should fail to list namespace doesn't exist",
-        NoSuchNamespaceException.class,
-        "Namespace does not exist",
-        () -> catalog.listNamespaces(Namespace.of("db", "db2", "ns2")));
+    Assertions.assertThatThrownBy(() -> catalog.listNamespaces(Namespace.of("db", "db2", "ns2")))
+        .isInstanceOf(NoSuchNamespaceException.class)
+        .hasMessage("Namespace does not exist: db.db2.ns2");
   }
 
   @Test
@@ -569,11 +558,10 @@ public class TestJdbcCatalog extends CatalogTests<JdbcCatalog> {
 
     Assert.assertTrue(catalog.loadNamespaceMetadata(Namespace.of("db")).containsKey("location"));
 
-    AssertHelpers.assertThrows(
-        "Should fail to load namespace doesn't exist",
-        NoSuchNamespaceException.class,
-        "Namespace does not exist",
-        () -> catalog.loadNamespaceMetadata(Namespace.of("db", "db2", "ns2")));
+    Assertions.assertThatThrownBy(
+            () -> catalog.loadNamespaceMetadata(Namespace.of("db", "db2", "ns2")))
+        .isInstanceOf(NoSuchNamespaceException.class)
+        .hasMessage("Namespace does not exist: db.db2.ns2");
   }
 
   @Test
@@ -608,21 +596,17 @@ public class TestJdbcCatalog extends CatalogTests<JdbcCatalog> {
     Lists.newArrayList(tbl0, tbl1, tbl2, tbl3, tbl4)
         .forEach(t -> catalog.createTable(t, SCHEMA, PartitionSpec.unpartitioned()));
 
-    AssertHelpers.assertThrows(
-        "Should fail to drop namespace has tables",
-        NamespaceNotEmptyException.class,
-        "is not empty. 2 tables exist.",
-        () -> catalog.dropNamespace(tbl1.namespace()));
-    AssertHelpers.assertThrows(
-        "Should fail to drop namespace has tables",
-        NamespaceNotEmptyException.class,
-        "is not empty. 1 tables exist.",
-        () -> catalog.dropNamespace(tbl2.namespace()));
-    AssertHelpers.assertThrows(
-        "Should fail to drop namespace has tables",
-        NamespaceNotEmptyException.class,
-        "is not empty. 1 tables exist.",
-        () -> catalog.dropNamespace(tbl4.namespace()));
+    Assertions.assertThatThrownBy(() -> catalog.dropNamespace(tbl1.namespace()))
+        .isInstanceOf(NamespaceNotEmptyException.class)
+        .hasMessage("Namespace db.ns1.ns2 is not empty. 2 tables exist.");
+
+    Assertions.assertThatThrownBy(() -> catalog.dropNamespace(tbl2.namespace()))
+        .isInstanceOf(NamespaceNotEmptyException.class)
+        .hasMessage("Namespace db.ns1 is not empty. 1 tables exist.");
+
+    Assertions.assertThatThrownBy(() -> catalog.dropNamespace(tbl4.namespace()))
+        .isInstanceOf(NamespaceNotEmptyException.class)
+        .hasMessage("Namespace db is not empty. 1 tables exist.");
   }
 
   @Test
diff --git a/core/src/test/java/org/apache/iceberg/mapping/TestNameMapping.java b/core/src/test/java/org/apache/iceberg/mapping/TestNameMapping.java
index 30cda48860..bde99b4113 100644
--- a/core/src/test/java/org/apache/iceberg/mapping/TestNameMapping.java
+++ b/core/src/test/java/org/apache/iceberg/mapping/TestNameMapping.java
@@ -20,9 +20,9 @@ package org.apache.iceberg.mapping;
 
 import static org.apache.iceberg.types.Types.NestedField.required;
 
-import org.apache.iceberg.AssertHelpers;
 import org.apache.iceberg.Schema;
 import org.apache.iceberg.types.Types;
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -176,23 +176,21 @@ public class TestNameMapping {
   @Test
   public void testFailsDuplicateId() {
     // the schema can be created because ID indexing is lazy
-    AssertHelpers.assertThrows(
-        "Should fail if IDs are reused",
-        IllegalArgumentException.class,
-        "Multiple entries with same",
-        () ->
-            new Schema(
-                required(1, "id", Types.LongType.get()),
-                required(1, "data", Types.StringType.get())));
+    Assertions.assertThatThrownBy(
+            () ->
+                new Schema(
+                    required(1, "id", Types.LongType.get()),
+                    required(1, "data", Types.StringType.get())))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Multiple entries with same key: 1=id and 1=data");
   }
 
   @Test
   public void testFailsDuplicateName() {
-    AssertHelpers.assertThrows(
-        "Should fail if names are reused",
-        IllegalArgumentException.class,
-        "Multiple entries with same key",
-        () -> new NameMapping(MappedFields.of(MappedField.of(1, "x"), MappedField.of(2, "x"))));
+    Assertions.assertThatThrownBy(
+            () -> new NameMapping(MappedFields.of(MappedField.of(1, "x"), MappedField.of(2, "x"))))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Multiple entries with same key: x=2 and x=1");
   }
 
   @Test
diff --git a/core/src/test/java/org/apache/iceberg/rest/TestHTTPClient.java b/core/src/test/java/org/apache/iceberg/rest/TestHTTPClient.java
index faf3d692b7..63f16cb2ea 100644
--- a/core/src/test/java/org/apache/iceberg/rest/TestHTTPClient.java
+++ b/core/src/test/java/org/apache/iceberg/rest/TestHTTPClient.java
@@ -39,11 +39,11 @@ import org.apache.hc.core5.http.EntityDetails;
 import org.apache.hc.core5.http.HttpException;
 import org.apache.hc.core5.http.HttpRequestInterceptor;
 import org.apache.hc.core5.http.protocol.HttpContext;
-import org.apache.iceberg.AssertHelpers;
 import org.apache.iceberg.IcebergBuild;
 import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
 import org.apache.iceberg.rest.responses.ErrorResponse;
 import org.apache.iceberg.rest.responses.ErrorResponseParser;
+import org.assertj.core.api.Assertions;
 import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.BeforeClass;
@@ -171,12 +171,11 @@ public class TestHTTPClient {
 
     String path = addRequestTestCaseAndGetPath(method, body, statusCode);
 
-    AssertHelpers.assertThrows(
-        "A response indicating a failed request should throw",
-        RuntimeException.class,
-        String.format(
-            "Called error handler for method %s due to status code: %d", method, statusCode),
-        () -> doExecuteRequest(method, path, body, onError, h -> {}));
+    Assertions.assertThatThrownBy(() -> doExecuteRequest(method, path, body, onError, h -> {}))
+        .isInstanceOf(RuntimeException.class)
+        .hasMessage(
+            String.format(
+                "Called error handler for method %s due to status code: %d", method, statusCode));
 
     verify(onError).accept(any());
   }
diff --git a/core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java b/core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java
index c4b277312b..02468f3d9b 100644
--- a/core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java
+++ b/core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java
@@ -38,7 +38,6 @@ import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Consumer;
 import java.util.stream.Collectors;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.iceberg.AssertHelpers;
 import org.apache.iceberg.CatalogProperties;
 import org.apache.iceberg.DataFiles;
 import org.apache.iceberg.FileScanTask;
@@ -289,17 +288,14 @@ public class TestRESTCatalog extends CatalogTests<RESTCatalog> {
   @Test
   public void testInitializeWithBadArguments() throws IOException {
     RESTCatalog restCat = new RESTCatalog();
-    AssertHelpers.assertThrows(
-        "Configuration passed to initialize cannot be null",
-        IllegalArgumentException.class,
-        "Invalid configuration: null",
-        () -> restCat.initialize("prod", null));
-
-    AssertHelpers.assertThrows(
-        "Configuration passed to initialize must have uri",
-        NullPointerException.class,
-        "Invalid uri for http client: null",
-        () -> restCat.initialize("prod", ImmutableMap.of()));
+    org.assertj.core.api.Assertions.assertThatThrownBy(() -> restCat.initialize("prod", null))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessage("Invalid configuration: null");
+
+    org.assertj.core.api.Assertions.assertThatThrownBy(
+            () -> restCat.initialize("prod", ImmutableMap.of()))
+        .isInstanceOf(NullPointerException.class)
+        .hasMessage("Invalid uri for http client: null");
 
     restCat.close();
   }
diff --git a/core/src/test/java/org/apache/iceberg/util/TestInMemoryLockManager.java b/core/src/test/java/org/apache/iceberg/util/TestInMemoryLockManager.java
index 4d56d1b202..48fc4a2cb3 100644
--- a/core/src/test/java/org/apache/iceberg/util/TestInMemoryLockManager.java
+++ b/core/src/test/java/org/apache/iceberg/util/TestInMemoryLockManager.java
@@ -24,10 +24,10 @@ import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
-import org.apache.iceberg.AssertHelpers;
 import org.apache.iceberg.CatalogProperties;
 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.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -58,11 +58,11 @@ public class TestInMemoryLockManager {
   @Test
   public void testAcquireOnceSingleProcess() {
     lockManager.acquireOnce(lockEntityId, ownerId);
-    AssertHelpers.assertThrows(
-        "should fail when acquire again",
-        IllegalStateException.class,
-        "currently held",
-        () -> lockManager.acquireOnce(lockEntityId, ownerId));
+    Assertions.assertThatThrownBy(() -> lockManager.acquireOnce(lockEntityId, ownerId))
+        .isInstanceOf(IllegalStateException.class)
+        .hasMessageStartingWith("Lock for")
+        .hasMessageContaining("currently held by")
+        .hasMessageContaining("expiration");
   }
 
   @Test
diff --git a/core/src/test/java/org/apache/iceberg/util/TestLocationUtil.java b/core/src/test/java/org/apache/iceberg/util/TestLocationUtil.java
index 89d41371ff..d0b2b98243 100644
--- a/core/src/test/java/org/apache/iceberg/util/TestLocationUtil.java
+++ b/core/src/test/java/org/apache/iceberg/util/TestLocationUtil.java
@@ -18,7 +18,7 @@
  */
 package org.apache.iceberg.util;
 
-import org.apache.iceberg.AssertHelpers;
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -54,11 +54,9 @@ public class TestLocationUtil {
     String[] invalidPaths = new String[] {null, ""};
 
     for (String invalidPath : invalidPaths) {
-      AssertHelpers.assertThrows(
-          "path must be valid",
-          IllegalArgumentException.class,
-          "path must not be null or empty",
-          () -> LocationUtil.stripTrailingSlash(invalidPath));
+      Assertions.assertThatThrownBy(() -> LocationUtil.stripTrailingSlash(invalidPath))
+          .isInstanceOf(IllegalArgumentException.class)
+          .hasMessage("path must not be null or empty");
     }
   }
 }
diff --git a/core/src/test/java/org/apache/iceberg/util/TestTableScanUtil.java b/core/src/test/java/org/apache/iceberg/util/TestTableScanUtil.java
index dce4f606f4..4976ff4d9d 100644
--- a/core/src/test/java/org/apache/iceberg/util/TestTableScanUtil.java
+++ b/core/src/test/java/org/apache/iceberg/util/TestTableScanUtil.java
@@ -22,7 +22,6 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
-import org.apache.iceberg.AssertHelpers;
 import org.apache.iceberg.BaseCombinedScanTask;
 import org.apache.iceberg.CombinedScanTask;
 import org.apache.iceberg.DataFile;
@@ -42,6 +41,7 @@ import org.apache.iceberg.relocated.com.google.common.collect.ImmutableList;
 import org.apache.iceberg.relocated.com.google.common.collect.Iterables;
 import org.apache.iceberg.relocated.com.google.common.collect.Lists;
 import org.apache.iceberg.types.Types;
+import org.assertj.core.api.Assertions;
 import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mockito;
@@ -237,11 +237,10 @@ public class TestTableScanUtil {
         ImmutableList.of(
             taskWithPartition(SPEC1, PARTITION1, 128), taskWithPartition(SPEC2, PARTITION2, 128));
 
-    AssertHelpers.assertThrows(
-        "Should throw exception",
-        IllegalArgumentException.class,
-        "Cannot find field",
-        () -> TableScanUtil.planTaskGroups(tasks2, 128, 10, 4, SPEC2.partitionType()));
+    Assertions.assertThatThrownBy(
+            () -> TableScanUtil.planTaskGroups(tasks2, 128, 10, 4, SPEC2.partitionType()))
+        .isInstanceOf(IllegalArgumentException.class)
+        .hasMessageStartingWith("Cannot find field");
   }
 
   private PartitionScanTask taskWithPartition(