diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextUtilBase.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextUtilBase.java
index 0a96d3e45ed9c..db479887b6e17 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextUtilBase.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextUtilBase.java
@@ -19,15 +19,15 @@
import static org.apache.hadoop.fs.FileContextTestHelper.readFile;
import static org.apache.hadoop.fs.FileContextTestHelper.writeFile;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.util.StringUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.slf4j.event.Level;
/**
@@ -57,12 +57,12 @@ public abstract class FileContextUtilBase {
}
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
fc.mkdir(fileContextTestHelper.getTestRootPath(fc), FileContext.DEFAULT_PERM, true);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
if (fc != null) {
fc.delete(fileContextTestHelper.getTestRootPath(fc), true);
@@ -80,10 +80,10 @@ public void testFcCopy() throws Exception{
fc.util().copy(file1, file2);
// verify that newly copied file2 exists
- assertTrue("Failed to copy file2 ", fc.util().exists(file2));
+ assertTrue(fc.util().exists(file2), "Failed to copy file2 ");
// verify that file2 contains test string
- assertTrue("Copied files does not match ",Arrays.equals(ts.getBytes(),
- readFile(fc,file2,ts.getBytes().length)));
+ assertTrue(Arrays.equals(ts.getBytes(),
+ readFile(fc, file2, ts.getBytes().length)), "Copied files does not match ");
}
@Test
@@ -103,9 +103,9 @@ public void testRecursiveFcCopy() throws Exception {
fc.util().copy(dir1, dir2);
// verify that newly copied file2 exists
- assertTrue("Failed to copy file2 ", fc.util().exists(file2));
+ assertTrue(fc.util().exists(file2), "Failed to copy file2 ");
// verify that file2 contains test string
- assertTrue("Copied files does not match ",Arrays.equals(ts.getBytes(),
- readFile(fc,file2,ts.getBytes().length)));
+ assertTrue(Arrays.equals(ts.getBytes(),
+ readFile(fc, file2, ts.getBytes().length)), "Copied files does not match ");
}
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemContractBaseTest.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemContractBaseTest.java
index 3a8b1e6ed085d..f1fea6df2a4c0 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemContractBaseTest.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemContractBaseTest.java
@@ -21,8 +21,8 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.concurrent.TimeUnit;
+import org.junit.jupiter.api.Timeout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -31,13 +31,15 @@
import org.apache.hadoop.security.AccessControlException;
import org.apache.hadoop.util.StringUtils;
-import static org.junit.Assert.*;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
-import org.junit.After;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.Timeout;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
/**
*
@@ -52,6 +54,7 @@
* {@link FileSystem} instance variable.
*
*/
+@Timeout(30)
public abstract class FileSystemContractBaseTest {
private static final Logger LOG =
LoggerFactory.getLogger(FileSystemContractBaseTest.class);
@@ -60,10 +63,6 @@ public abstract class FileSystemContractBaseTest {
protected FileSystem fs;
protected byte[] data = dataset(getBlockSize() * 2, 0, 255);
- @Rule
- public Timeout globalTimeout =
- new Timeout(getGlobalTimeout(), TimeUnit.MILLISECONDS);
-
/**
* Get the timeout in milliseconds for each test case.
* @return a time in milliseconds.
@@ -72,7 +71,7 @@ protected int getGlobalTimeout() {
return 30 * 1000;
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
if (fs != null) {
// some cases use this absolute path
@@ -195,7 +194,7 @@ public void testMkdirs() throws Exception {
assertTrue(fs.mkdirs(testDir));
assertTrue(fs.exists(testDir));
- assertTrue("Should be a directory", fs.isDirectory(testDir));
+ assertTrue(fs.isDirectory(testDir), "Should be a directory");
assertFalse(fs.isFile(testDir));
Path parentDir = testDir.getParent();
@@ -365,8 +364,8 @@ public void testOverwrite() throws IOException {
createFile(path);
- assertTrue("Exists", fs.exists(path));
- assertEquals("Length", data.length, fs.getFileStatus(path).getLen());
+ assertTrue(fs.exists(path), "Exists");
+ assertEquals(data.length, fs.getFileStatus(path).getLen(), "Length");
try {
fs.create(path, false).close();
@@ -379,27 +378,27 @@ public void testOverwrite() throws IOException {
out.write(data, 0, data.length);
out.close();
- assertTrue("Exists", fs.exists(path));
- assertEquals("Length", data.length, fs.getFileStatus(path).getLen());
+ assertTrue(fs.exists(path), "Exists");
+ assertEquals(data.length, fs.getFileStatus(path).getLen(), "Length");
}
@Test
public void testWriteInNonExistentDirectory() throws IOException {
Path path = path("testWriteInNonExistentDirectory/file");
- assertFalse("Parent exists", fs.exists(path.getParent()));
+ assertFalse(fs.exists(path.getParent()), "Parent exists");
createFile(path);
- assertTrue("Exists", fs.exists(path));
- assertEquals("Length", data.length, fs.getFileStatus(path).getLen());
- assertTrue("Parent exists", fs.exists(path.getParent()));
+ assertTrue(fs.exists(path), "Exists");
+ assertEquals(data.length, fs.getFileStatus(path).getLen(), "Length");
+ assertTrue(fs.exists(path.getParent()), "Parent exists");
}
@Test
public void testDeleteNonExistentFile() throws IOException {
Path path = path("testDeleteNonExistentFile/file");
- assertFalse("Path exists: " + path, fs.exists(path));
- assertFalse("No deletion", fs.delete(path, true));
+ assertFalse(fs.exists(path), "Path exists: " + path);
+ assertFalse(fs.delete(path, true), "No deletion");
}
@Test
@@ -409,11 +408,11 @@ public void testDeleteRecursively() throws IOException {
Path subdir = path("testDeleteRecursively/subdir");
createFile(file);
- assertTrue("Created subdir", fs.mkdirs(subdir));
+ assertTrue(fs.mkdirs(subdir), "Created subdir");
- assertTrue("File exists", fs.exists(file));
- assertTrue("Dir exists", fs.exists(dir));
- assertTrue("Subdir exists", fs.exists(subdir));
+ assertTrue(fs.exists(file), "File exists");
+ assertTrue(fs.exists(dir), "Dir exists");
+ assertTrue(fs.exists(subdir), "Subdir exists");
try {
fs.delete(dir, false);
@@ -421,23 +420,23 @@ public void testDeleteRecursively() throws IOException {
} catch (IOException e) {
// expected
}
- assertTrue("File still exists", fs.exists(file));
- assertTrue("Dir still exists", fs.exists(dir));
- assertTrue("Subdir still exists", fs.exists(subdir));
+ assertTrue(fs.exists(file), "File still exists");
+ assertTrue(fs.exists(dir), "Dir still exists");
+ assertTrue(fs.exists(subdir), "Subdir still exists");
- assertTrue("Deleted", fs.delete(dir, true));
- assertFalse("File doesn't exist", fs.exists(file));
- assertFalse("Dir doesn't exist", fs.exists(dir));
- assertFalse("Subdir doesn't exist", fs.exists(subdir));
+ assertTrue(fs.delete(dir, true), "Deleted");
+ assertFalse(fs.exists(file), "File doesn't exist");
+ assertFalse(fs.exists(dir), "Dir doesn't exist");
+ assertFalse(fs.exists(subdir), "Subdir doesn't exist");
}
@Test
public void testDeleteEmptyDirectory() throws IOException {
Path dir = path("testDeleteEmptyDirectory");
assertTrue(fs.mkdirs(dir));
- assertTrue("Dir exists", fs.exists(dir));
- assertTrue("Deleted", fs.delete(dir, false));
- assertFalse("Dir doesn't exist", fs.exists(dir));
+ assertTrue(fs.exists(dir), "Dir exists");
+ assertTrue(fs.delete(dir, false), "Deleted");
+ assertFalse(fs.exists(dir), "Dir doesn't exist");
}
@Test
@@ -516,14 +515,14 @@ public void testRenameDirectoryMoveToExistingDirectory() throws Exception {
fs.mkdirs(dst.getParent());
rename(src, dst, true, false, true);
- assertFalse("Nested file1 exists",
- fs.exists(path(src + "/file1")));
- assertFalse("Nested file2 exists",
- fs.exists(path(src + "/subdir/file2")));
- assertTrue("Renamed nested file1 exists",
- fs.exists(path(dst + "/file1")));
- assertTrue("Renamed nested exists",
- fs.exists(path(dst + "/subdir/file2")));
+ assertFalse(fs.exists(path(src + "/file1")),
+ "Nested file1 exists");
+ assertFalse(fs.exists(path(src + "/subdir/file2")),
+ "Nested file2 exists");
+ assertTrue(fs.exists(path(dst + "/file1")),
+ "Renamed nested file1 exists");
+ assertTrue(fs.exists(path(dst + "/subdir/file2")),
+ "Renamed nested exists");
}
@Test
@@ -548,16 +547,16 @@ public void testRenameDirectoryAsExistingDirectory() throws Exception {
final Path dst = path("testRenameDirectoryAsExistingDirectoryNew/newdir");
fs.mkdirs(dst);
rename(src, dst, true, false, true);
- assertTrue("Destination changed",
- fs.exists(path(dst + "/dir")));
- assertFalse("Nested file1 exists",
- fs.exists(path(src + "/file1")));
- assertFalse("Nested file2 exists",
- fs.exists(path(src + "/dir/subdir/file2")));
- assertTrue("Renamed nested file1 exists",
- fs.exists(path(dst + "/dir/file1")));
- assertTrue("Renamed nested exists",
- fs.exists(path(dst + "/dir/subdir/file2")));
+ assertTrue(fs.exists(path(dst + "/dir")),
+ "Destination changed");
+ assertFalse(fs.exists(path(src + "/file1")),
+ "Nested file1 exists");
+ assertFalse(fs.exists(path(src + "/dir/subdir/file2")),
+ "Nested file2 exists");
+ assertTrue(fs.exists(path(dst + "/dir/file1")),
+ "Renamed nested file1 exists");
+ assertTrue(fs.exists(path(dst + "/dir/subdir/file2")),
+ "Renamed nested exists");
}
@Test
@@ -590,9 +589,9 @@ protected void createFile(Path path) throws IOException {
protected void rename(Path src, Path dst, boolean renameSucceeded,
boolean srcExists, boolean dstExists) throws IOException {
- assertEquals("Rename result", renameSucceeded, fs.rename(src, dst));
- assertEquals("Source exists", srcExists, fs.exists(src));
- assertEquals("Destination exists" + dst, dstExists, fs.exists(dst));
+ assertEquals(renameSucceeded, fs.rename(src, dst), "Rename result");
+ assertEquals(srcExists, fs.exists(src), "Source exists");
+ assertEquals(dstExists, fs.exists(dst), "Destination exists" + dst);
}
/**
@@ -633,27 +632,26 @@ public void testFilesystemIsCaseSensitive() throws Exception {
String mixedCaseFilename = "testFilesystemIsCaseSensitive";
Path upper = path(mixedCaseFilename);
Path lower = path(StringUtils.toLowerCase(mixedCaseFilename));
- assertFalse("File exists" + upper, fs.exists(upper));
- assertFalse("File exists" + lower, fs.exists(lower));
+ assertFalse(fs.exists(upper), "File exists" + upper);
+ assertFalse(fs.exists(lower), "File exists" + lower);
FSDataOutputStream out = fs.create(upper);
out.writeUTF("UPPER");
out.close();
FileStatus upperStatus = fs.getFileStatus(upper);
- assertTrue("File does not exist" + upper, fs.exists(upper));
+ assertTrue(fs.exists(upper), "File does not exist" + upper);
//verify the lower-case version of the filename doesn't exist
- assertFalse("File exists" + lower, fs.exists(lower));
+ assertFalse(fs.exists(lower), "File exists" + lower);
//now overwrite the lower case version of the filename with a
//new version.
out = fs.create(lower);
out.writeUTF("l");
out.close();
- assertTrue("File does not exist" + lower, fs.exists(lower));
+ assertTrue(fs.exists(lower), "File does not exist" + lower);
//verify the length of the upper file hasn't changed
FileStatus newStatus = fs.getFileStatus(upper);
- assertEquals("Expected status:" + upperStatus
- + " actual status " + newStatus,
- upperStatus.getLen(),
- newStatus.getLen()); }
+ assertEquals(upperStatus.getLen(),
+ newStatus.getLen(), "Expected status:" + upperStatus
+ + " actual status " + newStatus); }
/**
* Asserts that a zero byte file has a status of file and not
@@ -693,7 +691,7 @@ public void testRootDirAlwaysExists() throws Exception {
fs.getFileStatus(path("/"));
//this catches overrides of the base exists() method that don't
//use getFileStatus() as an existence probe
- assertTrue("FileSystem.exists() fails for root", fs.exists(path("/")));
+ assertTrue(fs.exists(path("/")), "FileSystem.exists() fails for root");
}
/**
@@ -789,8 +787,8 @@ public void testMoveDirUnderParent() throws Throwable {
Path parent = testdir.getParent();
//the outcome here is ambiguous, so is not checked
fs.rename(testdir, parent);
- assertEquals("Source exists: " + testdir, true, fs.exists(testdir));
- assertEquals("Destination exists" + parent, true, fs.exists(parent));
+ assertEquals(true, fs.exists(testdir), "Source exists: " + testdir);
+ assertEquals(true, fs.exists(parent), "Destination exists" + parent);
}
/**
@@ -855,9 +853,8 @@ private void assertListFilesFinds(Path dir, Path subdir) throws IOException {
found = true;
}
}
- assertTrue("Path " + subdir
- + " not found in directory " + dir + ":" + builder,
- found);
+ assertTrue(found, "Path " + subdir
+ + " not found in directory " + dir + ":" + builder);
}
protected void assertListStatusFinds(Path dir, Path subdir)
@@ -871,9 +868,8 @@ protected void assertListStatusFinds(Path dir, Path subdir)
found = true;
}
}
- assertTrue("Path " + subdir
- + " not found in directory " + dir + ":" + builder,
- found);
+ assertTrue(found, "Path " + subdir
+ + " not found in directory " + dir + ":" + builder);
}
@@ -884,14 +880,14 @@ protected void assertListStatusFinds(Path dir, Path subdir)
* @throws IOException IO problems during file operations
*/
private void assertIsFile(Path filename) throws IOException {
- assertTrue("Does not exist: " + filename, fs.exists(filename));
+ assertTrue(fs.exists(filename), "Does not exist: " + filename);
FileStatus status = fs.getFileStatus(filename);
String fileInfo = filename + " " + status;
- assertTrue("Not a file " + fileInfo, status.isFile());
- assertFalse("File claims to be a symlink " + fileInfo,
- status.isSymlink());
- assertFalse("File claims to be a directory " + fileInfo,
- status.isDirectory());
+ assertTrue(status.isFile(), "Not a file " + fileInfo);
+ assertFalse(status.isSymlink(),
+ "File claims to be a symlink " + fileInfo);
+ assertFalse(status.isDirectory(),
+ "File claims to be a directory " + fileInfo);
}
/**
@@ -918,8 +914,8 @@ private void assertIsFile(Path filename) throws IOException {
protected void writeAndRead(Path path, byte[] src, int len,
boolean overwrite,
boolean delete) throws IOException {
- assertTrue("Not enough data in source array to write " + len + " bytes",
- src.length >= len);
+ assertTrue(src.length >= len,
+ "Not enough data in source array to write " + len + " bytes");
fs.mkdirs(path.getParent());
FSDataOutputStream out = fs.create(path, overwrite,
@@ -929,8 +925,8 @@ protected void writeAndRead(Path path, byte[] src, int len,
out.write(src, 0, len);
out.close();
- assertTrue("Exists", fs.exists(path));
- assertEquals("Length", len, fs.getFileStatus(path).getLen());
+ assertTrue(fs.exists(path), "Exists");
+ assertEquals(len, fs.getFileStatus(path).getLen(), "Length");
FSDataInputStream in = fs.open(path);
byte[] buf = new byte[len];
@@ -978,8 +974,8 @@ protected void writeAndRead(Path path, byte[] src, int len,
if (delete) {
boolean deleted = fs.delete(path, false);
- assertTrue("Deleted", deleted);
- assertFalse("No longer exists", fs.exists(path));
+ assertTrue(deleted, "Deleted");
+ assertFalse(fs.exists(path), "No longer exists");
}
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestHelper.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestHelper.java
index ef9e094c4c978..78bfab1a8d532 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestHelper.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestHelper.java
@@ -25,9 +25,10 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.token.Token;
import org.apache.hadoop.test.GenericTestUtils;
-import org.junit.Assert;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
/**
@@ -241,15 +242,15 @@ public enum fileType {isDir, isFile, isSymlink};
public static void checkFileStatus(FileSystem aFs, String path,
fileType expectedType) throws IOException {
FileStatus s = aFs.getFileStatus(new Path(path));
- Assert.assertNotNull(s);
+ assertNotNull(s);
if (expectedType == fileType.isDir) {
- Assert.assertTrue(s.isDirectory());
+ assertTrue(s.isDirectory());
} else if (expectedType == fileType.isFile) {
- Assert.assertTrue(s.isFile());
+ assertTrue(s.isFile());
} else if (expectedType == fileType.isSymlink) {
- Assert.assertTrue(s.isSymlink());
+ assertTrue(s.isSymlink());
}
- Assert.assertEquals(aFs.makeQualified(new Path(path)), s.getPath());
+ assertEquals(aFs.makeQualified(new Path(path)), s.getPath());
}
/**
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestWrapper.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestWrapper.java
index 933ad1a2358cd..47ae9bbdd65e9 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestWrapper.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestWrapper.java
@@ -17,6 +17,10 @@
*/
package org.apache.hadoop.fs;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.io.DataInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -29,7 +33,6 @@
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.security.AccessControlException;
import org.apache.hadoop.util.Progressable;
-import org.junit.Assert;
/**
* Helper class for unit tests.
@@ -170,29 +173,29 @@ public FileStatus containsPath(String path, FileStatus[] dirList)
public void checkFileStatus(String path, fileType expectedType)
throws IOException {
FileStatus s = fs.getFileStatus(new Path(path));
- Assert.assertNotNull(s);
+ assertNotNull(s);
if (expectedType == fileType.isDir) {
- Assert.assertTrue(s.isDirectory());
+ assertTrue(s.isDirectory());
} else if (expectedType == fileType.isFile) {
- Assert.assertTrue(s.isFile());
+ assertTrue(s.isFile());
} else if (expectedType == fileType.isSymlink) {
- Assert.assertTrue(s.isSymlink());
+ assertTrue(s.isSymlink());
}
- Assert.assertEquals(fs.makeQualified(new Path(path)), s.getPath());
+ assertEquals(fs.makeQualified(new Path(path)), s.getPath());
}
public void checkFileLinkStatus(String path, fileType expectedType)
throws IOException {
FileStatus s = fs.getFileLinkStatus(new Path(path));
- Assert.assertNotNull(s);
+ assertNotNull(s);
if (expectedType == fileType.isDir) {
- Assert.assertTrue(s.isDirectory());
+ assertTrue(s.isDirectory());
} else if (expectedType == fileType.isFile) {
- Assert.assertTrue(s.isFile());
+ assertTrue(s.isFile());
} else if (expectedType == fileType.isSymlink) {
- Assert.assertTrue(s.isSymlink());
+ assertTrue(s.isSymlink());
}
- Assert.assertEquals(fs.makeQualified(new Path(path)), s.getPath());
+ assertEquals(fs.makeQualified(new Path(path)), s.getPath());
}
//
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFs.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFs.java
index 0959845963000..1786bdde6cdf0 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFs.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFs.java
@@ -21,9 +21,9 @@
import java.io.IOException;
import java.util.EnumSet;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.permission.FsPermission;
@@ -40,7 +40,7 @@ public class TestChecksumFs extends HadoopTestBase {
private Path testRootDirPath;
private FileContext fc;
- @Before
+ @BeforeEach
public void setUp() throws Exception {
conf = getTestConfiguration();
fc = FileContext.getFileContext(conf);
@@ -49,7 +49,7 @@ public void setUp() throws Exception {
mkdirs(testRootDirPath);
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
if (fc != null) {
fc.delete(testRootDirPath, true);
@@ -101,11 +101,11 @@ private void verifyRename(Path srcPath, Path dstPath,
// ensure file + checksum are moved
createTestFile(fs, srcPath, 1);
- assertTrue("Checksum file doesn't exist for source file - " + srcPath,
- fc.util().exists(fs.getChecksumFile(srcPath)));
+ assertTrue(fc.util().exists(fs.getChecksumFile(srcPath)),
+ "Checksum file doesn't exist for source file - " + srcPath);
fs.rename(srcPath, dstPath, renameOpt);
- assertTrue("Checksum file doesn't exist for dest file - " + srcPath,
- fc.util().exists(fs.getChecksumFile(dstPath)));
+ assertTrue(fc.util().exists(fs.getChecksumFile(dstPath)),
+ "Checksum file doesn't exist for dest file - " + srcPath);
try (FSDataInputStream is = fs.open(dstPath)) {
assertEquals(1, is.readInt());
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFcLocalFsUtil.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFcLocalFsUtil.java
index 29b64638067b5..bb7d1a227f4e8 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFcLocalFsUtil.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFcLocalFsUtil.java
@@ -17,7 +17,7 @@
*/
package org.apache.hadoop.fs;
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
/**
* Test Util for localFs using FileContext API.
@@ -26,7 +26,7 @@ public class TestFcLocalFsUtil extends
FileContextUtilBase {
@Override
- @Before
+ @BeforeEach
public void setUp() throws Exception {
fc = FileContext.getLocalFSFileContext();
super.setUp();
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemCaching.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemCaching.java
index 67a933bb9e39c..119bad41a3028 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemCaching.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemCaching.java
@@ -37,13 +37,20 @@
import org.apache.hadoop.thirdparty.com.google.common.util.concurrent.ListeningExecutorService;
import org.apache.hadoop.util.BlockingThreadPoolExecutorService;
-import org.assertj.core.api.Assertions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_CREATION_PARALLEL_COUNT;
import static org.apache.hadoop.test.LambdaTestUtils.intercept;
-import static org.mockito.Mockito.*;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.anyBoolean;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.reset;
public class TestFileSystemCaching extends HadoopTestBase {
@@ -355,7 +362,7 @@ public void testCacheIncludesURIUserInfo() throws Throwable {
public void testCacheSingleSemaphoredConstruction() throws Exception {
FileSystem.Cache cache = semaphoredCache(1);
createFileSystems(cache, 10);
- Assertions.assertThat(cache.getDiscardedInstances())
+ assertThat(cache.getDiscardedInstances())
.describedAs("Discarded FS instances")
.isEqualTo(0);
}
@@ -374,7 +381,7 @@ public void testCacheSingleSemaphoredConstruction() throws Exception {
public void testCacheDualSemaphoreConstruction() throws Exception {
FileSystem.Cache cache = semaphoredCache(2);
createFileSystems(cache, 10);
- Assertions.assertThat(cache.getDiscardedInstances())
+ assertThat(cache.getDiscardedInstances())
.describedAs("Discarded FS instances")
.isEqualTo(1);
}
@@ -393,7 +400,7 @@ public void testCacheLargeSemaphoreConstruction() throws Exception {
FileSystem.Cache cache = semaphoredCache(999);
int count = 10;
createFileSystems(cache, count);
- Assertions.assertThat(cache.getDiscardedInstances())
+ assertThat(cache.getDiscardedInstances())
.describedAs("Discarded FS instances")
.isEqualTo(count -1);
}
@@ -450,8 +457,7 @@ private void createFileSystems(final FileSystem.Cache cache, final int count)
// verify all the others are the same instance
for (int i = 1; i < count; i++) {
FileSystem fs = futures.get(i).get();
- Assertions.assertThat(fs)
- .isSameAs(createdFS);
+ assertThat(fs).isSameAs(createdFS);
}
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetEnclosingRoot.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetEnclosingRoot.java
index 8bbab36d53096..7bcc44e453a0e 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetEnclosingRoot.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetEnclosingRoot.java
@@ -22,7 +22,7 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.test.HadoopTestBase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TestGetEnclosingRoot extends HadoopTestBase {
@Test
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestRawLocalFileSystemContract.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestRawLocalFileSystemContract.java
index b51419d8c53f9..a0fe028fa24f1 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestRawLocalFileSystemContract.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestRawLocalFileSystemContract.java
@@ -27,11 +27,11 @@
import org.apache.hadoop.util.NativeCodeLoader;
import org.apache.hadoop.util.Shell;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assume.assumeTrue;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,7 +60,7 @@ private static boolean looksLikeWindows(String filesys) {
return HAS_DRIVE_LETTER_SPECIFIER.matcher(filesys).find();
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
Configuration conf = new Configuration();
fs = FileSystem.getLocal(conf).getRawFileSystem();
@@ -129,8 +129,8 @@ protected boolean filesystemIsCaseSensitive() {
@Test
@SuppressWarnings("deprecation")
public void testPermission() throws Exception {
- assumeTrue("No native library",
- NativeCodeLoader.isNativeCodeLoaded());
+ assumeTrue(NativeCodeLoader.isNativeCodeLoaded(),
+ "No native library");
Path testDir = getTestBaseDir();
String testFilename = "teststat2File";
Path path = new Path(testDir, testFilename);
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/impl/TestFutureIO.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/impl/TestFutureIO.java
index 2e1270a1b8a2a..81b1987ecabc2 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/impl/TestFutureIO.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/impl/TestFutureIO.java
@@ -21,8 +21,8 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicInteger;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.apache.hadoop.test.HadoopTestBase;
import org.apache.hadoop.util.LambdaUtils;
@@ -35,7 +35,7 @@ public class TestFutureIO extends HadoopTestBase {
private ThreadLocal local;
- @Before
+ @BeforeEach
public void setup() throws Exception {
local = ThreadLocal.withInitial(() -> new AtomicInteger(1));
}
@@ -50,8 +50,8 @@ public void testEvalInCurrentThread() throws Throwable {
() -> {
return getLocal().addAndGet(2);
});
- assertEquals("Thread local value", 3, getLocalValue());
- assertEquals("Evaluated Value", 3, eval.get().intValue());
+ assertEquals(3, getLocalValue(), "Thread local value");
+ assertEquals(3, eval.get().intValue(), "Evaluated Value");
}
/**
@@ -61,8 +61,8 @@ public void testEvalInCurrentThread() throws Throwable {
public void testEvalAsync() throws Throwable {
final CompletableFuture eval = CompletableFuture.supplyAsync(
() -> getLocal().addAndGet(2));
- assertEquals("Thread local value", 1, getLocalValue());
- assertEquals("Evaluated Value", 3, eval.get().intValue());
+ assertEquals(1, getLocalValue(), "Thread local value");
+ assertEquals(3, eval.get().intValue(), "Evaluated Value");
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/impl/TestVectoredReadUtils.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/impl/TestVectoredReadUtils.java
index a3913732d1ebf..4985a6a1c1425 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/impl/TestVectoredReadUtils.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/impl/TestVectoredReadUtils.java
@@ -30,10 +30,9 @@
import java.util.function.Consumer;
import java.util.function.IntFunction;
-import org.assertj.core.api.Assertions;
import org.assertj.core.api.ListAssert;
import org.assertj.core.api.ObjectAssert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;
@@ -57,6 +56,7 @@
import static org.apache.hadoop.test.LambdaTestUtils.intercept;
import static org.apache.hadoop.test.MoreAsserts.assertFutureCompletedSuccessfully;
import static org.apache.hadoop.test.MoreAsserts.assertFutureFailedExceptionally;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* Test behavior of {@link VectoredReadUtils}.
@@ -78,11 +78,11 @@ public void testSliceTo() {
// ensure we don't make unnecessary slices
ByteBuffer slice = VectoredReadUtils.sliceTo(buffer, 100,
createFileRange(100, size));
- Assertions.assertThat(buffer)
+ assertThat(buffer)
.describedAs("Slicing on the same offset shouldn't " +
"create a new buffer")
.isEqualTo(slice);
- Assertions.assertThat(slice.position())
+ assertThat(slice.position())
.describedAs("Slicing should return buffers starting from position 0")
.isEqualTo(0);
@@ -93,19 +93,19 @@ public void testSliceTo() {
slice = VectoredReadUtils.sliceTo(buffer, offset,
createFileRange(offset + sliceStart, sliceLength));
// make sure they aren't the same, but use the same backing data
- Assertions.assertThat(buffer)
+ assertThat(buffer)
.describedAs("Slicing on new offset should create a new buffer")
.isNotEqualTo(slice);
- Assertions.assertThat(buffer.array())
+ assertThat(buffer.array())
.describedAs("Slicing should use the same underlying data")
.isEqualTo(slice.array());
- Assertions.assertThat(slice.position())
+ assertThat(slice.position())
.describedAs("Slicing should return buffers starting from position 0")
.isEqualTo(0);
// test the contents of the slice
intBuffer = slice.asIntBuffer();
for(int i=0; i < sliceLength / Integer.BYTES; ++i) {
- assertEquals("i = " + i, i + sliceStart / Integer.BYTES, intBuffer.get());
+ assertEquals(i + sliceStart / Integer.BYTES, intBuffer.get(), "i = " + i);
}
}
@@ -116,11 +116,11 @@ public void testSliceTo() {
@Test
public void testRounding() {
for (int i = 5; i < 10; ++i) {
- assertEquals("i = " + i, 5, VectoredReadUtils.roundDown(i, 5));
- assertEquals("i = " + i, 10, VectoredReadUtils.roundUp(i + 1, 5));
+ assertEquals(5, VectoredReadUtils.roundDown(i, 5), "i = " + i);
+ assertEquals(10, VectoredReadUtils.roundUp(i + 1, 5), "i = " + i);
}
- assertEquals("Error while roundDown", 13, VectoredReadUtils.roundDown(13, 1));
- assertEquals("Error while roundUp", 13, VectoredReadUtils.roundUp(13, 1));
+ assertEquals(13, VectoredReadUtils.roundDown(13, 1), "Error while roundDown");
+ assertEquals(13, VectoredReadUtils.roundUp(13, 1), "Error while roundUp");
}
/**
@@ -135,32 +135,32 @@ public void testMerge() {
CombinedFileRange mergeBase = new CombinedFileRange(2000, 3000, base);
// test when the gap between is too big
- assertFalse("Large gap ranges shouldn't get merged", mergeBase.merge(5000, 6000,
- createFileRange(5000, 1000), 2000, 4000));
+ assertFalse(mergeBase.merge(5000, 6000,
+ createFileRange(5000, 1000), 2000, 4000), "Large gap ranges shouldn't get merged");
assertUnderlyingSize(mergeBase,
"Number of ranges in merged range shouldn't increase",
1);
assertFileRange(mergeBase, 2000, 1000);
// test when the total size gets exceeded
- assertFalse("Large size ranges shouldn't get merged",
+ assertFalse(
mergeBase.merge(5000, 6000,
- createFileRange(5000, 1000), 2001, 3999));
- assertEquals("Number of ranges in merged range shouldn't increase",
- 1, mergeBase.getUnderlying().size());
+ createFileRange(5000, 1000), 2001, 3999), "Large size ranges shouldn't get merged");
+ assertEquals(1, mergeBase.getUnderlying().size(),
+ "Number of ranges in merged range shouldn't increase");
assertFileRange(mergeBase, 2000, 1000);
// test when the merge works
- assertTrue("ranges should get merged ", mergeBase.merge(5000, 6000,
+ assertTrue(mergeBase.merge(5000, 6000,
createFileRange(5000, 1000, tracker2),
- 2001, 4000));
+ 2001, 4000), "ranges should get merged ");
assertUnderlyingSize(mergeBase, "merge list after merge", 2);
assertFileRange(mergeBase, 2000, 4000);
- Assertions.assertThat(mergeBase.getUnderlying().get(0).getReference())
+ assertThat(mergeBase.getUnderlying().get(0).getReference())
.describedAs("reference of range %s", mergeBase.getUnderlying().get(0))
.isSameAs(tracker1);
- Assertions.assertThat(mergeBase.getUnderlying().get(1).getReference())
+ assertThat(mergeBase.getUnderlying().get(1).getReference())
.describedAs("reference of range %s", mergeBase.getUnderlying().get(1))
.isSameAs(tracker2);
@@ -168,8 +168,8 @@ public void testMerge() {
mergeBase = new CombinedFileRange(200, 300, base);
assertFileRange(mergeBase, 200, 100);
- assertTrue("ranges should get merged ", mergeBase.merge(500, 600,
- createFileRange(5000, 1000), 201, 400));
+ assertTrue(mergeBase.merge(500, 600,
+ createFileRange(5000, 1000), 201, 400), "ranges should get merged ");
assertUnderlyingSize(mergeBase, "merge list after merge", 2);
assertFileRange(mergeBase, 200, 400);
}
@@ -184,7 +184,7 @@ private static ListAssert assertUnderlyingSize(
final CombinedFileRange combinedFileRange,
final String description,
final int expected) {
- return Assertions.assertThat(combinedFileRange.getUnderlying())
+ return assertThat(combinedFileRange.getUnderlying())
.describedAs(description)
.hasSize(expected);
}
@@ -267,13 +267,13 @@ public void testSortAndMerge() {
private static void assertFileRange(
ELEMENT range, long start, int length) {
- Assertions.assertThat(range)
+ assertThat(range)
.describedAs("file range %s", range)
.isNotNull();
- Assertions.assertThat(range.getOffset())
+ assertThat(range.getOffset())
.describedAs("offset of %s", range)
.isEqualTo(start);
- Assertions.assertThat(range.getLength())
+ assertThat(range.getLength())
.describedAs("length of %s", range)
.isEqualTo(length);
}
@@ -291,10 +291,10 @@ public void testArraySortRange() throws Throwable {
);
final FileRange[] rangeArray = sortRanges(input);
final List extends FileRange> rangeList = sortRangeList(input);
- Assertions.assertThat(rangeArray)
+ assertThat(rangeArray)
.describedAs("range array from sortRanges()")
.isSortedAccordingTo(Comparator.comparingLong(FileRange::getOffset));
- Assertions.assertThat(rangeList.toArray(new FileRange[0]))
+ assertThat(rangeList.toArray(new FileRange[0]))
.describedAs("range from sortRangeList()")
.isEqualTo(rangeArray);
}
@@ -311,7 +311,7 @@ private static void assertFileRange(
ELEMENT range, long offset, int length, Object reference) {
assertFileRange(range, offset, length);
- Assertions.assertThat(range.getReference())
+ assertThat(range.getReference())
.describedAs("reference field of file range %s", range)
.isEqualTo(reference);
}
@@ -342,7 +342,7 @@ private static ObjectAssert assertIsSingleR
private static ListAssert assertRangeListSize(
final List ranges,
final int size) {
- return Assertions.assertThat(ranges)
+ return assertThat(ranges)
.describedAs("coalesced ranges")
.hasSize(size);
}
@@ -357,7 +357,7 @@ private static ListAssert assertRangeListSi
private static ListAssert assertRangesCountAtLeast(
final List ranges,
final int size) {
- return Assertions.assertThat(ranges)
+ return assertThat(ranges)
.describedAs("coalesced ranges")
.hasSizeGreaterThanOrEqualTo(size);
}
@@ -392,7 +392,7 @@ private static void assertOrderedDisjoint(
List extends FileRange> input,
int chunkSize,
int minimumSeek) {
- Assertions.assertThat(isOrderedDisjoint(input, chunkSize, minimumSeek))
+ assertThat(isOrderedDisjoint(input, chunkSize, minimumSeek))
.describedAs("ranges are ordered and disjoint")
.isTrue();
}
@@ -407,7 +407,7 @@ private static void assertIsNotOrderedDisjoint(
List input,
int chunkSize,
int minimumSeek) {
- Assertions.assertThat(isOrderedDisjoint(input, chunkSize, minimumSeek))
+ assertThat(isOrderedDisjoint(input, chunkSize, minimumSeek))
.describedAs("Ranges are non disjoint/ordered")
.isFalse();
}
@@ -426,7 +426,7 @@ public void testSortAndMergeMoreCases() throws Exception {
assertIsNotOrderedDisjoint(input, 100, 800);
List outputList = mergeSortedRanges(
sortRangeList(input), 1, 1001, 2500);
- Assertions.assertThat(outputList)
+ assertThat(outputList)
.describedAs("merged range size")
.hasSize(1);
CombinedFileRange output = outputList.get(0);
@@ -551,10 +551,10 @@ public void testReadSingleRange() throws Exception {
ByteBuffer::allocate);
assertFutureCompletedSuccessfully(result);
ByteBuffer buffer = result.get();
- assertEquals("Size of result buffer", 100, buffer.remaining());
+ assertEquals(100, buffer.remaining(), "Size of result buffer");
byte b = 0;
while (buffer.remaining() > 0) {
- assertEquals("remain = " + buffer.remaining(), b++, buffer.get());
+ assertEquals(b++, buffer.get(), "remain = " + buffer.remaining());
}
}
@@ -597,7 +597,7 @@ private static void runReadRangeFromPositionedReadable(IntFunction a
allocate);
assertFutureCompletedSuccessfully(result);
ByteBuffer buffer = result.get();
- assertEquals("Size of result buffer", 100, buffer.remaining());
+ assertEquals(100, buffer.remaining(), "Size of result buffer");
validateBuffer("buffer", buffer, 0);
@@ -639,8 +639,8 @@ public void testReadRangeDirect() throws Exception {
private static void validateBuffer(String message, ByteBuffer buffer, int start) {
byte expected = (byte) start;
while (buffer.remaining() > 0) {
- assertEquals(message + " remain: " + buffer.remaining(), expected,
- buffer.get());
+ assertEquals(expected,
+ buffer.get(), message + " remain: " + buffer.remaining());
// increment with wrapping.
expected = (byte) (expected + 1);
}
@@ -668,7 +668,7 @@ public void testReadVectoredZeroBytes() throws Exception {
runAndValidateVectoredRead(input);
// look up by name and validate.
final FileRange r1 = retrieve(input, "1");
- Assertions.assertThat(r1.getData().get().limit())
+ assertThat(r1.getData().get().limit())
.describedAs("Data limit of %s", r1)
.isEqualTo(0);
}
@@ -688,7 +688,7 @@ private static FileRange retrieve(List input, String key) {
}
/**
- * Mock run a vectored read and validate the results with the assertions.
+ * Mock run a vectored read and validate the results with the
*
* - {@code ByteBufferPositionedReadable.readFully()} is invoked once per range.
* - The buffers are filled with data
@@ -833,7 +833,7 @@ public void testVectorIOBufferPool() throws Throwable {
// inlined lambda to assert the pool size
Consumer assertPoolSizeEquals = (size) -> {
- Assertions.assertThat(elasticByteBufferPool.size(false))
+ assertThat(elasticByteBufferPool.size(false))
.describedAs("Pool size")
.isEqualTo(size);
};
@@ -855,7 +855,7 @@ public void testVectorIOBufferPool() throws Throwable {
// expect the returned buffer back
ByteBuffer b3 = vectorBuffers.getBuffer(true, 100);
- Assertions.assertThat(b3)
+ assertThat(b3)
.describedAs("buffer returned from a get after a previous one was returned")
.isSameAs(b1);
assertPoolSizeEquals.accept(0);
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestMoreWeakReferencedElasticByteBufferPool.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestMoreWeakReferencedElasticByteBufferPool.java
index 6ca380ef0e46b..aab390f9b286e 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestMoreWeakReferencedElasticByteBufferPool.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestMoreWeakReferencedElasticByteBufferPool.java
@@ -21,12 +21,12 @@
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
-import org.assertj.core.api.Assertions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.hadoop.test.HadoopTestBase;
import static org.apache.hadoop.test.LambdaTestUtils.intercept;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* Non parameterized tests for {@code WeakReferencedElasticByteBufferPool}.
@@ -87,10 +87,10 @@ public void testUnexpectedBufferSizes() throws Exception {
private void assertBufferCounts(WeakReferencedElasticByteBufferPool pool,
int numDirectBuffersExpected,
int numHeapBuffersExpected) {
- Assertions.assertThat(pool.getCurrentBuffersCount(true))
+ assertThat(pool.getCurrentBuffersCount(true))
.describedAs("Number of direct buffers in pool")
.isEqualTo(numDirectBuffersExpected);
- Assertions.assertThat(pool.getCurrentBuffersCount(false))
+ assertThat(pool.getCurrentBuffersCount(false))
.describedAs("Number of heap buffers in pool")
.isEqualTo(numHeapBuffersExpected);
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestWeakReferencedElasticByteBufferPool.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestWeakReferencedElasticByteBufferPool.java
index 1434010ffa652..859b856da7461 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestWeakReferencedElasticByteBufferPool.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestWeakReferencedElasticByteBufferPool.java
@@ -23,153 +23,157 @@
import java.util.List;
import java.util.Random;
-import org.assertj.core.api.Assertions;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
import org.apache.hadoop.test.HadoopTestBase;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import static org.assertj.core.api.Assertions.assertThat;
/**
* Unit tests for {@code WeakReferencedElasticByteBufferPool}.
*/
-@RunWith(Parameterized.class)
public class TestWeakReferencedElasticByteBufferPool
extends HadoopTestBase {
- private final boolean isDirect;
+ private boolean isDirect;
- private final String type;
+ private String type;
- @Parameterized.Parameters(name = "Buffer type : {0}")
public static List params() {
return Arrays.asList("direct", "array");
}
- public TestWeakReferencedElasticByteBufferPool(String type) {
- this.type = type;
- this.isDirect = !"array".equals(type);
+ public void initTestWeakReferencedElasticByteBufferPool(String pType) {
+ this.type = pType;
+ this.isDirect = !"array".equals(pType);
}
- @Test
- public void testGetAndPutBasic() {
+ @ParameterizedTest(name = "Buffer type : {0}")
+ @MethodSource("params")
+ public void testGetAndPutBasic(String pType) {
+ initTestWeakReferencedElasticByteBufferPool(pType);
WeakReferencedElasticByteBufferPool pool = new WeakReferencedElasticByteBufferPool();
int bufferSize = 5;
ByteBuffer buffer = pool.getBuffer(isDirect, bufferSize);
- Assertions.assertThat(buffer.isDirect())
- .describedAs("Buffered returned should be of correct type {}", type)
- .isEqualTo(isDirect);
- Assertions.assertThat(buffer.capacity())
- .describedAs("Initial capacity of returned buffer from pool")
- .isEqualTo(bufferSize);
- Assertions.assertThat(buffer.position())
- .describedAs("Initial position of returned buffer from pool")
- .isEqualTo(0);
+ assertThat(buffer.isDirect())
+ .describedAs("Buffered returned should be of correct type {}", type)
+ .isEqualTo(isDirect);
+ assertThat(buffer.capacity())
+ .describedAs("Initial capacity of returned buffer from pool")
+ .isEqualTo(bufferSize);
+ assertThat(buffer.position())
+ .describedAs("Initial position of returned buffer from pool")
+ .isEqualTo(0);
byte[] arr = createByteArray(bufferSize);
buffer.put(arr, 0, arr.length);
buffer.flip();
validateBufferContent(buffer, arr);
- Assertions.assertThat(buffer.position())
- .describedAs("Buffer's position after filling bytes in it")
- .isEqualTo(bufferSize);
+ assertThat(buffer.position())
+ .describedAs("Buffer's position after filling bytes in it")
+ .isEqualTo(bufferSize);
// releasing buffer to the pool.
pool.putBuffer(buffer);
- Assertions.assertThat(buffer.position())
- .describedAs("Position should be reset to 0 after returning buffer to the pool")
- .isEqualTo(0);
-
+ assertThat(buffer.position())
+ .describedAs("Position should be reset to 0 after returning buffer to the pool")
+ .isEqualTo(0);
}
- @Test
- public void testPoolingWithDifferentSizes() {
+ @ParameterizedTest(name = "Buffer type : {0}")
+ @MethodSource("params")
+ public void testPoolingWithDifferentSizes(String pType) {
+ initTestWeakReferencedElasticByteBufferPool(pType);
WeakReferencedElasticByteBufferPool pool = new WeakReferencedElasticByteBufferPool();
ByteBuffer buffer = pool.getBuffer(isDirect, 5);
ByteBuffer buffer1 = pool.getBuffer(isDirect, 10);
ByteBuffer buffer2 = pool.getBuffer(isDirect, 15);
- Assertions.assertThat(pool.getCurrentBuffersCount(isDirect))
+ assertThat(pool.getCurrentBuffersCount(isDirect))
.describedAs("Number of buffers in the pool")
.isEqualTo(0);
pool.putBuffer(buffer1);
pool.putBuffer(buffer2);
- Assertions.assertThat(pool.getCurrentBuffersCount(isDirect))
+ assertThat(pool.getCurrentBuffersCount(isDirect))
.describedAs("Number of buffers in the pool")
.isEqualTo(2);
ByteBuffer buffer3 = pool.getBuffer(isDirect, 12);
- Assertions.assertThat(buffer3.capacity())
+ assertThat(buffer3.capacity())
.describedAs("Pooled buffer should have older capacity")
.isEqualTo(15);
- Assertions.assertThat(pool.getCurrentBuffersCount(isDirect))
+ assertThat(pool.getCurrentBuffersCount(isDirect))
.describedAs("Number of buffers in the pool")
.isEqualTo(1);
pool.putBuffer(buffer);
ByteBuffer buffer4 = pool.getBuffer(isDirect, 6);
- Assertions.assertThat(buffer4.capacity())
+ assertThat(buffer4.capacity())
.describedAs("Pooled buffer should have older capacity")
.isEqualTo(10);
- Assertions.assertThat(pool.getCurrentBuffersCount(isDirect))
+ assertThat(pool.getCurrentBuffersCount(isDirect))
.describedAs("Number of buffers in the pool")
.isEqualTo(1);
pool.release();
- Assertions.assertThat(pool.getCurrentBuffersCount(isDirect))
+ assertThat(pool.getCurrentBuffersCount(isDirect))
.describedAs("Number of buffers in the pool post release")
.isEqualTo(0);
}
- @Test
- public void testPoolingWithDifferentInsertionTime() {
+ @ParameterizedTest(name = "Buffer type : {0}")
+ @MethodSource("params")
+ public void testPoolingWithDifferentInsertionTime(String pType) {
+ initTestWeakReferencedElasticByteBufferPool(pType);
WeakReferencedElasticByteBufferPool pool = new WeakReferencedElasticByteBufferPool();
ByteBuffer buffer = pool.getBuffer(isDirect, 10);
ByteBuffer buffer1 = pool.getBuffer(isDirect, 10);
ByteBuffer buffer2 = pool.getBuffer(isDirect, 10);
- Assertions.assertThat(pool.getCurrentBuffersCount(isDirect))
+ assertThat(pool.getCurrentBuffersCount(isDirect))
.describedAs("Number of buffers in the pool")
.isEqualTo(0);
pool.putBuffer(buffer1);
pool.putBuffer(buffer2);
- Assertions.assertThat(pool.getCurrentBuffersCount(isDirect))
+ assertThat(pool.getCurrentBuffersCount(isDirect))
.describedAs("Number of buffers in the pool")
.isEqualTo(2);
ByteBuffer buffer3 = pool.getBuffer(isDirect, 10);
// As buffer1 is returned to the pool before buffer2, it should
// be returned when buffer of same size is asked again from
// the pool. Memory references must match not just content
- // that is why {@code Assertions.isSameAs} is used here rather
- // than usual {@code Assertions.isEqualTo}.
- Assertions.assertThat(buffer3)
+ // that is why {@code isSameAs} is used here rather
+ // than usual {@code isEqualTo}.
+ assertThat(buffer3)
.describedAs("Buffers should be returned in order of their " +
"insertion time")
.isSameAs(buffer1);
pool.putBuffer(buffer);
ByteBuffer buffer4 = pool.getBuffer(isDirect, 10);
- Assertions.assertThat(buffer4)
+ assertThat(buffer4)
.describedAs("Buffers should be returned in order of their " +
"insertion time")
.isSameAs(buffer2);
}
- @Test
- public void testGarbageCollection() {
+ @ParameterizedTest(name = "Buffer type : {0}")
+ @MethodSource("params")
+ public void testGarbageCollection(String pType) {
+ initTestWeakReferencedElasticByteBufferPool(pType);
WeakReferencedElasticByteBufferPool pool = new WeakReferencedElasticByteBufferPool();
ByteBuffer buffer = pool.getBuffer(isDirect, 5);
ByteBuffer buffer1 = pool.getBuffer(isDirect, 10);
ByteBuffer buffer2 = pool.getBuffer(isDirect, 15);
- Assertions.assertThat(pool.getCurrentBuffersCount(isDirect))
+ assertThat(pool.getCurrentBuffersCount(isDirect))
.describedAs("Number of buffers in the pool")
.isEqualTo(0);
pool.putBuffer(buffer1);
pool.putBuffer(buffer2);
- Assertions.assertThat(pool.getCurrentBuffersCount(isDirect))
+ assertThat(pool.getCurrentBuffersCount(isDirect))
.describedAs("Number of buffers in the pool")
.isEqualTo(2);
// Before GC.
ByteBuffer buffer4 = pool.getBuffer(isDirect, 12);
- Assertions.assertThat(buffer4.capacity())
+ assertThat(buffer4.capacity())
.describedAs("Pooled buffer should have older capacity")
.isEqualTo(15);
pool.putBuffer(buffer4);
@@ -179,14 +183,16 @@ public void testGarbageCollection() {
buffer4 = null;
System.gc();
ByteBuffer buffer3 = pool.getBuffer(isDirect, 12);
- Assertions.assertThat(buffer3.capacity())
+ assertThat(buffer3.capacity())
.describedAs("After garbage collection new buffer should be " +
"returned with fixed capacity")
.isEqualTo(12);
}
- @Test
- public void testWeakReferencesPruning() {
+ @ParameterizedTest(name = "Buffer type : {0}")
+ @MethodSource("params")
+ public void testWeakReferencesPruning(String pType) {
+ initTestWeakReferencedElasticByteBufferPool(pType);
WeakReferencedElasticByteBufferPool pool = new WeakReferencedElasticByteBufferPool();
ByteBuffer buffer1 = pool.getBuffer(isDirect, 5);
ByteBuffer buffer2 = pool.getBuffer(isDirect, 10);
@@ -194,7 +200,7 @@ public void testWeakReferencesPruning() {
pool.putBuffer(buffer2);
pool.putBuffer(buffer3);
- Assertions.assertThat(pool.getCurrentBuffersCount(isDirect))
+ assertThat(pool.getCurrentBuffersCount(isDirect))
.describedAs("Number of buffers in the pool")
.isEqualTo(2);
@@ -204,10 +210,10 @@ public void testWeakReferencesPruning() {
ByteBuffer buffer4 = pool.getBuffer(isDirect, 10);
// Number of buffers in the pool is 0 as one got garbage
// collected and other got returned in above call.
- Assertions.assertThat(pool.getCurrentBuffersCount(isDirect))
+ assertThat(pool.getCurrentBuffersCount(isDirect))
.describedAs("Number of buffers in the pool")
.isEqualTo(0);
- Assertions.assertThat(buffer4.capacity())
+ assertThat(buffer4.capacity())
.describedAs("After gc, pool should return next greater than " +
"available buffer")
.isEqualTo(15);
@@ -216,10 +222,10 @@ public void testWeakReferencesPruning() {
private void validateBufferContent(ByteBuffer buffer, byte[] arr) {
for (int i=0; i {
+ CloseableReferenceCount clr = new CloseableReferenceCount();
+ clr.setClosed();
+ assertFalse(clr.isOpen(), "Reference count should be closed");
+ clr.reference();
+ });
}
- @Test(expected = ClosedChannelException.class)
+ @Test
public void testUnreferenceClosedReference() throws ClosedChannelException {
- CloseableReferenceCount clr = new CloseableReferenceCount();
- clr.reference();
- clr.setClosed();
- assertFalse("Reference count should be closed", clr.isOpen());
- clr.unreferenceCheckClosed();
+ assertThrows(ClosedChannelException.class, () -> {
+ CloseableReferenceCount clr = new CloseableReferenceCount();
+ clr.reference();
+ clr.setClosed();
+ assertFalse(clr.isOpen(), "Reference count should be closed");
+ clr.unreferenceCheckClosed();
+ });
}
- @Test(expected = ClosedChannelException.class)
+ @Test
public void testDoubleClose() throws ClosedChannelException {
- CloseableReferenceCount clr = new CloseableReferenceCount();
- assertTrue("Reference count should be open", clr.isOpen());
- clr.setClosed();
- assertFalse("Reference count should be closed", clr.isOpen());
- clr.setClosed();
+ assertThrows(ClosedChannelException.class, () -> {
+ CloseableReferenceCount clr = new CloseableReferenceCount();
+ assertTrue(clr.isOpen(), "Reference count should be open");
+ clr.setClosed();
+ assertFalse(clr.isOpen(), "Reference count should be closed");
+ clr.setClosed();
+ });
}
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestIntrusiveCollection.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestIntrusiveCollection.java
index 03bbf7b12fe63..3bc647ec8c23b 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestIntrusiveCollection.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestIntrusiveCollection.java
@@ -30,15 +30,11 @@
import java.util.Iterator;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.hadoop.test.HadoopTestBase;
import org.apache.hadoop.util.IntrusiveCollection.Element;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
public class TestIntrusiveCollection extends HadoopTestBase {
static class SimpleElement implements IntrusiveCollection.Element {
private Map, Element>
@@ -111,10 +107,10 @@ public void testShouldAddElement() {
SimpleElement element = new SimpleElement();
intrusiveCollection.add(element);
- assertFalse("Collection should not be empty",
- intrusiveCollection.isEmpty());
- assertTrue("Collection should contain added element",
- intrusiveCollection.contains(element));
+ assertFalse(intrusiveCollection.isEmpty(),
+ "Collection should not be empty");
+ assertTrue(intrusiveCollection.contains(element),
+ "Collection should contain added element");
}
/**
@@ -135,9 +131,9 @@ public void testShouldRemoveElement() {
intrusiveCollection.remove(element);
- assertTrue("Collection should be empty", intrusiveCollection.isEmpty());
- assertFalse("Collection should not contain removed element",
- intrusiveCollection.contains(element));
+ assertTrue(intrusiveCollection.isEmpty(), "Collection should be empty");
+ assertFalse(intrusiveCollection.contains(element),
+ "Collection should not contain removed element");
}
/**
@@ -159,7 +155,7 @@ public void testShouldRemoveAllElements() {
intrusiveCollection.clear();
- assertTrue("Collection should be empty", intrusiveCollection.isEmpty());
+ assertTrue(intrusiveCollection.isEmpty(), "Collection should be empty");
}
/**
@@ -184,10 +180,9 @@ public void testIterateShouldReturnAllElements() {
Iterator iterator = intrusiveCollection.iterator();
- assertEquals("First element returned is incorrect", elem1, iterator.next());
- assertEquals("Second element returned is incorrect", elem2,
- iterator.next());
- assertEquals("Third element returned is incorrect", elem3, iterator.next());
- assertFalse("Iterator should not have next element", iterator.hasNext());
+ assertEquals(elem1, iterator.next(), "First element returned is incorrect");
+ assertEquals(elem2, iterator.next(), "Second element returned is incorrect");
+ assertEquals(elem3, iterator.next(), "Third element returned is incorrect");
+ assertFalse(iterator.hasNext(), "Iterator should not have next element");
}
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestJsonSerialization.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestJsonSerialization.java
index 4a106e8fdf1f3..b433da0cd6aee 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestJsonSerialization.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestJsonSerialization.java
@@ -25,7 +25,7 @@
import java.util.Objects;
import com.fasterxml.jackson.core.JsonParseException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
@@ -106,7 +106,7 @@ public void setValue(String value) {
public void testStringRoundTrip() throws Throwable {
String wire = serDeser.toJson(source);
KeyVal unmarshalled = serDeser.fromJson(wire);
- assertEquals("Failed to unmarshall: " + wire, source, unmarshalled);
+ assertEquals(source, unmarshalled, "Failed to unmarshall: " + wire);
}
@Test
@@ -164,12 +164,10 @@ public void testFileSystemRoundTrip() throws Throwable {
LocalFileSystem fs = FileSystem.getLocal(new Configuration());
try {
serDeser.save(fs, tempPath, source, false);
- assertEquals("JSON loaded with load(fs, path)",
- source,
- serDeser.load(fs, tempPath));
- assertEquals("JSON loaded with load(fs, path, status)",
- source,
- serDeser.load(fs, tempPath, fs.getFileStatus(tempPath)));
+ assertEquals(source, serDeser.load(fs, tempPath),
+ "JSON loaded with load(fs, path)");
+ assertEquals(source, serDeser.load(fs, tempPath, fs.getFileStatus(tempPath)),
+ "JSON loaded with load(fs, path, status)");
} finally {
fs.delete(tempPath, false);
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestLimitInputStream.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestLimitInputStream.java
index 368fa37b7bd09..b4645e37f9963 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestLimitInputStream.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestLimitInputStream.java
@@ -22,13 +22,10 @@
import java.io.InputStream;
import java.util.Random;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.hadoop.test.HadoopTestBase;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
public class TestLimitInputStream extends HadoopTestBase {
static class RandomInputStream extends InputStream {
private Random rn = new Random(0);
@@ -41,22 +38,24 @@ static class RandomInputStream extends InputStream {
public void testRead() throws IOException {
try (LimitInputStream limitInputStream =
new LimitInputStream(new RandomInputStream(), 0)) {
- assertEquals("Reading byte after reaching limit should return -1", -1,
- limitInputStream.read());
+ assertEquals(-1, limitInputStream.read(),
+ "Reading byte after reaching limit should return -1");
}
try (LimitInputStream limitInputStream =
new LimitInputStream(new RandomInputStream(), 4)) {
- assertEquals("Incorrect byte returned", new Random(0).nextInt(),
- limitInputStream.read());
+ assertEquals(new Random(0).nextInt(),
+ limitInputStream.read(), "Incorrect byte returned");
}
}
- @Test(expected = IOException.class)
+ @Test
public void testResetWithoutMark() throws IOException {
- try (LimitInputStream limitInputStream =
- new LimitInputStream(new RandomInputStream(), 128)) {
- limitInputStream.reset();
- }
+ assertThrows(IOException.class, () -> {
+ try (LimitInputStream limitInputStream =
+ new LimitInputStream(new RandomInputStream(), 128)) {
+ limitInputStream.reset();
+ }
+ });
}
@Test
@@ -68,7 +67,7 @@ public void testReadBytes() throws IOException {
byte[] expected = { (byte) r.nextInt(), (byte) r.nextInt(),
(byte) r.nextInt(), (byte) r.nextInt() };
limitInputStream.read(data, 0, 4);
- assertArrayEquals("Incorrect bytes returned", expected, data);
+ assertArrayEquals(expected, data, "Incorrect bytes returned");
}
}
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestUTF8ByteArrayUtils.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestUTF8ByteArrayUtils.java
index 3aa549a4ca497..29001698f2124 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestUTF8ByteArrayUtils.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestUTF8ByteArrayUtils.java
@@ -18,40 +18,37 @@
package org.apache.hadoop.util;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.hadoop.test.HadoopTestBase;
-import static org.junit.Assert.assertEquals;
-
public class TestUTF8ByteArrayUtils extends HadoopTestBase {
@Test
public void testFindByte() {
byte[] data = "Hello, world!".getBytes();
- assertEquals("Character 'a' does not exist in string", -1,
- UTF8ByteArrayUtils.findByte(data, 0, data.length, (byte) 'a'));
- assertEquals("Did not find first occurrence of character 'o'", 4,
- UTF8ByteArrayUtils.findByte(data, 0, data.length, (byte) 'o'));
+ assertEquals(-1, UTF8ByteArrayUtils.findByte(data, 0, data.length, (byte) 'a'),
+ "Character 'a' does not exist in string");
+ assertEquals(4, UTF8ByteArrayUtils.findByte(data, 0, data.length, (byte) 'o'),
+ "Did not find first occurrence of character 'o'");
}
@Test
public void testFindBytes() {
byte[] data = "Hello, world!".getBytes();
- assertEquals("Did not find first occurrence of pattern 'ello'", 1,
- UTF8ByteArrayUtils.findBytes(data, 0, data.length, "ello".getBytes()));
- assertEquals(
- "Substring starting at position 2 does not contain pattern 'ello'", -1,
- UTF8ByteArrayUtils.findBytes(data, 2, data.length, "ello".getBytes()));
+ assertEquals(1, UTF8ByteArrayUtils.findBytes(data, 0, data.length, "ello".getBytes()),
+ "Did not find first occurrence of pattern 'ello'");
+ assertEquals(-1, UTF8ByteArrayUtils.findBytes(data, 2, data.length, "ello".getBytes()),
+ "Substring starting at position 2 does not contain pattern 'ello'");
}
@Test
public void testFindNthByte() {
byte[] data = "Hello, world!".getBytes();
- assertEquals("Did not find 2nd occurrence of character 'l'", 3,
- UTF8ByteArrayUtils.findNthByte(data, 0, data.length, (byte) 'l', 2));
- assertEquals("4th occurrence of character 'l' does not exist", -1,
- UTF8ByteArrayUtils.findNthByte(data, 0, data.length, (byte) 'l', 4));
- assertEquals("Did not find 3rd occurrence of character 'l'", 10,
- UTF8ByteArrayUtils.findNthByte(data, (byte) 'l', 3));
+ assertEquals(3, UTF8ByteArrayUtils.findNthByte(data, 0, data.length, (byte) 'l', 2),
+ "Did not find 2nd occurrence of character 'l'");
+ assertEquals(-1, UTF8ByteArrayUtils.findNthByte(data, 0, data.length, (byte) 'l', 4),
+ "4th occurrence of character 'l' does not exist");
+ assertEquals(10, UTF8ByteArrayUtils.findNthByte(data, (byte) 'l', 3),
+ "Did not find 3rd occurrence of character 'l'");
}
}
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/functional/TestTaskPool.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/functional/TestTaskPool.java
index dfee6fc75dcb3..02b7245968678 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/functional/TestTaskPool.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/functional/TestTaskPool.java
@@ -32,11 +32,10 @@
import java.util.stream.IntStream;
import org.apache.hadoop.thirdparty.com.google.common.util.concurrent.ThreadFactoryBuilder;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,7 +47,6 @@
* Test Task Pool class.
* This is pulled straight out of the S3A version.
*/
-@RunWith(Parameterized.class)
public class TestTaskPool extends HadoopTestBase {
private static final Logger LOG =
@@ -58,7 +56,7 @@ public class TestTaskPool extends HadoopTestBase {
private static final int FAILPOINT = 8;
- private final int numThreads;
+ private int numThreads;
/**
* Thread pool for task execution.
@@ -89,7 +87,6 @@ public class TestTaskPool extends HadoopTestBase {
* more checks on single thread than parallel ops.
* @return a list of parameter tuples.
*/
- @Parameterized.Parameters(name = "threads={0}")
public static Collection