Bläddra i källkod

HADOOP-19415. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-common Part2. (#7347)

Co-authored-by: Chris Nauroth <cnauroth@apache.org>
Reviewed-by: Chris Nauroth <cnauroth@apache.org>
Signed-off-by: Shilun Fan <slfan1989@apache.org>
slfan1989 5 månader sedan
förälder
incheckning
b5cbca37df
89 ändrade filer med 1433 tillägg och 1218 borttagningar
  1. 20 0
      hadoop-common-project/hadoop-common/pom.xml
  2. 9 5
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestAfsCheckPath.java
  3. 2 2
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestAvroFSInput.java
  4. 9 6
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestBlockLocation.java
  5. 17 13
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java
  6. 4 5
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestCommandFormat.java
  7. 31 32
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestContentSummary.java
  8. 6 6
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFCachingGetSpaceUsed.java
  9. 26 25
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFVariations.java
  10. 16 19
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java
  11. 1 1
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDefaultUri.java
  12. 4 3
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegateToFileSystem.java
  13. 1 1
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegateToFsCheckPath.java
  14. 21 10
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegationTokenRenewer.java
  15. 12 12
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileContext.java
  16. 16 14
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileContextDeleteOnExit.java
  17. 9 6
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileContextResolveAfs.java
  18. 5 4
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileStatus.java
  19. 6 6
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemCanonicalization.java
  20. 3 2
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemInitialization.java
  21. 8 12
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemStorageStatistics.java
  22. 10 3
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemTokens.java
  23. 18 13
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFileSystem.java
  24. 1 1
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFs.java
  25. 2 2
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsOptions.java
  26. 15 12
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShell.java
  27. 9 9
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellCopy.java
  28. 15 13
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellList.java
  29. 34 28
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java
  30. 5 5
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellTouch.java
  31. 11 10
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsUrlConnectionPath.java
  32. 7 6
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetFileBlockLocations.java
  33. 9 6
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetSpaceUsed.java
  34. 6 6
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGlobExpander.java
  35. 7 6
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGlobPattern.java
  36. 3 3
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java
  37. 29 29
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystemBasics.java
  38. 10 8
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHardLink.java
  39. 12 10
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestListFiles.java
  40. 126 79
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalDirAllocator.java
  41. 47 52
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java
  42. 11 10
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystemPermission.java
  43. 1 1
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocatedFileStatus.java
  44. 17 17
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestQuotaUsage.java
  45. 62 83
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java
  46. 2 2
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTruncatedInputBug.java
  47. 12 16
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/ftp/TestFTPFileSystem.java
  48. 4 4
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/http/TestHttpFileSystem.java
  49. 6 4
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestAcl.java
  50. 6 4
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java
  51. 2 2
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/protocolPB/TestFSSerialization.java
  52. 58 54
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/sftp/TestSFTPFileSystem.java
  53. 38 43
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestAclCommands.java
  54. 7 4
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCommandFactory.java
  55. 19 7
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCopy.java
  56. 20 16
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCopyFromLocal.java
  57. 44 25
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCopyPreserveFlag.java
  58. 27 20
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCopyToLocal.java
  59. 21 13
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCount.java
  60. 27 20
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCpCommand.java
  61. 43 31
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestLs.java
  62. 16 12
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestMove.java
  63. 37 28
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestPathData.java
  64. 3 3
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestPathExceptions.java
  65. 1 1
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestPrintableString.java
  66. 2 2
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestTail.java
  67. 56 43
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestTextCommand.java
  68. 21 21
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestXAttrCommands.java
  69. 8 9
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/find/TestAnd.java
  70. 14 11
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/find/TestFilterExpression.java
  71. 18 11
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/find/TestFind.java
  72. 6 10
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/find/TestIname.java
  73. 6 10
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/find/TestName.java
  74. 9 11
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/find/TestPrint.java
  75. 9 12
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/find/TestPrint0.java
  76. 2 2
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/find/TestResult.java
  77. 10 11
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/store/TestDataBlocks.java
  78. 3 3
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/store/TestEtagChecksum.java
  79. 83 72
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFs.java
  80. 5 4
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestRegexMountPointInterceptorFactory.java
  81. 11 10
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestRegexMountPointResolvedDstPathReplaceInterceptor.java
  82. 2 2
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFSOverloadSchemeCentralMountTableConfig.java
  83. 5 4
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java
  84. 4 4
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegationTokenSupport.java
  85. 25 18
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemOverloadSchemeLocalFileSystem.java
  86. 29 25
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsConfig.java
  87. 5 6
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java
  88. 1 1
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsURIs.java
  89. 13 11
      hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewfsFileStatus.java

+ 20 - 0
hadoop-common-project/hadoop-common/pom.xml

@@ -381,6 +381,26 @@
       <artifactId>lz4-java</artifactId>
       <artifactId>lz4-java</artifactId>
       <scope>provided</scope>
       <scope>provided</scope>
     </dependency>
     </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-engine</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-params</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.platform</groupId>
+      <artifactId>junit-platform-launcher</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   </dependencies>
 
 
   <build>
   <build>

+ 9 - 5
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestAfsCheckPath.java

@@ -27,7 +27,9 @@ import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.Options.ChecksumOpt;
 import org.apache.hadoop.fs.Options.ChecksumOpt;
 import org.apache.hadoop.security.AccessControlException;
 import org.apache.hadoop.security.AccessControlException;
 import org.apache.hadoop.util.Progressable;
 import org.apache.hadoop.util.Progressable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 
 public class TestAfsCheckPath {
 public class TestAfsCheckPath {
   
   
@@ -56,11 +58,13 @@ public class TestAfsCheckPath {
     afs.checkPath(new Path("dummy://dummy-host:" + OTHER_PORT));
     afs.checkPath(new Path("dummy://dummy-host:" + OTHER_PORT));
   }
   }
   
   
-  @Test(expected=InvalidPathException.class)
+  @Test
   public void testCheckPathWithDifferentPorts() throws URISyntaxException {
   public void testCheckPathWithDifferentPorts() throws URISyntaxException {
-    URI uri = new URI("dummy://dummy-host:" + DEFAULT_PORT);
-    AbstractFileSystem afs = new DummyFileSystem(uri);
-    afs.checkPath(new Path("dummy://dummy-host:" + OTHER_PORT));
+    assertThrows(InvalidPathException.class, () -> {
+      URI uri = new URI("dummy://dummy-host:" + DEFAULT_PORT);
+      AbstractFileSystem afs = new DummyFileSystem(uri);
+      afs.checkPath(new Path("dummy://dummy-host:" + OTHER_PORT));
+    });
   }
   }
   
   
   private static class DummyFileSystem extends AbstractFileSystem {
   private static class DummyFileSystem extends AbstractFileSystem {

+ 2 - 2
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestAvroFSInput.java

@@ -24,8 +24,8 @@ import java.io.OutputStreamWriter;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 
 
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 public class TestAvroFSInput {
 public class TestAvroFSInput {
 
 

+ 9 - 6
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestBlockLocation.java

@@ -17,11 +17,12 @@
  */
  */
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 public class TestBlockLocation {
 public class TestBlockLocation {
 
 
@@ -70,7 +71,8 @@ public class TestBlockLocation {
   /**
   /**
    * Call all the constructors and verify the delegation is working properly
    * Call all the constructors and verify the delegation is working properly
    */
    */
-  @Test(timeout = 5000)
+  @Test
+  @Timeout(value = 5)
   public void testBlockLocationConstructors() throws Exception {
   public void testBlockLocationConstructors() throws Exception {
     //
     //
     BlockLocation loc;
     BlockLocation loc;
@@ -91,7 +93,8 @@ public class TestBlockLocation {
   /**
   /**
    * Call each of the setters and verify
    * Call each of the setters and verify
    */
    */
-  @Test(timeout = 5000)
+  @Test
+  @Timeout(value = 5)
   public void testBlockLocationSetters() throws Exception {
   public void testBlockLocationSetters() throws Exception {
     BlockLocation loc;
     BlockLocation loc;
     loc = new BlockLocation();
     loc = new BlockLocation();

+ 17 - 13
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java

@@ -26,8 +26,14 @@ import org.apache.hadoop.fs.permission.FsPermission;
 import static org.apache.hadoop.fs.FileSystemTestHelper.*;
 import static org.apache.hadoop.fs.FileSystemTestHelper.*;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
-import org.junit.*;
-import static org.junit.Assert.*;
+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.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 public class TestChecksumFileSystem {
 public class TestChecksumFileSystem {
   static final String TEST_ROOT_DIR =
   static final String TEST_ROOT_DIR =
@@ -35,7 +41,7 @@ public class TestChecksumFileSystem {
 
 
   static LocalFileSystem localFs;
   static LocalFileSystem localFs;
 
 
-  @Before
+  @BeforeEach
   public void resetLocalFs() throws Exception {
   public void resetLocalFs() throws Exception {
     localFs = FileSystem.getLocal(new Configuration());
     localFs = FileSystem.getLocal(new Configuration());
     localFs.setVerifyChecksum(true);
     localFs.setVerifyChecksum(true);
@@ -77,12 +83,12 @@ public class TestChecksumFileSystem {
     readFile(localFs, testPath, 1025);
     readFile(localFs, testPath, 1025);
 
 
     localFs.delete(localFs.getChecksumFile(testPath), true);
     localFs.delete(localFs.getChecksumFile(testPath), true);
-    assertTrue("checksum deleted", !localFs.exists(localFs.getChecksumFile(testPath)));
+    assertTrue(!localFs.exists(localFs.getChecksumFile(testPath)), "checksum deleted");
     
     
     //copying the wrong checksum file
     //copying the wrong checksum file
     FileUtil.copy(localFs, localFs.getChecksumFile(testPath11), localFs, 
     FileUtil.copy(localFs, localFs.getChecksumFile(testPath11), localFs, 
         localFs.getChecksumFile(testPath),false,true,localFs.getConf());
         localFs.getChecksumFile(testPath),false,true,localFs.getConf());
-    assertTrue("checksum exists", localFs.exists(localFs.getChecksumFile(testPath)));
+    assertTrue(localFs.exists(localFs.getChecksumFile(testPath)), "checksum exists");
     
     
     boolean errorRead = false;
     boolean errorRead = false;
     try {
     try {
@@ -90,12 +96,12 @@ public class TestChecksumFileSystem {
     }catch(ChecksumException ie) {
     }catch(ChecksumException ie) {
       errorRead = true;
       errorRead = true;
     }
     }
-    assertTrue("error reading", errorRead);
+    assertTrue(errorRead, "error reading");
     
     
     //now setting verify false, the read should succeed
     //now setting verify false, the read should succeed
     localFs.setVerifyChecksum(false);
     localFs.setVerifyChecksum(false);
     String str = readFile(localFs, testPath, 1024).toString();
     String str = readFile(localFs, testPath, 1024).toString();
-    assertTrue("read", "testing".equals(str));
+    assertTrue("testing".equals(str), "read");
   }
   }
 
 
   @Test
   @Test
@@ -153,7 +159,7 @@ public class TestChecksumFileSystem {
     // telling it not to verify checksums, should avoid issue.
     // telling it not to verify checksums, should avoid issue.
     localFs.setVerifyChecksum(false);
     localFs.setVerifyChecksum(false);
     String str = readFile(localFs, testPath, 1024).toString();
     String str = readFile(localFs, testPath, 1024).toString();
-    assertTrue("read", "testing truncation".equals(str));
+    assertTrue("testing truncation".equals(str), "read");
   }
   }
   
   
   @Test
   @Test
@@ -164,13 +170,11 @@ public class TestChecksumFileSystem {
     
     
     localFs.setVerifyChecksum(true);
     localFs.setVerifyChecksum(true);
     in = localFs.open(testPath);
     in = localFs.open(testPath);
-    assertTrue("stream is input checker",
-        in.getWrappedStream() instanceof FSInputChecker);
+    assertTrue(in.getWrappedStream() instanceof FSInputChecker, "stream is input checker");
     
     
     localFs.setVerifyChecksum(false);
     localFs.setVerifyChecksum(false);
     in = localFs.open(testPath);
     in = localFs.open(testPath);
-    assertFalse("stream is not input checker",
-        in.getWrappedStream() instanceof FSInputChecker);
+    assertFalse(in.getWrappedStream() instanceof FSInputChecker, "stream is not input checker");
   }
   }
   
   
   @Test
   @Test
@@ -200,7 +204,7 @@ public class TestChecksumFileSystem {
     } catch (ChecksumException ce) {
     } catch (ChecksumException ce) {
       e = ce;
       e = ce;
     } finally {
     } finally {
-      assertNotNull("got checksum error", e);
+      assertNotNull(e, "got checksum error");
     }
     }
 
 
     localFs.setVerifyChecksum(false);
     localFs.setVerifyChecksum(false);

+ 4 - 5
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestCommandFormat.java

@@ -17,8 +17,7 @@
  */
  */
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
-
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
@@ -30,8 +29,8 @@ import org.apache.hadoop.fs.shell.CommandFormat;
 import org.apache.hadoop.fs.shell.CommandFormat.NotEnoughArgumentsException;
 import org.apache.hadoop.fs.shell.CommandFormat.NotEnoughArgumentsException;
 import org.apache.hadoop.fs.shell.CommandFormat.TooManyArgumentsException;
 import org.apache.hadoop.fs.shell.CommandFormat.TooManyArgumentsException;
 import org.apache.hadoop.fs.shell.CommandFormat.UnknownOptionException;
 import org.apache.hadoop.fs.shell.CommandFormat.UnknownOptionException;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 /**
 /**
  * This class tests the command line parsing
  * This class tests the command line parsing
@@ -41,7 +40,7 @@ public class TestCommandFormat {
   private static List<String> expectedArgs;
   private static List<String> expectedArgs;
   private static Set<String> expectedOpts;
   private static Set<String> expectedOpts;
   
   
-  @Before
+  @BeforeEach
   public void setUp() {
   public void setUp() {
     args = new ArrayList<>();
     args = new ArrayList<>();
     expectedOpts = new HashSet<>();
     expectedOpts = new HashSet<>();

+ 31 - 32
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestContentSummary.java

@@ -17,14 +17,16 @@
  */
  */
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 
 import java.io.DataInput;
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.DataOutput;
 import java.io.IOException;
 import java.io.IOException;
 
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.InOrder;
 import org.mockito.InOrder;
 
 
 public class TestContentSummary {
 public class TestContentSummary {
@@ -33,12 +35,12 @@ public class TestContentSummary {
   @Test
   @Test
   public void testConstructorEmpty() {
   public void testConstructorEmpty() {
     ContentSummary contentSummary = new ContentSummary.Builder().build();
     ContentSummary contentSummary = new ContentSummary.Builder().build();
-    assertEquals("getLength", 0, contentSummary.getLength());
-    assertEquals("getFileCount", 0, contentSummary.getFileCount());
-    assertEquals("getDirectoryCount", 0, contentSummary.getDirectoryCount());
-    assertEquals("getQuota", -1, contentSummary.getQuota());
-    assertEquals("getSpaceConsumed", 0, contentSummary.getSpaceConsumed());
-    assertEquals("getSpaceQuota", -1, contentSummary.getSpaceQuota());
+    assertEquals(0, contentSummary.getLength(), "getLength");
+    assertEquals(0, contentSummary.getFileCount(), "getFileCount");
+    assertEquals(0, contentSummary.getDirectoryCount(), "getDirectoryCount");
+    assertEquals(-1, contentSummary.getQuota(), "getQuota");
+    assertEquals(0, contentSummary.getSpaceConsumed(), "getSpaceConsumed");
+    assertEquals(-1, contentSummary.getSpaceQuota(), "getSpaceQuota");
   }
   }
 
 
   // check the full constructor with quota information
   // check the full constructor with quota information
@@ -54,14 +56,13 @@ public class TestContentSummary {
     ContentSummary contentSummary = new ContentSummary.Builder().length(length).
     ContentSummary contentSummary = new ContentSummary.Builder().length(length).
         fileCount(fileCount).directoryCount(directoryCount).quota(quota).
         fileCount(fileCount).directoryCount(directoryCount).quota(quota).
         spaceConsumed(spaceConsumed).spaceQuota(spaceQuota).build();
         spaceConsumed(spaceConsumed).spaceQuota(spaceQuota).build();
-    assertEquals("getLength", length, contentSummary.getLength());
-    assertEquals("getFileCount", fileCount, contentSummary.getFileCount());
-    assertEquals("getDirectoryCount", directoryCount,
-        contentSummary.getDirectoryCount());
-    assertEquals("getQuota", quota, contentSummary.getQuota());
-    assertEquals("getSpaceConsumed", spaceConsumed,
-        contentSummary.getSpaceConsumed());
-    assertEquals("getSpaceQuota", spaceQuota, contentSummary.getSpaceQuota());
+    assertEquals(length, contentSummary.getLength(), "getLength");
+    assertEquals(fileCount, contentSummary.getFileCount(), "getFileCount");
+    assertEquals(directoryCount, contentSummary.getDirectoryCount(), "getDirectoryCount");
+    assertEquals(quota, contentSummary.getQuota(), "getQuota");
+    assertEquals(spaceConsumed,
+        contentSummary.getSpaceConsumed(), "getSpaceConsumed");
+    assertEquals(spaceQuota, contentSummary.getSpaceQuota(), "getSpaceQuota");
   }
   }
 
 
   // check the constructor with quota information
   // check the constructor with quota information
@@ -74,13 +75,13 @@ public class TestContentSummary {
     ContentSummary contentSummary = new ContentSummary.Builder().length(length).
     ContentSummary contentSummary = new ContentSummary.Builder().length(length).
         fileCount(fileCount).directoryCount(directoryCount).
         fileCount(fileCount).directoryCount(directoryCount).
         spaceConsumed(length).build();
         spaceConsumed(length).build();
-    assertEquals("getLength", length, contentSummary.getLength());
-    assertEquals("getFileCount", fileCount, contentSummary.getFileCount());
-    assertEquals("getDirectoryCount", directoryCount,
-        contentSummary.getDirectoryCount());
-    assertEquals("getQuota", -1, contentSummary.getQuota());
-    assertEquals("getSpaceConsumed", length, contentSummary.getSpaceConsumed());
-    assertEquals("getSpaceQuota", -1, contentSummary.getSpaceQuota());
+    assertEquals(length, contentSummary.getLength(), "getLength");
+    assertEquals(fileCount, contentSummary.getFileCount(), "getFileCount");
+    assertEquals(directoryCount,
+        contentSummary.getDirectoryCount(), "getDirectoryCount");
+    assertEquals(-1, contentSummary.getQuota(), "getQuota");
+    assertEquals(length, contentSummary.getSpaceConsumed(), "getSpaceConsumed");
+    assertEquals(-1, contentSummary.getSpaceQuota(), "getSpaceQuota");
   }
   }
 
 
   // check the write method
   // check the write method
@@ -127,14 +128,12 @@ public class TestContentSummary {
         .thenReturn(spaceQuota);
         .thenReturn(spaceQuota);
 
 
     contentSummary.readFields(in);
     contentSummary.readFields(in);
-    assertEquals("getLength", length, contentSummary.getLength());
-    assertEquals("getFileCount", fileCount, contentSummary.getFileCount());
-    assertEquals("getDirectoryCount", directoryCount,
-        contentSummary.getDirectoryCount());
-    assertEquals("getQuota", quota, contentSummary.getQuota());
-    assertEquals("getSpaceConsumed", spaceConsumed,
-        contentSummary.getSpaceConsumed());
-    assertEquals("getSpaceQuota", spaceQuota, contentSummary.getSpaceQuota());
+    assertEquals(length, contentSummary.getLength(), "getLength");
+    assertEquals(fileCount, contentSummary.getFileCount(), "getFileCount");
+    assertEquals(directoryCount, contentSummary.getDirectoryCount(), "getDirectoryCount");
+    assertEquals(quota, contentSummary.getQuota(), "getQuota");
+    assertEquals(spaceConsumed, contentSummary.getSpaceConsumed(), "getSpaceConsumed");
+    assertEquals(spaceQuota, contentSummary.getSpaceQuota(), "getSpaceQuota");
   }
   }
 
 
   // check the header with quotas
   // check the header with quotas

+ 6 - 6
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFCachingGetSpaceUsed.java

@@ -19,16 +19,16 @@ package org.apache.hadoop.fs;
 
 
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
-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 java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
 import java.io.RandomAccessFile;
 import java.io.RandomAccessFile;
 
 
 
 
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
 /**
  * Test to make sure df can run and work.
  * Test to make sure df can run and work.
@@ -37,13 +37,13 @@ public class TestDFCachingGetSpaceUsed {
   final static private File DF_DIR = GenericTestUtils.getTestDir("testdfspace");
   final static private File DF_DIR = GenericTestUtils.getTestDir("testdfspace");
   public static final int FILE_SIZE = 1024;
   public static final int FILE_SIZE = 1024;
 
 
-  @Before
+  @BeforeEach
   public void setUp() {
   public void setUp() {
     FileUtil.fullyDelete(DF_DIR);
     FileUtil.fullyDelete(DF_DIR);
     assertTrue(DF_DIR.mkdirs());
     assertTrue(DF_DIR.mkdirs());
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws IOException {
   public void tearDown() throws IOException {
     FileUtil.fullyDelete(DF_DIR);
     FileUtil.fullyDelete(DF_DIR);
   }
   }

+ 26 - 25
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFVariations.java

@@ -17,9 +17,9 @@
 */
 */
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 import java.io.BufferedReader;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileNotFoundException;
@@ -29,24 +29,23 @@ import java.util.Random;
 
 
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.util.Shell;
 import org.apache.hadoop.util.Shell;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 public class TestDFVariations {
 public class TestDFVariations {
   private static final String TEST_ROOT_DIR =
   private static final String TEST_ROOT_DIR =
       GenericTestUtils.getTestDir("testdfvariations").getAbsolutePath();
       GenericTestUtils.getTestDir("testdfvariations").getAbsolutePath();
   private static File test_root = null;
   private static File test_root = null;
 
 
-  @Before
+  @BeforeEach
   public void setup() throws IOException {
   public void setup() throws IOException {
     test_root = new File(TEST_ROOT_DIR);
     test_root = new File(TEST_ROOT_DIR);
     test_root.mkdirs();
     test_root.mkdirs();
   }
   }
   
   
-  @After
+  @AfterEach
   public void after() throws IOException {
   public void after() throws IOException {
     FileUtil.setWritable(test_root, true);
     FileUtil.setWritable(test_root, true);
     FileUtil.fullyDelete(test_root);
     FileUtil.fullyDelete(test_root);
@@ -65,25 +64,26 @@ public class TestDFVariations {
     }
     }
   }
   }
 
 
-  @Test(timeout=5000)
+  @Test
+  @Timeout(value = 5)
   public void testMount() throws Exception {
   public void testMount() throws Exception {
     XXDF df = new XXDF();
     XXDF df = new XXDF();
     String expectedMount =
     String expectedMount =
         Shell.WINDOWS ? df.getDirPath().substring(0, 2) : "/foo/bar";
         Shell.WINDOWS ? df.getDirPath().substring(0, 2) : "/foo/bar";
-    assertEquals("Invalid mount point",
-        expectedMount, df.getMount());
+    assertEquals(expectedMount, df.getMount(), "Invalid mount point");
   }
   }
 
 
-  @Test(timeout=5000)
+  @Test
+  @Timeout(value = 5)
   public void testFileSystem() throws Exception {
   public void testFileSystem() throws Exception {
     XXDF df = new XXDF();
     XXDF df = new XXDF();
     String expectedFileSystem =
     String expectedFileSystem =
         Shell.WINDOWS ? df.getDirPath().substring(0, 2) : "/dev/sda3";
         Shell.WINDOWS ? df.getDirPath().substring(0, 2) : "/dev/sda3";
-    assertEquals("Invalid filesystem",
-        expectedFileSystem, df.getFilesystem());
+    assertEquals(expectedFileSystem, df.getFilesystem(), "Invalid filesystem");
   }
   }
 
 
-  @Test(timeout=5000)
+  @Test
+  @Timeout(value = 5)
   public void testDFInvalidPath() throws Exception {
   public void testDFInvalidPath() throws Exception {
     // Generate a path that doesn't exist
     // Generate a path that doesn't exist
     Random random = new Random(0xDEADBEEFl);
     Random random = new Random(0xDEADBEEFl);
@@ -106,7 +106,8 @@ public class TestDFVariations {
     }
     }
   }
   }
   
   
-  @Test(timeout=5000)
+  @Test
+  @Timeout(value = 5)
   public void testDFMalformedOutput() throws Exception {
   public void testDFMalformedOutput() throws Exception {
     DF df = new DF(new File("/"), 0l);
     DF df = new DF(new File("/"), 0l);
     BufferedReader reader = new BufferedReader(new StringReader(
     BufferedReader reader = new BufferedReader(new StringReader(
@@ -152,19 +153,19 @@ public class TestDFVariations {
     }
     }
   }
   }
 
 
-  @Test(timeout=5000)
+  @Test
+  @Timeout(value = 5)
   public void testGetMountCurrentDirectory() throws Exception {
   public void testGetMountCurrentDirectory() throws Exception {
     File currentDirectory = new File(".");
     File currentDirectory = new File(".");
     String workingDir = currentDirectory.getAbsoluteFile().getCanonicalPath();
     String workingDir = currentDirectory.getAbsoluteFile().getCanonicalPath();
     DF df = new DF(new File(workingDir), 0L);
     DF df = new DF(new File(workingDir), 0L);
     String mountPath = df.getMount();
     String mountPath = df.getMount();
     File mountDir = new File(mountPath);
     File mountDir = new File(mountPath);
-    assertTrue("Mount dir ["+mountDir.getAbsolutePath()+"] should exist.", 
-        mountDir.exists());
-    assertTrue("Mount dir ["+mountDir.getAbsolutePath()+"] should be directory.", 
-        mountDir.isDirectory());
-    assertTrue("Working dir ["+workingDir+"] should start with ["+mountPath+"].",
-        workingDir.startsWith(mountPath));
+    assertTrue(mountDir.exists(), "Mount dir ["+mountDir.getAbsolutePath()+"] should exist.");
+    assertTrue(mountDir.isDirectory(),
+        "Mount dir ["+mountDir.getAbsolutePath()+"] should be directory.");
+    assertTrue(workingDir.startsWith(mountPath),
+        "Working dir ["+workingDir+"] should start with ["+mountPath+"].");
   }
   }
 }
 }
 
 

+ 16 - 19
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java

@@ -18,11 +18,11 @@
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
 import org.apache.hadoop.util.Shell;
 import org.apache.hadoop.util.Shell;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-import static org.junit.Assume.assumeFalse;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeFalse;
 
 
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
@@ -37,14 +37,14 @@ import org.apache.hadoop.test.GenericTestUtils;
 public class TestDU {
 public class TestDU {
   final static private File DU_DIR = GenericTestUtils.getTestDir("dutmp");
   final static private File DU_DIR = GenericTestUtils.getTestDir("dutmp");
 
 
-  @Before
+  @BeforeEach
   public void setUp() {
   public void setUp() {
     assumeFalse(Shell.WINDOWS);
     assumeFalse(Shell.WINDOWS);
     FileUtil.fullyDelete(DU_DIR);
     FileUtil.fullyDelete(DU_DIR);
     assertTrue(DU_DIR.mkdirs());
     assertTrue(DU_DIR.mkdirs());
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws IOException {
   public void tearDown() throws IOException {
       FileUtil.fullyDelete(DU_DIR);
       FileUtil.fullyDelete(DU_DIR);
   }
   }
@@ -91,9 +91,8 @@ public class TestDU {
     long duSize = du.getUsed();
     long duSize = du.getUsed();
     du.close();
     du.close();
 
 
-    assertTrue("Invalid on-disk size",
-        duSize >= writtenSize &&
-        writtenSize <= (duSize + slack));
+    assertTrue(duSize >= writtenSize && writtenSize <= (duSize + slack),
+        "Invalid on-disk size");
 
 
     //test with 0 interval, will not launch thread
     //test with 0 interval, will not launch thread
     du = new DU(file, 0, 1, -1);
     du = new DU(file, 0, 1, -1);
@@ -101,18 +100,16 @@ public class TestDU {
     duSize = du.getUsed();
     duSize = du.getUsed();
     du.close();
     du.close();
 
 
-    assertTrue("Invalid on-disk size",
-        duSize >= writtenSize &&
-        writtenSize <= (duSize + slack));
+    assertTrue(duSize >= writtenSize && writtenSize <= (duSize + slack),
+        "Invalid on-disk size");
 
 
     //test without launching thread
     //test without launching thread
     du = new DU(file, 10000, 0, -1);
     du = new DU(file, 10000, 0, -1);
     du.init();
     du.init();
     duSize = du.getUsed();
     duSize = du.getUsed();
 
 
-    assertTrue("Invalid on-disk size",
-        duSize >= writtenSize &&
-        writtenSize <= (duSize + slack));
+    assertTrue(duSize >= writtenSize && writtenSize <= (duSize + slack),
+        "Invalid on-disk size");
   }
   }
 
 
   @Test
   @Test
@@ -124,7 +121,7 @@ public class TestDU {
     DU du = new DU(file, 10000L, 0, -1);
     DU du = new DU(file, 10000L, 0, -1);
     du.incDfsUsed(-Long.MAX_VALUE);
     du.incDfsUsed(-Long.MAX_VALUE);
     long duSize = du.getUsed();
     long duSize = du.getUsed();
-    assertTrue(String.valueOf(duSize), duSize >= 0L);
+    assertTrue(duSize >= 0L, String.valueOf(duSize));
   }
   }
 
 
   @Test
   @Test
@@ -133,14 +130,14 @@ public class TestDU {
     createFile(file, 8192);
     createFile(file, 8192);
     DU du = new DU(file, 3000, 0, 1024);
     DU du = new DU(file, 3000, 0, 1024);
     du.init();
     du.init();
-    assertTrue("Initial usage setting not honored", du.getUsed() == 1024);
+    assertTrue(du.getUsed() == 1024, "Initial usage setting not honored");
 
 
     // wait until the first du runs.
     // wait until the first du runs.
     try {
     try {
       Thread.sleep(5000);
       Thread.sleep(5000);
     } catch (InterruptedException ie) {}
     } catch (InterruptedException ie) {}
 
 
-    assertTrue("Usage didn't get updated", du.getUsed() == 8192);
+    assertTrue(du.getUsed() == 8192, "Usage didn't get updated");
   }
   }
 
 
 
 

+ 1 - 1
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDefaultUri.java

@@ -25,7 +25,7 @@ import java.net.URI;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import static org.apache.hadoop.test.LambdaTestUtils.*;
 import static org.apache.hadoop.test.LambdaTestUtils.*;
 
 
 /**
 /**

+ 4 - 3
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegateToFileSystem.java

@@ -21,8 +21,9 @@ import java.net.URI;
 
 
 import org.apache.commons.net.ftp.FTP;
 import org.apache.commons.net.ftp.FTP;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 public class TestDelegateToFileSystem {
 public class TestDelegateToFileSystem {
 
 
@@ -37,7 +38,7 @@ public class TestDelegateToFileSystem {
     FileSystem.setDefaultUri(conf, defaultUri);
     FileSystem.setDefaultUri(conf, defaultUri);
     final AbstractFileSystem ftpFs =
     final AbstractFileSystem ftpFs =
         AbstractFileSystem.get(FTP_URI_NO_PORT, conf);
         AbstractFileSystem.get(FTP_URI_NO_PORT, conf);
-    Assert.assertEquals(FTP_URI_WITH_PORT, ftpFs.getUri());
+    assertEquals(FTP_URI_WITH_PORT, ftpFs.getUri());
   }
   }
 
 
   @Test
   @Test

+ 1 - 1
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegateToFsCheckPath.java

@@ -26,7 +26,7 @@ import java.net.URISyntaxException;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.util.Progressable;
 import org.apache.hadoop.util.Progressable;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 /**
 /**
  * The default port of DelegateToFileSystem is set from child file system.
  * The default port of DelegateToFileSystem is set from child file system.

+ 21 - 10
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDelegationTokenRenewer.java

@@ -18,8 +18,17 @@
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
 import java.io.IOException;
 import java.io.IOException;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.atMost;
+import static org.mockito.Mockito.atLeast;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+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 org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.DelegationTokenRenewer.Renewable;
 import org.apache.hadoop.fs.DelegationTokenRenewer.Renewable;
@@ -27,8 +36,9 @@ import org.apache.hadoop.io.Text;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.util.Time;
 import org.apache.hadoop.util.Time;
 
 
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.mockito.stubbing.Answer;
 
 
@@ -42,7 +52,7 @@ public class TestDelegationTokenRenewer {
   Configuration conf;
   Configuration conf;
   FileSystem fs;
   FileSystem fs;
   
   
-  @Before
+  @BeforeEach
   public void setup() {
   public void setup() {
     DelegationTokenRenewer.renewCycle = RENEW_CYCLE;
     DelegationTokenRenewer.renewCycle = RENEW_CYCLE;
     DelegationTokenRenewer.reset();
     DelegationTokenRenewer.reset();
@@ -69,8 +79,8 @@ public class TestDelegationTokenRenewer {
 
 
     renewer.addRenewAction(fs);
     renewer.addRenewAction(fs);
     
     
-    assertEquals("FileSystem not added to DelegationTokenRenewer", 1,
-        renewer.getRenewQueueLength());
+    assertEquals(1, renewer.getRenewQueueLength(),
+        "FileSystem not added to DelegationTokenRenewer");
     
     
     Thread.sleep(RENEW_CYCLE*2);
     Thread.sleep(RENEW_CYCLE*2);
     verify(token, atLeast(2)).renew(eq(conf));
     verify(token, atLeast(2)).renew(eq(conf));
@@ -82,8 +92,8 @@ public class TestDelegationTokenRenewer {
     verify(fs, never()).getDelegationToken(null);
     verify(fs, never()).getDelegationToken(null);
     verify(fs, never()).setDelegationToken(any());
     verify(fs, never()).setDelegationToken(any());
     
     
-    assertEquals("FileSystem not removed from DelegationTokenRenewer", 0,
-        renewer.getRenewQueueLength());
+    assertEquals(0, renewer.getRenewQueueLength(),
+        "FileSystem not removed from DelegationTokenRenewer");
   }
   }
 
 
   @Test
   @Test
@@ -179,7 +189,8 @@ public class TestDelegationTokenRenewer {
     assertEquals(0, renewer.getRenewQueueLength());
     assertEquals(0, renewer.getRenewQueueLength());
   }
   }
   
   
-  @Test(timeout=4000)
+  @Test
+  @Timeout(value = 4)
   public void testMultipleTokensDoNotDeadlock() throws IOException,
   public void testMultipleTokensDoNotDeadlock() throws IOException,
       InterruptedException {
       InterruptedException {
     Configuration conf = mock(Configuration.class);
     Configuration conf = mock(Configuration.class);

+ 12 - 12
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileContext.java

@@ -17,14 +17,14 @@
  */
  */
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 import java.net.URI;
 import java.net.URI;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.FsPermission;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -51,32 +51,32 @@ public class TestFileContext {
 
 
     String defaultlUMask =
     String defaultlUMask =
         conf.get(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY);
         conf.get(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY);
-    assertEquals("Default UMask changed!", "022", defaultlUMask);
+    assertEquals("022", defaultlUMask, "Default UMask changed!");
 
 
     URI uri1 = new URI("file://mydfs:50070/");
     URI uri1 = new URI("file://mydfs:50070/");
     URI uri2 = new URI("file://tmp");
     URI uri2 = new URI("file://tmp");
 
 
     FileContext fc1 = FileContext.getFileContext(uri1, conf);
     FileContext fc1 = FileContext.getFileContext(uri1, conf);
     FileContext fc2 = FileContext.getFileContext(uri2, conf);
     FileContext fc2 = FileContext.getFileContext(uri2, conf);
-    assertEquals("Umask for fc1 is incorrect", 022, fc1.getUMask().toShort());
-    assertEquals("Umask for fc2 is incorrect", 022, fc2.getUMask().toShort());
+    assertEquals(022, fc1.getUMask().toShort(), "Umask for fc1 is incorrect");
+    assertEquals(022, fc2.getUMask().toShort(), "Umask for fc2 is incorrect");
 
 
     // Till a user explicitly calls FileContext.setUMask(), the updates through
     // Till a user explicitly calls FileContext.setUMask(), the updates through
     // configuration should be reflected..
     // configuration should be reflected..
     conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "011");
     conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "011");
-    assertEquals("Umask for fc1 is incorrect", 011, fc1.getUMask().toShort());
-    assertEquals("Umask for fc2 is incorrect", 011, fc2.getUMask().toShort());
+    assertEquals(011, fc1.getUMask().toShort(), "Umask for fc1 is incorrect");
+    assertEquals(011, fc2.getUMask().toShort(), "Umask for fc2 is incorrect");
 
 
     // Stop reflecting the conf update for specific FileContexts, once an
     // Stop reflecting the conf update for specific FileContexts, once an
     // explicit setUMask is done.
     // explicit setUMask is done.
     conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "066");
     conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "066");
     fc1.setUMask(FsPermission.createImmutable((short) 00033));
     fc1.setUMask(FsPermission.createImmutable((short) 00033));
-    assertEquals("Umask for fc1 is incorrect", 033, fc1.getUMask().toShort());
-    assertEquals("Umask for fc2 is incorrect", 066, fc2.getUMask().toShort());
+    assertEquals(033, fc1.getUMask().toShort(), "Umask for fc1 is incorrect");
+    assertEquals(066, fc2.getUMask().toShort(), "Umask for fc2 is incorrect");
 
 
     conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "077");
     conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "077");
     fc2.setUMask(FsPermission.createImmutable((short) 00044));
     fc2.setUMask(FsPermission.createImmutable((short) 00044));
-    assertEquals("Umask for fc1 is incorrect", 033, fc1.getUMask().toShort());
-    assertEquals("Umask for fc2 is incorrect", 044, fc2.getUMask().toShort());
+    assertEquals(033, fc1.getUMask().toShort(), "Umask for fc1 is incorrect");
+    assertEquals(044, fc2.getUMask().toShort(), "Umask for fc2 is incorrect");
   }
   }
 }
 }

+ 16 - 14
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileContextDeleteOnExit.java

@@ -20,16 +20,18 @@ package org.apache.hadoop.fs;
 import java.io.IOException;
 import java.io.IOException;
 import java.util.Set;
 import java.util.Set;
 
 
-import org.junit.Assert;
 import org.apache.hadoop.util.ShutdownHookManager;
 import org.apache.hadoop.util.ShutdownHookManager;
-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 static org.apache.hadoop.fs.FileContextTestHelper.*;
 import static org.apache.hadoop.fs.FileContextTestHelper.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
 /**
- * Tests {@link FileContext.#deleteOnExit(Path)} functionality.
+ * Tests {@link FileContext#deleteOnExit(Path)} functionality.
  */
  */
 public class TestFileContextDeleteOnExit {
 public class TestFileContextDeleteOnExit {
   private static int blockSize = 1024;
   private static int blockSize = 1024;
@@ -38,23 +40,23 @@ public class TestFileContextDeleteOnExit {
   private final FileContextTestHelper helper = new FileContextTestHelper();
   private final FileContextTestHelper helper = new FileContextTestHelper();
   private FileContext fc;
   private FileContext fc;
   
   
-  @Before
+  @BeforeEach
   public void setup() throws IOException {
   public void setup() throws IOException {
     fc = FileContext.getLocalFSFileContext();
     fc = FileContext.getLocalFSFileContext();
   }
   }
   
   
-  @After
+  @AfterEach
   public void tearDown() throws IOException {
   public void tearDown() throws IOException {
     fc.delete(helper.getTestRootPath(fc), true);
     fc.delete(helper.getTestRootPath(fc), true);
   }
   }
   
   
   
   
   private void checkDeleteOnExitData(int size, FileContext fc, Path... paths) {
   private void checkDeleteOnExitData(int size, FileContext fc, Path... paths) {
-    Assert.assertEquals(size, FileContext.DELETE_ON_EXIT.size());
+    assertEquals(size, FileContext.DELETE_ON_EXIT.size());
     Set<Path> set = FileContext.DELETE_ON_EXIT.get(fc);
     Set<Path> set = FileContext.DELETE_ON_EXIT.get(fc);
-    Assert.assertEquals(paths.length, (set == null ? 0 : set.size()));
+    assertEquals(paths.length, (set == null ? 0 : set.size()));
     for (Path path : paths) {
     for (Path path : paths) {
-      Assert.assertTrue(set.contains(path));
+      assertTrue(set.contains(path));
     }
     }
   }
   }
   
   
@@ -67,7 +69,7 @@ public class TestFileContextDeleteOnExit {
     checkDeleteOnExitData(1, fc, file1);
     checkDeleteOnExitData(1, fc, file1);
     
     
     // Ensure shutdown hook is added
     // Ensure shutdown hook is added
-    Assert.assertTrue(ShutdownHookManager.get().hasShutdownHook(FileContext.FINALIZER));
+    assertTrue(ShutdownHookManager.get().hasShutdownHook(FileContext.FINALIZER));
     
     
     Path file2 = helper.getTestRootPath(fc, "dir1/file2");
     Path file2 = helper.getTestRootPath(fc, "dir1/file2");
     createFile(fc, file2, numBlocks, blockSize);
     createFile(fc, file2, numBlocks, blockSize);
@@ -83,8 +85,8 @@ public class TestFileContextDeleteOnExit {
     // paths are cleaned up
     // paths are cleaned up
     FileContext.FINALIZER.run();
     FileContext.FINALIZER.run();
     checkDeleteOnExitData(0, fc, new Path[0]);
     checkDeleteOnExitData(0, fc, new Path[0]);
-    Assert.assertFalse(exists(fc, file1));
-    Assert.assertFalse(exists(fc, file2));
-    Assert.assertFalse(exists(fc, dir));
+    assertFalse(exists(fc, file1));
+    assertFalse(exists(fc, file2));
+    assertFalse(exists(fc, dir));
   }
   }
 }
 }

+ 9 - 6
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileContextResolveAfs.java

@@ -24,9 +24,11 @@ import java.util.Set;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 /**
 /**
  * Tests resolution of AbstractFileSystems for a given path with symlinks.
  * Tests resolution of AbstractFileSystems for a given path with symlinks.
@@ -42,12 +44,13 @@ public class TestFileContextResolveAfs {
   private FileContext fc;
   private FileContext fc;
   private FileSystem localFs;
   private FileSystem localFs;
   
   
-  @Before
+  @BeforeEach
   public void setup() throws IOException {
   public void setup() throws IOException {
     fc = FileContext.getFileContext();
     fc = FileContext.getFileContext();
   }
   }
   
   
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testFileContextResolveAfs() throws IOException {
   public void testFileContextResolveAfs() throws IOException {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     localFs = FileSystem.get(conf);
     localFs = FileSystem.get(conf);
@@ -60,7 +63,7 @@ public class TestFileContextResolveAfs {
     
     
     fc.createSymlink(localPath, linkPath, true);
     fc.createSymlink(localPath, linkPath, true);
     Set<AbstractFileSystem> afsList = fc.resolveAbstractFileSystems(linkPath);
     Set<AbstractFileSystem> afsList = fc.resolveAbstractFileSystems(linkPath);
-    Assert.assertEquals(1, afsList.size());
+    assertEquals(1, afsList.size());
     localFs.delete(linkPath, true);
     localFs.delete(linkPath, true);
     localFs.delete(localPath, true);
     localFs.delete(localPath, true);
     localFs.close();
     localFs.close();

+ 5 - 4
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileStatus.java

@@ -17,7 +17,9 @@
  */
  */
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayOutputStream;
@@ -32,7 +34,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Collections;
 import java.util.List;
 import java.util.List;
 
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.FsPermission;
@@ -85,8 +87,7 @@ public class TestFileStatus {
     int iterator = 0;
     int iterator = 0;
     for (FileStatus fs : tests) {
     for (FileStatus fs : tests) {
       dest.readFields(in);
       dest.readFields(in);
-      assertEquals("Different FileStatuses in iteration " + iterator,
-          dest, fs);
+      assertEquals(dest, fs, "Different FileStatuses in iteration " + iterator);
       iterator++;
       iterator++;
     }
     }
   }
   }

+ 6 - 6
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemCanonicalization.java

@@ -18,8 +18,8 @@
 
 
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URI;
@@ -29,8 +29,8 @@ import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.net.NetUtils;
 import org.apache.hadoop.security.NetUtilsTestResolver;
 import org.apache.hadoop.security.NetUtilsTestResolver;
 import org.apache.hadoop.util.Progressable;
 import org.apache.hadoop.util.Progressable;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 
 public class TestFileSystemCanonicalization {
 public class TestFileSystemCanonicalization {
   static String[] authorities = {
   static String[] authorities = {
@@ -44,7 +44,7 @@ public class TestFileSystemCanonicalization {
   };
   };
 
 
 
 
-  @BeforeClass
+  @BeforeAll
   public static void initialize() throws Exception {
   public static void initialize() throws Exception {
     NetUtilsTestResolver.install();
     NetUtilsTestResolver.install();
   }
   }
@@ -288,7 +288,7 @@ public class TestFileSystemCanonicalization {
       }
       }
       assertEquals(pathAuthority, fqPath.toUri().getAuthority());
       assertEquals(pathAuthority, fqPath.toUri().getAuthority());
     } else {
     } else {
-      assertNotNull("did not fail", e);
+      assertNotNull(e, "did not fail");
       assertEquals("Wrong FS: "+rawPath+", expected: "+fs.getUri(),
       assertEquals("Wrong FS: "+rawPath+", expected: "+fs.getUri(),
           e.getMessage());
           e.getMessage());
     }
     }

+ 3 - 2
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemInitialization.java

@@ -27,11 +27,12 @@ import java.net.URI;
 import java.net.URL;
 import java.net.URL;
 import java.util.ServiceConfigurationError;
 import java.util.ServiceConfigurationError;
 
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import static org.apache.hadoop.test.LambdaTestUtils.intercept;
 import static org.apache.hadoop.test.LambdaTestUtils.intercept;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 /**
 /**
  * Tests related to filesystem creation and lifecycle.
  * Tests related to filesystem creation and lifecycle.

+ 8 - 12
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemStorageStatistics.java

@@ -21,24 +21,23 @@ package org.apache.hadoop.fs;
 import org.apache.commons.lang3.RandomUtils;
 import org.apache.commons.lang3.RandomUtils;
 import org.apache.hadoop.fs.StorageStatistics.LongStatistic;
 import org.apache.hadoop.fs.StorageStatistics.LongStatistic;
 
 
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
-import org.junit.rules.Timeout;
+import org.junit.jupiter.api.Timeout;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
 import java.util.Iterator;
 import java.util.Iterator;
-import java.util.concurrent.TimeUnit;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 
 /**
 /**
  * This tests basic operations of {@link FileSystemStorageStatistics} class.
  * This tests basic operations of {@link FileSystemStorageStatistics} class.
  */
  */
+@Timeout(10)
 public class TestFileSystemStorageStatistics {
 public class TestFileSystemStorageStatistics {
   private static final Logger LOG = LoggerFactory.getLogger(
   private static final Logger LOG = LoggerFactory.getLogger(
       TestFileSystemStorageStatistics.class);
       TestFileSystemStorageStatistics.class);
@@ -62,10 +61,7 @@ public class TestFileSystemStorageStatistics {
   private FileSystemStorageStatistics storageStatistics =
   private FileSystemStorageStatistics storageStatistics =
       new FileSystemStorageStatistics(FS_STORAGE_STATISTICS_NAME, statistics);
       new FileSystemStorageStatistics(FS_STORAGE_STATISTICS_NAME, statistics);
 
 
-  @Rule
-  public final Timeout globalTimeout = new Timeout(10, TimeUnit.SECONDS);
-
-  @Before
+  @BeforeEach
   public void setup() {
   public void setup() {
     statistics.incrementBytesRead(RandomUtils.nextInt(0, 100));
     statistics.incrementBytesRead(RandomUtils.nextInt(0, 100));
     statistics.incrementBytesWritten(RandomUtils.nextInt(0, 100));
     statistics.incrementBytesWritten(RandomUtils.nextInt(0, 100));

+ 10 - 3
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFileSystemTokens.java

@@ -18,8 +18,15 @@
 
 
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.atLeast;
+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 java.io.IOException;
 import java.io.IOException;
 
 
@@ -28,7 +35,7 @@ import org.apache.hadoop.io.Text;
 import org.apache.hadoop.security.Credentials;
 import org.apache.hadoop.security.Credentials;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.TokenIdentifier;
 import org.apache.hadoop.security.token.TokenIdentifier;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.mockito.stubbing.Answer;
 
 

+ 18 - 13
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFileSystem.java

@@ -18,8 +18,16 @@
 
 
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.reset;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Method;
@@ -36,8 +44,8 @@ import org.apache.hadoop.security.Credentials;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.DelegationTokenIssuer;
 import org.apache.hadoop.security.token.DelegationTokenIssuer;
 import org.apache.hadoop.util.Progressable;
 import org.apache.hadoop.util.Progressable;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 
 
 public class TestFilterFileSystem {
 public class TestFilterFileSystem {
@@ -45,7 +53,7 @@ public class TestFilterFileSystem {
   private static final Logger LOG = FileSystem.LOG;
   private static final Logger LOG = FileSystem.LOG;
   private static final Configuration conf = new Configuration();
   private static final Configuration conf = new Configuration();
 
 
-  @BeforeClass
+  @BeforeAll
   public static void setup() {
   public static void setup() {
     conf.set("fs.flfs.impl", FilterLocalFileSystem.class.getName());
     conf.set("fs.flfs.impl", FilterLocalFileSystem.class.getName());
     conf.setBoolean("fs.flfs.impl.disable.cache", true);
     conf.setBoolean("fs.flfs.impl.disable.cache", true);
@@ -179,8 +187,8 @@ public class TestFilterFileSystem {
         }
         }
       }
       }
     }
     }
-    assertTrue((errors + " methods were not overridden correctly - see" +
-        " log"), errors <= 0);
+    assertTrue(errors <= 0, (errors + " methods were not overridden correctly - see" +
+        " log"));
   }
   }
   
   
   @Test
   @Test
@@ -299,11 +307,8 @@ public class TestFilterFileSystem {
     try (FilterFileSystem flfs = new FilterLocalFileSystem()) {
     try (FilterFileSystem flfs = new FilterLocalFileSystem()) {
       flfs.initialize(URI.create("filter:/"), conf);
       flfs.initialize(URI.create("filter:/"), conf);
       Path src = new Path("/src");
       Path src = new Path("/src");
-      assertFalse(
-          "hasPathCapability(FS_MULTIPART_UPLOADER) should have failed for "
-              + flfs,
-          flfs.hasPathCapability(src,
-              CommonPathCapabilities.FS_MULTIPART_UPLOADER));
+      assertFalse(flfs.hasPathCapability(src, CommonPathCapabilities.FS_MULTIPART_UPLOADER),
+          "hasPathCapability(FS_MULTIPART_UPLOADER) should have failed for " + flfs);
     }
     }
   }
   }
 
 
@@ -325,7 +330,7 @@ public class TestFilterFileSystem {
     int depth = 0;
     int depth = 0;
     while (true) {
     while (true) {
       depth++; 
       depth++; 
-      assertFalse("depth "+depth+">"+expectDepth, depth > expectDepth);
+      assertFalse(depth > expectDepth, "depth "+depth+">"+expectDepth);
       assertEquals(conf, fs.getConf());
       assertEquals(conf, fs.getConf());
       if (!(fs instanceof FilterFileSystem)) {
       if (!(fs instanceof FilterFileSystem)) {
         break;
         break;

+ 1 - 1
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFilterFs.java

@@ -25,7 +25,7 @@ import java.util.Iterator;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.viewfs.ConfigUtil;
 import org.apache.hadoop.fs.viewfs.ConfigUtil;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 
 
 public class TestFilterFs {
 public class TestFilterFs {

+ 2 - 2
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsOptions.java

@@ -17,12 +17,12 @@
  */
  */
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 import org.apache.hadoop.fs.Options.ChecksumOpt;
 import org.apache.hadoop.fs.Options.ChecksumOpt;
 import org.apache.hadoop.util.DataChecksum;
 import org.apache.hadoop.util.DataChecksum;
 
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestFsOptions {
 public class TestFsOptions {
 
 

+ 15 - 12
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShell.java

@@ -22,9 +22,12 @@ import org.apache.hadoop.fs.shell.Command;
 import org.apache.hadoop.fs.shell.CommandFactory;
 import org.apache.hadoop.fs.shell.CommandFactory;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.util.ToolRunner;
 import org.apache.hadoop.util.ToolRunner;
-import org.assertj.core.api.Assertions;
-import org.junit.Test;
-import org.mockito.Mockito;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 
 public class TestFsShell {
 public class TestFsShell {
 
 
@@ -65,11 +68,11 @@ public class TestFsShell {
     try (GenericTestUtils.SystemErrCapturer capture =
     try (GenericTestUtils.SystemErrCapturer capture =
              new GenericTestUtils.SystemErrCapturer()) {
              new GenericTestUtils.SystemErrCapturer()) {
       ToolRunner.run(shell, new String[]{"dfs -mkdirs"});
       ToolRunner.run(shell, new String[]{"dfs -mkdirs"});
-      Assertions.assertThat(capture.getOutput())
+      assertThat(capture.getOutput())
           .as("FSShell dfs command did not print the error " +
           .as("FSShell dfs command did not print the error " +
               "message when invalid command is passed")
               "message when invalid command is passed")
           .contains("-mkdirs: Unknown command");
           .contains("-mkdirs: Unknown command");
-      Assertions.assertThat(capture.getOutput())
+      assertThat(capture.getOutput())
           .as("FSShell dfs command did not print help " +
           .as("FSShell dfs command did not print help " +
               "message when invalid command is passed")
               "message when invalid command is passed")
           .contains("Usage: hadoop fs [generic options]");
           .contains("Usage: hadoop fs [generic options]");
@@ -79,22 +82,22 @@ public class TestFsShell {
   @Test
   @Test
   public void testExceptionNullMessage() throws Exception {
   public void testExceptionNullMessage() throws Exception {
     final String cmdName = "-cmdExNullMsg";
     final String cmdName = "-cmdExNullMsg";
-    final Command cmd = Mockito.mock(Command.class);
-    Mockito.when(cmd.run(Mockito.any())).thenThrow(
+    final Command cmd = mock(Command.class);
+    when(cmd.run(any())).thenThrow(
         new IllegalArgumentException());
         new IllegalArgumentException());
-    Mockito.when(cmd.getUsage()).thenReturn(cmdName);
+    when(cmd.getUsage()).thenReturn(cmdName);
 
 
-    final CommandFactory cmdFactory = Mockito.mock(CommandFactory.class);
+    final CommandFactory cmdFactory = mock(CommandFactory.class);
     final String[] names = {cmdName};
     final String[] names = {cmdName};
-    Mockito.when(cmdFactory.getNames()).thenReturn(names);
-    Mockito.when(cmdFactory.getInstance(cmdName)).thenReturn(cmd);
+    when(cmdFactory.getNames()).thenReturn(names);
+    when(cmdFactory.getInstance(cmdName)).thenReturn(cmd);
 
 
     FsShell shell = new FsShell(new Configuration());
     FsShell shell = new FsShell(new Configuration());
     shell.commandFactory = cmdFactory;
     shell.commandFactory = cmdFactory;
     try (GenericTestUtils.SystemErrCapturer capture =
     try (GenericTestUtils.SystemErrCapturer capture =
              new GenericTestUtils.SystemErrCapturer()) {
              new GenericTestUtils.SystemErrCapturer()) {
       ToolRunner.run(shell, new String[]{cmdName});
       ToolRunner.run(shell, new String[]{cmdName});
-      Assertions.assertThat(capture.getOutput())
+      assertThat(capture.getOutput())
           .contains(cmdName + ": Null exception message");
           .contains(cmdName + ": Null exception message");
     }
     }
   }
   }

+ 9 - 9
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellCopy.java

@@ -20,10 +20,10 @@ package org.apache.hadoop.fs;
 
 
 import static org.apache.hadoop.test.PlatformAssumptions.assumeWindows;
 import static org.apache.hadoop.test.PlatformAssumptions.assumeWindows;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.File;
@@ -34,9 +34,9 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.util.StringUtils;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -48,7 +48,7 @@ public class TestFsShellCopy {
   static LocalFileSystem lfs;
   static LocalFileSystem lfs;
   static Path testRootDir, srcPath, dstPath;
   static Path testRootDir, srcPath, dstPath;
   
   
-  @BeforeClass
+  @BeforeAll
   public static void setup() throws Exception {
   public static void setup() throws Exception {
     conf = new Configuration();
     conf = new Configuration();
     shell = new FsShell(conf);
     shell = new FsShell(conf);
@@ -62,7 +62,7 @@ public class TestFsShellCopy {
     dstPath = new Path(testRootDir, "dstFile");
     dstPath = new Path(testRootDir, "dstFile");
   }
   }
   
   
-  @Before
+  @BeforeEach
   public void prepFiles() throws Exception {
   public void prepFiles() throws Exception {
     lfs.setVerifyChecksum(true);
     lfs.setVerifyChecksum(true);
     lfs.setWriteChecksum(true);
     lfs.setWriteChecksum(true);

+ 15 - 13
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellList.java

@@ -19,11 +19,12 @@
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 
 /**
 /**
  * Test FsShell -ls command.
  * Test FsShell -ls command.
@@ -34,7 +35,7 @@ public class TestFsShellList {
   private static LocalFileSystem lfs;
   private static LocalFileSystem lfs;
   private static Path testRootDir;
   private static Path testRootDir;
 
 
-  @BeforeClass
+  @BeforeAll
   public static void setup() throws Exception {
   public static void setup() throws Exception {
     conf = new Configuration();
     conf = new Configuration();
     shell = new FsShell(conf);
     shell = new FsShell(conf);
@@ -47,7 +48,7 @@ public class TestFsShellList {
     assertThat(lfs.mkdirs(testRootDir)).isTrue();
     assertThat(lfs.mkdirs(testRootDir)).isTrue();
   }
   }
 
 
-  @AfterClass
+  @AfterAll
   public static void teardown() throws Exception {
   public static void teardown() throws Exception {
     lfs.delete(testRootDir, true);
     lfs.delete(testRootDir, true);
   }
   }
@@ -78,14 +79,15 @@ public class TestFsShellList {
   /*
   /*
   UGI params should take effect when we pass.
   UGI params should take effect when we pass.
  */
  */
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void testListWithUGI() throws Exception {
   public void testListWithUGI() throws Exception {
-    FsShell fsShell = new FsShell(new Configuration());
-    //Passing Dummy such that it should through IAE
-    fsShell.getConf()
-        .set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION,
-            "DUMMYAUTH");
-    String[] lsArgv = new String[] {"-ls", testRootDir.toString()};
-    fsShell.run(lsArgv);
+    assertThrows(IllegalArgumentException.class, () -> {
+      FsShell fsShell = new FsShell(new Configuration());
+      //Passing Dummy such that it should through IAE
+      fsShell.getConf().set(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHENTICATION,
+          "DUMMYAUTH");
+      String[] lsArgv = new String[]{"-ls", testRootDir.toString()};
+      fsShell.run(lsArgv);
+    });
   }
   }
 }
 }

+ 34 - 28
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellReturnCode.java

@@ -19,9 +19,9 @@
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
 import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SHELL_MISSING_DEFAULT_FS_WARNING_KEY;
 import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SHELL_MISSING_DEFAULT_FS_WARNING_KEY;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.IOException;
@@ -42,8 +42,9 @@ import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME
 
 
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.util.Shell;
 import org.apache.hadoop.util.Shell;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -59,7 +60,7 @@ public class TestFsShellReturnCode {
   private static FileSystem fileSys;
   private static FileSystem fileSys;
   private static FsShell fsShell;
   private static FsShell fsShell;
   
   
-  @BeforeClass
+  @BeforeAll
   public static void setup() throws IOException {
   public static void setup() throws IOException {
     conf.setClass("fs.file.impl", LocalFileSystemExtn.class, LocalFileSystem.class);
     conf.setClass("fs.file.impl", LocalFileSystemExtn.class, LocalFileSystem.class);
     fileSys = FileSystem.get(conf);
     fileSys = FileSystem.get(conf);
@@ -105,14 +106,10 @@ public class TestFsShellReturnCode {
       FileStatus[] stats = fileSys.globStatus(new Path(files[i]));
       FileStatus[] stats = fileSys.globStatus(new Path(files[i]));
       if (stats != null) {
       if (stats != null) {
         for (int j=0; j < stats.length; j++) {
         for (int j=0; j < stats.length; j++) {
-          assertEquals("check owner of " + files[i],
-              ((owner != null) ? "STUB-"+owner : oldStats[i][j].getOwner()),
-              stats[j].getOwner()
-          );
-          assertEquals("check group of " + files[i],
-              ((group != null) ? "STUB-"+group : oldStats[i][j].getGroup()),
-              stats[j].getGroup()
-          );        
+          assertEquals(((owner != null) ? "STUB-"+owner : oldStats[i][j].getOwner()),
+              stats[j].getOwner(), "check owner of " + files[i]);
+          assertEquals(((group != null) ? "STUB-"+group : oldStats[i][j].getGroup()),
+              stats[j].getGroup(), "check group of " + files[i]);
         }
         }
       }
       }
     }
     }
@@ -127,7 +124,8 @@ public class TestFsShellReturnCode {
    * 
    * 
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testChmod() throws Exception {
   public void testChmod() throws Exception {
     Path p1 = new Path(TEST_ROOT_DIR, "testChmod/fileExists");
     Path p1 = new Path(TEST_ROOT_DIR, "testChmod/fileExists");
 
 
@@ -183,7 +181,8 @@ public class TestFsShellReturnCode {
    * 
    * 
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testChown() throws Exception {
   public void testChown() throws Exception {
     Path p1 = new Path(TEST_ROOT_DIR, "testChown/fileExists");
     Path p1 = new Path(TEST_ROOT_DIR, "testChown/fileExists");
 
 
@@ -239,7 +238,8 @@ public class TestFsShellReturnCode {
    * 
    * 
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testChgrp() throws Exception {
   public void testChgrp() throws Exception {
     Path p1 = new Path(TEST_ROOT_DIR, "testChgrp/fileExists");
     Path p1 = new Path(TEST_ROOT_DIR, "testChgrp/fileExists");
 
 
@@ -284,7 +284,8 @@ public class TestFsShellReturnCode {
     change(1, null, "admin", f2, f7);
     change(1, null, "admin", f2, f7);
   }
   }
   
   
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testGetWithInvalidSourcePathShouldNotDisplayNullInConsole()
   public void testGetWithInvalidSourcePathShouldNotDisplayNullInConsole()
       throws Exception {
       throws Exception {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
@@ -303,20 +304,22 @@ public class TestFsShellReturnCode {
       args[0] = "-get";
       args[0] = "-get";
       args[1] = new Path(tdir.toUri().getPath(), "/invalidSrc").toString();
       args[1] = new Path(tdir.toUri().getPath(), "/invalidSrc").toString();
       args[2] = new Path(tdir.toUri().getPath(), "/invalidDst").toString();
       args[2] = new Path(tdir.toUri().getPath(), "/invalidDst").toString();
-      assertTrue("file exists", !fileSys.exists(new Path(args[1])));
-      assertTrue("file exists", !fileSys.exists(new Path(args[2])));
+      assertTrue(!fileSys.exists(new Path(args[1])), "file exists");
+      assertTrue(!fileSys.exists(new Path(args[2])), "file exists");
       int run = shell.run(args);
       int run = shell.run(args);
       results = bytes.toString();
       results = bytes.toString();
-      assertEquals("Return code should be 1", 1, run);
-      assertTrue(" Null is coming when source path is invalid. ",!results.contains("get: null"));
-      assertTrue(" Not displaying the intended message ",results.contains("get: `"+args[1]+"': No such file or directory"));
+      assertEquals(1, run, "Return code should be 1");
+      assertTrue(!results.contains("get: null"), " Null is coming when source path is invalid. ");
+      assertTrue(results.contains("get: `" + args[1] + "': No such file or directory"),
+          " Not displaying the intended message ");
     } finally {
     } finally {
       IOUtils.closeStream(out);
       IOUtils.closeStream(out);
       System.setErr(oldErr);
       System.setErr(oldErr);
     }
     }
   }
   }
   
   
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testRmWithNonexistentGlob() throws Exception {
   public void testRmWithNonexistentGlob() throws Exception {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     FsShell shell = new FsShell();
     FsShell shell = new FsShell();
@@ -337,7 +340,8 @@ public class TestFsShellReturnCode {
     }
     }
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testRmForceWithNonexistentGlob() throws Exception {
   public void testRmForceWithNonexistentGlob() throws Exception {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     FsShell shell = new FsShell();
     FsShell shell = new FsShell();
@@ -356,7 +360,8 @@ public class TestFsShellReturnCode {
     }
     }
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testInvalidDefaultFS() throws Exception {
   public void testInvalidDefaultFS() throws Exception {
     // if default fs doesn't exist or is invalid, but the path provided in 
     // if default fs doesn't exist or is invalid, but the path provided in 
     // arguments is valid - fsshell should work
     // arguments is valid - fsshell should work
@@ -379,7 +384,7 @@ public class TestFsShellReturnCode {
       int run = shell.run(args);
       int run = shell.run(args);
       results = bytes.toString();
       results = bytes.toString();
       LOG.info("result=" + results);
       LOG.info("result=" + results);
-      assertTrue("Return code should be 0", run == 0);
+      assertTrue(run == 0, "Return code should be 0");
     } finally {
     } finally {
       IOUtils.closeStream(out);
       IOUtils.closeStream(out);
       System.setErr(oldErr);
       System.setErr(oldErr);
@@ -387,7 +392,8 @@ public class TestFsShellReturnCode {
     
     
   }
   }
   
   
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testInterrupt() throws Exception {
   public void testInterrupt() throws Exception {
     MyFsShell shell = new MyFsShell();
     MyFsShell shell = new MyFsShell();
     shell.setConf(new Configuration());
     shell.setConf(new Configuration());

+ 5 - 5
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsShellTouch.java

@@ -24,9 +24,9 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.shell.TouchCommands.Touch;
 import org.apache.hadoop.fs.shell.TouchCommands.Touch;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.util.StringUtils;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -39,7 +39,7 @@ public class TestFsShellTouch {
   static LocalFileSystem lfs;
   static LocalFileSystem lfs;
   static Path testRootDir;
   static Path testRootDir;
 
 
-  @BeforeClass
+  @BeforeAll
   public static void setup() throws Exception {
   public static void setup() throws Exception {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     shell = new FsShell(conf);
     shell = new FsShell(conf);
@@ -51,7 +51,7 @@ public class TestFsShellTouch {
     lfs.setWorkingDirectory(testRootDir);
     lfs.setWorkingDirectory(testRootDir);
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void prepFiles() throws Exception {
   public void prepFiles() throws Exception {
     lfs.setVerifyChecksum(true);
     lfs.setVerifyChecksum(true);
     lfs.setWriteChecksum(true);
     lfs.setWriteChecksum(true);

+ 11 - 10
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestFsUrlConnectionPath.java

@@ -14,15 +14,16 @@
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.*;
 import java.io.*;
 import java.net.URL;
 import java.net.URL;
 import java.nio.file.Paths;
 import java.nio.file.Paths;
 
 
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 /**
 /**
  * Test case for FsUrlConnection with relativePath and SPACE.
  * Test case for FsUrlConnection with relativePath and SPACE.
  */
  */
@@ -43,7 +44,7 @@ public class TestFsUrlConnectionPath {
   private static final Configuration CONFIGURATION = new Configuration();
   private static final Configuration CONFIGURATION = new Configuration();
 
 
 
 
-  @BeforeClass
+  @BeforeAll
   public static void initialize() throws IOException{
   public static void initialize() throws IOException{
     write(ABSOLUTE_PATH.substring(5), DATA);
     write(ABSOLUTE_PATH.substring(5), DATA);
     write(RELATIVE_PATH.substring(5), DATA);
     write(RELATIVE_PATH.substring(5), DATA);
@@ -52,7 +53,7 @@ public class TestFsUrlConnectionPath {
     URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
     URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
   }
   }
 
 
-  @AfterClass
+  @AfterAll
   public static void cleanup(){
   public static void cleanup(){
     delete(ABSOLUTE_PATH.substring(5));
     delete(ABSOLUTE_PATH.substring(5));
     delete(RELATIVE_PATH.substring(5));
     delete(RELATIVE_PATH.substring(5));
@@ -83,25 +84,25 @@ public class TestFsUrlConnectionPath {
   @Test
   @Test
   public void testAbsolutePath() throws Exception{
   public void testAbsolutePath() throws Exception{
     int length = readStream(ABSOLUTE_PATH);
     int length = readStream(ABSOLUTE_PATH);
-    Assert.assertTrue(length > 1);
+    assertTrue(length > 1);
   }
   }
 
 
   @Test
   @Test
   public void testRelativePath() throws Exception{
   public void testRelativePath() throws Exception{
     int length = readStream(RELATIVE_PATH);
     int length = readStream(RELATIVE_PATH);
-    Assert.assertTrue(length > 1);
+    assertTrue(length > 1);
   }
   }
 
 
   @Test
   @Test
   public void testAbsolutePathWithSpace() throws Exception{
   public void testAbsolutePathWithSpace() throws Exception{
     int length = readStream(ABSOLUTE_PATH_W_ENCODED_SPACE);
     int length = readStream(ABSOLUTE_PATH_W_ENCODED_SPACE);
-    Assert.assertTrue(length > 1);
+    assertTrue(length > 1);
   }
   }
 
 
   @Test
   @Test
   public void testRelativePathWithSpace() throws Exception{
   public void testRelativePathWithSpace() throws Exception{
     int length = readStream(RELATIVE_PATH_W_ENCODED_SPACE);
     int length = readStream(RELATIVE_PATH_W_ENCODED_SPACE);
-    Assert.assertTrue(length > 1);
+    assertTrue(length > 1);
   }
   }
 
 
 }
 }

+ 7 - 6
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetFileBlockLocations.java

@@ -22,10 +22,11 @@ import java.util.Arrays;
 import java.util.Comparator;
 import java.util.Comparator;
 import java.util.Random;
 import java.util.Random;
 
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
@@ -42,7 +43,7 @@ public class TestGetFileBlockLocations {
   private FileSystem fs;
   private FileSystem fs;
   private Random random;
   private Random random;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws IOException {
   public void setUp() throws IOException {
     conf = new Configuration();
     conf = new Configuration();
     Path rootPath = new Path(TEST_ROOT_DIR);
     Path rootPath = new Path(TEST_ROOT_DIR);
@@ -92,7 +93,7 @@ public class TestGetFileBlockLocations {
     }
     }
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws IOException {
   public void tearDown() throws IOException {
     fs.delete(path, true);
     fs.delete(path, true);
     fs.close();
     fs.close();

+ 9 - 6
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGetSpaceUsed.java

@@ -19,26 +19,29 @@ package org.apache.hadoop.fs;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
-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 java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
 
 
-import static org.junit.Assert.*;
+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;
 
 
 public class TestGetSpaceUsed {
 public class TestGetSpaceUsed {
   final static private File DIR =
   final static private File DIR =
       GenericTestUtils.getTestDir("TestGetSpaceUsed");
       GenericTestUtils.getTestDir("TestGetSpaceUsed");
 
 
-  @Before
+  @BeforeEach
   public void setUp() {
   public void setUp() {
     FileUtil.fullyDelete(DIR);
     FileUtil.fullyDelete(DIR);
     assertTrue(DIR.mkdirs());
     assertTrue(DIR.mkdirs());
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws IOException {
   public void tearDown() throws IOException {
     FileUtil.fullyDelete(DIR);
     FileUtil.fullyDelete(DIR);
   }
   }

+ 6 - 6
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGlobExpander.java

@@ -20,8 +20,8 @@ package org.apache.hadoop.fs;
 import java.io.IOException;
 import java.io.IOException;
 import java.util.List;
 import java.util.List;
 
 
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 public class TestGlobExpander {
 public class TestGlobExpander {
 
 
@@ -55,11 +55,11 @@ public class TestGlobExpander {
   private void checkExpansion(String filePattern, String... expectedExpansions)
   private void checkExpansion(String filePattern, String... expectedExpansions)
       throws IOException {
       throws IOException {
     List<String> actualExpansions = GlobExpander.expand(filePattern);
     List<String> actualExpansions = GlobExpander.expand(filePattern);
-    assertEquals("Different number of expansions", expectedExpansions.length,
-        actualExpansions.size());
+    assertEquals(expectedExpansions.length,
+        actualExpansions.size(), "Different number of expansions");
     for (int i = 0; i < expectedExpansions.length; i++) {
     for (int i = 0; i < expectedExpansions.length; i++) {
-      assertEquals("Expansion of " + filePattern, expectedExpansions[i],
-          actualExpansions.get(i));
+      assertEquals(expectedExpansions[i],
+          actualExpansions.get(i), "Expansion of " + filePattern);
     }
     }
   }
   }
 }
 }

+ 7 - 6
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestGlobPattern.java

@@ -18,8 +18,9 @@
 
 
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 import com.google.re2j.PatternSyntaxException;
 import com.google.re2j.PatternSyntaxException;
 /**
 /**
@@ -31,8 +32,7 @@ public class TestGlobPattern {
 
 
     for (String s : input) {
     for (String s : input) {
       boolean result = pattern.matches(s);
       boolean result = pattern.matches(s);
-      assertTrue(glob +" should"+ (yes ? "" : " not") +" match "+ s,
-                 yes ? result : !result);
+      assertTrue(yes ? result : !result, glob +" should"+ (yes ? "" : " not") +" match "+ s);
     }
     }
   }
   }
 
 
@@ -45,7 +45,7 @@ public class TestGlobPattern {
         e.printStackTrace();
         e.printStackTrace();
         continue;
         continue;
       }
       }
-      assertTrue("glob "+ glob +" should throw", false);
+      assertTrue(false, "glob "+ glob +" should throw");
     }
     }
   }
   }
 
 
@@ -72,7 +72,8 @@ public class TestGlobPattern {
     shouldThrow("[", "[[]]", "{", "\\");
     shouldThrow("[", "[[]]", "{", "\\");
   }
   }
 
 
-  @Test(timeout=10000) public void testPathologicalPatterns() {
+  @Test @Timeout(value = 10)
+  public void testPathologicalPatterns() {
     String badFilename = "job_1429571161900_4222-1430338332599-tda%2D%2D+******************************+++...%270%27%28Stage-1430338580443-39-2000-SUCCEEDED-production%2Dhigh-1430338340360.jhist";
     String badFilename = "job_1429571161900_4222-1430338332599-tda%2D%2D+******************************+++...%270%27%28Stage-1430338580443-39-2000-SUCCEEDED-production%2Dhigh-1430338340360.jhist";
     assertMatch(true, badFilename, badFilename);
     assertMatch(true, badFilename, badFilename);
   }
   }

+ 3 - 3
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystem.java

@@ -28,8 +28,7 @@ import org.apache.hadoop.security.Credentials;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.DelegationTokenIssuer;
 import org.apache.hadoop.security.token.DelegationTokenIssuer;
 import org.apache.hadoop.util.Progressable;
 import org.apache.hadoop.util.Progressable;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -47,6 +46,7 @@ import static org.apache.hadoop.fs.Options.ChecksumOpt;
 import static org.apache.hadoop.fs.Options.CreateOpts;
 import static org.apache.hadoop.fs.Options.CreateOpts;
 import static org.apache.hadoop.fs.Options.Rename;
 import static org.apache.hadoop.fs.Options.Rename;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 @SuppressWarnings("deprecation")
 @SuppressWarnings("deprecation")
 public class TestHarFileSystem {
 public class TestHarFileSystem {
@@ -277,7 +277,7 @@ public class TestHarFileSystem {
     final Path p = new Path(s);
     final Path p = new Path(s);
     try {
     try {
       p.getFileSystem(conf);
       p.getFileSystem(conf);
-      Assert.fail(p + " is an invalid path.");
+      fail(p + " is an invalid path.");
     } catch (IOException e) {
     } catch (IOException e) {
       // Expected
       // Expected
     }
     }

+ 29 - 29
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHarFileSystemBasics.java

@@ -22,10 +22,9 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.util.Shell;
 import org.apache.hadoop.util.Shell;
-import org.junit.After;
-import org.junit.Assert;
-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 java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
@@ -34,9 +33,11 @@ import java.nio.charset.StandardCharsets;
 import java.util.HashSet;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.Set;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 
 
 /**
 /**
@@ -125,7 +126,7 @@ public class TestHarFileSystemBasics {
     }
     }
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void before() throws Exception {
   public void before() throws Exception {
     final File rootDirIoFile = new File(rootPath.toUri().getPath());
     final File rootDirIoFile = new File(rootPath.toUri().getPath());
     rootDirIoFile.mkdirs();
     rootDirIoFile.mkdirs();
@@ -138,7 +139,7 @@ public class TestHarFileSystemBasics {
     harFileSystem = createHarFileSystem(conf);
     harFileSystem = createHarFileSystem(conf);
   }
   }
 
 
-  @After
+  @AfterEach
   public void after() throws Exception {
   public void after() throws Exception {
     // close Har FS:
     // close Har FS:
     final FileSystem harFS = harFileSystem;
     final FileSystem harFS = harFileSystem;
@@ -256,11 +257,11 @@ public class TestHarFileSystemBasics {
     RemoteIterator<LocatedFileStatus> fileList = hfs.listLocatedStatus(path);
     RemoteIterator<LocatedFileStatus> fileList = hfs.listLocatedStatus(path);
     while (fileList.hasNext()) {
     while (fileList.hasNext()) {
       String fileName = fileList.next().getPath().getName();
       String fileName = fileList.next().getPath().getName();
-      assertTrue(fileName + " not in expected files list", expectedFileNames.contains(fileName));
+      assertTrue(expectedFileNames.contains(fileName), fileName + " not in expected files list");
       expectedFileNames.remove(fileName);
       expectedFileNames.remove(fileName);
     }
     }
-    assertEquals("Didn't find all of the expected file names: " + expectedFileNames,
-                 0, expectedFileNames.size());
+    assertEquals(0, expectedFileNames.size(),
+        "Didn't find all of the expected file names: " + expectedFileNames);
   }
   }
 
 
   @Test
   @Test
@@ -273,10 +274,9 @@ public class TestHarFileSystemBasics {
         + harPath.toUri().getPath().toString();
         + harPath.toUri().getPath().toString();
     Path path = new Path(harPathWithUserinfo);
     Path path = new Path(harPathWithUserinfo);
     Path qualifiedPath = path.getFileSystem(conf).makeQualified(path);
     Path qualifiedPath = path.getFileSystem(conf).makeQualified(path);
-    assertTrue(String.format(
-        "The qualified path (%s) did not match the expected path (%s).",
-        qualifiedPath.toString(), harPathWithUserinfo),
-        qualifiedPath.toString().equals(harPathWithUserinfo));
+    assertTrue(qualifiedPath.toString().equals(harPathWithUserinfo),
+        String.format("The qualified path (%s) did not match the expected path (%s).",
+        qualifiedPath.toString(), harPathWithUserinfo));
   }
   }
 
 
   // ========== Negative:
   // ========== Negative:
@@ -291,7 +291,7 @@ public class TestHarFileSystemBasics {
     final URI uri = new URI("har://" + harPath.toString());
     final URI uri = new URI("har://" + harPath.toString());
     try {
     try {
       hfs.initialize(uri, new Configuration());
       hfs.initialize(uri, new Configuration());
-      Assert.fail("Exception expected.");
+      fail("Exception expected.");
     } catch (IOException ioe) {
     } catch (IOException ioe) {
       // ok, expected.
       // ok, expected.
     }
     }
@@ -302,7 +302,7 @@ public class TestHarFileSystemBasics {
     final HarFileSystem hfs = new HarFileSystem(localFileSystem);
     final HarFileSystem hfs = new HarFileSystem(localFileSystem);
     try {
     try {
       int version = hfs.getHarVersion();
       int version = hfs.getHarVersion();
-      Assert.fail("Exception expected, but got a Har version " + version + ".");
+      fail("Exception expected, but got a Har version " + version + ".");
     } catch (IOException ioe) {
     } catch (IOException ioe) {
       // ok, expected.
       // ok, expected.
     }
     }
@@ -326,7 +326,7 @@ public class TestHarFileSystemBasics {
     final URI uri = new URI("har://" + harPath.toString());
     final URI uri = new URI("har://" + harPath.toString());
     try {
     try {
       hfs.initialize(uri, new Configuration());
       hfs.initialize(uri, new Configuration());
-      Assert.fail("IOException expected.");
+      fail("IOException expected.");
     } catch (IOException ioe) {
     } catch (IOException ioe) {
       // ok, expected.
       // ok, expected.
     }
     }
@@ -340,28 +340,28 @@ public class TestHarFileSystemBasics {
     try {
     try {
       harFileSystem.create(fooPath, new FsPermission("+rwx"), true, 1024,
       harFileSystem.create(fooPath, new FsPermission("+rwx"), true, 1024,
           (short) 88, 1024, null);
           (short) 88, 1024, null);
-      Assert.fail("IOException expected.");
+      fail("IOException expected.");
     } catch (IOException ioe) {
     } catch (IOException ioe) {
       // ok, expected.
       // ok, expected.
     }
     }
 
 
     try {
     try {
       harFileSystem.setReplication(fooPath, (short) 55);
       harFileSystem.setReplication(fooPath, (short) 55);
-      Assert.fail("IOException expected.");
+      fail("IOException expected.");
     } catch (IOException ioe) {
     } catch (IOException ioe) {
       // ok, expected.
       // ok, expected.
     }
     }
 
 
     try {
     try {
       harFileSystem.delete(fooPath, true);
       harFileSystem.delete(fooPath, true);
-      Assert.fail("IOException expected.");
+      fail("IOException expected.");
     } catch (IOException ioe) {
     } catch (IOException ioe) {
       // ok, expected.
       // ok, expected.
     }
     }
 
 
     try {
     try {
       harFileSystem.mkdirs(fooPath, new FsPermission("+rwx"));
       harFileSystem.mkdirs(fooPath, new FsPermission("+rwx"));
-      Assert.fail("IOException expected.");
+      fail("IOException expected.");
     } catch (IOException ioe) {
     } catch (IOException ioe) {
       // ok, expected.
       // ok, expected.
     }
     }
@@ -369,35 +369,35 @@ public class TestHarFileSystemBasics {
     final Path indexPath = new Path(harPath, "_index");
     final Path indexPath = new Path(harPath, "_index");
     try {
     try {
       harFileSystem.copyFromLocalFile(false, indexPath, fooPath);
       harFileSystem.copyFromLocalFile(false, indexPath, fooPath);
-      Assert.fail("IOException expected.");
+      fail("IOException expected.");
     } catch (IOException ioe) {
     } catch (IOException ioe) {
       // ok, expected.
       // ok, expected.
     }
     }
 
 
     try {
     try {
       harFileSystem.startLocalOutput(fooPath, indexPath);
       harFileSystem.startLocalOutput(fooPath, indexPath);
-      Assert.fail("IOException expected.");
+      fail("IOException expected.");
     } catch (IOException ioe) {
     } catch (IOException ioe) {
       // ok, expected.
       // ok, expected.
     }
     }
 
 
     try {
     try {
       harFileSystem.completeLocalOutput(fooPath, indexPath);
       harFileSystem.completeLocalOutput(fooPath, indexPath);
-      Assert.fail("IOException expected.");
+      fail("IOException expected.");
     } catch (IOException ioe) {
     } catch (IOException ioe) {
       // ok, expected.
       // ok, expected.
     }
     }
 
 
     try {
     try {
       harFileSystem.setOwner(fooPath, "user", "group");
       harFileSystem.setOwner(fooPath, "user", "group");
-      Assert.fail("IOException expected.");
+      fail("IOException expected.");
     } catch (IOException ioe) {
     } catch (IOException ioe) {
       // ok, expected.
       // ok, expected.
     }
     }
 
 
     try {
     try {
       harFileSystem.setPermission(fooPath, new FsPermission("+x"));
       harFileSystem.setPermission(fooPath, new FsPermission("+x"));
-      Assert.fail("IOException expected.");
+      fail("IOException expected.");
     } catch (IOException ioe) {
     } catch (IOException ioe) {
       // ok, expected.
       // ok, expected.
     }
     }
@@ -406,7 +406,7 @@ public class TestHarFileSystemBasics {
   @Test
   @Test
   public void testHarFsWithoutAuthority() throws Exception {
   public void testHarFsWithoutAuthority() throws Exception {
     final URI uri = harFileSystem.getUri();
     final URI uri = harFileSystem.getUri();
-    Assert.assertNull("har uri authority not null: " + uri, uri.getAuthority());
+    assertNull(uri.getAuthority(), "har uri authority not null: " + uri);
     FileContext.getFileContext(uri, conf);
     FileContext.getFileContext(uri, conf);
   }
   }
 
 

+ 10 - 8
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestHardLink.java

@@ -25,11 +25,13 @@ import java.io.IOException;
 import java.util.Arrays;
 import java.util.Arrays;
 
 
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
-import org.junit.After;
-import static org.junit.Assert.*;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 
 import static org.apache.hadoop.fs.HardLink.*;
 import static org.apache.hadoop.fs.HardLink.*;
 
 
@@ -85,7 +87,7 @@ public class TestHardLink {
    * Assure clean environment for start of testing
    * Assure clean environment for start of testing
    * @throws IOException
    * @throws IOException
    */
    */
-  @BeforeClass
+  @BeforeAll
   public static void setupClean() {
   public static void setupClean() {
     //delete source and target directories if they exist
     //delete source and target directories if they exist
     FileUtil.fullyDelete(src);
     FileUtil.fullyDelete(src);
@@ -100,7 +102,7 @@ public class TestHardLink {
   /**
   /**
    * Initialize clean environment for start of each test
    * Initialize clean environment for start of each test
    */
    */
-  @Before
+  @BeforeEach
   public void setupDirs() throws IOException {
   public void setupDirs() throws IOException {
     //check that we start out with empty top-level test data directory
     //check that we start out with empty top-level test data directory
     assertFalse(src.exists());
     assertFalse(src.exists());
@@ -176,7 +178,7 @@ public class TestHardLink {
     assertTrue(fetchFileContents(x3_mult).equals(str3));
     assertTrue(fetchFileContents(x3_mult).equals(str3));
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws IOException {
   public void tearDown() throws IOException {
     setupClean();
     setupClean();
   }
   }

+ 12 - 10
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestListFiles.java

@@ -25,9 +25,11 @@ import java.util.Set;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 
 
-import static org.junit.Assert.*;
-import org.junit.Test;
-import org.junit.BeforeClass;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.BeforeAll;
 import org.slf4j.event.Level;
 import org.slf4j.event.Level;
 
 
 /**
 /**
@@ -74,7 +76,7 @@ public class TestListFiles {
     FILE3 = new Path(DIR1, "file3");
     FILE3 = new Path(DIR1, "file3");
   }
   }
 
 
-  @BeforeClass
+  @BeforeAll
   public static void testSetUp() throws Exception {
   public static void testSetUp() throws Exception {
     fs = FileSystem.getLocal(conf);
     fs = FileSystem.getLocal(conf);
     fs.delete(TEST_DIR, true);
     fs.delete(TEST_DIR, true);
@@ -160,18 +162,18 @@ public class TestListFiles {
     itor = fs.listFiles(TEST_DIR, true);
     itor = fs.listFiles(TEST_DIR, true);
     stat = itor.next();
     stat = itor.next();
     assertTrue(stat.isFile());
     assertTrue(stat.isFile());
-    assertTrue("Path " + stat.getPath() + " unexpected",
-      filesToFind.remove(stat.getPath()));
+    assertTrue(filesToFind.remove(stat.getPath()),
+        "Path " + stat.getPath() + " unexpected");
 
 
     stat = itor.next();
     stat = itor.next();
     assertTrue(stat.isFile());
     assertTrue(stat.isFile());
-    assertTrue("Path " + stat.getPath() + " unexpected",
-      filesToFind.remove(stat.getPath()));
+    assertTrue(filesToFind.remove(stat.getPath()),
+        "Path " + stat.getPath() + " unexpected");
 
 
     stat = itor.next();
     stat = itor.next();
     assertTrue(stat.isFile());
     assertTrue(stat.isFile());
-    assertTrue("Path " + stat.getPath() + " unexpected",
-      filesToFind.remove(stat.getPath()));
+    assertTrue(filesToFind.remove(stat.getPath()),
+        "Path " + stat.getPath() + " unexpected");
     assertFalse(itor.hasNext());
     assertFalse(itor.hasNext());
     assertTrue(filesToFind.isEmpty());
     assertTrue(filesToFind.isEmpty());
     
     

+ 126 - 79
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalDirAllocator.java

@@ -30,13 +30,16 @@ import org.apache.hadoop.test.LambdaTestUtils;
 import org.apache.hadoop.util.DiskChecker.DiskErrorException;
 import org.apache.hadoop.util.DiskChecker.DiskErrorException;
 import org.apache.hadoop.util.Shell;
 import org.apache.hadoop.util.Shell;
 
 
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-import org.junit.Test;
+import org.junit.jupiter.api.Timeout;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 
 
 import static org.apache.hadoop.test.PlatformAssumptions.assumeNotWindows;
 import static org.apache.hadoop.test.PlatformAssumptions.assumeNotWindows;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 /** This test LocalDirAllocator works correctly;
 /** This test LocalDirAllocator works correctly;
  * Every test case uses different buffer dirs to
  * Every test case uses different buffer dirs to
@@ -45,7 +48,6 @@ import static org.junit.Assert.*;
  * a directory can be created in a read-only directory
  * a directory can be created in a read-only directory
  * which breaks this test.
  * which breaks this test.
  */
  */
-@RunWith(Parameterized.class)
 public class TestLocalDirAllocator {
 public class TestLocalDirAllocator {
   final static private Configuration conf = new Configuration();
   final static private Configuration conf = new Configuration();
   final static private String BUFFER_DIR_ROOT = "build/test/temp";
   final static private String BUFFER_DIR_ROOT = "build/test/temp";
@@ -62,8 +64,8 @@ public class TestLocalDirAllocator {
   final static private String RELATIVE = "/RELATIVE";
   final static private String RELATIVE = "/RELATIVE";
   final static private String ABSOLUTE = "/ABSOLUTE";
   final static private String ABSOLUTE = "/ABSOLUTE";
   final static private String QUALIFIED = "/QUALIFIED";
   final static private String QUALIFIED = "/QUALIFIED";
-  final private String ROOT;
-  final private String PREFIX;
+  private String root;
+  private String prefix;
 
 
   static {
   static {
     try {
     try {
@@ -84,12 +86,11 @@ public class TestLocalDirAllocator {
         BUFFER_DIR_ROOT).toUri().toString();
         BUFFER_DIR_ROOT).toUri().toString();
   }
   }
 
 
-  public TestLocalDirAllocator(String root, String prefix) {
-    ROOT = root;
-    PREFIX = prefix;
+  public void initTestLocalDirAllocator(String paramRoot, String paramPrefix) {
+    this.root = paramRoot;
+    this.prefix = paramPrefix;
   }
   }
 
 
-  @Parameters
   public static Collection<Object[]> params() {
   public static Collection<Object[]> params() {
     Object [][] data = new Object[][] {
     Object [][] data = new Object[][] {
       { BUFFER_DIR_ROOT, RELATIVE },
       { BUFFER_DIR_ROOT, RELATIVE },
@@ -107,8 +108,8 @@ public class TestLocalDirAllocator {
 
 
   private static void validateTempDirCreation(String dir) throws IOException {
   private static void validateTempDirCreation(String dir) throws IOException {
     File result = createTempFile(SMALL_FILE_SIZE);
     File result = createTempFile(SMALL_FILE_SIZE);
-    assertTrue("Checking for " + dir + " in " + result + " - FAILED!",
-        result.getPath().startsWith(new Path(dir, FILENAME).toUri().getPath()));
+    assertTrue(result.getPath().startsWith(new Path(dir, FILENAME).toUri().getPath()),
+        "Checking for " + dir + " in " + result + " - FAILED!");
   }
   }
 
 
   private static File createTempFile() throws IOException {
   private static File createTempFile() throws IOException {
@@ -122,18 +123,17 @@ public class TestLocalDirAllocator {
   }
   }
 
 
   private String buildBufferDir(String dir, int i) {
   private String buildBufferDir(String dir, int i) {
-    return dir + PREFIX + i;
+    return dir + prefix + i;
   }
   }
 
 
-  /** Two buffer dirs. The first dir does not exist & is on a read-only disk;
-   * The second dir exists & is RW
-   * @throws Exception
-   */
-  @Test (timeout = 30000)
-  public void test0() throws Exception {
+  @Timeout(value = 30)
+  @MethodSource("params")
+  @ParameterizedTest
+  public void test0(String paramRoot, String paramPrefix) throws Exception {
     assumeNotWindows();
     assumeNotWindows();
-    String dir0 = buildBufferDir(ROOT, 0);
-    String dir1 = buildBufferDir(ROOT, 1);
+    initTestLocalDirAllocator(paramRoot, paramPrefix);
+    String dir0 = buildBufferDir(root, 0);
+    String dir1 = buildBufferDir(root, 1);
     try {
     try {
       conf.set(CONTEXT, dir0 + "," + dir1);
       conf.set(CONTEXT, dir0 + "," + dir1);
       assertTrue(localFs.mkdirs(new Path(dir1)));
       assertTrue(localFs.mkdirs(new Path(dir1)));
@@ -151,11 +151,15 @@ public class TestLocalDirAllocator {
    * The second dir exists & is RW
    * The second dir exists & is RW
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test (timeout = 30000)
-  public void testROBufferDirAndRWBufferDir() throws Exception {
+  @Timeout(value = 30)
+  @MethodSource("params")
+  @ParameterizedTest
+  public void testROBufferDirAndRWBufferDir(String paramRoot, String paramPrefix)
+      throws Exception {
     assumeNotWindows();
     assumeNotWindows();
-    String dir1 = buildBufferDir(ROOT, 1);
-    String dir2 = buildBufferDir(ROOT, 2);
+    initTestLocalDirAllocator(paramRoot, paramPrefix);
+    String dir1 = buildBufferDir(root, 1);
+    String dir2 = buildBufferDir(root, 2);
     try {
     try {
       conf.set(CONTEXT, dir1 + "," + dir2);
       conf.set(CONTEXT, dir1 + "," + dir2);
       assertTrue(localFs.mkdirs(new Path(dir2)));
       assertTrue(localFs.mkdirs(new Path(dir2)));
@@ -168,14 +172,18 @@ public class TestLocalDirAllocator {
       rmBufferDirs();
       rmBufferDirs();
     }
     }
   }
   }
+
   /** Two buffer dirs. Both do not exist but on a RW disk.
   /** Two buffer dirs. Both do not exist but on a RW disk.
    * Check if tmp dirs are allocated in a round-robin
    * Check if tmp dirs are allocated in a round-robin
    */
    */
-  @Test (timeout = 30000)
-  public void testDirsNotExist() throws Exception {
+  @Timeout(value = 30)
+  @MethodSource("params")
+  @ParameterizedTest
+  public void testDirsNotExist(String paramRoot, String paramPrefix) throws Exception {
     assumeNotWindows();
     assumeNotWindows();
-    String dir2 = buildBufferDir(ROOT, 2);
-    String dir3 = buildBufferDir(ROOT, 3);
+    initTestLocalDirAllocator(paramRoot, paramPrefix);
+    String dir2 = buildBufferDir(root, 2);
+    String dir3 = buildBufferDir(root, 3);
     try {
     try {
       conf.set(CONTEXT, dir2 + "," + dir3);
       conf.set(CONTEXT, dir2 + "," + dir3);
 
 
@@ -185,9 +193,9 @@ public class TestLocalDirAllocator {
       int secondDirIdx = (firstDirIdx == 2) ? 3 : 2;
       int secondDirIdx = (firstDirIdx == 2) ? 3 : 2;
 
 
       // check if tmp dirs are allocated in a round-robin manner
       // check if tmp dirs are allocated in a round-robin manner
-      validateTempDirCreation(buildBufferDir(ROOT, firstDirIdx));
-      validateTempDirCreation(buildBufferDir(ROOT, secondDirIdx));
-      validateTempDirCreation(buildBufferDir(ROOT, firstDirIdx));
+      validateTempDirCreation(buildBufferDir(root, firstDirIdx));
+      validateTempDirCreation(buildBufferDir(root, secondDirIdx));
+      validateTempDirCreation(buildBufferDir(root, firstDirIdx));
     } finally {
     } finally {
       rmBufferDirs();
       rmBufferDirs();
     }
     }
@@ -197,11 +205,14 @@ public class TestLocalDirAllocator {
    * Later disk1 becomes read-only.
    * Later disk1 becomes read-only.
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test (timeout = 30000)
-  public void testRWBufferDirBecomesRO() throws Exception {
+  @Timeout(value = 30)
+  @MethodSource("params")
+  @ParameterizedTest
+  public void testRWBufferDirBecomesRO(String paramRoot, String paramPrefix) throws Exception {
     assumeNotWindows();
     assumeNotWindows();
-    String dir3 = buildBufferDir(ROOT, 3);
-    String dir4 = buildBufferDir(ROOT, 4);
+    initTestLocalDirAllocator(paramRoot, paramPrefix);
+    String dir3 = buildBufferDir(root, 3);
+    String dir4 = buildBufferDir(root, 4);
     try {
     try {
       conf.set(CONTEXT, dir3 + "," + dir4);
       conf.set(CONTEXT, dir3 + "," + dir4);
       assertTrue(localFs.mkdirs(new Path(dir3)));
       assertTrue(localFs.mkdirs(new Path(dir3)));
@@ -212,7 +223,7 @@ public class TestLocalDirAllocator {
 
 
       // Determine the round-robin sequence
       // Determine the round-robin sequence
       int nextDirIdx = (dirAllocator.getCurrentDirectoryIndex() == 0) ? 3 : 4;
       int nextDirIdx = (dirAllocator.getCurrentDirectoryIndex() == 0) ? 3 : 4;
-      validateTempDirCreation(buildBufferDir(ROOT, nextDirIdx));
+      validateTempDirCreation(buildBufferDir(root, nextDirIdx));
 
 
       // change buffer directory 2 to be read only
       // change buffer directory 2 to be read only
       new File(new Path(dir4).toUri().getPath()).setReadOnly();
       new File(new Path(dir4).toUri().getPath()).setReadOnly();
@@ -235,11 +246,15 @@ public class TestLocalDirAllocator {
    * @throws Exception
    * @throws Exception
    */
    */
   static final int TRIALS = 100;
   static final int TRIALS = 100;
-  @Test (timeout = 30000)
-  public void testCreateManyFiles() throws Exception {
+
+  @Timeout(value = 30)
+  @MethodSource("params")
+  @ParameterizedTest
+  public void testCreateManyFiles(String paramRoot, String paramPrefix) throws Exception {
     assumeNotWindows();
     assumeNotWindows();
-    String dir5 = buildBufferDir(ROOT, 5);
-    String dir6 = buildBufferDir(ROOT, 6);
+    initTestLocalDirAllocator(paramRoot, paramPrefix);
+    String dir5 = buildBufferDir(root, 5);
+    String dir6 = buildBufferDir(root, 6);
     try {
     try {
 
 
       conf.set(CONTEXT, dir5 + "," + dir6);
       conf.set(CONTEXT, dir5 + "," + dir6);
@@ -278,14 +293,17 @@ public class TestLocalDirAllocator {
    *
    *
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test (timeout = 30000)
-  public void testCreateManyFilesRandom() throws Exception {
+  @Timeout(value = 30)
+  @MethodSource("params")
+  @ParameterizedTest
+  public void testCreateManyFilesRandom(String paramRoot, String paramPrefix) throws Exception {
     assumeNotWindows();
     assumeNotWindows();
+    initTestLocalDirAllocator(paramRoot, paramPrefix);
     final int numDirs = 5;
     final int numDirs = 5;
     final int numTries = 100;
     final int numTries = 100;
     String[] dirs = new String[numDirs];
     String[] dirs = new String[numDirs];
     for (int d = 0; d < numDirs; ++d) {
     for (int d = 0; d < numDirs; ++d) {
-      dirs[d] = buildBufferDir(ROOT, d);
+      dirs[d] = buildBufferDir(root, d);
     }
     }
     boolean next_dir_not_selected_at_least_once = false;
     boolean next_dir_not_selected_at_least_once = false;
     try {
     try {
@@ -331,10 +349,14 @@ public class TestLocalDirAllocator {
    * directory. With checkAccess true, the directory should not be created.
    * directory. With checkAccess true, the directory should not be created.
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test (timeout = 30000)
-  public void testLocalPathForWriteDirCreation() throws IOException {
-    String dir0 = buildBufferDir(ROOT, 0);
-    String dir1 = buildBufferDir(ROOT, 1);
+  @Timeout(value = 30)
+  @MethodSource("params")
+  @ParameterizedTest
+  public void testLocalPathForWriteDirCreation(String paramRoot, String paramPrefix)
+      throws IOException {
+    initTestLocalDirAllocator(paramRoot, paramPrefix);
+    String dir0 = buildBufferDir(root, 0);
+    String dir1 = buildBufferDir(root, 1);
     try {
     try {
       conf.set(CONTEXT, dir0 + "," + dir1);
       conf.set(CONTEXT, dir0 + "," + dir1);
       assertTrue(localFs.mkdirs(new Path(dir1)));
       assertTrue(localFs.mkdirs(new Path(dir1)));
@@ -362,8 +384,11 @@ public class TestLocalDirAllocator {
    * Test when mapred.local.dir not configured and called
    * Test when mapred.local.dir not configured and called
    * getLocalPathForWrite
    * getLocalPathForWrite
    */
    */
-  @Test (timeout = 30000)
-  public void testShouldNotthrowNPE() throws Exception {
+  @Timeout(value = 30)
+  @MethodSource("params")
+  @ParameterizedTest
+  public void testShouldNotthrowNPE(String paramRoot, String paramPrefix) throws Exception {
+    initTestLocalDirAllocator(paramRoot, paramPrefix);
     Configuration conf1 = new Configuration();
     Configuration conf1 = new Configuration();
     try {
     try {
       dirAllocator.getLocalPathForWrite("/test", conf1);
       dirAllocator.getLocalPathForWrite("/test", conf1);
@@ -404,10 +429,13 @@ public class TestLocalDirAllocator {
    * are mistakenly created from fully qualified path strings.
    * are mistakenly created from fully qualified path strings.
    * @throws IOException
    * @throws IOException
    */
    */
-  @Test (timeout = 30000)
-  public void testNoSideEffects() throws IOException {
+  @Timeout(value = 30)
+  @MethodSource("params")
+  @ParameterizedTest
+  public void testNoSideEffects(String paramRoot, String paramPrefix) throws IOException {
     assumeNotWindows();
     assumeNotWindows();
-    String dir = buildBufferDir(ROOT, 0);
+    initTestLocalDirAllocator(paramRoot, paramPrefix);
+    String dir = buildBufferDir(root, 0);
     try {
     try {
       conf.set(CONTEXT, dir);
       conf.set(CONTEXT, dir);
       File result = dirAllocator.createTmpFileForWrite(FILENAME, -1, conf);
       File result = dirAllocator.createTmpFileForWrite(FILENAME, -1, conf);
@@ -426,10 +454,13 @@ public class TestLocalDirAllocator {
    *
    *
    * @throws IOException
    * @throws IOException
    */
    */
-  @Test (timeout = 30000)
-  public void testGetLocalPathToRead() throws IOException {
+  @Timeout(value = 30)
+  @MethodSource("params")
+  @ParameterizedTest
+  public void testGetLocalPathToRead(String paramRoot, String paramPrefix) throws IOException {
     assumeNotWindows();
     assumeNotWindows();
-    String dir = buildBufferDir(ROOT, 0);
+    initTestLocalDirAllocator(paramRoot, paramPrefix);
+    String dir = buildBufferDir(root, 0);
     try {
     try {
       conf.set(CONTEXT, dir);
       conf.set(CONTEXT, dir);
       assertTrue(localFs.mkdirs(new Path(dir)));
       assertTrue(localFs.mkdirs(new Path(dir)));
@@ -451,12 +482,14 @@ public class TestLocalDirAllocator {
    *
    *
    * @throws IOException
    * @throws IOException
    */
    */
-  @Test (timeout = 30000)
-  public void testGetAllLocalPathsToRead() throws IOException {
+  @Timeout(value = 30)
+  @MethodSource("params")
+  @ParameterizedTest
+  public void testGetAllLocalPathsToRead(String paramRoot, String paramPrefix) throws IOException {
     assumeNotWindows();
     assumeNotWindows();
-    
-    String dir0 = buildBufferDir(ROOT, 0);
-    String dir1 = buildBufferDir(ROOT, 1);
+    initTestLocalDirAllocator(paramRoot, paramPrefix);
+    String dir0 = buildBufferDir(root, 0);
+    String dir1 = buildBufferDir(root, 1);
     try {
     try {
       conf.set(CONTEXT, dir0 + "," + dir1);
       conf.set(CONTEXT, dir0 + "," + dir1);
       assertTrue(localFs.mkdirs(new Path(dir0)));
       assertTrue(localFs.mkdirs(new Path(dir0)));
@@ -478,8 +511,8 @@ public class TestLocalDirAllocator {
       // test #next() while no element to iterate any more: 
       // test #next() while no element to iterate any more: 
       try {
       try {
         Path p = pathIterable.iterator().next();
         Path p = pathIterable.iterator().next();
-        assertFalse("NoSuchElementException must be thrown, but returned ["+p
-            +"] instead.", true); // exception expected
+        assertFalse(true, "NoSuchElementException must be thrown, but returned ["+p
+            +"] instead."); // exception expected
       } catch (NoSuchElementException nsee) {
       } catch (NoSuchElementException nsee) {
         // okay
         // okay
       }
       }
@@ -499,9 +532,12 @@ public class TestLocalDirAllocator {
     }
     }
   }
   }
   
   
-  @Test (timeout = 30000)
-  public void testRemoveContext() throws IOException {
-    String dir = buildBufferDir(ROOT, 0);
+  @Timeout(value = 30)
+  @MethodSource("params")
+  @ParameterizedTest
+  public void testRemoveContext(String paramRoot, String paramPrefix) throws IOException {
+    initTestLocalDirAllocator(paramRoot, paramPrefix);
+    String dir = buildBufferDir(root, 0);
     try {
     try {
       String contextCfgItemName = "application_1340842292563_0004.app.cache.dirs";
       String contextCfgItemName = "application_1340842292563_0004.app.cache.dirs";
       conf.set(contextCfgItemName, dir);
       conf.set(contextCfgItemName, dir);
@@ -521,15 +557,19 @@ public class TestLocalDirAllocator {
    *
    *
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test(timeout = 30000)
-  public void testGetLocalPathForWriteForInvalidPaths() throws Exception {
+  @Timeout(value = 30)
+  @MethodSource("params")
+  @ParameterizedTest
+  public void testGetLocalPathForWriteForInvalidPaths(String paramRoot, String paramPrefix)
+      throws Exception {
+    initTestLocalDirAllocator(paramRoot, paramPrefix);
     conf.set(CONTEXT, " ");
     conf.set(CONTEXT, " ");
     try {
     try {
       dirAllocator.getLocalPathForWrite("/test", conf);
       dirAllocator.getLocalPathForWrite("/test", conf);
       fail("not throwing the exception");
       fail("not throwing the exception");
     } catch (IOException e) {
     } catch (IOException e) {
-      assertEquals("Incorrect exception message",
-          "No space available in any of the local directories.", e.getMessage());
+      assertEquals("No space available in any of the local directories.",
+          e.getMessage(), "Incorrect exception message");
     }
     }
   }
   }
 
 
@@ -538,10 +578,14 @@ public class TestLocalDirAllocator {
    *
    *
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test(timeout = 30000)
-  public void testGetLocalPathForWriteForLessSpace() throws Exception {
-    String dir0 = buildBufferDir(ROOT, 0);
-    String dir1 = buildBufferDir(ROOT, 1);
+  @Timeout(value = 30)
+  @MethodSource("params")
+  @ParameterizedTest
+  public void testGetLocalPathForWriteForLessSpace(String paramRoot, String paramPrefix)
+      throws Exception {
+    initTestLocalDirAllocator(paramRoot, paramPrefix);
+    String dir0 = buildBufferDir(root, 0);
+    String dir1 = buildBufferDir(root, 1);
     conf.set(CONTEXT, dir0 + "," + dir1);
     conf.set(CONTEXT, dir0 + "," + dir1);
     LambdaTestUtils.intercept(DiskErrorException.class,
     LambdaTestUtils.intercept(DiskErrorException.class,
         String.format("Could not find any valid local directory for %s with requested size %s",
         String.format("Could not find any valid local directory for %s with requested size %s",
@@ -552,9 +596,12 @@ public class TestLocalDirAllocator {
   /**
   /**
    * Test for HADOOP-18636 LocalDirAllocator cannot recover from directory tree deletion.
    * Test for HADOOP-18636 LocalDirAllocator cannot recover from directory tree deletion.
    */
    */
-  @Test(timeout = 30000)
-  public void testDirectoryRecovery() throws Throwable {
-    String dir0 = buildBufferDir(ROOT, 0);
+  @Timeout(value = 30)
+  @MethodSource("params")
+  @ParameterizedTest
+  public void testDirectoryRecovery(String paramRoot, String paramPrefix) throws Throwable {
+    initTestLocalDirAllocator(paramRoot, paramPrefix);
+    String dir0 = buildBufferDir(root, 0);
     String subdir = dir0 + "/subdir1/subdir2";
     String subdir = dir0 + "/subdir1/subdir2";
 
 
     conf.set(CONTEXT, subdir);
     conf.set(CONTEXT, subdir);

+ 47 - 52
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystem.java

@@ -40,32 +40,33 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.List;
 import java.util.Random;
 import java.util.Random;
 import java.util.Set;
 import java.util.Set;
-import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 import static org.apache.hadoop.test.PlatformAssumptions.assumeNotWindows;
 import static org.apache.hadoop.test.PlatformAssumptions.assumeNotWindows;
 import static org.apache.hadoop.test.PlatformAssumptions.assumeWindows;
 import static org.apache.hadoop.test.PlatformAssumptions.assumeWindows;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.*;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.Timeout;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+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.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import javax.annotation.Nonnull;
 import javax.annotation.Nonnull;
 
 
-import static org.assertj.core.api.Assertions.assertThat;
-
 /**
 /**
  * This class tests the local file system via the FileSystem abstraction.
  * This class tests the local file system via the FileSystem abstraction.
  */
  */
+@Timeout(60)
 public class TestLocalFileSystem {
 public class TestLocalFileSystem {
   private static final File base =
   private static final File base =
       GenericTestUtils.getTestDir("work-dir/localfs");
       GenericTestUtils.getTestDir("work-dir/localfs");
@@ -75,19 +76,13 @@ public class TestLocalFileSystem {
   private Configuration conf;
   private Configuration conf;
   private LocalFileSystem fileSys;
   private LocalFileSystem fileSys;
 
 
-  /**
-   * Set the timeout for every test.
-   */
-  @Rule
-  public Timeout testTimeout = new Timeout(60, TimeUnit.SECONDS);
-
   private void cleanupFile(FileSystem fs, Path name) throws IOException {
   private void cleanupFile(FileSystem fs, Path name) throws IOException {
     assertTrue(fs.exists(name));
     assertTrue(fs.exists(name));
     fs.delete(name, true);
     fs.delete(name, true);
     assertTrue(!fs.exists(name));
     assertTrue(!fs.exists(name));
   }
   }
   
   
-  @Before
+  @BeforeEach
   public void setup() throws IOException {
   public void setup() throws IOException {
     conf = new Configuration(false);
     conf = new Configuration(false);
     conf.set("fs.file.impl", LocalFileSystem.class.getName());
     conf.set("fs.file.impl", LocalFileSystem.class.getName());
@@ -95,7 +90,7 @@ public class TestLocalFileSystem {
     fileSys.delete(new Path(TEST_ROOT_DIR), true);
     fileSys.delete(new Path(TEST_ROOT_DIR), true);
   }
   }
   
   
-  @After
+  @AfterEach
   public void after() throws IOException {
   public void after() throws IOException {
     FileUtil.setWritable(base, true);
     FileUtil.setWritable(base, true);
     FileUtil.fullyDelete(base);
     FileUtil.fullyDelete(base);
@@ -248,9 +243,9 @@ public class TestLocalFileSystem {
     {
     {
       //check FileStatus and ContentSummary 
       //check FileStatus and ContentSummary 
       final FileStatus status = fileSys.getFileStatus(test_file);
       final FileStatus status = fileSys.getFileStatus(test_file);
-      Assert.assertEquals(fileSize, status.getLen());
+      assertEquals(fileSize, status.getLen());
       final ContentSummary summary = fileSys.getContentSummary(test_dir);
       final ContentSummary summary = fileSys.getContentSummary(test_dir);
-      Assert.assertEquals(fileSize, summary.getLength());
+      assertEquals(fileSize, summary.getLength());
     }
     }
     
     
     // creating dir over a file
     // creating dir over a file
@@ -281,10 +276,9 @@ public class TestLocalFileSystem {
     assertTrue(fileSys.mkdirs(dir1));
     assertTrue(fileSys.mkdirs(dir1));
     writeFile(fileSys, file1, 1);
     writeFile(fileSys, file1, 1);
     writeFile(fileSys, file2, 1);
     writeFile(fileSys, file2, 1);
-    assertFalse("Returned true deleting non-existant path", 
-            fileSys.delete(file3));
-    assertTrue("Did not delete file", fileSys.delete(file1));
-    assertTrue("Did not delete non-empty dir", fileSys.delete(dir1));
+    assertFalse(fileSys.delete(file3), "Returned true deleting non-existant path");
+    assertTrue(fileSys.delete(file1), "Did not delete file");
+    assertTrue(fileSys.delete(dir1), "Did not delete non-empty dir");
   }
   }
   
   
   @Test
   @Test
@@ -318,9 +312,9 @@ public class TestLocalFileSystem {
     File colonFile = new File(TEST_ROOT_DIR, "foo:bar");
     File colonFile = new File(TEST_ROOT_DIR, "foo:bar");
     colonFile.mkdirs();
     colonFile.mkdirs();
     FileStatus[] stats = fileSys.listStatus(new Path(TEST_ROOT_DIR));
     FileStatus[] stats = fileSys.listStatus(new Path(TEST_ROOT_DIR));
-    assertEquals("Unexpected number of stats", 1, stats.length);
-    assertEquals("Bad path from stat", colonFile.getAbsolutePath(),
-        stats[0].getPath().toUri().getPath());
+    assertEquals(1, stats.length, "Unexpected number of stats");
+    assertEquals(colonFile.getAbsolutePath(),
+        stats[0].getPath().toUri().getPath(), "Bad path from stat");
   }
   }
   
   
   @Test
   @Test
@@ -333,9 +327,9 @@ public class TestLocalFileSystem {
     File file = new File(dirNoDriveSpec, "foo");
     File file = new File(dirNoDriveSpec, "foo");
     file.mkdirs();
     file.mkdirs();
     FileStatus[] stats = fileSys.listStatus(new Path(dirNoDriveSpec));
     FileStatus[] stats = fileSys.listStatus(new Path(dirNoDriveSpec));
-    assertEquals("Unexpected number of stats", 1, stats.length);
-    assertEquals("Bad path from stat", new Path(file.getPath()).toUri().getPath(),
-        stats[0].getPath().toUri().getPath());
+    assertEquals(1, stats.length, "Unexpected number of stats");
+    assertEquals(new Path(file.getPath()).toUri().getPath(),
+        stats[0].getPath().toUri().getPath(), "Bad path from stat");
   }
   }
   
   
   @Test
   @Test
@@ -429,8 +423,9 @@ public class TestLocalFileSystem {
     long newAccTime = 23456000;
     long newAccTime = 23456000;
 
 
     FileStatus status = fileSys.getFileStatus(path);
     FileStatus status = fileSys.getFileStatus(path);
-    assertTrue("check we're actually changing something", newModTime != status.getModificationTime());
-    assertTrue("check we're actually changing something", newAccTime != status.getAccessTime());
+    assertTrue(newModTime != status.getModificationTime(),
+        "check we're actually changing something");
+    assertTrue(newAccTime != status.getAccessTime(), "check we're actually changing something");
 
 
     fileSys.setTimes(path, newModTime, newAccTime);
     fileSys.setTimes(path, newModTime, newAccTime);
     checkTimesStatus(path, newModTime, newAccTime);
     checkTimesStatus(path, newModTime, newAccTime);
@@ -606,8 +601,8 @@ public class TestLocalFileSystem {
     // Create test file with fragment
     // Create test file with fragment
     FileSystemTestHelper.createFile(fs, pathWithFragment);
     FileSystemTestHelper.createFile(fs, pathWithFragment);
     Path resolved = fs.resolvePath(pathWithFragment);
     Path resolved = fs.resolvePath(pathWithFragment);
-    assertEquals("resolvePath did not strip fragment from Path", pathQualified,
-        resolved);
+    assertEquals(pathQualified,
+        resolved, "resolvePath did not strip fragment from Path");
   }
   }
 
 
   @Test
   @Test
@@ -683,8 +678,8 @@ public class TestLocalFileSystem {
           new byte[(int) (fileSys.getFileStatus(path).getLen())];
           new byte[(int) (fileSys.getFileStatus(path).getLen())];
       input.readFully(0, buffer);
       input.readFully(0, buffer);
       input.close();
       input.close();
-      Assert.assertArrayEquals("The data be read should equals with the "
-          + "data written.", contentOrigin, buffer);
+      assertArrayEquals(contentOrigin, buffer, "The data be read should equals with the "
+          + "data written.");
     } catch (IOException e) {
     } catch (IOException e) {
       throw e;
       throw e;
     }
     }
@@ -770,8 +765,8 @@ public class TestLocalFileSystem {
     builder.must("strM", "value");
     builder.must("strM", "value");
     builder.must("unsupported", 12.34);
     builder.must("unsupported", 12.34);
 
 
-    assertEquals("Optional value should be overwrite by a mandatory value",
-        "value", builder.getOptions().get("strM"));
+    assertEquals("value", builder.getOptions().get("strM"),
+        "Optional value should be overwrite by a mandatory value");
 
 
     Set<String> mandatoryKeys = builder.getMandatoryKeys();
     Set<String> mandatoryKeys = builder.getMandatoryKeys();
     Set<String> expectedKeys = new HashSet<>();
     Set<String> expectedKeys = new HashSet<>();
@@ -799,8 +794,8 @@ public class TestLocalFileSystem {
         .stream()
         .stream()
         .filter(s -> s.getScheme().equals("file"))
         .filter(s -> s.getScheme().equals("file"))
         .collect(Collectors.toList());
         .collect(Collectors.toList());
-    assertEquals("Number of statistics counters for file://",
-        1, fileStats.size());
+    assertEquals(1, fileStats.size(),
+        "Number of statistics counters for file://");
     // this should be used for local and rawLocal, as they share the
     // this should be used for local and rawLocal, as they share the
     // same schema (although their class is different)
     // same schema (although their class is different)
     return fileStats.get(0);
     return fileStats.get(0);
@@ -832,8 +827,8 @@ public class TestLocalFileSystem {
     final long bytesOut0 = stats.getBytesWritten();
     final long bytesOut0 = stats.getBytesWritten();
     try {
     try {
       callable.call();
       callable.call();
-      assertEquals("Bytes written in " + operation + "; stats=" + stats,
-          CRC_SIZE + DATA.length, stats.getBytesWritten() - bytesOut0);
+      assertEquals(CRC_SIZE + DATA.length, stats.getBytesWritten() - bytesOut0,
+          "Bytes written in " + operation + "; stats=" + stats);
     } finally {
     } finally {
       if (delete) {
       if (delete) {
         // clean up
         // clean up
@@ -862,8 +857,8 @@ public class TestLocalFileSystem {
     final long bytesRead0 = stats.getBytesRead();
     final long bytesRead0 = stats.getBytesRead();
     fileSys.open(file).close();
     fileSys.open(file).close();
     final long bytesRead1 = stats.getBytesRead();
     final long bytesRead1 = stats.getBytesRead();
-    assertEquals("Bytes read in open() call with stats " + stats,
-        CRC_SIZE, bytesRead1 - bytesRead0);
+    assertEquals(CRC_SIZE, bytesRead1 - bytesRead0,
+        "Bytes read in open() call with stats " + stats);
   }
   }
 
 
   /**
   /**
@@ -974,8 +969,8 @@ public class TestLocalFileSystem {
     // now read back the data, again with the builder API
     // now read back the data, again with the builder API
     final long bytesRead0 = stats.getBytesRead();
     final long bytesRead0 = stats.getBytesRead();
     fileSys.openFile(file).build().get().close();
     fileSys.openFile(file).build().get().close();
-    assertEquals("Bytes read in openFile() call with stats " + stats,
-        CRC_SIZE, stats.getBytesRead() - bytesRead0);
+    assertEquals(CRC_SIZE, stats.getBytesRead() - bytesRead0,
+        "Bytes read in openFile() call with stats " + stats);
     // now write with overwrite = true
     // now write with overwrite = true
     assertWritesCRC("createFileNonRecursive()",
     assertWritesCRC("createFileNonRecursive()",
         file,
         file,

+ 11 - 10
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocalFileSystemPermission.java

@@ -21,8 +21,7 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.util.Shell;
 import org.apache.hadoop.util.Shell;
-import org.assertj.core.api.Assertions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.slf4j.event.Level;
 import org.slf4j.event.Level;
@@ -33,7 +32,10 @@ import java.util.List;
 import java.util.StringTokenizer;
 import java.util.StringTokenizer;
 
 
 import static org.apache.hadoop.test.PlatformAssumptions.assumeNotWindows;
 import static org.apache.hadoop.test.PlatformAssumptions.assumeNotWindows;
-import static org.junit.Assert.*;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
 /**
  * This class tests the local file system via the FileSystem abstraction.
  * This class tests the local file system via the FileSystem abstraction.
@@ -234,9 +236,9 @@ public class TestLocalFileSystemPermission {
     try {
     try {
       assertTrue(localfs.mkdirs(dir));
       assertTrue(localfs.mkdirs(dir));
       FsPermission initialPermission = getPermission(localfs, dir);
       FsPermission initialPermission = getPermission(localfs, dir);
-      assertEquals(
-          "With umask 022 permission should be 755 since the default " +
-              "permission is 777", new FsPermission("755"), initialPermission);
+      assertEquals(new FsPermission("755"),
+          initialPermission, "With umask 022 permission should be 755 since the default " +
+          "permission is 777");
 
 
       // Modify umask and create a new directory
       // Modify umask and create a new directory
       // and check if new umask is applied
       // and check if new umask is applied
@@ -244,12 +246,11 @@ public class TestLocalFileSystemPermission {
       assertTrue(localfs.mkdirs(dir2));
       assertTrue(localfs.mkdirs(dir2));
       FsPermission finalPermission = localfs.getFileStatus(dir2)
       FsPermission finalPermission = localfs.getFileStatus(dir2)
           .getPermission();
           .getPermission();
-      Assertions.assertThat(new FsPermission("755")).as(
+      assertThat(new FsPermission("755")).as(
           "With umask 062 permission should not be 755 since the " +
           "With umask 062 permission should not be 755 since the " +
           "default permission is 777").isNotEqualTo(finalPermission);
           "default permission is 777").isNotEqualTo(finalPermission);
-      assertEquals(
-          "With umask 062 we expect 715 since the default permission is 777",
-          new FsPermission("715"), finalPermission);
+      assertEquals(new FsPermission("715"), finalPermission,
+          "With umask 062 we expect 715 since the default permission is 777");
     } finally {
     } finally {
       conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "022");
       conf.set(CommonConfigurationKeys.FS_PERMISSIONS_UMASK_KEY, "022");
       cleanup(localfs, dir);
       cleanup(localfs, dir);

+ 1 - 1
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestLocatedFileStatus.java

@@ -19,7 +19,7 @@
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.FsPermission;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.IOException;
 import java.io.IOException;
 
 

+ 17 - 17
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestQuotaUsage.java

@@ -17,9 +17,9 @@
  */
  */
 package org.apache.hadoop.fs;
 package org.apache.hadoop.fs;
 
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestQuotaUsage {
 public class TestQuotaUsage {
 
 
@@ -27,9 +27,9 @@ public class TestQuotaUsage {
   @Test
   @Test
   public void testConstructorEmpty() {
   public void testConstructorEmpty() {
     QuotaUsage quotaUsage = new QuotaUsage.Builder().build();
     QuotaUsage quotaUsage = new QuotaUsage.Builder().build();
-    assertEquals("getQuota", -1, quotaUsage.getQuota());
-    assertEquals("getSpaceConsumed", 0, quotaUsage.getSpaceConsumed());
-    assertEquals("getSpaceQuota", -1, quotaUsage.getSpaceQuota());
+    assertEquals(-1, quotaUsage.getQuota(), "getQuota");
+    assertEquals(0, quotaUsage.getSpaceConsumed(), "getSpaceConsumed");
+    assertEquals(-1, quotaUsage.getSpaceQuota(), "getSpaceQuota");
   }
   }
 
 
   // check the full constructor with quota information
   // check the full constructor with quota information
@@ -43,12 +43,12 @@ public class TestQuotaUsage {
     QuotaUsage quotaUsage = new QuotaUsage.Builder().
     QuotaUsage quotaUsage = new QuotaUsage.Builder().
         fileAndDirectoryCount(fileAndDirCount).quota(quota).
         fileAndDirectoryCount(fileAndDirCount).quota(quota).
         spaceConsumed(spaceConsumed).spaceQuota(spaceQuota).build();
         spaceConsumed(spaceConsumed).spaceQuota(spaceQuota).build();
-    assertEquals("getFileAndDirectoryCount", fileAndDirCount,
-        quotaUsage.getFileAndDirectoryCount());
-    assertEquals("getQuota", quota, quotaUsage.getQuota());
-    assertEquals("getSpaceConsumed", spaceConsumed,
-        quotaUsage.getSpaceConsumed());
-    assertEquals("getSpaceQuota", spaceQuota, quotaUsage.getSpaceQuota());
+    assertEquals(fileAndDirCount,
+        quotaUsage.getFileAndDirectoryCount(), "getFileAndDirectoryCount");
+    assertEquals(quota, quotaUsage.getQuota(), "getQuota");
+    assertEquals(spaceConsumed,
+        quotaUsage.getSpaceConsumed(), "getSpaceConsumed");
+    assertEquals(spaceQuota, quotaUsage.getSpaceQuota(), "getSpaceQuota");
   }
   }
 
 
   // check the constructor with quota information
   // check the constructor with quota information
@@ -59,12 +59,12 @@ public class TestQuotaUsage {
     QuotaUsage quotaUsage = new QuotaUsage.Builder().
     QuotaUsage quotaUsage = new QuotaUsage.Builder().
         fileAndDirectoryCount(fileAndDirCount).
         fileAndDirectoryCount(fileAndDirCount).
         spaceConsumed(spaceConsumed).build();
         spaceConsumed(spaceConsumed).build();
-    assertEquals("getFileAndDirectoryCount", fileAndDirCount,
-        quotaUsage.getFileAndDirectoryCount());
-    assertEquals("getQuota", -1, quotaUsage.getQuota());
-    assertEquals("getSpaceConsumed", spaceConsumed,
-        quotaUsage.getSpaceConsumed());
-    assertEquals("getSpaceQuota", -1, quotaUsage.getSpaceQuota());
+    assertEquals(fileAndDirCount,
+        quotaUsage.getFileAndDirectoryCount(), "getFileAndDirectoryCount");
+    assertEquals(-1, quotaUsage.getQuota(), "getQuota");
+    assertEquals(spaceConsumed,
+        quotaUsage.getSpaceConsumed(), "getSpaceConsumed");
+    assertEquals(-1, quotaUsage.getSpaceQuota(), "getSpaceQuota");
   }
   }
 
 
   // check the header
   // check the header

+ 62 - 83
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTrash.java

@@ -34,15 +34,15 @@ import java.util.Set;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Supplier;
 import java.util.function.Supplier;
 
 
-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.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.TrashPolicyDefault.Emptier;
 import org.apache.hadoop.fs.TrashPolicyDefault.Emptier;
@@ -60,7 +60,7 @@ public class TestTrash {
 
 
   private final static Path TEST_DIR = new Path(BASE_PATH.getAbsolutePath());
   private final static Path TEST_DIR = new Path(BASE_PATH.getAbsolutePath());
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws IOException {
   public void setUp() throws IOException {
     // ensure each test initiates a FileSystem instance,
     // ensure each test initiates a FileSystem instance,
     // avoid getting an old instance from cache.
     // avoid getting an old instance from cache.
@@ -78,7 +78,7 @@ public class TestTrash {
   protected static void checkTrash(FileSystem trashFs, Path trashRoot,
   protected static void checkTrash(FileSystem trashFs, Path trashRoot,
       Path path) throws IOException {
       Path path) throws IOException {
     Path p = Path.mergePaths(trashRoot, path);
     Path p = Path.mergePaths(trashRoot, path);
-    assertTrue("Could not find file in trash: "+ p , trashFs.exists(p));
+    assertTrue(trashFs.exists(p), "Could not find file in trash: " + p);
   }
   }
   
   
   // counts how many instances of the file are in the Trash
   // counts how many instances of the file are in the Trash
@@ -169,7 +169,7 @@ public class TestTrash {
       int val = -1;
       int val = -1;
       val = shell.run(args);
       val = shell.run(args);
 
 
-      assertEquals("Expunge should return zero", 0, val);
+      assertEquals(0, val, "Expunge should return zero");
     }
     }
 
 
     // Verify that we succeed in removing the file we created.
     // Verify that we succeed in removing the file we created.
@@ -181,7 +181,7 @@ public class TestTrash {
       int val = -1;
       int val = -1;
       val = shell.run(args);
       val = shell.run(args);
 
 
-      assertEquals("Remove should return zero", 0, val);
+      assertEquals(0, val, "Remove should return zero");
 
 
       checkTrash(trashRootFs, trashRoot, fs.makeQualified(myFile));
       checkTrash(trashRootFs, trashRoot, fs.makeQualified(myFile));
     }
     }
@@ -197,7 +197,7 @@ public class TestTrash {
       int val = -1;
       int val = -1;
       val = shell.run(args);
       val = shell.run(args);
 
 
-      assertEquals("Remove should return zero", 0, val);
+      assertEquals(0, val, "Remove should return zero");
     }
     }
 
 
     // Verify that we can recreate the file
     // Verify that we can recreate the file
@@ -212,7 +212,7 @@ public class TestTrash {
       int val = -1;
       int val = -1;
       val = shell.run(args);
       val = shell.run(args);
 
 
-      assertEquals("Recursive Remove should return zero", 0, val);
+      assertEquals(0, val, "Recursive Remove should return zero");
     }
     }
 
 
     // recreate directory
     // recreate directory
@@ -226,7 +226,7 @@ public class TestTrash {
       int val = -1;
       int val = -1;
       val = shell.run(args);
       val = shell.run(args);
 
 
-      assertEquals("Recursive Remove should return zero", 0, val);
+      assertEquals(0, val, "Recursive Remove should return zero");
     }
     }
 
 
     // Check that we can delete a file from the trash
     // Check that we can delete a file from the trash
@@ -237,7 +237,7 @@ public class TestTrash {
 
 
       val = shell.run(new String[] {"-rm", toErase.toString()});
       val = shell.run(new String[] {"-rm", toErase.toString()});
 
 
-      assertEquals("Recursive Remove should return zero", 0, val);
+      assertEquals(0, val, "Recursive Remove should return zero");
       checkNotInTrash(trashRootFs, trashRoot, toErase.toString());
       checkNotInTrash(trashRootFs, trashRoot, toErase.toString());
       checkNotInTrash(trashRootFs, trashRoot, toErase.toString()+".1");
       checkNotInTrash(trashRootFs, trashRoot, toErase.toString()+".1");
     }
     }
@@ -249,7 +249,7 @@ public class TestTrash {
       int val = -1;
       int val = -1;
       val = shell.run(args);
       val = shell.run(args);
 
 
-      assertEquals("Expunge should return zero", 0, val);
+      assertEquals(0, val, "Expunge should return zero");
     }
     }
 
 
     // verify that after expunging the Trash, it really goes away
     // verify that after expunging the Trash, it really goes away
@@ -268,7 +268,7 @@ public class TestTrash {
       int val = -1;
       int val = -1;
       val = shell.run(args);
       val = shell.run(args);
 
 
-      assertEquals("Remove should return zero", 0, val);
+      assertEquals(0, val, "Remove should return zero");
       checkTrash(trashRootFs, trashRoot, myFile);
       checkTrash(trashRootFs, trashRoot, myFile);
 
 
       args = new String[2];
       args = new String[2];
@@ -277,7 +277,7 @@ public class TestTrash {
       val = -1;
       val = -1;
       val = shell.run(args);
       val = shell.run(args);
 
 
-      assertEquals("Recursive Remove should return zero", 0, val);
+      assertEquals(0, val, "Recursive Remove should return zero");
       checkTrash(trashRootFs, trashRoot, myPath);
       checkTrash(trashRootFs, trashRoot, myPath);
     }
     }
 
 
@@ -289,7 +289,7 @@ public class TestTrash {
       int val = -1;
       int val = -1;
       val = shell.run(args);
       val = shell.run(args);
 
 
-      assertEquals("Recursive Remove should return exit code 1", 1, val);
+      assertEquals(1, val, "Recursive Remove should return exit code 1");
       assertTrue(trashRootFs.exists(trashRoot));
       assertTrue(trashRootFs.exists(trashRoot));
     }
     }
     
     
@@ -307,17 +307,15 @@ public class TestTrash {
       args[2] = myFile.toString();
       args[2] = myFile.toString();
       int val = -1;
       int val = -1;
       // Clear out trash
       // Clear out trash
-      assertEquals("-expunge failed",
-          0, shell.run(new String[] {"-expunge" }));
+      assertEquals(0, shell.run(new String[] {"-expunge" }), "-expunge failed");
 
 
       val = shell.run(args);
       val = shell.run(args);
 
 
-      assertFalse("Expected TrashRoot (" + trashRoot + 
+      assertFalse(trashRootFs.exists(trashRoot), "Expected TrashRoot (" + trashRoot +
           ") to exist in file system:"
           ") to exist in file system:"
-          + trashRootFs.getUri(), 
-          trashRootFs.exists(trashRoot)); // No new Current should be created
+          + trashRootFs.getUri()); // No new Current should be created
       assertFalse(fs.exists(myFile));
       assertFalse(fs.exists(myFile));
-      assertEquals("Remove with skipTrash should return zero", 0, val);
+      assertEquals(0, val, "Remove with skipTrash should return zero");
     }
     }
     
     
     // recreate directory and file
     // recreate directory and file
@@ -340,15 +338,14 @@ public class TestTrash {
       assertFalse(trashRootFs.exists(trashRoot)); // No new Current should be created
       assertFalse(trashRootFs.exists(trashRoot)); // No new Current should be created
       assertFalse(fs.exists(myPath));
       assertFalse(fs.exists(myPath));
       assertFalse(fs.exists(myFile));
       assertFalse(fs.exists(myFile));
-      assertEquals("Remove with skipTrash should return zero", 0, val);
+      assertEquals(0, val, "Remove with skipTrash should return zero");
     }
     }
     
     
     // deleting same file multiple times
     // deleting same file multiple times
     {     
     {     
       int val = -1;
       int val = -1;
       mkdir(fs, myPath);
       mkdir(fs, myPath);
-      assertEquals("Expunge should return zero",
-            0, shell.run(new String[] {"-expunge" }));
+      assertEquals(0, shell.run(new String[] {"-expunge" }), "Expunge should return zero");
 
 
       
       
       // create a file in that directory.
       // create a file in that directory.
@@ -363,7 +360,7 @@ public class TestTrash {
         // delete file
         // delete file
         val = shell.run(args);
         val = shell.run(args);
 
 
-        assertEquals("Remove should return zero", 0, val);
+        assertEquals(0, val, "Remove should return zero");
       }
       }
       // current trash directory
       // current trash directory
       Path trashDir = Path.mergePaths(new Path(trashRoot.toUri().getPath()),
       Path trashDir = Path.mergePaths(new Path(trashRoot.toUri().getPath()),
@@ -377,7 +374,7 @@ public class TestTrash {
       int count = countSameDeletedFiles(fs, trashDir, myFile);
       int count = countSameDeletedFiles(fs, trashDir, myFile);
       System.out.println("counted " + count + " files "
       System.out.println("counted " + count + " files "
           + myFile.getName() + "* in " + trashDir);
           + myFile.getName() + "* in " + trashDir);
-      assertEquals("Count should have returned 10", num_runs, count);
+      assertEquals(num_runs, count, "Count should have returned 10");
     }
     }
     
     
     //Verify skipTrash option is suggested when rm fails due to its absence
     //Verify skipTrash option is suggested when rm fails due to its absence
@@ -397,11 +394,10 @@ public class TestTrash {
       String output = byteStream.toString();
       String output = byteStream.toString();
       System.setOut(stdout);
       System.setOut(stdout);
       System.setErr(stderr);
       System.setErr(stderr);
-      assertTrue("skipTrash wasn't suggested as remedy to failed rm command" +
-          " or we deleted / even though we could not get server defaults",
-          output.indexOf("Consider using -skipTrash option") != -1 ||
-          output.indexOf("Failed to determine server "
-              + "trash configuration") != -1);
+      assertTrue(output.indexOf("Consider using -skipTrash option") != -1 ||
+          output.indexOf("Failed to determine server " + "trash configuration") != -1,
+          "skipTrash wasn't suggested as remedy to failed rm command" +
+          " or we deleted / even though we could not get server defaults");
     }
     }
 
 
     // Verify old checkpoint format is recognized
     // Verify old checkpoint format is recognized
@@ -423,11 +419,10 @@ public class TestTrash {
       int rc = -1;
       int rc = -1;
       rc = shell.run(new String[] {"-expunge" });
       rc = shell.run(new String[] {"-expunge" });
 
 
-      assertEquals("Expunge should return zero", 0, rc);
-      assertFalse("old checkpoint format not recognized",
-          trashRootFs.exists(dirToDelete));
-      assertTrue("old checkpoint format directory should not be removed",
-          trashRootFs.exists(dirToKeep));
+      assertEquals(0, rc, "Expunge should return zero");
+      assertFalse(trashRootFs.exists(dirToDelete), "old checkpoint format not recognized");
+      assertTrue(trashRootFs.exists(dirToKeep),
+          "old checkpoint format directory should not be removed");
     }
     }
 
 
     // Verify expunge -immediate removes all checkpoints and current folder
     // Verify expunge -immediate removes all checkpoints and current folder
@@ -451,15 +446,12 @@ public class TestTrash {
       int rc = -1;
       int rc = -1;
       rc = shell.run(new String[] {"-expunge", "-immediate"});
       rc = shell.run(new String[] {"-expunge", "-immediate"});
 
 
-      assertEquals("Expunge immediate should return zero", 0, rc);
-      assertFalse("Old checkpoint should be removed",
-          trashRootFs.exists(oldCheckpoint));
-      assertFalse("Recent checkpoint should be removed",
-          trashRootFs.exists(recentCheckpoint));
-      assertFalse("Current folder should be removed",
-          trashRootFs.exists(currentFolder));
-      assertEquals("Ensure trash folder is empty", 0,
-          trashRootFs.listStatus(trashRoot.getParent()).length);
+      assertEquals(0, rc, "Expunge immediate should return zero");
+      assertFalse(trashRootFs.exists(oldCheckpoint), "Old checkpoint should be removed");
+      assertFalse(trashRootFs.exists(recentCheckpoint), "Recent checkpoint should be removed");
+      assertFalse(trashRootFs.exists(currentFolder), "Current folder should be removed");
+      assertEquals(0, trashRootFs.listStatus(trashRoot.getParent()).length,
+          "Ensure trash folder is empty");
     }
     }
   }
   }
 
 
@@ -510,16 +502,12 @@ public class TestTrash {
           "-fs", "testlfs:/"};
           "-fs", "testlfs:/"};
       int val = testlfsshell.run(args);
       int val = testlfsshell.run(args);
 
 
-      assertEquals("Expunge immediate with filesystem should return zero",
-          0, val);
-      assertFalse("Old checkpoint should be removed",
-          testlfs.exists(oldCheckpoint));
-      assertFalse("Recent checkpoint should be removed",
-          testlfs.exists(recentCheckpoint));
-      assertFalse("Current folder should be removed",
-          testlfs.exists(currentFolder));
-      assertEquals("Ensure trash folder is empty", 0,
-          testlfs.listStatus(trashRoot.getParent()).length);
+      assertEquals(0, val, "Expunge immediate with filesystem should return zero");
+      assertFalse(testlfs.exists(oldCheckpoint), "Old checkpoint should be removed");
+      assertFalse(testlfs.exists(recentCheckpoint), "Recent checkpoint should be removed");
+      assertFalse(testlfs.exists(currentFolder), "Current folder should be removed");
+      assertEquals(0,
+          testlfs.listStatus(trashRoot.getParent()).length, "Ensure trash folder is empty");
 
 
       // Incorrect FileSystem scheme
       // Incorrect FileSystem scheme
       String incorrectFS = "incorrectfs:/";
       String incorrectFS = "incorrectfs:/";
@@ -527,17 +515,15 @@ public class TestTrash {
           "-fs", incorrectFS};
           "-fs", incorrectFS};
       val = testlfsshell.run(args);
       val = testlfsshell.run(args);
 
 
-      assertEquals("Expunge immediate should return exit code 1 when "
-              + "incorrect Filesystem is passed",
-          1, val);
+      assertEquals(1, val, "Expunge immediate should return exit code 1 when "
+          + "incorrect Filesystem is passed");
 
 
       // Empty FileSystem scheme
       // Empty FileSystem scheme
       args = new String[]{"-expunge", "-immediate",
       args = new String[]{"-expunge", "-immediate",
           "-fs", ""};
           "-fs", ""};
       val = testlfsshell.run(args);
       val = testlfsshell.run(args);
 
 
-      assertNotEquals("Expunge immediate should fail when filesystem is NULL",
-          0, val);
+      assertNotEquals(0, val, "Expunge immediate should fail when filesystem is NULL");
       FileSystem.removeFileSystemForTesting(testlfsURI, config, testlfs);
       FileSystem.removeFileSystemForTesting(testlfsURI, config, testlfs);
     }
     }
   }
   }
@@ -836,7 +822,7 @@ public class TestTrash {
     emptierThread.join();
     emptierThread.join();
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws IOException {
   public void tearDown() throws IOException {
     File trashDir = new File(TEST_DIR.toUri().getPath());
     File trashDir = new File(TEST_DIR.toUri().getPath());
     if (trashDir.exists() && !FileUtil.fullyDelete(trashDir)) {
     if (trashDir.exists() && !FileUtil.fullyDelete(trashDir)) {
@@ -969,18 +955,14 @@ public class TestTrash {
       Path trashRoot = trash.getCurrentTrashDir(emptyDir);
       Path trashRoot = trash.getCurrentTrashDir(emptyDir);
       fileSystem.delete(trashRoot, true);
       fileSystem.delete(trashRoot, true);
       // Move to trash should be succeed
       // Move to trash should be succeed
-      assertTrue("Move an empty directory to trash failed",
-          trash.moveToTrash(emptyDir));
+      assertTrue(trash.moveToTrash(emptyDir), "Move an empty directory to trash failed");
       // Verify the empty dir is removed
       // Verify the empty dir is removed
-      assertFalse("The empty directory still exists on file system",
-          fileSystem.exists(emptyDir));
+      assertFalse(fileSystem.exists(emptyDir), "The empty directory still exists on file system");
       emptyDir = fileSystem.makeQualified(emptyDir);
       emptyDir = fileSystem.makeQualified(emptyDir);
       Path dirInTrash = Path.mergePaths(trashRoot, emptyDir);
       Path dirInTrash = Path.mergePaths(trashRoot, emptyDir);
-      assertTrue("Directory wasn't moved to trash",
-          fileSystem.exists(dirInTrash));
+      assertTrue(fileSystem.exists(dirInTrash), "Directory wasn't moved to trash");
       FileStatus[] flist = fileSystem.listStatus(dirInTrash);
       FileStatus[] flist = fileSystem.listStatus(dirInTrash);
-      assertTrue("Directory is not empty",
-          flist!= null && flist.length == 0);
+      assertTrue(flist!= null && flist.length == 0, "Directory is not empty");
     }
     }
   }
   }
 
 
@@ -1029,15 +1011,14 @@ public class TestTrash {
         }
         }
         Path fileInTrash = Path.mergePaths(trashDir, file);
         Path fileInTrash = Path.mergePaths(trashDir, file);
         FileStatus fstat = wrapper.getFileStatus(fileInTrash);
         FileStatus fstat = wrapper.getFileStatus(fileInTrash);
-        assertTrue(String.format("File %s is not moved to trash",
-            fileInTrash.toString()),
-            wrapper.exists(fileInTrash));
+        assertTrue(wrapper.exists(fileInTrash), String.format("File %s is not moved to trash",
+            fileInTrash.toString()));
         // Verify permission not change
         // Verify permission not change
-        assertTrue(String.format("Expected file: %s is %s, but actual is %s",
+        assertTrue(fstat.getPermission().equals(fsPermission),
+            String.format("Expected file: %s is %s, but actual is %s",
             fileInTrash.toString(),
             fileInTrash.toString(),
             fsPermission.toString(),
             fsPermission.toString(),
-            fstat.getPermission().toString()),
-            fstat.getPermission().equals(fsPermission));
+            fstat.getPermission().toString()));
       }
       }
 
 
       // Verify the trash directory can be removed
       // Verify the trash directory can be removed
@@ -1077,11 +1058,9 @@ public class TestTrash {
       emptierThread.join();
       emptierThread.join();
 
 
       AuditableTrashPolicy at = (AuditableTrashPolicy) trash.getTrashPolicy();
       AuditableTrashPolicy at = (AuditableTrashPolicy) trash.getTrashPolicy();
-      assertEquals(
+      assertEquals(expectedNumOfCheckpoints, at.getNumberOfCheckpoints(),
           String.format("Expected num of checkpoints is %s, but actual is %s",
           String.format("Expected num of checkpoints is %s, but actual is %s",
-              expectedNumOfCheckpoints, at.getNumberOfCheckpoints()),
-          expectedNumOfCheckpoints,
-          at.getNumberOfCheckpoints());
+          expectedNumOfCheckpoints, at.getNumberOfCheckpoints()));
     } catch (InterruptedException  e) {
     } catch (InterruptedException  e) {
       // Ignore
       // Ignore
     } finally {
     } finally {

+ 2 - 2
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestTruncatedInputBug.java

@@ -20,11 +20,11 @@ package org.apache.hadoop.fs;
 import java.io.DataOutputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.io.IOException;
 
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 /**
 /**
  * test for the input truncation bug when mark/reset is used.
  * test for the input truncation bug when mark/reset is used.

+ 12 - 16
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/ftp/TestFTPFileSystem.java

@@ -22,7 +22,6 @@ import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
 import java.nio.file.Files;
 import java.util.Comparator;
 import java.util.Comparator;
-import java.util.concurrent.TimeUnit;
 
 
 import org.apache.hadoop.util.Preconditions;
 import org.apache.hadoop.util.Preconditions;
 import org.apache.commons.net.ftp.FTP;
 import org.apache.commons.net.ftp.FTP;
@@ -39,29 +38,26 @@ import org.apache.hadoop.fs.permission.FsAction;
 import org.apache.hadoop.io.IOUtils;
 import org.apache.hadoop.io.IOUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.LambdaTestUtils;
 import org.apache.hadoop.test.LambdaTestUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.Timeout;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
 /**
  * Test basic @{link FTPFileSystem} class methods. Contract tests are in
  * Test basic @{link FTPFileSystem} class methods. Contract tests are in
  * TestFTPContractXXXX.
  * TestFTPContractXXXX.
  */
  */
+@Timeout(180)
 public class TestFTPFileSystem {
 public class TestFTPFileSystem {
 
 
   private FtpTestServer server;
   private FtpTestServer server;
   private java.nio.file.Path testDir;
   private java.nio.file.Path testDir;
-  @Rule
-  public Timeout testTimeout = new Timeout(180000, TimeUnit.MILLISECONDS);
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     testDir = Files.createTempDirectory(
     testDir = Files.createTempDirectory(
         GenericTestUtils.getTestDir().toPath(), getClass().getName()
         GenericTestUtils.getTestDir().toPath(), getClass().getName()
@@ -69,7 +65,7 @@ public class TestFTPFileSystem {
     server = new FtpTestServer(testDir).start();
     server = new FtpTestServer(testDir).start();
   }
   }
 
 
-  @After
+  @AfterEach
   @SuppressWarnings("ResultOfMethodCallIgnored")
   @SuppressWarnings("ResultOfMethodCallIgnored")
   public void tearDown() throws Exception {
   public void tearDown() throws Exception {
     if (server != null) {
     if (server != null) {
@@ -98,7 +94,7 @@ public class TestFTPFileSystem {
       outputStream.write(bytesExpected);
       outputStream.write(bytesExpected);
     }
     }
     try (FSDataInputStream input = fs.open(new Path("test1.txt"))) {
     try (FSDataInputStream input = fs.open(new Path("test1.txt"))) {
-      assertThat(bytesExpected, equalTo(IOUtils.readFullyToByteArray(input)));
+      assertThat(bytesExpected).isEqualTo(IOUtils.readFullyToByteArray(input));
     }
     }
   }
   }
 
 
@@ -193,7 +189,7 @@ public class TestFTPFileSystem {
     String errorMessageFormat = "expect FsAction is %s, whereas it is %s now.";
     String errorMessageFormat = "expect FsAction is %s, whereas it is %s now.";
     String notEqualErrorMessage = String.format(errorMessageFormat,
     String notEqualErrorMessage = String.format(errorMessageFormat,
         actionA.name(), actionB.name());
         actionA.name(), actionB.name());
-    assertEquals(notEqualErrorMessage, actionA, actionB);
+    assertEquals(actionA, actionB, notEqualErrorMessage);
   }
   }
 
 
   private FTPFile getFTPFileOf(int access, FsAction action) {
   private FTPFile getFTPFileOf(int access, FsAction action) {

+ 4 - 4
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/http/TestHttpFileSystem.java

@@ -25,8 +25,8 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.IOUtils;
 import org.apache.hadoop.io.IOUtils;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 
 
 import java.io.IOException;
 import java.io.IOException;
@@ -37,7 +37,7 @@ import java.net.URL;
 import java.nio.charset.StandardCharsets;
 import java.nio.charset.StandardCharsets;
 import java.util.stream.IntStream;
 import java.util.stream.IntStream;
 
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 /**
 /**
  * Testing HttpFileSystem.
  * Testing HttpFileSystem.
@@ -45,7 +45,7 @@ import static org.junit.Assert.assertEquals;
 public class TestHttpFileSystem {
 public class TestHttpFileSystem {
   private final Configuration conf = new Configuration(false);
   private final Configuration conf = new Configuration(false);
 
 
-  @Before
+  @BeforeEach
   public void setUp() {
   public void setUp() {
     conf.set("fs.http.impl", HttpFileSystem.class.getCanonicalName());
     conf.set("fs.http.impl", HttpFileSystem.class.getCanonicalName());
   }
   }

+ 6 - 4
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestAcl.java

@@ -17,10 +17,12 @@
  */
  */
 package org.apache.hadoop.fs.permission;
 package org.apache.hadoop.fs.permission;
 
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
 
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 
 /**
 /**
  * Tests covering basic functionality of the ACL objects.
  * Tests covering basic functionality of the ACL objects.
@@ -30,7 +32,7 @@ public class TestAcl {
     ENTRY7, ENTRY8, ENTRY9, ENTRY10, ENTRY11, ENTRY12, ENTRY13;
     ENTRY7, ENTRY8, ENTRY9, ENTRY10, ENTRY11, ENTRY12, ENTRY13;
   private static AclStatus STATUS1, STATUS2, STATUS3, STATUS4;
   private static AclStatus STATUS1, STATUS2, STATUS3, STATUS4;
 
 
-  @BeforeClass
+  @BeforeAll
   public static void setUp() {
   public static void setUp() {
     // named user
     // named user
     AclEntry.Builder aclEntryBuilder = new AclEntry.Builder()
     AclEntry.Builder aclEntryBuilder = new AclEntry.Builder()

+ 6 - 4
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/permission/TestFsPermission.java

@@ -21,8 +21,10 @@ import java.io.IOException;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 
 
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 import static org.apache.hadoop.fs.permission.FsAction.*;
 import static org.apache.hadoop.fs.permission.FsAction.*;
 
 
@@ -252,8 +254,8 @@ public class TestFsPermission {
         FsPermission.getUMask(conf);
         FsPermission.getUMask(conf);
         fail("Shouldn't have been able to parse bad umask");
         fail("Shouldn't have been able to parse bad umask");
       } catch(IllegalArgumentException iae) {
       } catch(IllegalArgumentException iae) {
-        assertTrue("Exception should specify parsing error and invalid umask: " 
-            + iae.getMessage(), isCorrectExceptionMessage(iae.getMessage(), b));
+        assertTrue(isCorrectExceptionMessage(iae.getMessage(), b),
+            "Exception should specify parsing error and invalid umask: " + iae.getMessage());
       }
       }
     }
     }
   }
   }

+ 2 - 2
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/protocolPB/TestFSSerialization.java

@@ -24,8 +24,8 @@ import org.apache.hadoop.io.DataInputBuffer;
 import org.apache.hadoop.io.DataOutputBuffer;
 import org.apache.hadoop.io.DataOutputBuffer;
 import static org.apache.hadoop.fs.FSProtos.*;
 import static org.apache.hadoop.fs.FSProtos.*;
 
 
-import org.junit.Test;
-import static org.junit.Assert.*;
+import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 /**
 /**
  * Verify PB serialization of FS data structures.
  * Verify PB serialization of FS data structures.

+ 58 - 54
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/sftp/TestSFTPFileSystem.java

@@ -44,18 +44,19 @@ import org.apache.sshd.server.session.ServerSession;
 import org.apache.sshd.sftp.server.SftpSubsystemFactory;
 import org.apache.sshd.sftp.server.SftpSubsystemFactory;
 
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TestName;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInfo;
 
 
 public class TestSFTPFileSystem {
 public class TestSFTPFileSystem {
 
 
@@ -63,8 +64,6 @@ public class TestSFTPFileSystem {
   private static final String TEST_ROOT_DIR =
   private static final String TEST_ROOT_DIR =
       GenericTestUtils.getTestDir().getAbsolutePath();
       GenericTestUtils.getTestDir().getAbsolutePath();
 
 
-  @Rule public TestName name = new TestName();
-
   private static final String connection = "sftp://user:password@localhost";
   private static final String connection = "sftp://user:password@localhost";
   private static Path localDir = null;
   private static Path localDir = null;
   private static FileSystem localFs = null;
   private static FileSystem localFs = null;
@@ -102,12 +101,12 @@ public class TestSFTPFileSystem {
     port = sshd.getPort();
     port = sshd.getPort();
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void init() throws Exception {
   public void init() throws Exception {
     sftpFs = FileSystem.get(URI.create(connection), conf);
     sftpFs = FileSystem.get(URI.create(connection), conf);
   }
   }
 
 
-  @After
+  @AfterEach
   public void cleanUp() throws Exception {
   public void cleanUp() throws Exception {
     if (sftpFs != null) {
     if (sftpFs != null) {
       try {
       try {
@@ -118,7 +117,7 @@ public class TestSFTPFileSystem {
     }
     }
   }
   }
 
 
-  @BeforeClass
+  @BeforeAll
   public static void setUp() throws Exception {
   public static void setUp() throws Exception {
     // skip all tests if running on Windows
     // skip all tests if running on Windows
     assumeNotWindows();
     assumeNotWindows();
@@ -138,7 +137,7 @@ public class TestSFTPFileSystem {
     localFs.mkdirs(localDir);
     localFs.mkdirs(localDir);
   }
   }
 
 
-  @AfterClass
+  @AfterAll
   public static void tearDown() {
   public static void tearDown() {
     if (localFs != null) {
     if (localFs != null) {
       try {
       try {
@@ -185,8 +184,8 @@ public class TestSFTPFileSystem {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  public void testCreateFile() throws Exception {
-    Path file = touch(sftpFs, name.getMethodName().toLowerCase());
+  public void testCreateFile(TestInfo testInfo) throws Exception {
+    Path file = touch(sftpFs, testInfo.getDisplayName().toLowerCase());
     assertTrue(localFs.exists(file));
     assertTrue(localFs.exists(file));
     assertTrue(sftpFs.delete(file, false));
     assertTrue(sftpFs.delete(file, false));
     assertFalse(localFs.exists(file));
     assertFalse(localFs.exists(file));
@@ -201,8 +200,8 @@ public class TestSFTPFileSystem {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  public void testFileExists() throws Exception {
-    Path file = touch(localFs, name.getMethodName().toLowerCase());
+  public void testFileExists(TestInfo testInfo) throws Exception {
+    Path file = touch(localFs, testInfo.getDisplayName().toLowerCase());
     assertTrue(sftpFs.exists(file));
     assertTrue(sftpFs.exists(file));
     assertTrue(localFs.exists(file));
     assertTrue(localFs.exists(file));
     assertTrue(sftpFs.delete(file, false));
     assertTrue(sftpFs.delete(file, false));
@@ -219,9 +218,9 @@ public class TestSFTPFileSystem {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  public void testReadFile() throws Exception {
+  public void testReadFile(TestInfo testInfo) throws Exception {
     byte[] data = "yaks".getBytes();
     byte[] data = "yaks".getBytes();
-    Path file = touch(localFs, name.getMethodName().toLowerCase(), data);
+    Path file = touch(localFs, testInfo.getDisplayName().toLowerCase(), data);
     FSDataInputStream is = null;
     FSDataInputStream is = null;
     try {
     try {
       is = sftpFs.open(file);
       is = sftpFs.open(file);
@@ -245,9 +244,9 @@ public class TestSFTPFileSystem {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  public void testStatFile() throws Exception {
+  public void testStatFile(TestInfo testInfo) throws Exception {
     byte[] data = "yaks".getBytes();
     byte[] data = "yaks".getBytes();
-    Path file = touch(localFs, name.getMethodName().toLowerCase(), data);
+    Path file = touch(localFs, testInfo.getDisplayName().toLowerCase(), data);
 
 
     FileStatus lstat = localFs.getFileStatus(file);
     FileStatus lstat = localFs.getFileStatus(file);
     FileStatus sstat = sftpFs.getFileStatus(file);
     FileStatus sstat = sftpFs.getFileStatus(file);
@@ -268,13 +267,14 @@ public class TestSFTPFileSystem {
    *
    *
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test(expected=java.io.IOException.class)
-  public void testDeleteNonEmptyDir() throws Exception {
-    Path file = touch(localFs, name.getMethodName().toLowerCase());
-    sftpFs.delete(localDir, false);
-    assertThat(
-        ((SFTPFileSystem) sftpFs).getConnectionPool().getLiveConnCount())
-        .isEqualTo(1);
+  @Test
+  public void testDeleteNonEmptyDir(TestInfo testInfo) throws Exception {
+    assertThrows(IOException.class, () -> {
+      Path file = touch(localFs, testInfo.getDisplayName().toLowerCase());
+      sftpFs.delete(localDir, false);
+      assertThat(((SFTPFileSystem) sftpFs).getConnectionPool().getLiveConnCount()).
+          isEqualTo(1);
+    });
   }
   }
 
 
   /**
   /**
@@ -283,8 +283,8 @@ public class TestSFTPFileSystem {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  public void testDeleteNonExistFile() throws Exception {
-    Path file = new Path(localDir, name.getMethodName().toLowerCase());
+  public void testDeleteNonExistFile(TestInfo testInfo) throws Exception {
+    Path file = new Path(localDir, testInfo.getDisplayName().toLowerCase());
     assertFalse(sftpFs.delete(file, false));
     assertFalse(sftpFs.delete(file, false));
     assertThat(
     assertThat(
         ((SFTPFileSystem) sftpFs).getConnectionPool().getLiveConnCount())
         ((SFTPFileSystem) sftpFs).getConnectionPool().getLiveConnCount())
@@ -297,10 +297,10 @@ public class TestSFTPFileSystem {
    * @throws Exception
    * @throws Exception
    */
    */
   @Test
   @Test
-  public void testRenameFile() throws Exception {
+  public void testRenameFile(TestInfo testInfo) throws Exception {
     byte[] data = "dingos".getBytes();
     byte[] data = "dingos".getBytes();
-    Path file1 = touch(localFs, name.getMethodName().toLowerCase() + "1");
-    Path file2 = new Path(localDir, name.getMethodName().toLowerCase() + "2");
+    Path file1 = touch(localFs, testInfo.getDisplayName().toLowerCase() + "1");
+    Path file2 = new Path(localDir, testInfo.getDisplayName().toLowerCase() + "2");
 
 
     assertTrue(sftpFs.rename(file1, file2));
     assertTrue(sftpFs.rename(file1, file2));
 
 
@@ -321,11 +321,13 @@ public class TestSFTPFileSystem {
    *
    *
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test(expected=java.io.IOException.class)
-  public void testRenameNonExistFile() throws Exception {
-    Path file1 = new Path(localDir, name.getMethodName().toLowerCase() + "1");
-    Path file2 = new Path(localDir, name.getMethodName().toLowerCase() + "2");
-    sftpFs.rename(file1, file2);
+  @Test
+  public void testRenameNonExistFile(TestInfo testInfo) throws Exception {
+    assertThrows(IOException.class, ()->{
+      Path file1 = new Path(localDir, testInfo.getDisplayName().toLowerCase() + "1");
+      Path file2 = new Path(localDir, testInfo.getDisplayName().toLowerCase() + "2");
+      sftpFs.rename(file1, file2);
+    });
   }
   }
 
 
   /**
   /**
@@ -333,16 +335,18 @@ public class TestSFTPFileSystem {
    *
    *
    * @throws Exception
    * @throws Exception
    */
    */
-  @Test(expected=java.io.IOException.class)
-  public void testRenamingFileOntoExistingFile() throws Exception {
-    Path file1 = touch(localFs, name.getMethodName().toLowerCase() + "1");
-    Path file2 = touch(localFs, name.getMethodName().toLowerCase() + "2");
-    sftpFs.rename(file1, file2);
+  @Test
+  public void testRenamingFileOntoExistingFile(TestInfo testInfo) throws Exception {
+    assertThrows(IOException.class, ()->{
+      Path file1 = touch(localFs, testInfo.getDisplayName().toLowerCase() + "1");
+      Path file2 = touch(localFs, testInfo.getDisplayName().toLowerCase() + "2");
+      sftpFs.rename(file1, file2);
+    });
   }
   }
 
 
   @Test
   @Test
-  public void testGetAccessTime() throws IOException {
-    Path file = touch(localFs, name.getMethodName().toLowerCase());
+  public void testGetAccessTime(TestInfo testInfo) throws IOException {
+    Path file = touch(localFs, testInfo.getDisplayName().toLowerCase());
     LocalFileSystem local = (LocalFileSystem)localFs;
     LocalFileSystem local = (LocalFileSystem)localFs;
     java.nio.file.Path path = (local).pathToFile(file).toPath();
     java.nio.file.Path path = (local).pathToFile(file).toPath();
     long accessTime1 = Files.readAttributes(path, BasicFileAttributes.class)
     long accessTime1 = Files.readAttributes(path, BasicFileAttributes.class)
@@ -357,8 +361,8 @@ public class TestSFTPFileSystem {
   }
   }
 
 
   @Test
   @Test
-  public void testGetModifyTime() throws IOException {
-    Path file = touch(localFs, name.getMethodName().toLowerCase() + "1");
+  public void testGetModifyTime(TestInfo testInfo) throws IOException {
+    Path file = touch(localFs, testInfo.getDisplayName().toLowerCase() + "1");
     java.io.File localFile = ((LocalFileSystem) localFs).pathToFile(file);
     java.io.File localFile = ((LocalFileSystem) localFs).pathToFile(file);
     long modifyTime1 = localFile.lastModified();
     long modifyTime1 = localFile.lastModified();
     // SFTPFileSystem doesn't have milliseconds. Excluding it.
     // SFTPFileSystem doesn't have milliseconds. Excluding it.
@@ -371,9 +375,9 @@ public class TestSFTPFileSystem {
   }
   }
 
 
   @Test
   @Test
-  public void testMkDirs() throws IOException {
+  public void testMkDirs(TestInfo testInfo) throws IOException {
     Path path = new Path(localDir.toUri().getPath(),
     Path path = new Path(localDir.toUri().getPath(),
-        new Path(name.getMethodName(), "subdirectory"));
+        new Path(testInfo.getDisplayName(), "subdirectory"));
     sftpFs.mkdirs(path);
     sftpFs.mkdirs(path);
     assertTrue(localFs.exists(path));
     assertTrue(localFs.exists(path));
     assertTrue(localFs.getFileStatus(path).isDirectory());
     assertTrue(localFs.getFileStatus(path).isDirectory());

+ 38 - 43
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestAclCommands.java

@@ -17,7 +17,9 @@
  */
  */
 package org.apache.hadoop.fs.shell;
 package org.apache.hadoop.fs.shell;
 
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URI;
@@ -42,55 +44,49 @@ import org.apache.hadoop.ipc.RemoteException;
 import org.apache.hadoop.ipc.RpcNoSuchMethodException;
 import org.apache.hadoop.ipc.RpcNoSuchMethodException;
 import org.apache.hadoop.util.Progressable;
 import org.apache.hadoop.util.Progressable;
 import org.apache.hadoop.util.ToolRunner;
 import org.apache.hadoop.util.ToolRunner;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 
 public class TestAclCommands {
 public class TestAclCommands {
-  @Rule
-  public TemporaryFolder testFolder = new TemporaryFolder();
 
 
   private String path;
   private String path;
 
 
   private Configuration conf = null;
   private Configuration conf = null;
 
 
-  @Before
-  public void setup() throws IOException {
+  @BeforeEach
+  public void setup(@TempDir java.nio.file.Path testFolder) throws IOException {
     conf = new Configuration();
     conf = new Configuration();
-    path = testFolder.newFile("file").getPath();
+    path = testFolder.resolve("file").toFile().getPath();
   }
   }
 
 
   @Test
   @Test
   public void testGetfaclValidations() throws Exception {
   public void testGetfaclValidations() throws Exception {
-    assertFalse("getfacl should fail without path",
-        0 == runCommand(new String[] {"-getfacl"}));
-    assertFalse("getfacl should fail with extra argument",
-        0 == runCommand(new String[] {"-getfacl", path, "extraArg"}));
+    assertFalse(0 == runCommand(new String[] {"-getfacl"}), "getfacl should fail without path");
+    assertFalse(0 == runCommand(new String[] {"-getfacl", path, "extraArg"}),
+        "getfacl should fail with extra argument");
   }
   }
 
 
   @Test
   @Test
   public void testSetfaclValidations() throws Exception {
   public void testSetfaclValidations() throws Exception {
-    assertFalse("setfacl should fail without options",
-        0 == runCommand(new String[] {"-setfacl", path}));
-    assertFalse("setfacl should fail without options -b, -k, -m, -x or --set",
-        0 == runCommand(new String[] {"-setfacl", "-R", path}));
-    assertFalse("setfacl should fail without path",
-        0 == runCommand(new String[] {"-setfacl"}));
-    assertFalse("setfacl should fail without aclSpec",
-        0 == runCommand(new String[] {"-setfacl", "-m", path}));
-    assertFalse("setfacl should fail with conflicting options",
-        0 == runCommand(new String[] {"-setfacl", "-m", path}));
-    assertFalse("setfacl should fail with extra arguments",
-        0 == runCommand(new String[] {"-setfacl", path, "extra"}));
-    assertFalse("setfacl should fail with extra arguments",
-        0 == runCommand(new String[] {"-setfacl", "--set",
-            "default:user::rwx", path, "extra"}));
-    assertFalse("setfacl should fail with permissions for -x",
-        0 == runCommand(new String[] {"-setfacl", "-x", "user:user1:rwx",
-            path}));
-    assertFalse("setfacl should fail ACL spec missing",
-        0 == runCommand(new String[] {"-setfacl", "-m", "", path}));
+    assertFalse(0 == runCommand(new String[] {"-setfacl", path}),
+        "setfacl should fail without options");
+    assertFalse(0 == runCommand(new String[] {"-setfacl", "-R", path}),
+        "setfacl should fail without options -b, -k, -m, -x or --set");
+    assertFalse(0 == runCommand(new String[] {"-setfacl"}),
+        "setfacl should fail without path");
+    assertFalse(0 == runCommand(new String[] {"-setfacl", "-m", path}),
+        "setfacl should fail without aclSpec");
+    assertFalse(0 == runCommand(new String[] {"-setfacl", "-m", path}),
+        "setfacl should fail with conflicting options");
+    assertFalse(0 == runCommand(new String[] {"-setfacl", path, "extra"}),
+        "setfacl should fail with extra arguments");
+    assertFalse(0 == runCommand(new String[] {"-setfacl", "--set",
+        "default:user::rwx", path, "extra"}), "setfacl should fail with extra arguments");
+    assertFalse(0 == runCommand(new String[] {"-setfacl", "-x", "user:user1:rwx",
+        path}), "setfacl should fail with permissions for -x");
+    assertFalse(0 == runCommand(new String[] {"-setfacl", "-m", "", path}),
+        "setfacl should fail ACL spec missing");
   }
   }
 
 
   @Test
   @Test
@@ -101,9 +97,8 @@ public class TestAclCommands {
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
     }
     }
     assertTrue(parsedList.size() == 0);
     assertTrue(parsedList.size() == 0);
-    assertFalse("setfacl should fail with less arguments",
-        0 == runCommand(new String[] { "-setfacl", "-m", "user:user1:",
-            "/path" }));
+    assertFalse(0 == runCommand(new String[]{"-setfacl", "-m", "user:user1:",
+        "/path"}), "setfacl should fail with less arguments");
   }
   }
 
 
   @Test
   @Test
@@ -129,7 +124,7 @@ public class TestAclCommands {
     expectedList.add(user2Acl);
     expectedList.add(user2Acl);
     expectedList.add(group1Acl);
     expectedList.add(group1Acl);
     expectedList.add(defaultAcl);
     expectedList.add(defaultAcl);
-    assertEquals("Parsed Acl not correct", expectedList, parsedList);
+    assertEquals(expectedList, parsedList, "Parsed Acl not correct");
   }
   }
 
 
   @Test
   @Test
@@ -160,7 +155,7 @@ public class TestAclCommands {
     expectedList.add(other);
     expectedList.add(other);
     expectedList.add(defaultUser);
     expectedList.add(defaultUser);
     expectedList.add(defaultMask);
     expectedList.add(defaultMask);
-    assertEquals("Parsed Acl not correct", expectedList, parsedList);
+    assertEquals(expectedList, parsedList, "Parsed Acl not correct");
   }
   }
 
 
   @Test
   @Test
@@ -169,8 +164,8 @@ public class TestAclCommands {
     conf.set(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY, "stubfs:///");
     conf.set(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY, "stubfs:///");
     conf.setClass("fs.stubfs.impl", StubFileSystem.class, FileSystem.class);
     conf.setClass("fs.stubfs.impl", StubFileSystem.class, FileSystem.class);
     conf.setBoolean("stubfs.noRpcForGetAclStatus", true);
     conf.setBoolean("stubfs.noRpcForGetAclStatus", true);
-    assertEquals("ls must succeed even if getAclStatus RPC does not exist.",
-      0, ToolRunner.run(conf, new FsShell(), new String[] { "-ls", "/" }));
+    assertEquals(0, ToolRunner.run(conf, new FsShell(), new String[]{"-ls", "/"}),
+        "ls must succeed even if getAclStatus RPC does not exist.");
   }
   }
 
 
   @Test
   @Test
@@ -178,8 +173,8 @@ public class TestAclCommands {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     conf.set(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY, "stubfs:///");
     conf.set(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY, "stubfs:///");
     conf.setClass("fs.stubfs.impl", StubFileSystem.class, FileSystem.class);
     conf.setClass("fs.stubfs.impl", StubFileSystem.class, FileSystem.class);
-    assertEquals("ls must succeed even if FileSystem does not implement ACLs.",
-      0, ToolRunner.run(conf, new FsShell(), new String[] { "-ls", "/" }));
+    assertEquals(0, ToolRunner.run(conf, new FsShell(), new String[]{"-ls", "/"}),
+        "ls must succeed even if FileSystem does not implement ACLs.");
   }
   }
 
 
   public static class StubFileSystem extends FileSystem {
   public static class StubFileSystem extends FileSystem {

+ 7 - 4
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCommandFactory.java

@@ -18,11 +18,14 @@
 
 
 package org.apache.hadoop.fs.shell;
 package org.apache.hadoop.fs.shell;
 
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 public class TestCommandFactory {
 public class TestCommandFactory {
   static CommandFactory factory;
   static CommandFactory factory;
@@ -31,7 +34,7 @@ public class TestCommandFactory {
   static void registerCommands(CommandFactory factory) {
   static void registerCommands(CommandFactory factory) {
   }
   }
   
   
-  @Before
+  @BeforeEach
   public void testSetup() {
   public void testSetup() {
     factory = new CommandFactory(conf);
     factory = new CommandFactory(conf);
     assertNotNull(factory);
     assertNotNull(factory);

+ 19 - 7
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCopy.java

@@ -19,8 +19,20 @@
 package org.apache.hadoop.fs.shell;
 package org.apache.hadoop.fs.shell;
 
 
 import static org.apache.hadoop.test.GenericTestUtils.assertExceptionContains;
 import static org.apache.hadoop.test.GenericTestUtils.assertExceptionContains;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyBoolean;
+import static org.mockito.Mockito.anyInt;
+import static org.mockito.Mockito.anyLong;
+import static org.mockito.Mockito.anyShort;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.reset;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStream;
@@ -37,9 +49,9 @@ import org.apache.hadoop.fs.FilterFileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.shell.CopyCommands.Put;
 import org.apache.hadoop.fs.shell.CopyCommands.Put;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.mockito.stubbing.OngoingStubbing;
 import org.mockito.stubbing.OngoingStubbing;
 
 
 public class TestCopy {
 public class TestCopy {
@@ -51,7 +63,7 @@ public class TestCopy {
   static PathData target;
   static PathData target;
   static FileStatus fileStat;
   static FileStatus fileStat;
   
   
-  @BeforeClass
+  @BeforeAll
   public static void setup() throws IOException {
   public static void setup() throws IOException {
     conf = new Configuration();
     conf = new Configuration();
     conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
     conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
@@ -60,7 +72,7 @@ public class TestCopy {
     when(fileStat.isDirectory()).thenReturn(false);
     when(fileStat.isDirectory()).thenReturn(false);
   }
   }
   
   
-  @Before
+  @BeforeEach
   public void resetMock() throws IOException {
   public void resetMock() throws IOException {
     reset(mockFs);
     reset(mockFs);
     target = new PathData(path.toString(), conf);
     target = new PathData(path.toString(), conf);

+ 20 - 16
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCopyFromLocal.java

@@ -21,11 +21,11 @@ import java.io.IOException;
 import java.util.LinkedList;
 import java.util.LinkedList;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.ThreadPoolExecutor;
 
 
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.RandomUtils;
 import org.apache.commons.lang3.RandomUtils;
@@ -37,7 +37,8 @@ import org.apache.hadoop.fs.LocalFileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.shell.CopyCommands.CopyFromLocal;
 import org.apache.hadoop.fs.shell.CopyCommands.CopyFromLocal;
 
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
 /**
  * Test for copyFromLocal.
  * Test for copyFromLocal.
@@ -82,7 +83,7 @@ public class TestCopyFromLocal {
     return numTotalFiles;
     return numTotalFiles;
   }
   }
 
 
-  @BeforeClass
+  @BeforeAll
   public static void init() throws Exception {
   public static void init() throws Exception {
     conf = new Configuration(false);
     conf = new Configuration(false);
     conf.set("fs.file.impl", LocalFileSystem.class.getName());
     conf.set("fs.file.impl", LocalFileSystem.class.getName());
@@ -95,13 +96,13 @@ public class TestCopyFromLocal {
     fs.setWorkingDirectory(testDir);
     fs.setWorkingDirectory(testDir);
   }
   }
 
 
-  @AfterClass
+  @AfterAll
   public static void cleanup() throws Exception {
   public static void cleanup() throws Exception {
     fs.delete(testDir, true);
     fs.delete(testDir, true);
     fs.close();
     fs.close();
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void initDirectory() throws Exception {
   public void initDirectory() throws Exception {
     dir = new Path("dir" + RandomStringUtils.randomNumeric(4));
     dir = new Path("dir" + RandomStringUtils.randomNumeric(4));
     numFiles = initialize(dir);
     numFiles = initialize(dir);
@@ -113,14 +114,16 @@ public class TestCopyFromLocal {
     assertEquals(0, cmd.run(args));
     assertEquals(0, cmd.run(args));
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCopyFromLocal() {
   public void testCopyFromLocal() {
     run(new TestMultiThreadedCopy(1, 0),
     run(new TestMultiThreadedCopy(1, 0),
         new Path(dir, FROM_DIR_NAME).toString(),
         new Path(dir, FROM_DIR_NAME).toString(),
         new Path(dir, TO_DIR_NAME).toString());
         new Path(dir, TO_DIR_NAME).toString());
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCopyFromLocalWithThreads(){
   public void testCopyFromLocalWithThreads(){
     int threads = Runtime.getRuntime().availableProcessors() * 2 + 1;
     int threads = Runtime.getRuntime().availableProcessors() * 2 + 1;
     run(new TestMultiThreadedCopy(threads, numFiles),
     run(new TestMultiThreadedCopy(threads, numFiles),
@@ -129,7 +132,8 @@ public class TestCopyFromLocal {
         new Path(dir, TO_DIR_NAME).toString());
         new Path(dir, TO_DIR_NAME).toString());
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCopyFromLocalWithThreadWrong(){
   public void testCopyFromLocalWithThreadWrong(){
     run(new TestMultiThreadedCopy(1, 0), "-t", "0",
     run(new TestMultiThreadedCopy(1, 0), "-t", "0",
         new Path(dir, FROM_DIR_NAME).toString(),
         new Path(dir, FROM_DIR_NAME).toString(),
@@ -150,7 +154,7 @@ public class TestCopyFromLocal {
     protected void processArguments(LinkedList<PathData> args)
     protected void processArguments(LinkedList<PathData> args)
         throws IOException {
         throws IOException {
       // Check if the correct number of threads are spawned
       // Check if the correct number of threads are spawned
-      Assert.assertEquals(expectedThreads, getThreadCount());
+      assertEquals(expectedThreads, getThreadCount());
       super.processArguments(args);
       super.processArguments(args);
 
 
       if (isMultiThreadNecessary(args)) {
       if (isMultiThreadNecessary(args)) {
@@ -159,10 +163,10 @@ public class TestCopyFromLocal {
         // 2) There are no active tasks in the executor
         // 2) There are no active tasks in the executor
         // 3) Executor has shutdown correctly
         // 3) Executor has shutdown correctly
         ThreadPoolExecutor executor = getExecutor();
         ThreadPoolExecutor executor = getExecutor();
-        Assert.assertEquals(expectedCompletedTaskCount,
+        assertEquals(expectedCompletedTaskCount,
             executor.getCompletedTaskCount());
             executor.getCompletedTaskCount());
-        Assert.assertEquals(0, executor.getActiveCount());
-        Assert.assertTrue(executor.isTerminated());
+        assertEquals(0, executor.getActiveCount());
+        assertTrue(executor.isTerminated());
       } else {
       } else {
         assert getExecutor() == null;
         assert getExecutor() == null;
       }
       }

+ 44 - 25
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCopyPreserveFlag.java

@@ -19,9 +19,10 @@ package org.apache.hadoop.fs.shell;
 
 
 import java.io.IOException;
 import java.io.IOException;
 
 
-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.junit.jupiter.api.Timeout;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FSDataOutputStream;
@@ -37,8 +38,8 @@ import org.apache.hadoop.fs.shell.CopyCommands.Cp;
 import org.apache.hadoop.fs.shell.CopyCommands.Get;
 import org.apache.hadoop.fs.shell.CopyCommands.Get;
 import org.apache.hadoop.fs.shell.CopyCommands.Put;
 import org.apache.hadoop.fs.shell.CopyCommands.Put;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 
 
 public class TestCopyPreserveFlag {
 public class TestCopyPreserveFlag {
   private static final int MODIFICATION_TIME = 12345000;
   private static final int MODIFICATION_TIME = 12345000;
@@ -59,7 +60,7 @@ public class TestCopyPreserveFlag {
   private Path testDir;
   private Path testDir;
   private Configuration conf;
   private Configuration conf;
 
 
-  @Before
+  @BeforeEach
   public void initialize() throws Exception {
   public void initialize() throws Exception {
     conf = new Configuration(false);
     conf = new Configuration(false);
     conf.set("fs.file.impl", LocalFileSystem.class.getName());
     conf.set("fs.file.impl", LocalFileSystem.class.getName());
@@ -86,7 +87,7 @@ public class TestCopyPreserveFlag {
     fs.setTimes(DIR_FROM, MODIFICATION_TIME, ACCESS_TIME);
     fs.setTimes(DIR_FROM, MODIFICATION_TIME, ACCESS_TIME);
   }
   }
 
 
-  @After
+  @AfterEach
   public void cleanup() throws Exception {
   public void cleanup() throws Exception {
     fs.delete(testDir, true);
     fs.delete(testDir, true);
     fs.close();
     fs.close();
@@ -111,19 +112,22 @@ public class TestCopyPreserveFlag {
     assertEquals(0, cmd.run(args));
     assertEquals(0, cmd.run(args));
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testPutWithP() throws Exception {
   public void testPutWithP() throws Exception {
     run(new Put(), "-p", FROM.toString(), TO.toString());
     run(new Put(), "-p", FROM.toString(), TO.toString());
     assertAttributesPreserved(TO);
     assertAttributesPreserved(TO);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testPutWithoutP() throws Exception {
   public void testPutWithoutP() throws Exception {
     run(new Put(), FROM.toString(), TO.toString());
     run(new Put(), FROM.toString(), TO.toString());
     assertAttributesChanged(TO);
     assertAttributesChanged(TO);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testPutWithPQ() throws Exception {
   public void testPutWithPQ() throws Exception {
     Put put = new Put();
     Put put = new Put();
     run(put, "-p", "-q", "100", FROM.toString(), TO.toString());
     run(put, "-p", "-q", "100", FROM.toString(), TO.toString());
@@ -131,7 +135,8 @@ public class TestCopyPreserveFlag {
     assertAttributesPreserved(TO);
     assertAttributesPreserved(TO);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testPutWithQ() throws Exception {
   public void testPutWithQ() throws Exception {
     Put put = new Put();
     Put put = new Put();
     run(put, "-q", "100", FROM.toString(), TO.toString());
     run(put, "-q", "100", FROM.toString(), TO.toString());
@@ -139,7 +144,8 @@ public class TestCopyPreserveFlag {
     assertAttributesChanged(TO);
     assertAttributesChanged(TO);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testPutWithSplCharacter() throws Exception {
   public void testPutWithSplCharacter() throws Exception {
     fs.mkdirs(DIR_FROM_SPL);
     fs.mkdirs(DIR_FROM_SPL);
     fs.createNewFile(FROM_SPL);
     fs.createNewFile(FROM_SPL);
@@ -147,37 +153,43 @@ public class TestCopyPreserveFlag {
     assertAttributesChanged(TO);
     assertAttributesChanged(TO);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCopyFromLocal() throws Exception {
   public void testCopyFromLocal() throws Exception {
     run(new CopyFromLocal(), FROM.toString(), TO.toString());
     run(new CopyFromLocal(), FROM.toString(), TO.toString());
     assertAttributesChanged(TO);
     assertAttributesChanged(TO);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCopyFromLocalWithThreads() throws Exception {
   public void testCopyFromLocalWithThreads() throws Exception {
     run(new CopyFromLocal(), "-t", "10", FROM.toString(), TO.toString());
     run(new CopyFromLocal(), "-t", "10", FROM.toString(), TO.toString());
     assertAttributesChanged(TO);
     assertAttributesChanged(TO);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCopyFromLocalWithThreadsPreserve() throws Exception {
   public void testCopyFromLocalWithThreadsPreserve() throws Exception {
     run(new CopyFromLocal(), "-p", "-t", "10", FROM.toString(), TO.toString());
     run(new CopyFromLocal(), "-p", "-t", "10", FROM.toString(), TO.toString());
     assertAttributesPreserved(TO);
     assertAttributesPreserved(TO);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testGetWithP() throws Exception {
   public void testGetWithP() throws Exception {
     run(new Get(), "-p", FROM.toString(), TO.toString());
     run(new Get(), "-p", FROM.toString(), TO.toString());
     assertAttributesPreserved(TO);
     assertAttributesPreserved(TO);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testGetWithoutP() throws Exception {
   public void testGetWithoutP() throws Exception {
     run(new Get(), FROM.toString(), TO.toString());
     run(new Get(), FROM.toString(), TO.toString());
     assertAttributesChanged(TO);
     assertAttributesChanged(TO);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testGetWithPQ() throws Exception {
   public void testGetWithPQ() throws Exception {
     Get get = new Get();
     Get get = new Get();
     run(get, "-p", "-q", "100", FROM.toString(), TO.toString());
     run(get, "-p", "-q", "100", FROM.toString(), TO.toString());
@@ -185,7 +197,8 @@ public class TestCopyPreserveFlag {
     assertAttributesPreserved(TO);
     assertAttributesPreserved(TO);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testGetWithQ() throws Exception {
   public void testGetWithQ() throws Exception {
     Get get = new Get();
     Get get = new Get();
     run(get, "-q", "100", FROM.toString(), TO.toString());
     run(get, "-q", "100", FROM.toString(), TO.toString());
@@ -193,37 +206,43 @@ public class TestCopyPreserveFlag {
     assertAttributesChanged(TO);
     assertAttributesChanged(TO);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testGetWithThreads() throws Exception {
   public void testGetWithThreads() throws Exception {
     run(new Get(), "-t", "10", FROM.toString(), TO.toString());
     run(new Get(), "-t", "10", FROM.toString(), TO.toString());
     assertAttributesChanged(TO);
     assertAttributesChanged(TO);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testGetWithThreadsPreserve() throws Exception {
   public void testGetWithThreadsPreserve() throws Exception {
     run(new Get(), "-p", "-t", "10", FROM.toString(), TO.toString());
     run(new Get(), "-p", "-t", "10", FROM.toString(), TO.toString());
     assertAttributesPreserved(TO);
     assertAttributesPreserved(TO);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCpWithP() throws Exception {
   public void testCpWithP() throws Exception {
       run(new Cp(), "-p", FROM.toString(), TO.toString());
       run(new Cp(), "-p", FROM.toString(), TO.toString());
       assertAttributesPreserved(TO);
       assertAttributesPreserved(TO);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCpWithoutP() throws Exception {
   public void testCpWithoutP() throws Exception {
       run(new Cp(), FROM.toString(), TO.toString());
       run(new Cp(), FROM.toString(), TO.toString());
       assertAttributesChanged(TO);
       assertAttributesChanged(TO);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testDirectoryCpWithP() throws Exception {
   public void testDirectoryCpWithP() throws Exception {
     run(new Cp(), "-p", DIR_FROM.toString(), DIR_TO2.toString());
     run(new Cp(), "-p", DIR_FROM.toString(), DIR_TO2.toString());
     assertAttributesPreserved(DIR_TO2);
     assertAttributesPreserved(DIR_TO2);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testDirectoryCpWithoutP() throws Exception {
   public void testDirectoryCpWithoutP() throws Exception {
     run(new Cp(), DIR_FROM.toString(), DIR_TO2.toString());
     run(new Cp(), DIR_FROM.toString(), DIR_TO2.toString());
     assertAttributesChanged(DIR_TO2);
     assertAttributesChanged(DIR_TO2);

+ 27 - 20
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCopyToLocal.java

@@ -21,11 +21,11 @@ import java.io.IOException;
 import java.util.LinkedList;
 import java.util.LinkedList;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.ThreadPoolExecutor;
 
 
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.RandomUtils;
 import org.apache.commons.lang3.RandomUtils;
@@ -38,7 +38,8 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.shell.CopyCommands.CopyToLocal;
 import org.apache.hadoop.fs.shell.CopyCommands.CopyToLocal;
 
 
 import static org.apache.hadoop.fs.shell.CopyCommandWithMultiThread.DEFAULT_QUEUE_SIZE;
 import static org.apache.hadoop.fs.shell.CopyCommandWithMultiThread.DEFAULT_QUEUE_SIZE;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestCopyToLocal {
 public class TestCopyToLocal {
 
 
@@ -81,7 +82,7 @@ public class TestCopyToLocal {
     return numTotalFiles;
     return numTotalFiles;
   }
   }
 
 
-  @BeforeClass
+  @BeforeAll
   public static void init() throws Exception {
   public static void init() throws Exception {
     conf = new Configuration(false);
     conf = new Configuration(false);
     conf.set("fs.file.impl", LocalFileSystem.class.getName());
     conf.set("fs.file.impl", LocalFileSystem.class.getName());
@@ -94,7 +95,7 @@ public class TestCopyToLocal {
     fs.setWorkingDirectory(testDir);
     fs.setWorkingDirectory(testDir);
   }
   }
 
 
-  @AfterClass
+  @AfterAll
   public static void cleanup() throws Exception {
   public static void cleanup() throws Exception {
     fs.delete(testDir, true);
     fs.delete(testDir, true);
     fs.close();
     fs.close();
@@ -105,13 +106,14 @@ public class TestCopyToLocal {
     assertEquals(0, cmd.run(args));
     assertEquals(0, cmd.run(args));
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void initDirectory() throws Exception {
   public void initDirectory() throws Exception {
     dir = new Path("dir" + RandomStringUtils.randomNumeric(4));
     dir = new Path("dir" + RandomStringUtils.randomNumeric(4));
     numFiles = initialize(dir);
     numFiles = initialize(dir);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCopy() throws Exception {
   public void testCopy() throws Exception {
     MultiThreadedCopy copy = new MultiThreadedCopy(1, DEFAULT_QUEUE_SIZE, 0);
     MultiThreadedCopy copy = new MultiThreadedCopy(1, DEFAULT_QUEUE_SIZE, 0);
     run(copy, new Path(dir, FROM_DIR_NAME).toString(),
     run(copy, new Path(dir, FROM_DIR_NAME).toString(),
@@ -119,21 +121,24 @@ public class TestCopyToLocal {
     assert copy.getExecutor() == null;
     assert copy.getExecutor() == null;
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCopyWithThreads() {
   public void testCopyWithThreads() {
     run(new MultiThreadedCopy(5, DEFAULT_QUEUE_SIZE, numFiles), "-t", "5",
     run(new MultiThreadedCopy(5, DEFAULT_QUEUE_SIZE, numFiles), "-t", "5",
         new Path(dir, FROM_DIR_NAME).toString(),
         new Path(dir, FROM_DIR_NAME).toString(),
         new Path(dir, TO_DIR_NAME).toString());
         new Path(dir, TO_DIR_NAME).toString());
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCopyWithThreadWrong() {
   public void testCopyWithThreadWrong() {
     run(new MultiThreadedCopy(1, DEFAULT_QUEUE_SIZE, 0), "-t", "0",
     run(new MultiThreadedCopy(1, DEFAULT_QUEUE_SIZE, 0), "-t", "0",
         new Path(dir, FROM_DIR_NAME).toString(),
         new Path(dir, FROM_DIR_NAME).toString(),
         new Path(dir, TO_DIR_NAME).toString());
         new Path(dir, TO_DIR_NAME).toString());
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCopyWithThreadsAndQueueSize() {
   public void testCopyWithThreadsAndQueueSize() {
     int queueSize = 256;
     int queueSize = 256;
     run(new MultiThreadedCopy(5, queueSize, numFiles), "-t", "5", "-q",
     run(new MultiThreadedCopy(5, queueSize, numFiles), "-t", "5", "-q",
@@ -142,7 +147,8 @@ public class TestCopyToLocal {
         new Path(dir, TO_DIR_NAME).toString());
         new Path(dir, TO_DIR_NAME).toString());
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCopyWithThreadsAndQueueSizeWrong() {
   public void testCopyWithThreadsAndQueueSizeWrong() {
     int queueSize = 0;
     int queueSize = 0;
     run(new MultiThreadedCopy(5, DEFAULT_QUEUE_SIZE, numFiles), "-t", "5", "-q",
     run(new MultiThreadedCopy(5, DEFAULT_QUEUE_SIZE, numFiles), "-t", "5", "-q",
@@ -151,7 +157,8 @@ public class TestCopyToLocal {
         new Path(dir, TO_DIR_NAME).toString());
         new Path(dir, TO_DIR_NAME).toString());
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCopySingleFile() throws Exception {
   public void testCopySingleFile() throws Exception {
     Path fromDirPath = new Path(dir, FROM_DIR_NAME);
     Path fromDirPath = new Path(dir, FROM_DIR_NAME);
     Path subFile = new Path(fromDirPath, "file0");
     Path subFile = new Path(fromDirPath, "file0");
@@ -186,9 +193,9 @@ public class TestCopyToLocal {
     protected void processArguments(LinkedList<PathData> args)
     protected void processArguments(LinkedList<PathData> args)
         throws IOException {
         throws IOException {
       // Check if the number of threads are same as expected
       // Check if the number of threads are same as expected
-      Assert.assertEquals(expectedThreads, getThreadCount());
+      assertEquals(expectedThreads, getThreadCount());
       // Check if the queue pool size of executor is same as expected
       // Check if the queue pool size of executor is same as expected
-      Assert.assertEquals(expectedQueuePoolSize, getThreadPoolQueueSize());
+      assertEquals(expectedQueuePoolSize, getThreadPoolQueueSize());
 
 
       super.processArguments(args);
       super.processArguments(args);
 
 
@@ -198,10 +205,10 @@ public class TestCopyToLocal {
         // 2) There are no active tasks in the executor
         // 2) There are no active tasks in the executor
         // 3) Executor has shutdown correctly
         // 3) Executor has shutdown correctly
         ThreadPoolExecutor executor = getExecutor();
         ThreadPoolExecutor executor = getExecutor();
-        Assert.assertEquals(expectedCompletedTaskCount,
+        assertEquals(expectedCompletedTaskCount,
             executor.getCompletedTaskCount());
             executor.getCompletedTaskCount());
-        Assert.assertEquals(0, executor.getActiveCount());
-        Assert.assertTrue(executor.isTerminated());
+        assertEquals(0, executor.getActiveCount());
+        assertTrue(executor.isTerminated());
       } else {
       } else {
         assert getExecutor() == null;
         assert getExecutor() == null;
       }
       }

+ 21 - 13
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCount.java

@@ -17,8 +17,16 @@
  */
  */
 package org.apache.hadoop.fs.shell;
 package org.apache.hadoop.fs.shell;
 
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.reset;
 
 
 import java.io.PrintStream;
 import java.io.PrintStream;
 import java.io.IOException;
 import java.io.IOException;
@@ -35,9 +43,9 @@ import org.apache.hadoop.fs.StorageType;
 import org.apache.hadoop.fs.ContentSummary;
 import org.apache.hadoop.fs.ContentSummary;
 import org.apache.hadoop.fs.FilterFileSystem;
 import org.apache.hadoop.fs.FilterFileSystem;
 import org.apache.hadoop.fs.shell.CommandFormat.NotEnoughArgumentsException;
 import org.apache.hadoop.fs.shell.CommandFormat.NotEnoughArgumentsException;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
 
 
 /**
 /**
  * JUnit test class for {@link org.apache.hadoop.fs.shell.Count}
  * JUnit test class for {@link org.apache.hadoop.fs.shell.Count}
@@ -53,7 +61,7 @@ public class TestCount {
   private static FileSystem mockFs;
   private static FileSystem mockFs;
   private static FileStatus fileStat;
   private static FileStatus fileStat;
 
 
-  @BeforeClass
+  @BeforeAll
   public static void setup() {
   public static void setup() {
     conf = new Configuration();
     conf = new Configuration();
     conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
     conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
@@ -62,7 +70,7 @@ public class TestCount {
     when(fileStat.isFile()).thenReturn(true);
     when(fileStat.isFile()).thenReturn(true);
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void resetMock() {
   public void resetMock() {
     reset(mockFs);
     reset(mockFs);
   }
   }
@@ -436,7 +444,7 @@ public class TestCount {
     Count count = new Count();
     Count count = new Count();
     String actual = count.getCommandName();
     String actual = count.getCommandName();
     String expected = "count";
     String expected = "count";
-    assertEquals("Count.getCommandName", expected, actual);
+    assertEquals(expected, actual, "Count.getCommandName");
   }
   }
 
 
   @Test
   @Test
@@ -444,7 +452,7 @@ public class TestCount {
     Count count = new Count();
     Count count = new Count();
     boolean actual = count.isDeprecated();
     boolean actual = count.isDeprecated();
     boolean expected = false;
     boolean expected = false;
-    assertEquals("Count.isDeprecated", expected, actual);
+    assertEquals(expected, actual, "Count.isDeprecated");
   }
   }
 
 
   @Test
   @Test
@@ -452,7 +460,7 @@ public class TestCount {
     Count count = new Count();
     Count count = new Count();
     String actual = count.getReplacementCommand();
     String actual = count.getReplacementCommand();
     String expected = null;
     String expected = null;
-    assertEquals("Count.getReplacementCommand", expected, actual);
+    assertEquals(expected, actual, "Count.getReplacementCommand");
   }
   }
 
 
   @Test
   @Test
@@ -460,7 +468,7 @@ public class TestCount {
     Count count = new Count();
     Count count = new Count();
     String actual = count.getName();
     String actual = count.getName();
     String expected = "count";
     String expected = "count";
-    assertEquals("Count.getName", expected, actual);
+    assertEquals(expected, actual, "Count.getName");
   }
   }
 
 
   @Test
   @Test
@@ -470,7 +478,7 @@ public class TestCount {
     String expected =
     String expected =
         "-count [-q] [-h] [-v] [-t [<storage type>]]"
         "-count [-q] [-h] [-v] [-t [<storage type>]]"
         + " [-u] [-x] [-e] [-s] <path> ...";
         + " [-u] [-x] [-e] [-s] <path> ...";
-    assertEquals("Count.getUsage", expected, actual);
+    assertEquals(expected, actual, "Count.getUsage");
   }
   }
 
 
   // check the correct description is returned
   // check the correct description is returned
@@ -504,7 +512,7 @@ public class TestCount {
         + "The -e option shows the erasure coding policy."
         + "The -e option shows the erasure coding policy."
         + "The -s option shows snapshot counts.";
         + "The -s option shows snapshot counts.";
 
 
-    assertEquals("Count.getDescription", expected, actual);
+    assertEquals(expected, actual, "Count.getDescription");
   }
   }
 
 
   @Test
   @Test

+ 27 - 20
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestCpCommand.java

@@ -21,11 +21,11 @@ import java.io.IOException;
 import java.util.LinkedList;
 import java.util.LinkedList;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.ThreadPoolExecutor;
 
 
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.RandomUtils;
 import org.apache.commons.lang3.RandomUtils;
@@ -38,7 +38,8 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.shell.CopyCommands.Cp;
 import org.apache.hadoop.fs.shell.CopyCommands.Cp;
 
 
 import static org.apache.hadoop.fs.shell.CopyCommandWithMultiThread.DEFAULT_QUEUE_SIZE;
 import static org.apache.hadoop.fs.shell.CopyCommandWithMultiThread.DEFAULT_QUEUE_SIZE;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 public class TestCpCommand {
 public class TestCpCommand {
 
 
@@ -81,7 +82,7 @@ public class TestCpCommand {
     return numTotalFiles;
     return numTotalFiles;
   }
   }
 
 
-  @BeforeClass
+  @BeforeAll
   public static void init() throws Exception {
   public static void init() throws Exception {
     conf = new Configuration(false);
     conf = new Configuration(false);
     conf.set("fs.file.impl", LocalFileSystem.class.getName());
     conf.set("fs.file.impl", LocalFileSystem.class.getName());
@@ -94,7 +95,7 @@ public class TestCpCommand {
     fs.setWorkingDirectory(testDir);
     fs.setWorkingDirectory(testDir);
   }
   }
 
 
-  @AfterClass
+  @AfterAll
   public static void cleanup() throws Exception {
   public static void cleanup() throws Exception {
     fs.delete(testDir, true);
     fs.delete(testDir, true);
     fs.close();
     fs.close();
@@ -105,13 +106,14 @@ public class TestCpCommand {
     assertEquals(0, cmd.run(args));
     assertEquals(0, cmd.run(args));
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void initDirectory() throws Exception {
   public void initDirectory() throws Exception {
     dir = new Path("dir" + RandomStringUtils.randomNumeric(4));
     dir = new Path("dir" + RandomStringUtils.randomNumeric(4));
     numFiles = initialize(dir);
     numFiles = initialize(dir);
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCp() throws Exception {
   public void testCp() throws Exception {
     MultiThreadedCp copy = new MultiThreadedCp(1, DEFAULT_QUEUE_SIZE, 0);
     MultiThreadedCp copy = new MultiThreadedCp(1, DEFAULT_QUEUE_SIZE, 0);
     run(copy, new Path(dir, FROM_DIR_NAME).toString(),
     run(copy, new Path(dir, FROM_DIR_NAME).toString(),
@@ -119,21 +121,24 @@ public class TestCpCommand {
     assert copy.getExecutor() == null;
     assert copy.getExecutor() == null;
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCpWithThreads() {
   public void testCpWithThreads() {
     run(new MultiThreadedCp(5, DEFAULT_QUEUE_SIZE, numFiles), "-t", "5",
     run(new MultiThreadedCp(5, DEFAULT_QUEUE_SIZE, numFiles), "-t", "5",
         new Path(dir, FROM_DIR_NAME).toString(),
         new Path(dir, FROM_DIR_NAME).toString(),
         new Path(dir, TO_DIR_NAME).toString());
         new Path(dir, TO_DIR_NAME).toString());
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCpWithThreadWrong() {
   public void testCpWithThreadWrong() {
     run(new MultiThreadedCp(1, DEFAULT_QUEUE_SIZE, 0), "-t", "0",
     run(new MultiThreadedCp(1, DEFAULT_QUEUE_SIZE, 0), "-t", "0",
         new Path(dir, FROM_DIR_NAME).toString(),
         new Path(dir, FROM_DIR_NAME).toString(),
         new Path(dir, TO_DIR_NAME).toString());
         new Path(dir, TO_DIR_NAME).toString());
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCpWithThreadsAndQueueSize() {
   public void testCpWithThreadsAndQueueSize() {
     int queueSize = 256;
     int queueSize = 256;
     run(new MultiThreadedCp(5, queueSize, numFiles), "-t", "5", "-q",
     run(new MultiThreadedCp(5, queueSize, numFiles), "-t", "5", "-q",
@@ -142,7 +147,8 @@ public class TestCpCommand {
         new Path(dir, TO_DIR_NAME).toString());
         new Path(dir, TO_DIR_NAME).toString());
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCpWithThreadsAndQueueSizeWrong() {
   public void testCpWithThreadsAndQueueSizeWrong() {
     int queueSize = 0;
     int queueSize = 0;
     run(new MultiThreadedCp(5, DEFAULT_QUEUE_SIZE, numFiles), "-t", "5", "-q",
     run(new MultiThreadedCp(5, DEFAULT_QUEUE_SIZE, numFiles), "-t", "5", "-q",
@@ -151,7 +157,8 @@ public class TestCpCommand {
         new Path(dir, TO_DIR_NAME).toString());
         new Path(dir, TO_DIR_NAME).toString());
   }
   }
 
 
-  @Test(timeout = 10000)
+  @Test
+  @Timeout(value = 10)
   public void testCpSingleFile() throws Exception {
   public void testCpSingleFile() throws Exception {
     Path fromDirPath = new Path(dir, FROM_DIR_NAME);
     Path fromDirPath = new Path(dir, FROM_DIR_NAME);
     Path subFile = new Path(fromDirPath, "file0");
     Path subFile = new Path(fromDirPath, "file0");
@@ -186,9 +193,9 @@ public class TestCpCommand {
     protected void processArguments(LinkedList<PathData> args)
     protected void processArguments(LinkedList<PathData> args)
         throws IOException {
         throws IOException {
       // Check if the number of threads are same as expected
       // Check if the number of threads are same as expected
-      Assert.assertEquals(expectedThreads, getThreadCount());
+      assertEquals(expectedThreads, getThreadCount());
       // Check if the queue pool size of executor is same as expected
       // Check if the queue pool size of executor is same as expected
-      Assert.assertEquals(expectedQueuePoolSize, getThreadPoolQueueSize());
+      assertEquals(expectedQueuePoolSize, getThreadPoolQueueSize());
 
 
       super.processArguments(args);
       super.processArguments(args);
 
 
@@ -198,10 +205,10 @@ public class TestCpCommand {
         // 2) There are no active tasks in the executor
         // 2) There are no active tasks in the executor
         // 3) Executor has shutdown correctly
         // 3) Executor has shutdown correctly
         ThreadPoolExecutor executor = getExecutor();
         ThreadPoolExecutor executor = getExecutor();
-        Assert.assertEquals(expectedCompletedTaskCount,
+        assertEquals(expectedCompletedTaskCount,
             executor.getCompletedTaskCount());
             executor.getCompletedTaskCount());
-        Assert.assertEquals(0, executor.getActiveCount());
-        Assert.assertTrue(executor.isTerminated());
+        assertEquals(0, executor.getActiveCount());
+        assertTrue(executor.isTerminated());
       } else {
       } else {
         assert getExecutor() == null;
         assert getExecutor() == null;
       }
       }

+ 43 - 31
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestLs.java

@@ -19,9 +19,17 @@ package org.apache.hadoop.fs.shell;
 
 
 import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY;
 import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY;
 import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SHELL_MISSING_DEFAULT_FS_WARNING_KEY;
 import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SHELL_MISSING_DEFAULT_FS_WARNING_KEY;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.reset;
 
 
 import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.IOException;
@@ -41,9 +49,9 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.AclEntry;
 import org.apache.hadoop.fs.permission.AclEntry;
 import org.apache.hadoop.fs.permission.AclStatus;
 import org.apache.hadoop.fs.permission.AclStatus;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.FsPermission;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.mockito.InOrder;
 import org.mockito.InOrder;
 
 
 /**
 /**
@@ -56,7 +64,7 @@ public class TestLs {
 
 
   private static final Date NOW = new Date();
   private static final Date NOW = new Date();
 
 
-  @BeforeClass
+  @BeforeAll
   public static void setup() throws IOException {
   public static void setup() throws IOException {
     conf = new Configuration();
     conf = new Configuration();
     conf.set(FS_DEFAULT_NAME_KEY, "mockfs:///");
     conf.set(FS_DEFAULT_NAME_KEY, "mockfs:///");
@@ -64,7 +72,7 @@ public class TestLs {
     mockFs = mock(FileSystem.class);
     mockFs = mock(FileSystem.class);
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void resetMock() throws IOException, URISyntaxException {
   public void resetMock() throws IOException, URISyntaxException {
     reset(mockFs);
     reset(mockFs);
     AclStatus mockAclStatus = mock(AclStatus.class);
     AclStatus mockAclStatus = mock(AclStatus.class);
@@ -1113,7 +1121,7 @@ public class TestLs {
     Ls ls = new Ls();
     Ls ls = new Ls();
     boolean actual = ls.isDeprecated();
     boolean actual = ls.isDeprecated();
     boolean expected = false;
     boolean expected = false;
-    assertEquals("Ls.isDeprecated", expected, actual);
+    assertEquals(expected, actual, "Ls.isDeprecated");
   }
   }
 
 
   // check there's no replacement command
   // check there's no replacement command
@@ -1122,7 +1130,7 @@ public class TestLs {
     Ls ls = new Ls();
     Ls ls = new Ls();
     String actual = ls.getReplacementCommand();
     String actual = ls.getReplacementCommand();
     String expected = null;
     String expected = null;
-    assertEquals("Ls.getReplacementCommand", expected, actual);
+    assertEquals(expected, actual, "Ls.getReplacementCommand");
   }
   }
 
 
   // check the correct name is returned
   // check the correct name is returned
@@ -1131,36 +1139,40 @@ public class TestLs {
     Ls ls = new Ls();
     Ls ls = new Ls();
     String actual = ls.getName();
     String actual = ls.getName();
     String expected = "ls";
     String expected = "ls";
-    assertEquals("Ls.getName", expected, actual);
+    assertEquals(expected, actual, "Ls.getName");
   }
   }
 
 
-  @Test(expected = UnsupportedOperationException.class)
+  @Test
   public void processPathFileDisplayECPolicyWhenUnsupported()
   public void processPathFileDisplayECPolicyWhenUnsupported()
       throws IOException {
       throws IOException {
-    TestFile testFile = new TestFile("testDirectory", "testFile");
-    LinkedList<PathData> pathData = new LinkedList<PathData>();
-    pathData.add(testFile.getPathData());
-    Ls ls = new Ls();
-    LinkedList<String> options = new LinkedList<String>();
-    options.add("-e");
-    ls.processOptions(options);
-    ls.processArguments(pathData);
+    assertThrows(UnsupportedOperationException.class, ()->{
+      TestFile testFile = new TestFile("testDirectory", "testFile");
+      LinkedList<PathData> pathData = new LinkedList<PathData>();
+      pathData.add(testFile.getPathData());
+      Ls ls = new Ls();
+      LinkedList<String> options = new LinkedList<String>();
+      options.add("-e");
+      ls.processOptions(options);
+      ls.processArguments(pathData);
+    });
   }
   }
 
 
-  @Test(expected = UnsupportedOperationException.class)
+  @Test
   public void processPathDirDisplayECPolicyWhenUnsupported()
   public void processPathDirDisplayECPolicyWhenUnsupported()
       throws IOException {
       throws IOException {
-    TestFile testFile = new TestFile("testDirectory", "testFile");
-    TestFile testDir = new TestFile("", "testDirectory");
-    testDir.setIsDir(true);
-    testDir.addContents(testFile);
-    LinkedList<PathData> pathData = new LinkedList<PathData>();
-    pathData.add(testDir.getPathData());
-    Ls ls = new Ls();
-    LinkedList<String> options = new LinkedList<String>();
-    options.add("-e");
-    ls.processOptions(options);
-    ls.processArguments(pathData);
+    assertThrows(UnsupportedOperationException.class, () -> {
+      TestFile testFile = new TestFile("testDirectory", "testFile");
+      TestFile testDir = new TestFile("", "testDirectory");
+      testDir.setIsDir(true);
+      testDir.addContents(testFile);
+      LinkedList<PathData> pathData = new LinkedList<PathData>();
+      pathData.add(testDir.getPathData());
+      Ls ls = new Ls();
+      LinkedList<String> options = new LinkedList<String>();
+      options.add("-e");
+      ls.processOptions(options);
+      ls.processArguments(pathData);
+    });
   }
   }
 
 
   // test class representing a file to be listed
   // test class representing a file to be listed

+ 16 - 12
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestMove.java

@@ -18,9 +18,12 @@
 
 
 package org.apache.hadoop.fs.shell;
 package org.apache.hadoop.fs.shell;
 
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.reset;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URI;
@@ -33,22 +36,22 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FilterFileSystem;
 import org.apache.hadoop.fs.FilterFileSystem;
 import org.apache.hadoop.fs.PathExistsException;
 import org.apache.hadoop.fs.PathExistsException;
 import org.apache.hadoop.fs.shell.CommandFormat.UnknownOptionException;
 import org.apache.hadoop.fs.shell.CommandFormat.UnknownOptionException;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 
 public class TestMove {
 public class TestMove {
   static Configuration conf;
   static Configuration conf;
   static FileSystem mockFs;
   static FileSystem mockFs;
  
  
-  @BeforeClass
+  @BeforeAll
   public static void setup() throws IOException, URISyntaxException {
   public static void setup() throws IOException, URISyntaxException {
     mockFs = mock(FileSystem.class);
     mockFs = mock(FileSystem.class);
     conf = new Configuration();
     conf = new Configuration();
     conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
     conf.setClass("fs.mockfs.impl", MockFileSystem.class, FileSystem.class);
   }
   }
     
     
-  @Before
+  @BeforeEach
   public void resetMock() throws IOException {
   public void resetMock() throws IOException {
     reset(mockFs);
     reset(mockFs);
   }
   }
@@ -91,14 +94,15 @@ public class TestMove {
     cmd.run(cmdargs);
     cmd.run(cmdargs);
     
     
     // make sure command failed with the proper exception
     // make sure command failed with the proper exception
-    assertTrue("Rename should have failed with path exists exception",
-                         cmd.error instanceof PathExistsException);
+    assertTrue(cmd.error instanceof PathExistsException,
+        "Rename should have failed with path exists exception");
   }
   }
 
 
-  @Test(expected = UnknownOptionException.class)
+  @Test
   public void testMoveFromLocalDoesNotAllowTOption() {
   public void testMoveFromLocalDoesNotAllowTOption() {
-    new MoveCommands.MoveFromLocal().run("-t", "2",
-        null, null);
+    assertThrows(UnknownOptionException.class, () -> {
+      new MoveCommands.MoveFromLocal().run("-t", "2", null, null);
+    });
   }
   }
     
     
   static class MockFileSystem extends FilterFileSystem {
   static class MockFileSystem extends FilterFileSystem {

+ 37 - 28
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestPathData.java

@@ -18,9 +18,9 @@
 package org.apache.hadoop.fs.shell;
 package org.apache.hadoop.fs.shell;
 
 
 import static org.apache.hadoop.test.PlatformAssumptions.assumeWindows;
 import static org.apache.hadoop.test.PlatformAssumptions.assumeWindows;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
@@ -32,10 +32,10 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.util.Shell;
 import org.apache.hadoop.util.Shell;
-import org.junit.After;
-import org.junit.Assert;
-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.junit.jupiter.api.Timeout;
 
 
 public class TestPathData {
 public class TestPathData {
   private static final String TEST_ROOT_DIR =
   private static final String TEST_ROOT_DIR =
@@ -44,7 +44,7 @@ public class TestPathData {
   protected FileSystem fs;
   protected FileSystem fs;
   protected Path testDir;
   protected Path testDir;
   
   
-  @Before
+  @BeforeEach
   public void initialize() throws Exception {
   public void initialize() throws Exception {
     conf = new Configuration();
     conf = new Configuration();
     fs = FileSystem.getLocal(conf);
     fs = FileSystem.getLocal(conf);
@@ -64,13 +64,14 @@ public class TestPathData {
     fs.create(new Path("d2","f3"));
     fs.create(new Path("d2","f3"));
   }
   }
 
 
-  @After
+  @AfterEach
   public void cleanup() throws Exception {
   public void cleanup() throws Exception {
     fs.delete(testDir, true);
     fs.delete(testDir, true);
     fs.close();
     fs.close();
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testWithDirStringAndConf() throws Exception {
   public void testWithDirStringAndConf() throws Exception {
     String dirString = "d1";
     String dirString = "d1";
     PathData item = new PathData(dirString, conf);
     PathData item = new PathData(dirString, conf);
@@ -83,7 +84,8 @@ public class TestPathData {
     checkPathData(dirString, item);
     checkPathData(dirString, item);
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testUnqualifiedUriContents() throws Exception {
   public void testUnqualifiedUriContents() throws Exception {
     String dirString = "d1";
     String dirString = "d1";
     PathData item = new PathData(dirString, conf);
     PathData item = new PathData(dirString, conf);
@@ -94,7 +96,8 @@ public class TestPathData {
     );
     );
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testQualifiedUriContents() throws Exception {
   public void testQualifiedUriContents() throws Exception {
     String dirString = fs.makeQualified(new Path("d1")).toString();
     String dirString = fs.makeQualified(new Path("d1")).toString();
     PathData item = new PathData(dirString, conf);
     PathData item = new PathData(dirString, conf);
@@ -105,7 +108,8 @@ public class TestPathData {
     );
     );
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testCwdContents() throws Exception {
   public void testCwdContents() throws Exception {
     String dirString = Path.CUR_DIR;
     String dirString = Path.CUR_DIR;
     PathData item = new PathData(dirString, conf);
     PathData item = new PathData(dirString, conf);
@@ -116,7 +120,8 @@ public class TestPathData {
     );
     );
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testToFile() throws Exception {
   public void testToFile() throws Exception {
     PathData item = new PathData(".", conf);
     PathData item = new PathData(".", conf);
     assertEquals(new File(testDir.toString()), item.toFile());
     assertEquals(new File(testDir.toString()), item.toFile());
@@ -126,7 +131,8 @@ public class TestPathData {
     assertEquals(new File(testDir + "/d1/f1"), item.toFile());
     assertEquals(new File(testDir + "/d1/f1"), item.toFile());
   }
   }
 
 
-  @Test (timeout = 5000)
+  @Test
+  @Timeout(value = 5)
   public void testToFileRawWindowsPaths() throws Exception {
   public void testToFileRawWindowsPaths() throws Exception {
     assumeWindows();
     assumeWindows();
 
 
@@ -153,7 +159,8 @@ public class TestPathData {
     assertEquals(new File(testDir + "\\foo\\bar"), item.toFile());
     assertEquals(new File(testDir + "\\foo\\bar"), item.toFile());
   }
   }
 
 
-  @Test (timeout = 5000)
+  @Test
+  @Timeout(value = 5)
   public void testInvalidWindowsPath() throws Exception {
   public void testInvalidWindowsPath() throws Exception {
     assumeWindows();
     assumeWindows();
 
 
@@ -171,7 +178,8 @@ public class TestPathData {
     }
     }
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testAbsoluteGlob() throws Exception {
   public void testAbsoluteGlob() throws Exception {
     PathData[] items = PathData.expandAsGlob(testDir+"/d1/f1*", conf);
     PathData[] items = PathData.expandAsGlob(testDir+"/d1/f1*", conf);
     assertEquals(
     assertEquals(
@@ -199,7 +207,8 @@ public class TestPathData {
     );
     );
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testRelativeGlob() throws Exception {
   public void testRelativeGlob() throws Exception {
     PathData[] items = PathData.expandAsGlob("d1/f1*", conf);
     PathData[] items = PathData.expandAsGlob("d1/f1*", conf);
     assertEquals(
     assertEquals(
@@ -208,7 +217,8 @@ public class TestPathData {
     );
     );
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testRelativeGlobBack() throws Exception {
   public void testRelativeGlobBack() throws Exception {
     fs.setWorkingDirectory(new Path("d1"));
     fs.setWorkingDirectory(new Path("d1"));
     PathData[] items = PathData.expandAsGlob("../d2/*", conf);
     PathData[] items = PathData.expandAsGlob("../d2/*", conf);
@@ -226,7 +236,7 @@ public class TestPathData {
     fs.setPermission(obscuredDir, new FsPermission((short)0)); //no access
     fs.setPermission(obscuredDir, new FsPermission((short)0)); //no access
     try {
     try {
       PathData.expandAsGlob("foo/*", conf);
       PathData.expandAsGlob("foo/*", conf);
-      Assert.fail("Should throw IOException");
+      fail("Should throw IOException");
     } catch (IOException ioe) {
     } catch (IOException ioe) {
       // expected
       // expected
     } finally {
     } finally {
@@ -235,7 +245,8 @@ public class TestPathData {
     }
     }
   }
   }
 
 
-  @Test (timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testWithStringAndConfForBuggyPath() throws Exception {
   public void testWithStringAndConfForBuggyPath() throws Exception {
     String dirString = "file:///tmp";
     String dirString = "file:///tmp";
     Path tmpDir = new Path(dirString);
     Path tmpDir = new Path(dirString);
@@ -249,13 +260,11 @@ public class TestPathData {
   }
   }
 
 
   public void checkPathData(String dirString, PathData item) throws Exception {
   public void checkPathData(String dirString, PathData item) throws Exception {
-    assertEquals("checking fs", fs, item.fs);
-    assertEquals("checking string", dirString, item.toString());
-    assertEquals("checking path",
-        fs.makeQualified(new Path(item.toString())), item.path
-    );
-    assertTrue("checking exist", item.stat != null);
-    assertTrue("checking isDir", item.stat.isDirectory());
+    assertEquals(fs, item.fs, "checking fs");
+    assertEquals(dirString, item.toString(), "checking string");
+    assertEquals(fs.makeQualified(new Path(item.toString())), item.path, "checking path");
+    assertTrue(item.stat != null, "checking exist");
+    assertTrue(item.stat.isDirectory(), "checking isDir");
   }
   }
   
   
   /* junit does a lousy job of comparing arrays
   /* junit does a lousy job of comparing arrays

+ 3 - 3
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestPathExceptions.java

@@ -18,15 +18,15 @@
 
 
 package org.apache.hadoop.fs.shell;
 package org.apache.hadoop.fs.shell;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 import java.io.IOException;
 import java.io.IOException;
 
 
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.PathIOException;
 import org.apache.hadoop.fs.PathIOException;
 import org.apache.hadoop.ipc.RemoteException;
 import org.apache.hadoop.ipc.RemoteException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestPathExceptions {
 public class TestPathExceptions {
 
 

+ 1 - 1
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestPrintableString.java

@@ -18,7 +18,7 @@
 
 
 package org.apache.hadoop.fs.shell;
 package org.apache.hadoop.fs.shell;
 
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThat;
 
 

+ 2 - 2
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestTail.java

@@ -18,12 +18,12 @@
 
 
 package org.apache.hadoop.fs.shell;
 package org.apache.hadoop.fs.shell;
 
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.LinkedList;
 import java.util.LinkedList;
 
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 /**
 /**
  * Test class to verify Tail shell command.
  * Test class to verify Tail shell command.

+ 56 - 43
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestTextCommand.java

@@ -19,6 +19,7 @@
 package org.apache.hadoop.fs.shell;
 package org.apache.hadoop.fs.shell;
 
 
 import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_KEY;
 import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_KEY;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 
 import java.io.File;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.FileOutputStream;
@@ -36,7 +37,7 @@ import org.apache.hadoop.io.SequenceFile;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.assertj.core.api.Assertions;
 import org.assertj.core.api.Assertions;
 import org.junit.Rule;
 import org.junit.Rule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.junit.rules.Timeout;
 import org.junit.rules.Timeout;
 
 
 /**
 /**
@@ -95,34 +96,40 @@ public class TestTextCommand {
     Assertions.assertThat(output).describedAs("output").isEmpty();
     Assertions.assertThat(output).describedAs("output").isEmpty();
   }
   }
 
 
-  @Test(expected = NullPointerException.class)
+  @Test
   public void testAvroFileInputStreamNullBuffer() throws Exception {
   public void testAvroFileInputStreamNullBuffer() throws Exception {
-    createFile(AVRO_FILENAME, generateWeatherAvroBinaryData());
-    URI uri = new URI(AVRO_FILENAME);
-    Configuration conf = new Configuration();
-    try (InputStream is = getInputStream(uri, conf)) {
-      is.read(null, 0, 10);
-    }
+    assertThrows(NullPointerException.class, () -> {
+      createFile(AVRO_FILENAME, generateWeatherAvroBinaryData());
+      URI uri = new URI(AVRO_FILENAME);
+      Configuration conf = new Configuration();
+      try (InputStream is = getInputStream(uri, conf)) {
+        is.read(null, 0, 10);
+      }
+    });
   }
   }
 
 
-  @Test(expected = IndexOutOfBoundsException.class)
+  @Test
   public void testAvroFileInputStreamNegativePosition() throws Exception {
   public void testAvroFileInputStreamNegativePosition() throws Exception {
-    createFile(AVRO_FILENAME, generateWeatherAvroBinaryData());
-    URI uri = new URI(AVRO_FILENAME);
-    Configuration conf = new Configuration();
-    try (InputStream is = getInputStream(uri, conf)) {
-      is.read(new byte[10], -1, 10);
-    }
+    assertThrows(IndexOutOfBoundsException.class, () -> {
+      createFile(AVRO_FILENAME, generateWeatherAvroBinaryData());
+      URI uri = new URI(AVRO_FILENAME);
+      Configuration conf = new Configuration();
+      try (InputStream is = getInputStream(uri, conf)) {
+        is.read(new byte[10], -1, 10);
+      }
+    });
   }
   }
 
 
-  @Test(expected = IndexOutOfBoundsException.class)
+  @Test
   public void testAvroFileInputStreamTooLong() throws Exception {
   public void testAvroFileInputStreamTooLong() throws Exception {
-    createFile(AVRO_FILENAME, generateWeatherAvroBinaryData());
-    URI uri = new URI(AVRO_FILENAME);
-    Configuration conf = new Configuration();
-    try (InputStream is = getInputStream(uri, conf)) {
-      is.read(new byte[10], 0, 11);
-    }
+    assertThrows(IndexOutOfBoundsException.class, () -> {
+      createFile(AVRO_FILENAME, generateWeatherAvroBinaryData());
+      URI uri = new URI(AVRO_FILENAME);
+      Configuration conf = new Configuration();
+      try (InputStream is = getInputStream(uri, conf)) {
+        is.read(new byte[10], 0, 11);
+      }
+    });
   }
   }
 
 
   @Test
   @Test
@@ -223,34 +230,40 @@ public class TestTextCommand {
     Assertions.assertThat(output).describedAs("output").isEmpty();
     Assertions.assertThat(output).describedAs("output").isEmpty();
   }
   }
 
 
-  @Test(expected = NullPointerException.class)
+  @Test
   public void testSequenceFileInputStreamNullBuffer() throws Exception {
   public void testSequenceFileInputStreamNullBuffer() throws Exception {
-    Configuration conf = new Configuration();
-    createNonWritableSequenceFile(SEQUENCE_FILENAME, conf);
-    URI uri = new URI(SEQUENCE_FILENAME);
-    try (InputStream is = getInputStream(uri, conf)) {
-      is.read(null, 0, 10);
-    }
+    assertThrows(NullPointerException.class, () -> {
+      Configuration conf = new Configuration();
+      createNonWritableSequenceFile(SEQUENCE_FILENAME, conf);
+      URI uri = new URI(SEQUENCE_FILENAME);
+      try (InputStream is = getInputStream(uri, conf)) {
+        is.read(null, 0, 10);
+      }
+    });
   }
   }
 
 
-  @Test(expected = IndexOutOfBoundsException.class)
+  @Test
   public void testSequenceFileInputStreamNegativePosition() throws Exception {
   public void testSequenceFileInputStreamNegativePosition() throws Exception {
-    Configuration conf = new Configuration();
-    createNonWritableSequenceFile(SEQUENCE_FILENAME, conf);
-    URI uri = new URI(SEQUENCE_FILENAME);
-    try (InputStream is = getInputStream(uri, conf)) {
-      is.read(new byte[10], -1, 10);
-    }
+    assertThrows(IndexOutOfBoundsException.class, () -> {
+      Configuration conf = new Configuration();
+      createNonWritableSequenceFile(SEQUENCE_FILENAME, conf);
+      URI uri = new URI(SEQUENCE_FILENAME);
+      try (InputStream is = getInputStream(uri, conf)) {
+        is.read(new byte[10], -1, 10);
+      }
+    });
   }
   }
 
 
-  @Test(expected = IndexOutOfBoundsException.class)
+  @Test
   public void testSequenceFileInputStreamTooLong() throws Exception {
   public void testSequenceFileInputStreamTooLong() throws Exception {
-    Configuration conf = new Configuration();
-    createNonWritableSequenceFile(SEQUENCE_FILENAME, conf);
-    URI uri = new URI(SEQUENCE_FILENAME);
-    try (InputStream is = getInputStream(uri, conf)) {
-      is.read(new byte[10], 0, 11);
-    }
+    assertThrows(IndexOutOfBoundsException.class, () -> {
+      Configuration conf = new Configuration();
+      createNonWritableSequenceFile(SEQUENCE_FILENAME, conf);
+      URI uri = new URI(SEQUENCE_FILENAME);
+      try (InputStream is = getInputStream(uri, conf)) {
+        is.read(new byte[10], 0, 11);
+      }
+    });
   }
   }
 
 
   @Test
   @Test

+ 21 - 21
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/TestXAttrCommands.java

@@ -17,8 +17,8 @@
  */
  */
 package org.apache.hadoop.fs.shell;
 package org.apache.hadoop.fs.shell;
 
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.IOException;
@@ -27,9 +27,9 @@ import java.io.PrintStream;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FsShell;
 import org.apache.hadoop.fs.FsShell;
 import org.apache.hadoop.util.ToolRunner;
 import org.apache.hadoop.util.ToolRunner;
-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;
 
 
 public class TestXAttrCommands {
 public class TestXAttrCommands {
   private final ByteArrayOutputStream errContent = 
   private final ByteArrayOutputStream errContent = 
@@ -37,7 +37,7 @@ public class TestXAttrCommands {
   private Configuration conf = null;
   private Configuration conf = null;
   private PrintStream initialStdErr;
   private PrintStream initialStdErr;
 
 
-  @Before
+  @BeforeEach
   public void setup() throws IOException {
   public void setup() throws IOException {
     errContent.reset();
     errContent.reset();
     initialStdErr = System.err;
     initialStdErr = System.err;
@@ -45,7 +45,7 @@ public class TestXAttrCommands {
     conf = new Configuration();
     conf = new Configuration();
   }
   }
   
   
-  @After
+  @AfterEach
   public void cleanUp() throws Exception {
   public void cleanUp() throws Exception {
     errContent.reset();
     errContent.reset();
     System.setErr(initialStdErr);
     System.setErr(initialStdErr);
@@ -54,41 +54,41 @@ public class TestXAttrCommands {
   @Test
   @Test
   public void testGetfattrValidations() throws Exception {
   public void testGetfattrValidations() throws Exception {
     errContent.reset();
     errContent.reset();
-    assertFalse("getfattr should fail without path",
-        0 == runCommand(new String[] { "-getfattr", "-d"}));
+    assertFalse(0 == runCommand(new String[]{"-getfattr", "-d"}),
+        "getfattr should fail without path");
     assertTrue(errContent.toString().contains("<path> is missing"));
     assertTrue(errContent.toString().contains("<path> is missing"));
 
 
     errContent.reset();
     errContent.reset();
-    assertFalse("getfattr should fail with extra argument",
-        0 == runCommand(new String[] { "-getfattr", "extra", "-d", "/test"}));
+    assertFalse(0 == runCommand(new String[]{"-getfattr", "extra", "-d", "/test"}),
+        "getfattr should fail with extra argument");
     assertTrue(errContent.toString().contains("Too many arguments"));
     assertTrue(errContent.toString().contains("Too many arguments"));
     
     
     errContent.reset();
     errContent.reset();
-    assertFalse("getfattr should fail without \"-n name\" or \"-d\"",
-        0 == runCommand(new String[] { "-getfattr", "/test"}));
+    assertFalse(0 == runCommand(new String[]{"-getfattr", "/test"}),
+        "getfattr should fail without \"-n name\" or \"-d\"");
     assertTrue(errContent.toString().contains("Must specify '-n name' or '-d' option"));
     assertTrue(errContent.toString().contains("Must specify '-n name' or '-d' option"));
     
     
     errContent.reset();
     errContent.reset();
-    assertFalse("getfattr should fail with invalid encoding",
-        0 == runCommand(new String[] { "-getfattr", "-d", "-e", "aaa", "/test"}));
+    assertFalse(0 == runCommand(new String[]{"-getfattr", "-d", "-e", "aaa", "/test"}),
+        "getfattr should fail with invalid encoding");
     assertTrue(errContent.toString().contains("Invalid/unsupported encoding option specified: aaa"));
     assertTrue(errContent.toString().contains("Invalid/unsupported encoding option specified: aaa"));
   }
   }
 
 
   @Test
   @Test
   public void testSetfattrValidations() throws Exception {
   public void testSetfattrValidations() throws Exception {
     errContent.reset();
     errContent.reset();
-    assertFalse("setfattr should fail without path",
-        0 == runCommand(new String[] { "-setfattr", "-n", "user.a1" }));
+    assertFalse(0 == runCommand(new String[]{"-setfattr", "-n", "user.a1"}),
+        "setfattr should fail without path");
     assertTrue(errContent.toString().contains("<path> is missing"));
     assertTrue(errContent.toString().contains("<path> is missing"));
     
     
     errContent.reset();
     errContent.reset();
-    assertFalse("setfattr should fail with extra arguments",
-        0 == runCommand(new String[] { "-setfattr", "extra", "-n", "user.a1", "/test"}));
+    assertFalse(0 == runCommand(new String[]{"-setfattr", "extra", "-n", "user.a1", "/test"}),
+        "setfattr should fail with extra arguments");
     assertTrue(errContent.toString().contains("Too many arguments"));
     assertTrue(errContent.toString().contains("Too many arguments"));
     
     
     errContent.reset();
     errContent.reset();
-    assertFalse("setfattr should fail without \"-n name\" or \"-x name\"",
-        0 == runCommand(new String[] { "-setfattr", "/test"}));
+    assertFalse(0 == runCommand(new String[]{"-setfattr", "/test"}),
+        "setfattr should fail without \"-n name\" or \"-x name\"");
     assertTrue(errContent.toString().contains("Must specify '-n name' or '-x name' option"));
     assertTrue(errContent.toString().contains("Must specify '-n name' or '-x name' option"));
   }
   }
 
 

+ 8 - 9
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/find/TestAnd.java

@@ -18,24 +18,23 @@
 
 
 package org.apache.hadoop.fs.shell.find;
 package org.apache.hadoop.fs.shell.find;
 
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.Deque;
 import java.util.Deque;
 import java.util.LinkedList;
 import java.util.LinkedList;
-import java.util.concurrent.TimeUnit;
 
 
 import org.apache.hadoop.fs.shell.PathData;
 import org.apache.hadoop.fs.shell.PathData;
-import org.junit.Rule;
-import org.junit.rules.Timeout;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
+@Timeout(10)
 public class TestAnd {
 public class TestAnd {
 
 
-  @Rule
-  public Timeout globalTimeout = new Timeout(10000, TimeUnit.MILLISECONDS);
-
   // test all expressions passing
   // test all expressions passing
   @Test
   @Test
   public void testPass() throws IOException {
   public void testPass() throws IOException {

+ 14 - 11
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/find/TestFilterExpression.java

@@ -17,28 +17,31 @@
  */
  */
 package org.apache.hadoop.fs.shell.find;
 package org.apache.hadoop.fs.shell.find;
 
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.Deque;
 import java.util.Deque;
-import java.util.concurrent.TimeUnit;
 
 
 import org.apache.hadoop.fs.shell.PathData;
 import org.apache.hadoop.fs.shell.PathData;
 
 
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.Timeout;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
+@Timeout(10)
 public class TestFilterExpression {
 public class TestFilterExpression {
   private Expression expr;
   private Expression expr;
   private FilterExpression test;
   private FilterExpression test;
 
 
-  @Rule
-  public Timeout globalTimeout = new Timeout(10000, TimeUnit.MILLISECONDS);
-
-  @Before
+  @BeforeEach
   public void setup() {
   public void setup() {
     expr = mock(Expression.class);
     expr = mock(Expression.class);
     test = new FilterExpression(expr) {
     test = new FilterExpression(expr) {

+ 18 - 11
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/find/TestFind.java

@@ -17,8 +17,19 @@
  */
  */
 package org.apache.hadoop.fs.shell.find;
 package org.apache.hadoop.fs.shell.find;
 
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyInt;
+import static org.mockito.Mockito.eq;
+import static org.mockito.Mockito.inOrder;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.io.PrintStream;
@@ -26,7 +37,6 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.LinkedList;
 import java.util.NoSuchElementException;
 import java.util.NoSuchElementException;
-import java.util.concurrent.TimeUnit;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileStatus;
@@ -39,24 +49,21 @@ import org.apache.hadoop.fs.shell.find.Expression;
 import org.apache.hadoop.fs.shell.find.Find;
 import org.apache.hadoop.fs.shell.find.Find;
 import org.apache.hadoop.fs.shell.find.FindOptions;
 import org.apache.hadoop.fs.shell.find.FindOptions;
 import org.apache.hadoop.fs.shell.find.Result;
 import org.apache.hadoop.fs.shell.find.Result;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.Timeout;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 import org.mockito.InOrder;
 import org.mockito.InOrder;
 import org.mockito.Mockito;
 import org.mockito.Mockito;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
 import org.mockito.stubbing.Answer;
 
 
+@Timeout(10)
 public class TestFind {
 public class TestFind {
 
 
-  @Rule
-  public Timeout timeout = new Timeout(10000, TimeUnit.MILLISECONDS);
-
   private static FileSystem mockFs;
   private static FileSystem mockFs;
   private static Configuration conf;
   private static Configuration conf;
 
 
-  @Before
+  @BeforeEach
   public void setup() throws IOException {
   public void setup() throws IOException {
     mockFs = MockFileSystem.setup();
     mockFs = MockFileSystem.setup();
     conf = mockFs.getConf();
     conf = mockFs.getConf();

+ 6 - 10
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/find/TestIname.java

@@ -17,27 +17,23 @@
  */
  */
 package org.apache.hadoop.fs.shell.find;
 package org.apache.hadoop.fs.shell.find;
 
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.apache.hadoop.fs.shell.find.TestHelper.*;
 import static org.apache.hadoop.fs.shell.find.TestHelper.*;
 
 
 import java.io.IOException;
 import java.io.IOException;
-import java.util.concurrent.TimeUnit;
 
 
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.shell.PathData;
 import org.apache.hadoop.fs.shell.PathData;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.Timeout;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
+@Timeout(10)
 public class TestIname {
 public class TestIname {
   private FileSystem mockFs;
   private FileSystem mockFs;
   private Name.Iname name;
   private Name.Iname name;
 
 
-  @Rule
-  public Timeout globalTimeout = new Timeout(10000, TimeUnit.MILLISECONDS);
-
-  @Before
+  @BeforeEach
   public void resetMock() throws IOException {
   public void resetMock() throws IOException {
     mockFs = MockFileSystem.setup();
     mockFs = MockFileSystem.setup();
   }
   }

+ 6 - 10
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/find/TestName.java

@@ -17,27 +17,23 @@
  */
  */
 package org.apache.hadoop.fs.shell.find;
 package org.apache.hadoop.fs.shell.find;
 
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.apache.hadoop.fs.shell.find.TestHelper.*;
 import static org.apache.hadoop.fs.shell.find.TestHelper.*;
 
 
 import java.io.IOException;
 import java.io.IOException;
-import java.util.concurrent.TimeUnit;
 
 
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.shell.PathData;
 import org.apache.hadoop.fs.shell.PathData;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.Timeout;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
+@Timeout(10)
 public class TestName {
 public class TestName {
   private FileSystem mockFs;
   private FileSystem mockFs;
   private Name name;
   private Name name;
 
 
-  @Rule
-  public Timeout globalTimeout = new Timeout(10000, TimeUnit.MILLISECONDS);
-
-  @Before
+  @BeforeEach
   public void resetMock() throws IOException {
   public void resetMock() throws IOException {
     mockFs = MockFileSystem.setup();
     mockFs = MockFileSystem.setup();
   }
   }

+ 9 - 11
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/find/TestPrint.java

@@ -17,29 +17,27 @@
  */
  */
 package org.apache.hadoop.fs.shell.find;
 package org.apache.hadoop.fs.shell.find;
 
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
 
 
 import java.io.IOException;
 import java.io.IOException;
 
 
 import org.apache.hadoop.fs.shell.PathData;
 import org.apache.hadoop.fs.shell.PathData;
 
 
 import java.io.PrintStream;
 import java.io.PrintStream;
-import java.util.concurrent.TimeUnit;
 
 
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.Timeout;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
+@Timeout(10)
 public class TestPrint {
 public class TestPrint {
   private FileSystem mockFs;
   private FileSystem mockFs;
 
 
-  @Rule
-  public Timeout globalTimeout = new Timeout(10000, TimeUnit.MILLISECONDS);
-
-  @Before
+  @BeforeEach
   public void resetMock() throws IOException {
   public void resetMock() throws IOException {
     mockFs = MockFileSystem.setup();
     mockFs = MockFileSystem.setup();
   }
   }

+ 9 - 12
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/find/TestPrint0.java

@@ -17,29 +17,26 @@
  */
  */
 package org.apache.hadoop.fs.shell.find;
 package org.apache.hadoop.fs.shell.find;
 
 
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
 import java.io.IOException;
 import java.io.IOException;
 
 
 import org.apache.hadoop.fs.shell.PathData;
 import org.apache.hadoop.fs.shell.PathData;
 
 
 import java.io.PrintStream;
 import java.io.PrintStream;
-import java.util.concurrent.TimeUnit;
 
 
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.Timeout;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
+@Timeout(10)
 public class TestPrint0 {
 public class TestPrint0 {
   private FileSystem mockFs;
   private FileSystem mockFs;
 
 
-  @Rule
-  public Timeout globalTimeout = new Timeout(10000, TimeUnit.MILLISECONDS);
-
-  @Before
+  @BeforeEach
   public void resetMock() throws IOException {
   public void resetMock() throws IOException {
     mockFs = MockFileSystem.setup();
     mockFs = MockFileSystem.setup();
   }
   }

+ 2 - 2
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/find/TestResult.java

@@ -17,11 +17,11 @@
  */
  */
 package org.apache.hadoop.fs.shell.find;
 package org.apache.hadoop.fs.shell.find;
 
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 
 
 import org.junit.Rule;
 import org.junit.Rule;
 import org.junit.rules.Timeout;
 import org.junit.rules.Timeout;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeUnit;
 
 

+ 10 - 11
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/store/TestDataBlocks.java

@@ -21,7 +21,7 @@ package org.apache.hadoop.fs.store;
 import java.io.IOException;
 import java.io.IOException;
 import java.util.Random;
 import java.util.Random;
 
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -32,9 +32,9 @@ import org.apache.hadoop.test.LambdaTestUtils;
 import static org.apache.hadoop.fs.store.DataBlocks.DATA_BLOCKS_BUFFER_ARRAY;
 import static org.apache.hadoop.fs.store.DataBlocks.DATA_BLOCKS_BUFFER_ARRAY;
 import static org.apache.hadoop.fs.store.DataBlocks.DATA_BLOCKS_BUFFER_DISK;
 import static org.apache.hadoop.fs.store.DataBlocks.DATA_BLOCKS_BUFFER_DISK;
 import static org.apache.hadoop.fs.store.DataBlocks.DATA_BLOCKS_BYTEBUFFER;
 import static org.apache.hadoop.fs.store.DataBlocks.DATA_BLOCKS_BYTEBUFFER;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
 /**
  * UTs to test {@link DataBlocks} functionalities.
  * UTs to test {@link DataBlocks} functionalities.
@@ -86,13 +86,12 @@ public class TestDataBlocks {
     // Verify DataBlock state is at Writing.
     // Verify DataBlock state is at Writing.
     dataBlock.verifyState(DataBlocks.DataBlock.DestState.Writing);
     dataBlock.verifyState(DataBlocks.DataBlock.DestState.Writing);
     // Verify that the DataBlock has data written.
     // Verify that the DataBlock has data written.
-    assertTrue("Expected Data block to have data", dataBlock.hasData());
+    assertTrue(dataBlock.hasData(), "Expected Data block to have data");
     // Verify the size of data.
     // Verify the size of data.
-    assertEquals("Mismatch in data size in block", ONE_KB,
-        dataBlock.dataSize());
+    assertEquals(ONE_KB, dataBlock.dataSize(), "Mismatch in data size in block");
     // Verify that no capacity is left in the data block to write more.
     // Verify that no capacity is left in the data block to write more.
-    assertFalse("Expected the data block to have no capacity to write 1 byte "
-        + "of data", dataBlock.hasCapacity(1));
+    assertFalse(dataBlock.hasCapacity(1),
+        "Expected the data block to have no capacity to write 1 byte of data");
   }
   }
 
 
   /**
   /**
@@ -110,8 +109,8 @@ public class TestDataBlocks {
     byte[] bytesWritten = blockUploadData.toByteArray();
     byte[] bytesWritten = blockUploadData.toByteArray();
     // Verify that we can call toByteArray() more than once and gives the
     // Verify that we can call toByteArray() more than once and gives the
     // same byte[].
     // same byte[].
-    assertEquals("Mismatch in byteArray provided by toByteArray() the second "
-        + "time", bytesWritten, blockUploadData.toByteArray());
+    assertEquals(bytesWritten, blockUploadData.toByteArray(),
+        "Mismatch in byteArray provided by toByteArray() the second time");
     IOUtils.close(blockUploadData);
     IOUtils.close(blockUploadData);
     // Verify that after closing blockUploadData, we can't call toByteArray().
     // Verify that after closing blockUploadData, we can't call toByteArray().
     LambdaTestUtils.intercept(IllegalStateException.class,
     LambdaTestUtils.intercept(IllegalStateException.class,

+ 3 - 3
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/store/TestEtagChecksum.java

@@ -20,8 +20,8 @@ package org.apache.hadoop.fs.store;
 
 
 import java.io.IOException;
 import java.io.IOException;
 
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 
 
 import org.apache.hadoop.io.DataInputBuffer;
 import org.apache.hadoop.io.DataInputBuffer;
 import org.apache.hadoop.io.DataOutputBuffer;
 import org.apache.hadoop.io.DataOutputBuffer;
@@ -29,7 +29,7 @@ import org.apache.hadoop.io.DataOutputBuffer;
 /**
 /**
  * Unit test of etag operations.
  * Unit test of etag operations.
  */
  */
-public class TestEtagChecksum extends Assert {
+public class TestEtagChecksum extends Assertions {
 
 
   private final EtagChecksum empty1 = tag("");
   private final EtagChecksum empty1 = tag("");
   private final EtagChecksum empty2 = tag("");
   private final EtagChecksum empty2 = tag("");

+ 83 - 72
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestChRootedFs.java

@@ -23,6 +23,12 @@ import java.net.URI;
 import java.util.EnumSet;
 import java.util.EnumSet;
 
 
 import static org.apache.hadoop.fs.FileContextTestHelper.*;
 import static org.apache.hadoop.fs.FileContextTestHelper.*;
+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.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.AbstractFileSystem;
 import org.apache.hadoop.fs.AbstractFileSystem;
@@ -33,10 +39,10 @@ import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FsConstants;
 import org.apache.hadoop.fs.FsConstants;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.viewfs.ChRootedFs;
 import org.apache.hadoop.fs.viewfs.ChRootedFs;
-import org.junit.After;
-import org.junit.Assert;
-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.junit.jupiter.api.Timeout;
 import org.mockito.Mockito;
 import org.mockito.Mockito;
 
 
 public class TestChRootedFs {
 public class TestChRootedFs {
@@ -45,7 +51,7 @@ public class TestChRootedFs {
   FileContext fcTarget; // 
   FileContext fcTarget; // 
   Path chrootedTo;
   Path chrootedTo;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     // create the test root on local_fs
     // create the test root on local_fs
     fcTarget = FileContext.getLocalFSFileContext();
     fcTarget = FileContext.getLocalFSFileContext();
@@ -62,7 +68,7 @@ public class TestChRootedFs {
         new ChRootedFs(fcTarget.getDefaultFileSystem(), chrootedTo), conf);
         new ChRootedFs(fcTarget.getDefaultFileSystem(), chrootedTo), conf);
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
   public void tearDown() throws Exception {
     fcTarget.delete(chrootedTo, true);
     fcTarget.delete(chrootedTo, true);
   }
   }
@@ -71,11 +77,11 @@ public class TestChRootedFs {
   @Test
   @Test
   public void testBasicPaths() {
   public void testBasicPaths() {
     URI uri = fc.getDefaultFileSystem().getUri();
     URI uri = fc.getDefaultFileSystem().getUri();
-    Assert.assertEquals(chrootedTo.toUri(), uri);
-    Assert.assertEquals(fc.makeQualified(
+    assertEquals(chrootedTo.toUri(), uri);
+    assertEquals(fc.makeQualified(
         new Path(System.getProperty("user.home"))),
         new Path(System.getProperty("user.home"))),
         fc.getWorkingDirectory());
         fc.getWorkingDirectory());
-    Assert.assertEquals(fc.makeQualified(
+    assertEquals(fc.makeQualified(
         new Path(System.getProperty("user.home"))),
         new Path(System.getProperty("user.home"))),
         fc.getHomeDirectory());
         fc.getHomeDirectory());
     /*
     /*
@@ -85,13 +91,13 @@ public class TestChRootedFs {
      * But if we were to fix Path#makeQualified() then  the next test should
      * But if we were to fix Path#makeQualified() then  the next test should
      *  have been:
      *  have been:
 
 
-    Assert.assertEquals(
+    assertEquals(
         new Path(chrootedTo + "/foo/bar").makeQualified(
         new Path(chrootedTo + "/foo/bar").makeQualified(
             FsConstants.LOCAL_FS_URI, null),
             FsConstants.LOCAL_FS_URI, null),
         fc.makeQualified(new Path( "/foo/bar")));
         fc.makeQualified(new Path( "/foo/bar")));
     */
     */
     
     
-    Assert.assertEquals(
+    assertEquals(
         new Path("/foo/bar").makeQualified(FsConstants.LOCAL_FS_URI, null),
         new Path("/foo/bar").makeQualified(FsConstants.LOCAL_FS_URI, null),
         fc.makeQualified(new Path("/foo/bar")));
         fc.makeQualified(new Path("/foo/bar")));
   }
   }
@@ -109,50 +115,50 @@ public class TestChRootedFs {
 
 
     // Create file 
     // Create file 
     fileContextTestHelper.createFileNonRecursive(fc, "/foo");
     fileContextTestHelper.createFileNonRecursive(fc, "/foo");
-    Assert.assertTrue(isFile(fc, new Path("/foo")));
-    Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo, "foo")));
+    assertTrue(isFile(fc, new Path("/foo")));
+    assertTrue(isFile(fcTarget, new Path(chrootedTo, "foo")));
     
     
     // Create file with recursive dir
     // Create file with recursive dir
     fileContextTestHelper.createFile(fc, "/newDir/foo");
     fileContextTestHelper.createFile(fc, "/newDir/foo");
-    Assert.assertTrue(isFile(fc, new Path("/newDir/foo")));
-    Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo,"newDir/foo")));
+    assertTrue(isFile(fc, new Path("/newDir/foo")));
+    assertTrue(isFile(fcTarget, new Path(chrootedTo, "newDir/foo")));
     
     
     // Delete the created file
     // Delete the created file
-    Assert.assertTrue(fc.delete(new Path("/newDir/foo"), false));
-    Assert.assertFalse(exists(fc, new Path("/newDir/foo")));
-    Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"newDir/foo")));
+    assertTrue(fc.delete(new Path("/newDir/foo"), false));
+    assertFalse(exists(fc, new Path("/newDir/foo")));
+    assertFalse(exists(fcTarget, new Path(chrootedTo, "newDir/foo")));
     
     
     // Create file with a 2 component dirs recursively
     // Create file with a 2 component dirs recursively
     fileContextTestHelper.createFile(fc, "/newDir/newDir2/foo");
     fileContextTestHelper.createFile(fc, "/newDir/newDir2/foo");
-    Assert.assertTrue(isFile(fc, new Path("/newDir/newDir2/foo")));
-    Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo,"newDir/newDir2/foo")));
+    assertTrue(isFile(fc, new Path("/newDir/newDir2/foo")));
+    assertTrue(isFile(fcTarget, new Path(chrootedTo, "newDir/newDir2/foo")));
     
     
     // Delete the created file
     // Delete the created file
-    Assert.assertTrue(fc.delete(new Path("/newDir/newDir2/foo"), false));
-    Assert.assertFalse(exists(fc, new Path("/newDir/newDir2/foo")));
-    Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"newDir/newDir2/foo")));
+    assertTrue(fc.delete(new Path("/newDir/newDir2/foo"), false));
+    assertFalse(exists(fc, new Path("/newDir/newDir2/foo")));
+    assertFalse(exists(fcTarget, new Path(chrootedTo, "newDir/newDir2/foo")));
   }
   }
   
   
   
   
   @Test
   @Test
   public void testMkdirDelete() throws IOException {
   public void testMkdirDelete() throws IOException {
     fc.mkdir(fileContextTestHelper.getTestRootPath(fc, "/dirX"), FileContext.DEFAULT_PERM, false);
     fc.mkdir(fileContextTestHelper.getTestRootPath(fc, "/dirX"), FileContext.DEFAULT_PERM, false);
-    Assert.assertTrue(isDir(fc, new Path("/dirX")));
-    Assert.assertTrue(isDir(fcTarget, new Path(chrootedTo,"dirX")));
+    assertTrue(isDir(fc, new Path("/dirX")));
+    assertTrue(isDir(fcTarget, new Path(chrootedTo, "dirX")));
     
     
     fc.mkdir(fileContextTestHelper.getTestRootPath(fc, "/dirX/dirY"), FileContext.DEFAULT_PERM, false);
     fc.mkdir(fileContextTestHelper.getTestRootPath(fc, "/dirX/dirY"), FileContext.DEFAULT_PERM, false);
-    Assert.assertTrue(isDir(fc, new Path("/dirX/dirY")));
-    Assert.assertTrue(isDir(fcTarget, new Path(chrootedTo,"dirX/dirY")));
+    assertTrue(isDir(fc, new Path("/dirX/dirY")));
+    assertTrue(isDir(fcTarget, new Path(chrootedTo, "dirX/dirY")));
     
     
 
 
     // Delete the created dir
     // Delete the created dir
-    Assert.assertTrue(fc.delete(new Path("/dirX/dirY"), false));
-    Assert.assertFalse(exists(fc, new Path("/dirX/dirY")));
-    Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"dirX/dirY")));
+    assertTrue(fc.delete(new Path("/dirX/dirY"), false));
+    assertFalse(exists(fc, new Path("/dirX/dirY")));
+    assertFalse(exists(fcTarget, new Path(chrootedTo, "dirX/dirY")));
     
     
-    Assert.assertTrue(fc.delete(new Path("/dirX"), false));
-    Assert.assertFalse(exists(fc, new Path("/dirX")));
-    Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"dirX")));
+    assertTrue(fc.delete(new Path("/dirX"), false));
+    assertFalse(exists(fc, new Path("/dirX")));
+    assertFalse(exists(fcTarget, new Path(chrootedTo, "dirX")));
     
     
   }
   }
   @Test
   @Test
@@ -160,23 +166,23 @@ public class TestChRootedFs {
     // Rename a file
     // Rename a file
     fileContextTestHelper.createFile(fc, "/newDir/foo");
     fileContextTestHelper.createFile(fc, "/newDir/foo");
     fc.rename(new Path("/newDir/foo"), new Path("/newDir/fooBar"));
     fc.rename(new Path("/newDir/foo"), new Path("/newDir/fooBar"));
-    Assert.assertFalse(exists(fc, new Path("/newDir/foo")));
-    Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"newDir/foo")));
-    Assert.assertTrue(isFile(fc, fileContextTestHelper.getTestRootPath(fc,"/newDir/fooBar")));
-    Assert.assertTrue(isFile(fcTarget, new Path(chrootedTo,"newDir/fooBar")));
+    assertFalse(exists(fc, new Path("/newDir/foo")));
+    assertFalse(exists(fcTarget, new Path(chrootedTo, "newDir/foo")));
+    assertTrue(isFile(fc, fileContextTestHelper.getTestRootPath(fc, "/newDir/fooBar")));
+    assertTrue(isFile(fcTarget, new Path(chrootedTo, "newDir/fooBar")));
     
     
     
     
     // Rename a dir
     // Rename a dir
     fc.mkdir(new Path("/newDir/dirFoo"), FileContext.DEFAULT_PERM, false);
     fc.mkdir(new Path("/newDir/dirFoo"), FileContext.DEFAULT_PERM, false);
     fc.rename(new Path("/newDir/dirFoo"), new Path("/newDir/dirFooBar"));
     fc.rename(new Path("/newDir/dirFoo"), new Path("/newDir/dirFooBar"));
-    Assert.assertFalse(exists(fc, new Path("/newDir/dirFoo")));
-    Assert.assertFalse(exists(fcTarget, new Path(chrootedTo,"newDir/dirFoo")));
-    Assert.assertTrue(isDir(fc, fileContextTestHelper.getTestRootPath(fc,"/newDir/dirFooBar")));
-    Assert.assertTrue(isDir(fcTarget, new Path(chrootedTo,"newDir/dirFooBar")));
+    assertFalse(exists(fc, new Path("/newDir/dirFoo")));
+    assertFalse(exists(fcTarget, new Path(chrootedTo, "newDir/dirFoo")));
+    assertTrue(isDir(fc, fileContextTestHelper.getTestRootPath(fc, "/newDir/dirFooBar")));
+    assertTrue(isDir(fcTarget, new Path(chrootedTo, "newDir/dirFooBar")));
   }
   }
   
   
   
   
-  /**
+  /*
    * We would have liked renames across file system to fail but 
    * We would have liked renames across file system to fail but 
    * Unfortunately there is not way to distinguish the two file systems 
    * Unfortunately there is not way to distinguish the two file systems 
    * @throws IOException
    * @throws IOException
@@ -193,15 +199,15 @@ public class TestChRootedFs {
   public void testList() throws IOException {
   public void testList() throws IOException {
     
     
     FileStatus fs = fc.getFileStatus(new Path("/"));
     FileStatus fs = fc.getFileStatus(new Path("/"));
-    Assert.assertTrue(fs.isDirectory());
+    assertTrue(fs.isDirectory());
     //  should return the full path not the chrooted path
     //  should return the full path not the chrooted path
-    Assert.assertEquals(fs.getPath(), chrootedTo);
+    assertEquals(fs.getPath(), chrootedTo);
     
     
     // list on Slash
     // list on Slash
     
     
     FileStatus[] dirPaths = fc.util().listStatus(new Path("/"));
     FileStatus[] dirPaths = fc.util().listStatus(new Path("/"));
 
 
-    Assert.assertEquals(0, dirPaths.length);
+    assertEquals(0, dirPaths.length);
     
     
     
     
 
 
@@ -213,21 +219,21 @@ public class TestChRootedFs {
     fc.mkdir(new Path("/dirX/dirXX"), FileContext.DEFAULT_PERM, false);
     fc.mkdir(new Path("/dirX/dirXX"), FileContext.DEFAULT_PERM, false);
     
     
     dirPaths = fc.util().listStatus(new Path("/"));
     dirPaths = fc.util().listStatus(new Path("/"));
-    Assert.assertEquals(4, dirPaths.length);
+    assertEquals(4, dirPaths.length);
     
     
     // Note the the file status paths are the full paths on target
     // Note the the file status paths are the full paths on target
     fs = fileContextTestHelper.containsPath(fcTarget, "foo", dirPaths);
     fs = fileContextTestHelper.containsPath(fcTarget, "foo", dirPaths);
-      Assert.assertNotNull(fs);
-      Assert.assertTrue(fs.isFile());
+    assertNotNull(fs);
+    assertTrue(fs.isFile());
     fs = fileContextTestHelper.containsPath(fcTarget, "bar", dirPaths);
     fs = fileContextTestHelper.containsPath(fcTarget, "bar", dirPaths);
-      Assert.assertNotNull(fs);
-      Assert.assertTrue(fs.isFile());
+    assertNotNull(fs);
+    assertTrue(fs.isFile());
     fs = fileContextTestHelper.containsPath(fcTarget, "dirX", dirPaths);
     fs = fileContextTestHelper.containsPath(fcTarget, "dirX", dirPaths);
-      Assert.assertNotNull(fs);
-      Assert.assertTrue(fs.isDirectory());
+    assertNotNull(fs);
+    assertTrue(fs.isDirectory());
     fs = fileContextTestHelper.containsPath(fcTarget, "dirY", dirPaths);
     fs = fileContextTestHelper.containsPath(fcTarget, "dirY", dirPaths);
-      Assert.assertNotNull(fs);
-      Assert.assertTrue(fs.isDirectory());
+    assertNotNull(fs);
+    assertTrue(fs.isDirectory());
   }
   }
   
   
   @Test
   @Test
@@ -238,13 +244,13 @@ public class TestChRootedFs {
     Path workDir = new Path("/testWd");
     Path workDir = new Path("/testWd");
     Path fqWd = fc.makeQualified(workDir);
     Path fqWd = fc.makeQualified(workDir);
     fc.setWorkingDirectory(workDir);
     fc.setWorkingDirectory(workDir);
-    Assert.assertEquals(fqWd, fc.getWorkingDirectory());
+    assertEquals(fqWd, fc.getWorkingDirectory());
 
 
     fc.setWorkingDirectory(new Path("."));
     fc.setWorkingDirectory(new Path("."));
-    Assert.assertEquals(fqWd, fc.getWorkingDirectory());
+    assertEquals(fqWd, fc.getWorkingDirectory());
 
 
     fc.setWorkingDirectory(new Path(".."));
     fc.setWorkingDirectory(new Path(".."));
-    Assert.assertEquals(fqWd.getParent(), fc.getWorkingDirectory());
+    assertEquals(fqWd.getParent(), fc.getWorkingDirectory());
     
     
     // cd using a relative path
     // cd using a relative path
 
 
@@ -252,20 +258,20 @@ public class TestChRootedFs {
     workDir = new Path("/testWd");
     workDir = new Path("/testWd");
     fqWd = fc.makeQualified(workDir);
     fqWd = fc.makeQualified(workDir);
     fc.setWorkingDirectory(workDir);
     fc.setWorkingDirectory(workDir);
-    Assert.assertEquals(fqWd, fc.getWorkingDirectory());
+    assertEquals(fqWd, fc.getWorkingDirectory());
     
     
     Path relativeDir = new Path("existingDir1");
     Path relativeDir = new Path("existingDir1");
     Path absoluteDir = new Path(workDir,"existingDir1");
     Path absoluteDir = new Path(workDir,"existingDir1");
     fc.mkdir(absoluteDir, FileContext.DEFAULT_PERM, true);
     fc.mkdir(absoluteDir, FileContext.DEFAULT_PERM, true);
     Path fqAbsoluteDir = fc.makeQualified(absoluteDir);
     Path fqAbsoluteDir = fc.makeQualified(absoluteDir);
     fc.setWorkingDirectory(relativeDir);
     fc.setWorkingDirectory(relativeDir);
-    Assert.assertEquals(fqAbsoluteDir, fc.getWorkingDirectory());
+    assertEquals(fqAbsoluteDir, fc.getWorkingDirectory());
     // cd using a absolute path
     // cd using a absolute path
     absoluteDir = new Path("/test/existingDir2");
     absoluteDir = new Path("/test/existingDir2");
     fqAbsoluteDir = fc.makeQualified(absoluteDir);
     fqAbsoluteDir = fc.makeQualified(absoluteDir);
     fc.mkdir(absoluteDir, FileContext.DEFAULT_PERM, true);
     fc.mkdir(absoluteDir, FileContext.DEFAULT_PERM, true);
     fc.setWorkingDirectory(absoluteDir);
     fc.setWorkingDirectory(absoluteDir);
-    Assert.assertEquals(fqAbsoluteDir, fc.getWorkingDirectory());
+    assertEquals(fqAbsoluteDir, fc.getWorkingDirectory());
     
     
     // Now open a file relative to the wd we just set above.
     // Now open a file relative to the wd we just set above.
     Path absolutePath = new Path(absoluteDir, "foo");
     Path absolutePath = new Path(absoluteDir, "foo");
@@ -274,12 +280,12 @@ public class TestChRootedFs {
     
     
     // Now mkdir relative to the dir we cd'ed to
     // Now mkdir relative to the dir we cd'ed to
     fc.mkdir(new Path("newDir"), FileContext.DEFAULT_PERM, true);
     fc.mkdir(new Path("newDir"), FileContext.DEFAULT_PERM, true);
-    Assert.assertTrue(isDir(fc, new Path(absoluteDir, "newDir")));
+    assertTrue(isDir(fc, new Path(absoluteDir, "newDir")));
 
 
     absoluteDir = fileContextTestHelper.getTestRootPath(fc, "nonexistingPath");
     absoluteDir = fileContextTestHelper.getTestRootPath(fc, "nonexistingPath");
     try {
     try {
       fc.setWorkingDirectory(absoluteDir);
       fc.setWorkingDirectory(absoluteDir);
-      Assert.fail("cd to non existing dir should have failed");
+      fail("cd to non existing dir should have failed");
     } catch (Exception e) {
     } catch (Exception e) {
       // Exception as expected
       // Exception as expected
     }
     }
@@ -289,7 +295,7 @@ public class TestChRootedFs {
     absoluteDir = new Path(LOCAL_FS_ROOT_URI + "/existingDir");
     absoluteDir = new Path(LOCAL_FS_ROOT_URI + "/existingDir");
     fc.mkdir(absoluteDir, FileContext.DEFAULT_PERM, true);
     fc.mkdir(absoluteDir, FileContext.DEFAULT_PERM, true);
     fc.setWorkingDirectory(absoluteDir);
     fc.setWorkingDirectory(absoluteDir);
-    Assert.assertEquals(absoluteDir, fc.getWorkingDirectory());
+    assertEquals(absoluteDir, fc.getWorkingDirectory());
 
 
   }
   }
   
   
@@ -299,15 +305,17 @@ public class TestChRootedFs {
   
   
   @Test
   @Test
   public void testResolvePath() throws IOException {
   public void testResolvePath() throws IOException {
-    Assert.assertEquals(chrootedTo, fc.getDefaultFileSystem().resolvePath(new Path("/"))); 
+    assertEquals(chrootedTo, fc.getDefaultFileSystem().resolvePath(new Path("/")));
     fileContextTestHelper.createFile(fc, "/foo");
     fileContextTestHelper.createFile(fc, "/foo");
-    Assert.assertEquals(new Path(chrootedTo, "foo"),
+    assertEquals(new Path(chrootedTo, "foo"),
         fc.getDefaultFileSystem().resolvePath(new Path("/foo"))); 
         fc.getDefaultFileSystem().resolvePath(new Path("/foo"))); 
   }
   }
 
 
-  @Test(expected=FileNotFoundException.class) 
+  @Test
   public void testResolvePathNonExisting() throws IOException {
   public void testResolvePathNonExisting() throws IOException {
+    assertThrows(FileNotFoundException.class, () -> {
       fc.getDefaultFileSystem().resolvePath(new Path("/nonExisting"));
       fc.getDefaultFileSystem().resolvePath(new Path("/nonExisting"));
+    });
   }
   }
  
  
   @Test
   @Test
@@ -315,7 +323,7 @@ public class TestChRootedFs {
     AbstractFileSystem baseFs = Mockito.spy(fc.getDefaultFileSystem());
     AbstractFileSystem baseFs = Mockito.spy(fc.getDefaultFileSystem());
     ChRootedFs chRootedFs = new ChRootedFs(baseFs, new Path("/chroot"));
     ChRootedFs chRootedFs = new ChRootedFs(baseFs, new Path("/chroot"));
     Mockito.doReturn(true).when(baseFs).isValidName(Mockito.anyString());
     Mockito.doReturn(true).when(baseFs).isValidName(Mockito.anyString());
-    Assert.assertTrue(chRootedFs.isValidName("/test"));
+    assertTrue(chRootedFs.isValidName("/test"));
     Mockito.verify(baseFs).isValidName("/chroot/test");
     Mockito.verify(baseFs).isValidName("/chroot/test");
   }
   }
 
 
@@ -324,11 +332,12 @@ public class TestChRootedFs {
     AbstractFileSystem baseFs = Mockito.spy(fc.getDefaultFileSystem());
     AbstractFileSystem baseFs = Mockito.spy(fc.getDefaultFileSystem());
     ChRootedFs chRootedFs = new ChRootedFs(baseFs, new Path("/chroot"));
     ChRootedFs chRootedFs = new ChRootedFs(baseFs, new Path("/chroot"));
     Mockito.doReturn(false).when(baseFs).isValidName(Mockito.anyString());
     Mockito.doReturn(false).when(baseFs).isValidName(Mockito.anyString());
-    Assert.assertFalse(chRootedFs.isValidName("/test"));
+    assertFalse(chRootedFs.isValidName("/test"));
     Mockito.verify(baseFs).isValidName("/chroot/test");
     Mockito.verify(baseFs).isValidName("/chroot/test");
   }
   }
 
 
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testCreateSnapshot() throws Exception {
   public void testCreateSnapshot() throws Exception {
     Path snapRootPath = new Path("/snapPath");
     Path snapRootPath = new Path("/snapPath");
     Path chRootedSnapRootPath = new Path(
     Path chRootedSnapRootPath = new Path(
@@ -337,12 +346,13 @@ public class TestChRootedFs {
     ChRootedFs chRootedFs = new ChRootedFs(baseFs, chrootedTo);
     ChRootedFs chRootedFs = new ChRootedFs(baseFs, chrootedTo);
     Mockito.doReturn(snapRootPath).when(baseFs)
     Mockito.doReturn(snapRootPath).when(baseFs)
         .createSnapshot(chRootedSnapRootPath, "snap1");
         .createSnapshot(chRootedSnapRootPath, "snap1");
-    Assert.assertEquals(snapRootPath,
+    assertEquals(snapRootPath,
         chRootedFs.createSnapshot(snapRootPath, "snap1"));
         chRootedFs.createSnapshot(snapRootPath, "snap1"));
     Mockito.verify(baseFs).createSnapshot(chRootedSnapRootPath, "snap1");
     Mockito.verify(baseFs).createSnapshot(chRootedSnapRootPath, "snap1");
   }
   }
 
 
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testDeleteSnapshot() throws Exception {
   public void testDeleteSnapshot() throws Exception {
     Path snapRootPath = new Path("/snapPath");
     Path snapRootPath = new Path("/snapPath");
     Path chRootedSnapRootPath = new Path(
     Path chRootedSnapRootPath = new Path(
@@ -355,7 +365,8 @@ public class TestChRootedFs {
     Mockito.verify(baseFs).deleteSnapshot(chRootedSnapRootPath, "snap1");
     Mockito.verify(baseFs).deleteSnapshot(chRootedSnapRootPath, "snap1");
   }
   }
 
 
-  @Test(timeout = 30000)
+  @Test
+  @Timeout(value = 30)
   public void testRenameSnapshot() throws Exception {
   public void testRenameSnapshot() throws Exception {
     Path snapRootPath = new Path("/snapPath");
     Path snapRootPath = new Path("/snapPath");
     Path chRootedSnapRootPath = new Path(
     Path chRootedSnapRootPath = new Path(

+ 5 - 4
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestRegexMountPointInterceptorFactory.java

@@ -17,8 +17,9 @@
  */
  */
 package org.apache.hadoop.fs.viewfs;
 package org.apache.hadoop.fs.viewfs;
 
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
 /**
  * Test Regex Mount Point Interceptor Factory.
  * Test Regex Mount Point Interceptor Factory.
@@ -34,7 +35,7 @@ public class TestRegexMountPointInterceptorFactory {
             .toString(RegexMountPoint.INTERCEPTOR_INTERNAL_SEP) + "replace";
             .toString(RegexMountPoint.INTERCEPTOR_INTERNAL_SEP) + "replace";
     RegexMountPointInterceptor interceptor =
     RegexMountPointInterceptor interceptor =
         RegexMountPointInterceptorFactory.create(replaceInterceptorStr);
         RegexMountPointInterceptorFactory.create(replaceInterceptorStr);
-    Assert.assertTrue(
+    assertTrue(
         interceptor
         interceptor
             instanceof RegexMountPointResolvedDstPathReplaceInterceptor);
             instanceof RegexMountPointResolvedDstPathReplaceInterceptor);
   }
   }
@@ -49,6 +50,6 @@ public class TestRegexMountPointInterceptorFactory {
             + "replace";
             + "replace";
     RegexMountPointInterceptor interceptor =
     RegexMountPointInterceptor interceptor =
         RegexMountPointInterceptorFactory.create(replaceInterceptorStr);
         RegexMountPointInterceptorFactory.create(replaceInterceptorStr);
-    Assert.assertTrue(interceptor == null);
+    assertTrue(interceptor == null);
   }
   }
 }
 }

+ 11 - 10
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestRegexMountPointResolvedDstPathReplaceInterceptor.java

@@ -19,10 +19,11 @@ package org.apache.hadoop.fs.viewfs;
 
 
 import java.io.IOException;
 import java.io.IOException;
 
 
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import static org.apache.hadoop.fs.viewfs.RegexMountPointInterceptorType.REPLACE_RESOLVED_DST_PATH;
 import static org.apache.hadoop.fs.viewfs.RegexMountPointInterceptorType.REPLACE_RESOLVED_DST_PATH;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 
 /**
 /**
  * Test RegexMountPointResolvedDstPathReplaceInterceptor.
  * Test RegexMountPointResolvedDstPathReplaceInterceptor.
@@ -43,11 +44,11 @@ public class TestRegexMountPointResolvedDstPathReplaceInterceptor {
     RegexMountPointResolvedDstPathReplaceInterceptor interceptor =
     RegexMountPointResolvedDstPathReplaceInterceptor interceptor =
         RegexMountPointResolvedDstPathReplaceInterceptor
         RegexMountPointResolvedDstPathReplaceInterceptor
             .deserializeFromString(serializedString);
             .deserializeFromString(serializedString);
-    Assert.assertEquals(srcRegex, interceptor.getSrcRegexString());
-    Assert.assertEquals(replaceString, interceptor.getReplaceString());
-    Assert.assertNull(interceptor.getSrcRegexPattern());
+    assertEquals(srcRegex, interceptor.getSrcRegexString());
+    assertEquals(replaceString, interceptor.getReplaceString());
+    assertNull(interceptor.getSrcRegexPattern());
     interceptor.initialize();
     interceptor.initialize();
-    Assert.assertEquals(srcRegex,
+    assertEquals(srcRegex,
         interceptor.getSrcRegexPattern().toString());
         interceptor.getSrcRegexPattern().toString());
   }
   }
 
 
@@ -60,7 +61,7 @@ public class TestRegexMountPointResolvedDstPathReplaceInterceptor {
     RegexMountPointResolvedDstPathReplaceInterceptor interceptor =
     RegexMountPointResolvedDstPathReplaceInterceptor interceptor =
         RegexMountPointResolvedDstPathReplaceInterceptor
         RegexMountPointResolvedDstPathReplaceInterceptor
             .deserializeFromString(serializedString);
             .deserializeFromString(serializedString);
-    Assert.assertNull(interceptor);
+    assertNull(interceptor);
   }
   }
 
 
   @Test
   @Test
@@ -71,7 +72,7 @@ public class TestRegexMountPointResolvedDstPathReplaceInterceptor {
     RegexMountPointResolvedDstPathReplaceInterceptor interceptor =
     RegexMountPointResolvedDstPathReplaceInterceptor interceptor =
         new RegexMountPointResolvedDstPathReplaceInterceptor(srcRegex,
         new RegexMountPointResolvedDstPathReplaceInterceptor(srcRegex,
             replaceString);
             replaceString);
-    Assert.assertEquals(interceptor.serializeToString(), serializedString);
+    assertEquals(interceptor.serializeToString(), serializedString);
   }
   }
 
 
   @Test
   @Test
@@ -82,7 +83,7 @@ public class TestRegexMountPointResolvedDstPathReplaceInterceptor {
         new RegexMountPointResolvedDstPathReplaceInterceptor(srcRegex,
         new RegexMountPointResolvedDstPathReplaceInterceptor(srcRegex,
             replaceString);
             replaceString);
     String sourcePath = "/a/b/l3/dd";
     String sourcePath = "/a/b/l3/dd";
-    Assert.assertEquals(sourcePath, interceptor.interceptSource(sourcePath));
+    assertEquals(sourcePath, interceptor.interceptSource(sourcePath));
   }
   }
 
 
   @Test
   @Test
@@ -95,7 +96,7 @@ public class TestRegexMountPointResolvedDstPathReplaceInterceptor {
         new RegexMountPointResolvedDstPathReplaceInterceptor(srcRegex,
         new RegexMountPointResolvedDstPathReplaceInterceptor(srcRegex,
             replaceString);
             replaceString);
     interceptor.initialize();
     interceptor.initialize();
-    Assert.assertEquals("/user-hdfs",
+    assertEquals("/user-hdfs",
         interceptor.interceptResolvedDestPathStr(pathAfterResolution));
         interceptor.interceptResolvedDestPathStr(pathAfterResolution));
   }
   }
 }
 }

+ 2 - 2
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFSOverloadSchemeCentralMountTableConfig.java

@@ -25,7 +25,7 @@ import java.net.URISyntaxException;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
-import org.junit.Before;
+import org.junit.jupiter.api.BeforeEach;
 
 
 /**
 /**
  * Test the TestViewFSOverloadSchemeCentralMountTableConfig with mount-table
  * Test the TestViewFSOverloadSchemeCentralMountTableConfig with mount-table
@@ -36,7 +36,7 @@ public class TestViewFSOverloadSchemeCentralMountTableConfig
   private Path oldMountTablePath;
   private Path oldMountTablePath;
   private Path latestMountTablepath;
   private Path latestMountTablepath;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     super.setUp();
     super.setUp();
     // Mount table name format: mount-table.<versionNumber>.xml
     // Mount table name format: mount-table.<versionNumber>.xml

+ 5 - 4
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegation.java

@@ -31,11 +31,12 @@ import org.apache.hadoop.fs.LocalFileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.permission.AclEntry;
 import org.apache.hadoop.fs.permission.AclEntry;
 import org.apache.hadoop.fs.viewfs.TestChRootedFileSystem.MockFileSystem;
 import org.apache.hadoop.fs.viewfs.TestChRootedFileSystem.MockFileSystem;
-import org.junit.*;
 
 
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.BeforeAll;
 import static org.apache.hadoop.fs.viewfs.TestChRootedFileSystem.getChildFileSystem;
 import static org.apache.hadoop.fs.viewfs.TestChRootedFileSystem.getChildFileSystem;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.verify;
 
 
 /**
 /**
  * Verify that viewfs propagates certain methods to the underlying fs 
  * Verify that viewfs propagates certain methods to the underlying fs 
@@ -46,7 +47,7 @@ public class TestViewFileSystemDelegation { //extends ViewFileSystemTestSetup {
   static FakeFileSystem fs1;
   static FakeFileSystem fs1;
   static FakeFileSystem fs2;
   static FakeFileSystem fs2;
 
 
-  @BeforeClass
+  @BeforeAll
   public static void setup() throws Exception {
   public static void setup() throws Exception {
     conf = ViewFileSystemTestSetup.createConfig();
     conf = ViewFileSystemTestSetup.createConfig();
     setupFileSystem(new URI("fs1:/"), FakeFileSystem.class);
     setupFileSystem(new URI("fs1:/"), FakeFileSystem.class);

+ 4 - 4
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemDelegationTokenSupport.java

@@ -17,7 +17,7 @@
  */
  */
 package org.apache.hadoop.fs.viewfs;
 package org.apache.hadoop.fs.viewfs;
 
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
 import static org.apache.hadoop.fs.viewfs.TestChRootedFileSystem.getChildFileSystem;
 import static org.apache.hadoop.fs.viewfs.TestChRootedFileSystem.getChildFileSystem;
 
 
 import java.io.IOException;
 import java.io.IOException;
@@ -34,8 +34,8 @@ import org.apache.hadoop.io.Text;
 import org.apache.hadoop.security.Credentials;
 import org.apache.hadoop.security.Credentials;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.Token;
 import org.apache.hadoop.security.token.TokenIdentifier;
 import org.apache.hadoop.security.token.TokenIdentifier;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 
 
 /**
 /**
  * Test ViewFileSystem's support for having delegation tokens fetched and cached
  * Test ViewFileSystem's support for having delegation tokens fetched and cached
@@ -52,7 +52,7 @@ public class TestViewFileSystemDelegationTokenSupport {
   static FakeFileSystem fs1;
   static FakeFileSystem fs1;
   static FakeFileSystem fs2;
   static FakeFileSystem fs2;
 
 
-  @BeforeClass
+  @BeforeAll
   public static void setup() throws Exception {
   public static void setup() throws Exception {
     conf = ViewFileSystemTestSetup.createConfig();
     conf = ViewFileSystemTestSetup.createConfig();
     setupFileSystem(new URI("fs1:///"), FakeFileSystem.class);
     setupFileSystem(new URI("fs1:///"), FakeFileSystem.class);

+ 25 - 18
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemOverloadSchemeLocalFileSystem.java

@@ -29,13 +29,18 @@ import org.apache.hadoop.fs.FileSystemTestHelper;
 import org.apache.hadoop.fs.FsConstants;
 import org.apache.hadoop.fs.FsConstants;
 import org.apache.hadoop.fs.LocalFileSystem;
 import org.apache.hadoop.fs.LocalFileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
-import org.junit.After;
-import org.junit.Assert;
-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.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
 /**
 /**
  *
  *
  * Test the TestViewFileSystemOverloadSchemeLF using a file with authority:
  * Test the TestViewFileSystemOverloadSchemeLF using a file with authority:
@@ -51,7 +56,7 @@ public class TestViewFileSystemOverloadSchemeLocalFileSystem {
   private FileSystemTestHelper fileSystemTestHelper =
   private FileSystemTestHelper fileSystemTestHelper =
       new FileSystemTestHelper();
       new FileSystemTestHelper();
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     conf = new Configuration();
     conf = new Configuration();
     conf.set(String.format("fs.%s.impl", FILE),
     conf.set(String.format("fs.%s.impl", FILE),
@@ -94,7 +99,7 @@ public class TestViewFileSystemOverloadSchemeLocalFileSystem {
       }
       }
 
 
       try (FSDataInputStream lViewIs = lViewFs.open(testPath)) {
       try (FSDataInputStream lViewIs = lViewFs.open(testPath)) {
-        Assert.assertEquals(testString, lViewIs.readUTF());
+        assertEquals(testString, lViewIs.readUTF());
       }
       }
     }
     }
   }
   }
@@ -111,9 +116,9 @@ public class TestViewFileSystemOverloadSchemeLocalFileSystem {
     try (FileSystem lViewFS = FileSystem.get(mountURI, conf)) {
     try (FileSystem lViewFS = FileSystem.get(mountURI, conf)) {
       Path testPath = new Path(mountURI.toString() + "/lfsroot/test");
       Path testPath = new Path(mountURI.toString() + "/lfsroot/test");
       lViewFS.createNewFile(testPath);
       lViewFS.createNewFile(testPath);
-      Assert.assertTrue(lViewFS.exists(testPath));
+      assertTrue(lViewFS.exists(testPath));
       lViewFS.delete(testPath, true);
       lViewFS.delete(testPath, true);
-      Assert.assertFalse(lViewFS.exists(testPath));
+      assertFalse(lViewFS.exists(testPath));
     }
     }
   }
   }
 
 
@@ -131,7 +136,7 @@ public class TestViewFileSystemOverloadSchemeLocalFileSystem {
     try (FileSystem lViewFS = FileSystem.get(mountURI, conf)) {
     try (FileSystem lViewFS = FileSystem.get(mountURI, conf)) {
       Path fileOnRoot = new Path(mountURI.toString() + "/NewFile");
       Path fileOnRoot = new Path(mountURI.toString() + "/NewFile");
       lViewFS.createNewFile(fileOnRoot);
       lViewFS.createNewFile(fileOnRoot);
-      Assert.assertTrue(lViewFS.exists(fileOnRoot));
+      assertTrue(lViewFS.exists(fileOnRoot));
     }
     }
   }
   }
 
 
@@ -139,18 +144,20 @@ public class TestViewFileSystemOverloadSchemeLocalFileSystem {
    * Tests with linkMergeSlash and other mounts in
    * Tests with linkMergeSlash and other mounts in
    * ViewFileSystemOverloadScheme.
    * ViewFileSystemOverloadScheme.
    */
    */
-  @Test(expected = IOException.class)
+  @Test
   public void testLocalFsLinkSlashMergeWithOtherMountLinks() throws Exception {
   public void testLocalFsLinkSlashMergeWithOtherMountLinks() throws Exception {
-    LOG.info("Starting testLocalFsLinkSlashMergeWithOtherMountLinks");
-    addMountLinks("mt",
-        new String[] {"/lfsroot", Constants.CONFIG_VIEWFS_LINK_MERGE_SLASH },
-        new String[] {targetTestRoot + "/wd2", targetTestRoot + "/wd2" }, conf);
-    final URI mountURI = URI.create("file://mt/");
-    FileSystem.get(mountURI, conf);
-    Assert.fail("A merge slash cannot be configured with other mount links.");
+    assertThrows(IOException.class, ()->{
+      LOG.info("Starting testLocalFsLinkSlashMergeWithOtherMountLinks");
+      addMountLinks("mt",
+          new String[] {"/lfsroot", Constants.CONFIG_VIEWFS_LINK_MERGE_SLASH },
+          new String[] {targetTestRoot + "/wd2", targetTestRoot + "/wd2" }, conf);
+      final URI mountURI = URI.create("file://mt/");
+      FileSystem.get(mountURI, conf);
+      fail("A merge slash cannot be configured with other mount links.");
+    });
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
   public void tearDown() throws Exception {
     if (null != fsTarget) {
     if (null != fsTarget) {
       fsTarget.delete(fileSystemTestHelper.getTestRootPath(fsTarget), true);
       fsTarget.delete(fileSystemTestHelper.getTestRootPath(fsTarget), true);

+ 29 - 25
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsConfig.java

@@ -25,41 +25,45 @@ import java.net.URISyntaxException;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.FileAlreadyExistsException;
 import org.apache.hadoop.fs.FileAlreadyExistsException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 
 public class TestViewFsConfig {
 public class TestViewFsConfig {
 
 
-  @Test(expected = FileAlreadyExistsException.class)
+  @Test
   public void testInvalidConfig() throws IOException, URISyntaxException {
   public void testInvalidConfig() throws IOException, URISyntaxException {
-    Configuration conf = new Configuration();
-    ConfigUtil.setIsNestedMountPointSupported(conf, false);
-    ConfigUtil.addLink(conf, "/internalDir/linkToDir2",
-        new Path("file:///dir2").toUri());
-    ConfigUtil.addLink(conf, "/internalDir/linkToDir2/linkToDir3",
-        new Path("file:///dir3").toUri());
+    assertThrows(FileAlreadyExistsException.class, ()-> {
+      Configuration conf = new Configuration();
+      ConfigUtil.setIsNestedMountPointSupported(conf, false);
+      ConfigUtil.addLink(conf, "/internalDir/linkToDir2",
+          new Path("file:///dir2").toUri());
+      ConfigUtil.addLink(conf, "/internalDir/linkToDir2/linkToDir3",
+          new Path("file:///dir3").toUri());
 
 
-    class Foo {
-    }
+      class Foo {
+      }
 
 
-    new InodeTree<Foo>(conf, null, null, false) {
+      new InodeTree<Foo>(conf, null, null, false) {
 
 
-      @Override
-      protected Function<URI, Foo> initAndGetTargetFs() {
-        return null;
-      }
+        @Override
+        protected Function<URI, Foo> initAndGetTargetFs() {
+          return null;
+        }
 
 
-      @Override
-      protected Foo getTargetFileSystem(final INodeDir<Foo> dir) {
-        return null;
-      }
+        @Override
+        protected Foo getTargetFileSystem(final INodeDir<Foo> dir) {
+          return null;
+        }
 
 
-      @Override
-      protected Foo getTargetFileSystem(final String settings,
-          final URI[] mergeFsURIList) {
-        return null;
-      }
+        @Override
+        protected Foo getTargetFileSystem(final String settings,
+            final URI[] mergeFsURIList) {
+          return null;
+        }
 
 
-    };
+      };
+    });
   }
   }
 
 
 }
 }

+ 5 - 6
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsTrash.java

@@ -29,12 +29,11 @@ import org.apache.hadoop.fs.TestTrash;
 import org.apache.hadoop.fs.Trash;
 import org.apache.hadoop.fs.Trash;
 import org.apache.hadoop.fs.TrashPolicyDefault;
 import org.apache.hadoop.fs.TrashPolicyDefault;
 import org.apache.hadoop.fs.contract.ContractTestUtils;
 import org.apache.hadoop.fs.contract.ContractTestUtils;
-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 static org.apache.hadoop.fs.CommonConfigurationKeysPublic.*;
 import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.*;
 import static org.apache.hadoop.fs.viewfs.Constants.*;
 import static org.apache.hadoop.fs.viewfs.Constants.*;
-import static org.junit.Assert.*;
 
 
 public class TestViewFsTrash {
 public class TestViewFsTrash {
   FileSystem fsTarget;  // the target file system - the mount will point here
   FileSystem fsTarget;  // the target file system - the mount will point here
@@ -42,7 +41,7 @@ public class TestViewFsTrash {
   Configuration conf;
   Configuration conf;
   private FileSystemTestHelper fileSystemTestHelper;
   private FileSystemTestHelper fileSystemTestHelper;
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
     Configuration targetFSConf = new Configuration();
     Configuration targetFSConf = new Configuration();
     targetFSConf.setClass("fs.file.impl", TestTrash.TestLFS.class, FileSystem.class);
     targetFSConf.setClass("fs.file.impl", TestTrash.TestLFS.class, FileSystem.class);
@@ -62,7 +61,7 @@ public class TestViewFsTrash {
 
 
   }
   }
  
  
-  @After
+  @AfterEach
   public void tearDown() throws Exception {
   public void tearDown() throws Exception {
     ViewFileSystemTestSetup.tearDown(fileSystemTestHelper, fsTarget);
     ViewFileSystemTestSetup.tearDown(fileSystemTestHelper, fsTarget);
     fsTarget.delete(new Path(fsTarget.getHomeDirectory(), ".Trash/Current"),
     fsTarget.delete(new Path(fsTarget.getHomeDirectory(), ".Trash/Current"),

+ 1 - 1
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsURIs.java

@@ -22,7 +22,7 @@ import java.net.URI;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileContext;
 import org.apache.hadoop.fs.FileContext;
 import org.apache.hadoop.fs.FsConstants;
 import org.apache.hadoop.fs.FsConstants;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestViewFsURIs {
 public class TestViewFsURIs {
   @Test
   @Test

+ 13 - 11
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/TestViewfsFileStatus.java

@@ -33,13 +33,15 @@ import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.io.DataInputBuffer;
 import org.apache.hadoop.io.DataInputBuffer;
 import org.apache.hadoop.io.DataOutputBuffer;
 import org.apache.hadoop.io.DataOutputBuffer;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.mockito.Mockito;
 
 
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
 /**
  * The FileStatus is being serialized in MR as jobs are submitted.
  * The FileStatus is being serialized in MR as jobs are submitted.
@@ -51,13 +53,13 @@ public class TestViewfsFileStatus {
   private static final File TEST_DIR = GenericTestUtils.getTestDir(
   private static final File TEST_DIR = GenericTestUtils.getTestDir(
       TestViewfsFileStatus.class.getSimpleName());
       TestViewfsFileStatus.class.getSimpleName());
 
 
-  @Before
+  @BeforeEach
   public void setUp() {
   public void setUp() {
     FileUtil.fullyDelete(TEST_DIR);
     FileUtil.fullyDelete(TEST_DIR);
     assertTrue(TEST_DIR.mkdirs());
     assertTrue(TEST_DIR.mkdirs());
   }
   }
 
 
-  @After
+  @AfterEach
   public void tearDown() throws IOException {
   public void tearDown() throws IOException {
     FileUtil.fullyDelete(TEST_DIR);
     FileUtil.fullyDelete(TEST_DIR);
   }
   }
@@ -83,9 +85,9 @@ public class TestViewfsFileStatus {
       FileStatus stat = vfs.getFileStatus(path);
       FileStatus stat = vfs.getFileStatus(path);
       assertEquals(content.length, stat.getLen());
       assertEquals(content.length, stat.getLen());
       ContractTestUtils.assertNotErasureCoded(vfs, path);
       ContractTestUtils.assertNotErasureCoded(vfs, path);
-      assertTrue(path + " should have erasure coding unset in " +
-          "FileStatus#toString(): " + stat,
-          stat.toString().contains("isErasureCoded=false"));
+      assertTrue(stat.toString().contains("isErasureCoded=false"),
+          path + " should have erasure coding unset in " +
+          "FileStatus#toString(): " + stat);
 
 
       // check serialization/deserialization
       // check serialization/deserialization
       DataOutputBuffer dob = new DataOutputBuffer();
       DataOutputBuffer dob = new DataOutputBuffer();
@@ -180,7 +182,7 @@ public class TestViewfsFileStatus {
     Mockito.verify(mockFS).getFileChecksum(new Path("someFile"));
     Mockito.verify(mockFS).getFileChecksum(new Path("someFile"));
   }
   }
 
 
-  @AfterClass
+  @AfterAll
   public static void cleanup() throws IOException {
   public static void cleanup() throws IOException {
     FileUtil.fullyDelete(TEST_DIR);
     FileUtil.fullyDelete(TEST_DIR);
   }
   }