Skip to content

Commit 7ed24ad

Browse files
committed
HADOOP-19343: Remove JUnit 4 dependencies from hadoop-gcp.
Closes #7872 Signed-off-by: Shilun Fan <[email protected]>
1 parent 5df54c8 commit 7ed24ad

File tree

4 files changed

+85
-64
lines changed

4 files changed

+85
-64
lines changed

hadoop-tools/hadoop-gcp/pom.xml

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -425,23 +425,23 @@
425425
</plugins>
426426
</build>
427427

428-
<dependencyManagement>
429-
<dependencies>
430-
<dependency>
431-
<!--
432-
We're using a specific Protobuf version to ensure compatibility with the
433-
Google Cloud Storage (GCS) client. The GCS client often relies on
434-
particular Long-Term Support (LTS) versions of Protobuf. When we upgrade
435-
the GCS client, we'll likely need to update Protobuf too. To prevent
436-
dependency conflicts, Protobuf will be shaded within the GCS connector's
437-
fat JAR.
438-
-->
439-
<groupId>com.google.protobuf</groupId>
440-
<artifactId>protobuf-java</artifactId>
441-
<version>3.25.5</version>
442-
</dependency>
443-
</dependencies>
444-
</dependencyManagement>
428+
<dependencyManagement>
429+
<dependencies>
430+
<dependency>
431+
<!--
432+
We're using a specific Protobuf version to ensure compatibility with the
433+
Google Cloud Storage (GCS) client. The GCS client often relies on
434+
particular Long-Term Support (LTS) versions of Protobuf. When we upgrade
435+
the GCS client, we'll likely need to update Protobuf too. To prevent
436+
dependency conflicts, Protobuf will be shaded within the GCS connector's
437+
fat JAR.
438+
-->
439+
<groupId>com.google.protobuf</groupId>
440+
<artifactId>protobuf-java</artifactId>
441+
<version>3.25.5</version>
442+
</dependency>
443+
</dependencies>
444+
</dependencyManagement>
445445

446446
<dependencies>
447447
<dependency>
@@ -475,26 +475,16 @@
475475
<artifactId>assertj-core</artifactId>
476476
<scope>test</scope>
477477
</dependency>
478-
<dependency>
479-
<groupId>junit</groupId>
480-
<artifactId>junit</artifactId>
481-
<scope>test</scope>
482-
</dependency>
483478
<dependency>
484479
<groupId>org.junit.platform</groupId>
485480
<artifactId>junit-platform-launcher</artifactId>
486481
<scope>test</scope>
487482
</dependency>
488-
<dependency>
489-
<groupId>org.junit.vintage</groupId>
490-
<artifactId>junit-vintage-engine</artifactId>
491-
<scope>test</scope>
492-
</dependency>
493483
<dependency>
494484
<groupId>com.google.cloud</groupId>
495485
<artifactId>google-cloud-storage</artifactId>
496486
</dependency>
497-
<dependency>
487+
<dependency>
498488
<groupId>org.junit.jupiter</groupId>
499489
<artifactId>junit-jupiter-api</artifactId>
500490
<scope>test</scope>
@@ -511,4 +501,3 @@
511501
</dependency>
512502
</dependencies>
513503
</project>
514-

hadoop-tools/hadoop-gcp/src/test/java/org/apache/hadoop/fs/gs/TestStorageResourceId.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
import java.net.URI;
2222

23-
import org.junit.Test;
23+
import org.junit.jupiter.api.Test;
2424

2525
import static org.junit.jupiter.api.Assertions.assertNull;
2626
import static org.junit.jupiter.api.Assertions.assertThrows;

hadoop-tools/hadoop-gcp/src/test/java/org/apache/hadoop/fs/gs/TestStringPaths.java

Lines changed: 47 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818

1919
package org.apache.hadoop.fs.gs;
2020

