Skip to content

Commit 213fa1e

Browse files
committed
HADOOP-19415. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-common Part7.
1 parent db81ea6 commit 213fa1e

File tree

201 files changed

+3809
-3335
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+3809
-3335
lines changed

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfigRedactor.java

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

1919
package org.apache.hadoop.conf;
2020

21-
import org.junit.Test;
21+
import org.junit.jupiter.api.Test;
2222

2323
import java.util.Arrays;
2424
import java.util.List;

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FSMainOperationsBaseTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,13 +1001,13 @@ private void doTestRenameDirectoryAsNonExistentDirectory(Rename... options)
10011001
fSys.mkdirs(dst.getParent());
10021002

10031003
rename(src, dst, true, false, true, options);
1004-
Assert.assertFalse("Nested file1 exists",
1004+
Assert.assertFalse("Nested file1 exists",
10051005
exists(fSys, getTestRootPath(fSys, "test/hadoop/dir/file1")));
1006-
Assert.assertFalse("Nested file2 exists",
1006+
Assert.assertFalse("Nested file2 exists",
10071007
exists(fSys, getTestRootPath(fSys, "test/hadoop/dir/subdir/file2")));
10081008
Assert.assertTrue("Renamed nested file1 exists",
10091009
exists(fSys, getTestRootPath(fSys, "test/new/newdir/file1")));
1010-
Assert.assertTrue("Renamed nested exists",
1010+
Assert.assertTrue("Renamed nested exists",
10111011
exists(fSys, getTestRootPath(fSys, "test/new/newdir/subdir/file2")));
10121012
}
10131013

@@ -1117,7 +1117,7 @@ public void testGetWrappedInputStream() throws IOException {
11171117
FSDataInputStream in = fSys.open(src);
11181118
InputStream is = in.getWrappedStream();
11191119
in.close();
1120-
Assert.assertNotNull(is);
1120+
Assert.assertNotNull(is);
11211121
}
11221122

11231123
@Test

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextMainOperationsBaseTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ public void testListStatus() throws Exception {
357357
// test listStatus that returns an iterator
358358
RemoteIterator<FileStatus> pathsIterator =
359359
fc.listStatus(getTestRootPath(fc, "test"));
360-
Assert.assertEquals(getTestRootPath(fc, "test/hadoop"),
360+
Assert.assertEquals(getTestRootPath(fc, "test/hadoop"),
361361
pathsIterator.next().getPath());
362362
Assert.assertFalse(pathsIterator.hasNext());
363363

@@ -1123,7 +1123,7 @@ public void testRenameDirectoryToItself() throws Exception {
11231123
rename(src, src, true, true, Rename.OVERWRITE);
11241124
Assert.fail("Renamed directory to itself");
11251125
} catch (IOException e) {
1126-
Assert.assertTrue(unwrapException(e) instanceof FileAlreadyExistsException);
1126+
Assert.assertTrue(unwrapException(e) instanceof FileAlreadyExistsException);
11271127
}
11281128
}
11291129

@@ -1169,13 +1169,13 @@ private void testRenameDirectoryAsNonExistentDirectory(Rename... options) throws
11691169
fc.mkdir(dst.getParent(), FileContext.DEFAULT_PERM, true);
11701170

11711171
rename(src, dst, false, true, options);
1172-
Assert.assertFalse("Nested file1 exists",
1172+
Assert.assertFalse("Nested file1 exists",
11731173
exists(fc, getTestRootPath(fc, "test/hadoop/dir/file1")));
1174-
Assert.assertFalse("Nested file2 exists",
1174+
Assert.assertFalse("Nested file2 exists",
11751175
exists(fc, getTestRootPath(fc, "test/hadoop/dir/subdir/file2")));
11761176
Assert.assertTrue("Renamed nested file1 exists",
11771177
exists(fc, getTestRootPath(fc, "test/new/newdir/file1")));
1178-
Assert.assertTrue("Renamed nested exists",
1178+
Assert.assertTrue("Renamed nested exists",
11791179
exists(fc, getTestRootPath(fc, "test/new/newdir/subdir/file2")));
11801180
}
11811181

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextTestHelper.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
*/
1818
package org.apache.hadoop.fs;
1919

20+
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertNotNull;
22+
import static org.junit.jupiter.api.Assertions.assertTrue;
23+
2024
import java.io.DataInputStream;
2125
import java.io.IOException;
2226
import java.io.FileNotFoundException;
@@ -26,7 +30,6 @@
2630
import org.apache.hadoop.fs.Options.CreateOpts.BlockSize;
2731
import org.apache.hadoop.io.IOUtils;
2832
import org.apache.hadoop.test.GenericTestUtils;
29-
import org.junit.Assert;
3033

3134
/**
3235
* Helper class for unit tests.
@@ -220,28 +223,28 @@ public enum fileType {isDir, isFile, isSymlink};
220223
public static void checkFileStatus(FileContext aFc, String path,
221224
fileType expectedType) throws IOException {
222225
FileStatus s = aFc.getFileStatus(new Path(path));
223-
Assert.assertNotNull(s);
226+
assertNotNull(s);
224227
if (expectedType == fileType.isDir) {
225-
Assert.assertTrue(s.isDirectory());
228+
assertTrue(s.isDirectory());
226229
} else if (expectedType == fileType.isFile) {
227-
Assert.assertTrue(s.isFile());
230+
assertTrue(s.isFile());
228231
} else if (expectedType == fileType.isSymlink) {
229-
Assert.assertTrue(s.isSymlink());
232+
assertTrue(s.isSymlink());
230233
}
231-
Assert.assertEquals(aFc.makeQualified(new Path(path)), s.getPath());
234+
assertEquals(aFc.makeQualified(new Path(path)), s.getPath());
232235
}
233236

234237
public static void checkFileLinkStatus(FileContext aFc, String path,
235238
fileType expectedType) throws IOException {
236239
FileStatus s = aFc.getFileLinkStatus(new Path(path));
237-
Assert.assertNotNull(s);
240+
assertNotNull(s);
238241
if (expectedType == fileType.isDir) {
239-
Assert.assertTrue(s.isDirectory());
242+
assertTrue(s.isDirectory());
240243
} else if (expectedType == fileType.isFile) {
241-
Assert.assertTrue(s.isFile());
244+
assertTrue(s.isFile());
242245
} else if (expectedType == fileType.isSymlink) {
243-
Assert.assertTrue(s.isSymlink());
246+
assertTrue(s.isSymlink());
244247
}
245-
Assert.assertEquals(aFc.makeQualified(new Path(path)), s.getPath());
248+
assertEquals(aFc.makeQualified(new Path(path)), s.getPath());
246249
}
247250
}

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextTestWrapper.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
*/
1818
package org.apache.hadoop.fs;
1919

20+
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertNotNull;
22+
import static org.junit.jupiter.api.Assertions.assertTrue;
23+
2024
import java.io.DataInputStream;
2125
import java.io.IOException;
2226
import java.io.FileNotFoundException;
@@ -28,7 +32,6 @@
2832
import org.apache.hadoop.fs.permission.FsPermission;
2933
import org.apache.hadoop.io.IOUtils;
3034
import org.apache.hadoop.security.AccessControlException;
31-
import org.junit.Assert;
3235

3336
/**
3437
* Helper class for unit tests.
@@ -169,29 +172,29 @@ public FileStatus containsPath(String path, FileStatus[] dirList)
169172
public void checkFileStatus(String path, fileType expectedType)
170173
throws IOException {
171174
FileStatus s = fc.getFileStatus(new Path(path));
172-
Assert.assertNotNull(s);
175+
assertNotNull(s);
173176
if (expectedType == fileType.isDir) {
174-
Assert.assertTrue(s.isDirectory());
177+
assertTrue(s.isDirectory());
175178
} else if (expectedType == fileType.isFile) {
176-
Assert.assertTrue(s.isFile());
179+
assertTrue(s.isFile());
177180
} else if (expectedType == fileType.isSymlink) {
178-
Assert.assertTrue(s.isSymlink());
181+
assertTrue(s.isSymlink());
179182
}
180-
Assert.assertEquals(fc.makeQualified(new Path(path)), s.getPath());
183+
assertEquals(fc.makeQualified(new Path(path)), s.getPath());
181184
}
182185

183186
public void checkFileLinkStatus(String path, fileType expectedType)
184187
throws IOException {
185188
FileStatus s = fc.getFileLinkStatus(new Path(path));
186-
Assert.assertNotNull(s);
189+
assertNotNull(s);
187190
if (expectedType == fileType.isDir) {
188-
Assert.assertTrue(s.isDirectory());
191+
assertTrue(s.isDirectory());
189192
} else if (expectedType == fileType.isFile) {
190-
Assert.assertTrue(s.isFile());
193+
assertTrue(s.isFile());
191194
} else if (expectedType == fileType.isSymlink) {
192-
Assert.assertTrue(s.isSymlink());
195+
assertTrue(s.isSymlink());
193196
}
194-
Assert.assertEquals(fc.makeQualified(new Path(path)), s.getPath());
197+
assertEquals(fc.makeQualified(new Path(path)), s.getPath());
195198
}
196199

197200
//

0 commit comments

Comments
 (0)