Skip to content

Commit 57bb057

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

File tree

9 files changed

+352
-445
lines changed

9 files changed

+352
-445
lines changed

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: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
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-
2420
import java.io.DataInputStream;
2521
import java.io.IOException;
2622
import java.io.FileNotFoundException;
@@ -30,6 +26,7 @@
3026
import org.apache.hadoop.fs.Options.CreateOpts.BlockSize;
3127
import org.apache.hadoop.io.IOUtils;
3228
import org.apache.hadoop.test.GenericTestUtils;
29+
import org.junit.Assert;
3330

3431
/**
3532
* Helper class for unit tests.
@@ -223,28 +220,28 @@ public enum fileType {isDir, isFile, isSymlink};
223220
public static void checkFileStatus(FileContext aFc, String path,
224221
fileType expectedType) throws IOException {
225222
FileStatus s = aFc.getFileStatus(new Path(path));
226-
assertNotNull(s);
223+
Assert.assertNotNull(s);
227224
if (expectedType == fileType.isDir) {
228-
assertTrue(s.isDirectory());
225+
Assert.assertTrue(s.isDirectory());
229226
} else if (expectedType == fileType.isFile) {
230-
assertTrue(s.isFile());
227+
Assert.assertTrue(s.isFile());
231228
} else if (expectedType == fileType.isSymlink) {
232-
assertTrue(s.isSymlink());
229+
Assert.assertTrue(s.isSymlink());
233230
}
234-
assertEquals(aFc.makeQualified(new Path(path)), s.getPath());
231+
Assert.assertEquals(aFc.makeQualified(new Path(path)), s.getPath());
235232
}
236233

237234
public static void checkFileLinkStatus(FileContext aFc, String path,
238235
fileType expectedType) throws IOException {
239236
FileStatus s = aFc.getFileLinkStatus(new Path(path));
240-
assertNotNull(s);
237+
Assert.assertNotNull(s);
241238
if (expectedType == fileType.isDir) {
242-
assertTrue(s.isDirectory());
239+
Assert.assertTrue(s.isDirectory());
243240
} else if (expectedType == fileType.isFile) {
244-
assertTrue(s.isFile());
241+
Assert.assertTrue(s.isFile());
245242
} else if (expectedType == fileType.isSymlink) {
246-
assertTrue(s.isSymlink());
243+
Assert.assertTrue(s.isSymlink());
247244
}
248-
assertEquals(aFc.makeQualified(new Path(path)), s.getPath());
245+
Assert.assertEquals(aFc.makeQualified(new Path(path)), s.getPath());
249246
}
250247
}

0 commit comments

Comments
 (0)