21-
import org.junit.Test;
21+
import org.junit.jupiter.api.Test;
2222
import static org.junit.jupiter.api.Assertions.assertNull;
2323
import static org.junit.jupiter.api.Assertions.assertEquals;
24+
import static org.junit.jupiter.api.Assertions.assertThrows;
2425
import static org.junit.jupiter.api.Assertions.assertTrue;
2526
import static org.junit.jupiter.api.Assertions.assertFalse;
2627

@@ -42,29 +43,39 @@ public void testValidateBucketNameEndsWithSlash() {
4243
assertEquals("another-bucket", StringPaths.validateBucketName("another-bucket/"));
4344
}
4445

45-
@Test(expected = IllegalArgumentException.class)
46+
@Test
4647
public void testValidateBucketNameEmpty() {
47-
StringPaths.validateBucketName("");
48+
assertThrows(IllegalArgumentException.class, () -> {
49+
StringPaths.validateBucketName("");
50+
});
4851
}
4952

50-
@Test(expected = IllegalArgumentException.class)
53+
@Test
5154
public void testValidateBucketNameNull() {
52-
StringPaths.validateBucketName(null);
55+
assertThrows(IllegalArgumentException.class, () -> {
56+
StringPaths.validateBucketName(null);
57+
});
5358
}
5459

55-
@Test(expected = IllegalArgumentException.class)
60+
@Test
5661
public void testValidateBucketNameInvalidChars() {
57-
StringPaths.validateBucketName("my bucket"); // Space
62+
assertThrows(IllegalArgumentException.class, () -> {
63+
StringPaths.validateBucketName("my bucket"); // Space
64+
});
5865
}
5966

60-
@Test(expected = IllegalArgumentException.class)
67+
@Test
6168
public void testValidateBucketNameInvalidChars2() {
62-
StringPaths.validateBucketName("my@bucket"); // @ symbol
69+
assertThrows(IllegalArgumentException.class, () -> {
70+
StringPaths.validateBucketName("my@bucket"); // @ symbol
71+
});
6372
}
6473

65-
@Test(expected = IllegalArgumentException.class)
74+
@Test
6675
public void testValidateBucketNameUpperCase() {
67-
StringPaths.validateBucketName("MyBucket"); // Uppercase
76+
assertThrows(IllegalArgumentException.class, () -> {
77+
StringPaths.validateBucketName("MyBucket"); // Uppercase
78+
});
6879
}
6980

7081
@Test
@@ -84,14 +95,18 @@ public void testValidateObjectNameLeadingSlash() {
8495
assertEquals("object", StringPaths.validateObjectName("/object", false));
8596
}
8697

87-
@Test(expected = IllegalArgumentException.class)
98+
@Test
8899
public void testValidateObjectNameEmptyNotAllowed() {
89-
StringPaths.validateObjectName("", false);
100+
assertThrows(IllegalArgumentException.class, () -> {
101+
StringPaths.validateObjectName("", false);
102+
});
90103
}
91104

92-
@Test(expected = IllegalArgumentException.class)
105+
@Test
93106
public void testValidateObjectNameNullNotAllowed() {
94-
StringPaths.validateObjectName(null, false);
107+
assertThrows(IllegalArgumentException.class, () -> {
108+
StringPaths.validateObjectName(null, false);
109+
});
95110
}
96111

97112
@Test
@@ -101,19 +116,25 @@ public void testValidateObjectNameEmptyAllowed() {
101116
assertEquals("", StringPaths.validateObjectName("/", true)); // Single slash becomes empty
102117
}
103118

104-
@Test(expected = IllegalArgumentException.class)
119+
@Test
105120
public void testValidateObjectNameConsecutiveSlashes() {
106-
StringPaths.validateObjectName("path//to/object", false);
121+
assertThrows(IllegalArgumentException.class, () -> {
122+
StringPaths.validateObjectName("path//to/object", false);
123+
});
107124
}
108125

