This is an automated email from the ASF dual-hosted git repository. cnauroth pushed a commit to branch HADOOP-19343 in repository https://gitbox.apache.org/repos/asf/hadoop.git
commit 7ed24ad5ac30b3cc3307d8f22d28aff7ae5429df Author: Chris Nauroth <cnaur...@apache.org> AuthorDate: Thu Aug 14 20:49:00 2025 +0000 HADOOP-19343: Remove JUnit 4 dependencies from hadoop-gcp. Closes #7872 Signed-off-by: Shilun Fan <slfan1...@apache.org> --- hadoop-tools/hadoop-gcp/pom.xml | 47 ++++++-------- .../apache/hadoop/fs/gs/TestStorageResourceId.java | 2 +- .../org/apache/hadoop/fs/gs/TestStringPaths.java | 71 ++++++++++++++-------- .../java/org/apache/hadoop/fs/gs/TestUriPaths.java | 29 ++++++--- 4 files changed, 85 insertions(+), 64 deletions(-) diff --git a/hadoop-tools/hadoop-gcp/pom.xml b/hadoop-tools/hadoop-gcp/pom.xml index 2da2881ab79..c3c2c6bbd8e 100644 --- a/hadoop-tools/hadoop-gcp/pom.xml +++ b/hadoop-tools/hadoop-gcp/pom.xml @@ -425,23 +425,23 @@ </plugins> </build> -<dependencyManagement> - <dependencies> - <dependency> - <!-- - We're using a specific Protobuf version to ensure compatibility with the - Google Cloud Storage (GCS) client. The GCS client often relies on - particular Long-Term Support (LTS) versions of Protobuf. When we upgrade - the GCS client, we'll likely need to update Protobuf too. To prevent - dependency conflicts, Protobuf will be shaded within the GCS connector's - fat JAR. - --> - <groupId>com.google.protobuf</groupId> - <artifactId>protobuf-java</artifactId> - <version>3.25.5</version> - </dependency> - </dependencies> - </dependencyManagement> + <dependencyManagement> + <dependencies> + <dependency> + <!-- + We're using a specific Protobuf version to ensure compatibility with the + Google Cloud Storage (GCS) client. The GCS client often relies on + particular Long-Term Support (LTS) versions of Protobuf. When we upgrade + the GCS client, we'll likely need to update Protobuf too. To prevent + dependency conflicts, Protobuf will be shaded within the GCS connector's + fat JAR. + --> + <groupId>com.google.protobuf</groupId> + <artifactId>protobuf-java</artifactId> + <version>3.25.5</version> + </dependency> + </dependencies> + </dependencyManagement> <dependencies> <dependency> @@ -475,26 +475,16 @@ <artifactId>assertj-core</artifactId> <scope>test</scope> </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-launcher</artifactId> <scope>test</scope> </dependency> - <dependency> - <groupId>org.junit.vintage</groupId> - <artifactId>junit-vintage-engine</artifactId> - <scope>test</scope> - </dependency> <dependency> <groupId>com.google.cloud</groupId> <artifactId>google-cloud-storage</artifactId> </dependency> - <dependency> + <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <scope>test</scope> @@ -511,4 +501,3 @@ </dependency> </dependencies> </project> - diff --git a/hadoop-tools/hadoop-gcp/src/test/java/org/apache/hadoop/fs/gs/TestStorageResourceId.java b/hadoop-tools/hadoop-gcp/src/test/java/org/apache/hadoop/fs/gs/TestStorageResourceId.java index e027c7b4091..5a60858487f 100644 --- a/hadoop-tools/hadoop-gcp/src/test/java/org/apache/hadoop/fs/gs/TestStorageResourceId.java +++ b/hadoop-tools/hadoop-gcp/src/test/java/org/apache/hadoop/fs/gs/TestStorageResourceId.java @@ -20,7 +20,7 @@ import java.net.URI; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/hadoop-tools/hadoop-gcp/src/test/java/org/apache/hadoop/fs/gs/TestStringPaths.java b/hadoop-tools/hadoop-gcp/src/test/java/org/apache/hadoop/fs/gs/TestStringPaths.java index a6b64ff7cff..e9ea55b52ad 100644 --- a/hadoop-tools/hadoop-gcp/src/test/java/org/apache/hadoop/fs/gs/TestStringPaths.java +++ b/hadoop-tools/hadoop-gcp/src/test/java/org/apache/hadoop/fs/gs/TestStringPaths.java @@ -18,9 +18,10 @@ package org.apache.hadoop.fs.gs; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -42,29 +43,39 @@ public void testValidateBucketNameEndsWithSlash() { assertEquals("another-bucket", StringPaths.validateBucketName("another-bucket/")); } - @Test(expected = IllegalArgumentException.class) + @Test public void testValidateBucketNameEmpty() { - StringPaths.validateBucketName(""); + assertThrows(IllegalArgumentException.class, () -> { + StringPaths.validateBucketName(""); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void testValidateBucketNameNull() { - StringPaths.validateBucketName(null); + assertThrows(IllegalArgumentException.class, () -> { + StringPaths.validateBucketName(null); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void testValidateBucketNameInvalidChars() { - StringPaths.validateBucketName("my bucket"); // Space + assertThrows(IllegalArgumentException.class, () -> { + StringPaths.validateBucketName("my bucket"); // Space + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void testValidateBucketNameInvalidChars2() { - StringPaths.validateBucketName("my@bucket"); // @ symbol + assertThrows(IllegalArgumentException.class, () -> { + StringPaths.validateBucketName("my@bucket"); // @ symbol + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void testValidateBucketNameUpperCase() { - StringPaths.validateBucketName("MyBucket"); // Uppercase + assertThrows(IllegalArgumentException.class, () -> { + StringPaths.validateBucketName("MyBucket"); // Uppercase + }); } @Test @@ -84,14 +95,18 @@ public void testValidateObjectNameLeadingSlash() { assertEquals("object", StringPaths.validateObjectName("/object", false)); } - @Test(expected = IllegalArgumentException.class) + @Test public void testValidateObjectNameEmptyNotAllowed() { - StringPaths.validateObjectName("", false); + assertThrows(IllegalArgumentException.class, () -> { + StringPaths.validateObjectName("", false); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void testValidateObjectNameNullNotAllowed() { - StringPaths.validateObjectName(null, false); + assertThrows(IllegalArgumentException.class, () -> { + StringPaths.validateObjectName(null, false); + }); } @Test @@ -101,19 +116,25 @@ public void testValidateObjectNameEmptyAllowed() { assertEquals("", StringPaths.validateObjectName("/", true)); // Single slash becomes empty } - @Test(expected = IllegalArgumentException.class) + @Test public void testValidateObjectNameConsecutiveSlashes() { - StringPaths.validateObjectName("path//to/object", false); + assertThrows(IllegalArgumentException.class, () -> { + StringPaths.validateObjectName("path//to/object", false); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void testValidateObjectNameConsecutiveSlashesAtStart() { - StringPaths.validateObjectName("//path/to/object", false); + assertThrows(IllegalArgumentException.class, () -> { + StringPaths.validateObjectName("//path/to/object", false); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void testValidateObjectNameConsecutiveSlashesAtEnd() { - StringPaths.validateObjectName("path/to/object//", false); + assertThrows(IllegalArgumentException.class, () -> { + StringPaths.validateObjectName("path/to/object//", false); + }); } @Test @@ -124,9 +145,11 @@ public void testFromComponentsValid() { assertEquals("gs://my-bucket/", StringPaths.fromComponents("my-bucket", "")); } - @Test(expected = IllegalArgumentException.class) + @Test public void testFromComponentsNullBucketNonNullObject() { - StringPaths.fromComponents(null, "path/to/object"); + assertThrows(IllegalArgumentException.class, () -> { + StringPaths.fromComponents(null, "path/to/object"); + }); } @Test @@ -163,4 +186,4 @@ public void testToDirectoryPath() { assertEquals("", StringPaths.toDirectoryPath("")); assertNull(StringPaths.toDirectoryPath(null)); } -} \ No newline at end of file +} diff --git a/hadoop-tools/hadoop-gcp/src/test/java/org/apache/hadoop/fs/gs/TestUriPaths.java b/hadoop-tools/hadoop-gcp/src/test/java/org/apache/hadoop/fs/gs/TestUriPaths.java index 0325df52f9b..20b36d90842 100644 --- a/hadoop-tools/hadoop-gcp/src/test/java/org/apache/hadoop/fs/gs/TestUriPaths.java +++ b/hadoop-tools/hadoop-gcp/src/test/java/org/apache/hadoop/fs/gs/TestUriPaths.java @@ -20,8 +20,9 @@ import java.net.URI; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class TestUriPaths { @Test @@ -130,23 +131,31 @@ public void testFromStringPathComponentsValid() throws Exception { UriPaths.fromStringPathComponents("my-bucket", "", true)); } - @Test(expected = IllegalArgumentException.class) + @Test public void testFromStringPathComponentsNullBucketNameNotAllowed() { - UriPaths.fromStringPathComponents(null, "object", false); + assertThrows(IllegalArgumentException.class, () -> { + UriPaths.fromStringPathComponents(null, "object", false); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void testFromStringPathComponentsEmptyObjectNameNotAllowed() { - UriPaths.fromStringPathComponents("my-bucket", "", false); + assertThrows(IllegalArgumentException.class, () -> { + UriPaths.fromStringPathComponents("my-bucket", "", false); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void testFromStringPathComponentsConsecutiveSlashes() { - UriPaths.fromStringPathComponents("my-bucket", "path//to/object", false); + assertThrows(IllegalArgumentException.class, () -> { + UriPaths.fromStringPathComponents("my-bucket", "path//to/object", false); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void testFromStringPathComponentsInvalidBucketName() { - UriPaths.fromStringPathComponents("MyBucket", "object", false); // Uppercase + assertThrows(IllegalArgumentException.class, () -> { + UriPaths.fromStringPathComponents("MyBucket", "object", false); // Uppercase + }); } -} \ No newline at end of file +} --------------------------------------------------------------------- To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-commits-h...@hadoop.apache.org