109-
@Test(expected = IllegalArgumentException.class)
126+
@Test
110127
public void testValidateObjectNameConsecutiveSlashesAtStart() {
111-
StringPaths.validateObjectName("//path/to/object", false);
128+
assertThrows(IllegalArgumentException.class, () -> {
129+
StringPaths.validateObjectName("//path/to/object", false);
130+
});
112131
}
113132

114-
@Test(expected = IllegalArgumentException.class)
133+
@Test
115134
public void testValidateObjectNameConsecutiveSlashesAtEnd() {
116-
StringPaths.validateObjectName("path/to/object//", false);
135+
assertThrows(IllegalArgumentException.class, () -> {
136+
StringPaths.validateObjectName("path/to/object//", false);
137+
});
117138
}
118139

119140
@Test
@@ -124,9 +145,11 @@ public void testFromComponentsValid() {
124145
assertEquals("gs://my-bucket/", StringPaths.fromComponents("my-bucket", ""));
125146
}
126147

127-
@Test(expected = IllegalArgumentException.class)
148+
@Test
128149
public void testFromComponentsNullBucketNonNullObject() {
129-
StringPaths.fromComponents(null, "path/to/object");
150+
assertThrows(IllegalArgumentException.class, () -> {
151+
StringPaths.fromComponents(null, "path/to/object");
152+
});
130153
}
131154

132155
@Test
@@ -163,4 +186,4 @@ public void testToDirectoryPath() {
163186
assertEquals("", StringPaths.toDirectoryPath(""));
164187
assertNull(StringPaths.toDirectoryPath(null));
165188
}
166-
}
189+
}

hadoop-tools/hadoop-gcp/src/test/java/org/apache/hadoop/fs/gs/TestUriPaths.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020

2121
import java.net.URI;
2222

23-
import org.junit.Test;
23+
import org.junit.jupiter.api.Test;
2424
import static org.junit.jupiter.api.Assertions.assertEquals;
25+
import static org.junit.jupiter.api.Assertions.assertThrows;
2526

2627
public class TestUriPaths {
2728
@Test
@@ -130,23 +131,31 @@ public void testFromStringPathComponentsValid() throws Exception {
130131
UriPaths.fromStringPathComponents("my-bucket", "", true));
131132
}
132133

133-
@Test(expected = IllegalArgumentException.class)
134+
@Test
134135
public void testFromStringPathComponentsNullBucketNameNotAllowed() {
135-
UriPaths.fromStringPathComponents(null, "object", false);
136+
assertThrows(IllegalArgumentException.class, () -> {
137+
UriPaths.fromStringPathComponents(null, "object", false);
138+
});
136139
}
137140

138-
@Test(expected = IllegalArgumentException.class)
141+
@Test
139142
public void testFromStringPathComponentsEmptyObjectNameNotAllowed() {
140-
UriPaths.fromStringPathComponents("my-bucket", "", false);
143+
assertThrows(IllegalArgumentException.class, () -> {
144+
UriPaths.fromStringPathComponents("my-bucket", "", false);
145+
});
141146
}
142147

143-
@Test(expected = IllegalArgumentException.class)
148+
@Test
144149
public void testFromStringPathComponentsConsecutiveSlashes() {
145-
UriPaths.fromStringPathComponents("my-bucket", "path//to/object", false);
150+
assertThrows(IllegalArgumentException.class, () -> {
151+
UriPaths.fromStringPathComponents("my-bucket", "path//to/object", false);
152+
});
146153
}
147154

148-
@Test(expected = IllegalArgumentException.class)
155+
@Test
149156
public void testFromStringPathComponentsInvalidBucketName() {
150-
UriPaths.fromStringPathComponents("MyBucket", "object", false); // Uppercase
157+
assertThrows(IllegalArgumentException.class, () -> {
158+
UriPaths.fromStringPathComponents("MyBucket", "object", false); // Uppercase
159+
});
151160
}
152-
}
161+
}

0 commit comments

Comments
 (0)