Browse Source

HDFS-17719. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-hdfs-httpfs Part1. (#7371)

Co-authored-by: Chris Nauroth <cnauroth@apache.org>
Co-authored-by: Tsz-wo Sze <szetszwo@apache.org>
Reviewed-by: Chris Nauroth <cnauroth@apache.org>
Reviewed-by: Tsz-wo Sze <szetszwo@apache.org>
Signed-off-by: Shilun Fan <slfan1989@apache.org>
slfan1989 2 months ago
parent
commit
b24996cb96
39 changed files with 819 additions and 742 deletions
  1. 20 0
      hadoop-hdfs-project/hadoop-hdfs-httpfs/pom.xml
  2. 140 147
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/BaseTestHttpFSWith.java
  3. 3 7
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/TestHttpFSFWithSWebhdfsFileSystem.java
  4. 1 5
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/TestHttpFSFWithWebhdfsFileSystem.java
  5. 4 7
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/TestHttpFSFileSystemLocalFileSystem.java
  6. 1 5
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/TestHttpFSWithHttpFSFileSystem.java
  7. 1 1
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestCheckUploadContentTypeFilter.java
  8. 15 13
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSAccessControlled.java
  9. 168 165
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServer.java
  10. 17 15
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServerNoACLs.java
  11. 15 13
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServerNoXAttrs.java
  12. 15 15
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServerWebServer.java
  13. 18 19
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSWithKerberos.java
  14. 9 8
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/lang/TestRunnableCallable.java
  15. 3 3
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/lang/TestXException.java
  16. 4 4
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/server/TestBaseService.java
  17. 48 32
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/server/TestServer.java
  18. 20 17
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/server/TestServerConstructor.java
  19. 24 21
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/service/hadoop/TestFileSystemAccessService.java
  20. 5 5
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/service/instrumentation/TestInstrumentationService.java
  21. 2 2
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/service/scheduler/TestSchedulerService.java
  22. 14 10
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/service/security/TestGroupsService.java
  23. 3 3
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/servlet/TestHostnameFilter.java
  24. 4 4
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/servlet/TestMDCFilter.java
  25. 22 17
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/servlet/TestServerWebApp.java
  26. 67 35
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/util/TestCheck.java
  27. 3 3
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/util/TestConfigurationUtils.java
  28. 2 2
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/wsrs/TestInputStreamEntity.java
  29. 4 4
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/wsrs/TestJSONMapProvider.java
  30. 4 4
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/wsrs/TestJSONProvider.java
  31. 3 3
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/wsrs/TestParam.java
  32. 3 4
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/test/HFSTestCase.java
  33. 8 9
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/test/HTestCase.java
  34. 22 26
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/test/TestDirHelper.java
  35. 30 33
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/test/TestExceptionHelper.java
  36. 25 14
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/test/TestHFSTestCase.java
  37. 17 10
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/test/TestHTestCase.java
  38. 28 27
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/test/TestHdfsHelper.java
  39. 27 30
      hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/test/TestJettyHelper.java

+ 20 - 0
hadoop-hdfs-project/hadoop-hdfs-httpfs/pom.xml

@@ -210,6 +210,26 @@
       <artifactId>kotlin-stdlib-jdk8</artifactId>
       <artifactId>kotlin-stdlib-jdk8</artifactId>
       <scope>test</scope>
       <scope>test</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>

+ 140 - 147
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/BaseTestHttpFSWith.java

@@ -81,13 +81,10 @@ import org.apache.hadoop.util.Lists;
 import org.json.simple.JSONObject;
 import org.json.simple.JSONObject;
 import org.json.simple.parser.ContainerFactory;
 import org.json.simple.parser.ContainerFactory;
 import org.json.simple.parser.JSONParser;
 import org.json.simple.parser.JSONParser;
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.webapp.WebAppContext;
 import org.eclipse.jetty.webapp.WebAppContext;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 
 
 import java.io.File;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.FileOutputStream;
@@ -107,13 +104,15 @@ import java.util.Map;
 import java.util.regex.Pattern;
 import java.util.regex.Pattern;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.atomic.AtomicReference;
 
 
-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 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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assumptions.assumeFalse;
 
 
-@RunWith(value = Parameterized.class)
 public abstract class BaseTestHttpFSWith extends HFSTestCase {
 public abstract class BaseTestHttpFSWith extends HFSTestCase {
   protected abstract Path getProxiedFSTestDir();
   protected abstract Path getProxiedFSTestDir();
 
 
@@ -251,12 +250,12 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
     testCreate(path, true);
     testCreate(path, true);
     try {
     try {
       testCreate(path, false);
       testCreate(path, false);
-      Assert.fail("the create should have failed because the file exists " +
-                  "and override is FALSE");
+      fail("the create should have failed because the file exists " +
+          "and override is FALSE");
     } catch (IOException ex) {
     } catch (IOException ex) {
       System.out.println("#");
       System.out.println("#");
     } catch (Exception ex) {
     } catch (Exception ex) {
-      Assert.fail(ex.toString());
+      fail(ex.toString());
     }
     }
   }
   }
 
 
@@ -299,7 +298,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       final int newLength = blockSize;
       final int newLength = blockSize;
 
 
       boolean isReady = fs.truncate(file, newLength);
       boolean isReady = fs.truncate(file, newLength);
-      assertTrue("Recovery is not expected.", isReady);
+      assertTrue(isReady, "Recovery is not expected.");
 
 
       FileStatus fileStatus = fs.getFileStatus(file);
       FileStatus fileStatus = fs.getFileStatus(file);
       assertEquals(fileStatus.getLen(), newLength);
       assertEquals(fileStatus.getLen(), newLength);
@@ -312,8 +311,8 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
 
 
   private void assertPathCapabilityForTruncate(Path file) throws Exception {
   private void assertPathCapabilityForTruncate(Path file) throws Exception {
     FileSystem fs = this.getHttpFSFileSystem();
     FileSystem fs = this.getHttpFSFileSystem();
-    assertTrue("HttpFS/WebHdfs/SWebHdfs support truncate",
-        fs.hasPathCapability(file, CommonPathCapabilities.FS_TRUNCATE));
+    assertTrue(fs.hasPathCapability(file, CommonPathCapabilities.FS_TRUNCATE),
+        "HttpFS/WebHdfs/SWebHdfs support truncate");
     fs.close();
     fs.close();
   }
   }
 
 
@@ -371,10 +370,10 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
     assertFalse(fs.exists(foo));
     assertFalse(fs.exists(foo));
     try {
     try {
       hoopFs.delete(new Path(bar.toUri().getPath()), false);
       hoopFs.delete(new Path(bar.toUri().getPath()), false);
-      Assert.fail();
+      fail();
     } catch (IOException ex) {
     } catch (IOException ex) {
     } catch (Exception ex) {
     } catch (Exception ex) {
-      Assert.fail();
+      fail();
     }
     }
     assertTrue(fs.exists(bar));
     assertTrue(fs.exists(bar));
     assertTrue(hoopFs.delete(new Path(bar.toUri().getPath()), true));
     assertTrue(hoopFs.delete(new Path(bar.toUri().getPath()), true));
@@ -467,10 +466,10 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
 
 
     // The full path should be the path to the file. See HDFS-12139
     // The full path should be the path to the file. See HDFS-12139
     FileStatus[] statl = fs.listStatus(path);
     FileStatus[] statl = fs.listStatus(path);
-    Assert.assertEquals(1, statl.length);
-    Assert.assertEquals(status2.getPath(), statl[0].getPath());
-    Assert.assertEquals(statl[0].getPath().getName(), path.getName());
-    Assert.assertEquals(stati[0].getPath(), statl[0].getPath());
+    assertEquals(1, statl.length);
+    assertEquals(status2.getPath(), statl[0].getPath());
+    assertEquals(statl[0].getPath().getName(), path.getName());
+    assertEquals(stati[0].getPath(), statl[0].getPath());
   }
   }
 
 
   private void testFileStatusAttr() throws Exception {
   private void testFileStatusAttr() throws Exception {
@@ -483,18 +482,18 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       // Get the FileSystem instance that's being tested
       // Get the FileSystem instance that's being tested
       FileSystem fs = this.getHttpFSFileSystem();
       FileSystem fs = this.getHttpFSFileSystem();
       // Check FileStatus
       // Check FileStatus
-      assertFalse("Snapshot should be disallowed by default",
-          fs.getFileStatus(path).isSnapshotEnabled());
+      assertFalse(fs.getFileStatus(path).isSnapshotEnabled(),
+          "Snapshot should be disallowed by default");
       // Allow snapshot
       // Allow snapshot
       distributedFs.allowSnapshot(path);
       distributedFs.allowSnapshot(path);
       // Check FileStatus
       // Check FileStatus
-      assertTrue("Snapshot enabled bit is not set in FileStatus",
-          fs.getFileStatus(path).isSnapshotEnabled());
+      assertTrue(fs.getFileStatus(path).isSnapshotEnabled(),
+          "Snapshot enabled bit is not set in FileStatus");
       // Disallow snapshot
       // Disallow snapshot
       distributedFs.disallowSnapshot(path);
       distributedFs.disallowSnapshot(path);
       // Check FileStatus
       // Check FileStatus
-      assertFalse("Snapshot enabled bit is not cleared in FileStatus",
-          fs.getFileStatus(path).isSnapshotEnabled());
+      assertFalse(fs.getFileStatus(path).isSnapshotEnabled(),
+          "Snapshot enabled bit is not cleared in FileStatus");
       // Cleanup
       // Cleanup
       fs.delete(path, true);
       fs.delete(path, true);
       fs.close();
       fs.close();
@@ -529,7 +528,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
     // LocalFileSystem writes checksum files next to the data files, which
     // LocalFileSystem writes checksum files next to the data files, which
     // show up when listing via LFS. This makes the listings not compare
     // show up when listing via LFS. This makes the listings not compare
     // properly.
     // properly.
-    Assume.assumeFalse(isLocalFS());
+    assumeFalse(isLocalFS());
 
 
     FileSystem proxyFs = FileSystem.get(getProxiedFSConf());
     FileSystem proxyFs = FileSystem.get(getProxiedFSConf());
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
@@ -555,13 +554,13 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
     RemoteIterator<FileStatus> si = proxyFs.listStatusIterator(dir1);
     RemoteIterator<FileStatus> si = proxyFs.listStatusIterator(dir1);
     FileStatus statusl = si.next();
     FileStatus statusl = si.next();
     FileStatus status = proxyFs.getFileStatus(file1);
     FileStatus status = proxyFs.getFileStatus(file1);
-    Assert.assertEquals(file1.getName(), statusl.getPath().getName());
-    Assert.assertEquals(status.getPath(), statusl.getPath());
+    assertEquals(file1.getName(), statusl.getPath().getName());
+    assertEquals(status.getPath(), statusl.getPath());
 
 
     si = proxyFs.listStatusIterator(file1);
     si = proxyFs.listStatusIterator(file1);
     statusl = si.next();
     statusl = si.next();
-    Assert.assertEquals(file1.getName(), statusl.getPath().getName());
-    Assert.assertEquals(status.getPath(), statusl.getPath());
+    assertEquals(file1.getName(), statusl.getPath().getName());
+    assertEquals(status.getPath(), statusl.getPath());
   }
   }
 
 
   private void testWorkingdirectory() throws Exception {
   private void testWorkingdirectory() throws Exception {
@@ -845,7 +844,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       fs.setXAttr(path, name4, value4);
       fs.setXAttr(path, name4, value4);
       try {
       try {
         fs.setXAttr(path, name5, value1);
         fs.setXAttr(path, name5, value1);
-        Assert.fail("Set xAttr with incorrect name format should fail.");
+        fail("Set xAttr with incorrect name format should fail.");
       } catch (IOException e) {
       } catch (IOException e) {
       } catch (IllegalArgumentException e) {
       } catch (IllegalArgumentException e) {
       }
       }
@@ -910,7 +909,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       final String name5 = "a1";
       final String name5 = "a1";
       try {
       try {
         value = fs.getXAttr(path, name5);
         value = fs.getXAttr(path, name5);
-        Assert.fail("Get xAttr with incorrect name format should fail.");
+        fail("Get xAttr with incorrect name format should fail.");
       } catch (IOException e) {
       } catch (IOException e) {
       } catch (IllegalArgumentException e) {
       } catch (IllegalArgumentException e) {
       }
       }
@@ -961,7 +960,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       fs.removeXAttr(path, name4);
       fs.removeXAttr(path, name4);
       try {
       try {
         fs.removeXAttr(path, name5);
         fs.removeXAttr(path, name5);
-        Assert.fail("Remove xAttr with incorrect name format should fail.");
+        fail("Remove xAttr with incorrect name format should fail.");
       } catch (IOException e) {
       } catch (IOException e) {
       } catch (IllegalArgumentException e) {
       } catch (IllegalArgumentException e) {
       }
       }
@@ -1151,7 +1150,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
   }
   }
 
 
   private void testErasureCoding() throws Exception {
   private void testErasureCoding() throws Exception {
-    Assume.assumeFalse("Assume its not a local FS!", isLocalFS());
+    assumeFalse(isLocalFS(), "Assume its not a local FS!");
     FileSystem proxyFs = FileSystem.get(getProxiedFSConf());
     FileSystem proxyFs = FileSystem.get(getProxiedFSConf());
     FileSystem httpFS = getHttpFSFileSystem();
     FileSystem httpFS = getHttpFSFileSystem();
     Path filePath = new Path(getProxiedFSTestDir(), "foo.txt");
     Path filePath = new Path(getProxiedFSTestDir(), "foo.txt");
@@ -1169,15 +1168,15 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
   }
   }
 
 
   private void testStoragePolicy() throws Exception {
   private void testStoragePolicy() throws Exception {
-    Assume.assumeFalse("Assume its not a local FS", isLocalFS());
+    assumeFalse(isLocalFS(), "Assume its not a local FS");
     FileSystem fs = FileSystem.get(getProxiedFSConf());
     FileSystem fs = FileSystem.get(getProxiedFSConf());
     fs.mkdirs(getProxiedFSTestDir());
     fs.mkdirs(getProxiedFSTestDir());
     Path path = new Path(getProxiedFSTestDir(), "policy.txt");
     Path path = new Path(getProxiedFSTestDir(), "policy.txt");
     FileSystem httpfs = getHttpFSFileSystem();
     FileSystem httpfs = getHttpFSFileSystem();
     // test getAllStoragePolicies
     // test getAllStoragePolicies
-    Assert.assertArrayEquals(
-        "Policy array returned from the DFS and HttpFS should be equals",
-        fs.getAllStoragePolicies().toArray(), httpfs.getAllStoragePolicies().toArray());
+    assertArrayEquals(fs.getAllStoragePolicies().toArray(),
+        httpfs.getAllStoragePolicies().toArray(),
+        "Policy array returned from the DFS and HttpFS should be equals");
 
 
     // test get/set/unset policies
     // test get/set/unset policies
     DFSTestUtil.createFile(fs, path, 0, (short) 1, 0L);
     DFSTestUtil.createFile(fs, path, 0, (short) 1, 0L);
@@ -1189,22 +1188,15 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
     BlockStoragePolicySpi dfsPolicy = fs.getStoragePolicy(path);
     BlockStoragePolicySpi dfsPolicy = fs.getStoragePolicy(path);
     // get policy from webhdfs
     // get policy from webhdfs
     BlockStoragePolicySpi httpFsPolicy = httpfs.getStoragePolicy(path);
     BlockStoragePolicySpi httpFsPolicy = httpfs.getStoragePolicy(path);
-    Assert
-       .assertEquals(
-            "Storage policy returned from the get API should"
-            + " be same as set policy",
-            HdfsConstants.COLD_STORAGE_POLICY_NAME.toString(),
-            httpFsPolicy.getName());
-    Assert.assertEquals(
-        "Storage policy returned from the DFS and HttpFS should be equals",
-        httpFsPolicy, dfsPolicy);
+    assertEquals(HdfsConstants.COLD_STORAGE_POLICY_NAME.toString(),
+        httpFsPolicy.getName(), "Storage policy returned from the get API should" +
+        " be same as set policy");
+    assertEquals(httpFsPolicy, dfsPolicy,
+        "Storage policy returned from the DFS and HttpFS should be equals");
     // unset policy
     // unset policy
     httpfs.unsetStoragePolicy(path);
     httpfs.unsetStoragePolicy(path);
-    Assert
-       .assertEquals(
-            "After unset storage policy, the get API shoudld"
-            + " return the default policy",
-            defaultdfsPolicy, httpfs.getStoragePolicy(path));
+    assertEquals(defaultdfsPolicy, httpfs.getStoragePolicy(path),
+        "After unset storage policy, the get API shoudld return the default policy");
     fs.close();
     fs.close();
   }
   }
 
 
@@ -1380,7 +1372,6 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
     }
     }
   }
   }
 
 
-  @Parameterized.Parameters
   public static Collection operations() {
   public static Collection operations() {
     Object[][] ops = new Object[Operation.values().length][];
     Object[][] ops = new Object[Operation.values().length][];
     for (int i = 0; i < Operation.values().length; i++) {
     for (int i = 0; i < Operation.values().length; i++) {
@@ -1393,24 +1384,28 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
 
 
   private Operation operation;
   private Operation operation;
 
 
-  public BaseTestHttpFSWith(Operation operation) {
-    this.operation = operation;
+  public void initBaseTestHttpFSWith(Operation pOperation) {
+    this.operation = pOperation;
   }
   }
 
 
-  @Test
+  @MethodSource("operations")
+  @ParameterizedTest
   @TestDir
   @TestDir
   @TestJetty
   @TestJetty
   @TestHdfs
   @TestHdfs
-  public void testOperation() throws Exception {
+  public void testOperation(Operation pOperation) throws Exception {
+    initBaseTestHttpFSWith(pOperation);
     createHttpFSServer();
     createHttpFSServer();
     operation(operation);
     operation(operation);
   }
   }
 
 
-  @Test
+  @MethodSource("operations")
+  @ParameterizedTest
   @TestDir
   @TestDir
   @TestJetty
   @TestJetty
   @TestHdfs
   @TestHdfs
-  public void testOperationDoAs() throws Exception {
+  public void testOperationDoAs(Operation pOperation) throws Exception {
+    initBaseTestHttpFSWith(pOperation);
     createHttpFSServer();
     createHttpFSServer();
     UserGroupInformation ugi = UserGroupInformation.createProxyUser(HadoopUsersConfTestHelper.getHadoopUsers()[0],
     UserGroupInformation ugi = UserGroupInformation.createProxyUser(HadoopUsersConfTestHelper.getHadoopUsers()[0],
                                                                     UserGroupInformation.getCurrentUser());
                                                                     UserGroupInformation.getCurrentUser());
@@ -1436,16 +1431,15 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       }
       }
       Path snapshotsDir = new Path("/tmp/tmp-snap-test/.snapshot");
       Path snapshotsDir = new Path("/tmp/tmp-snap-test/.snapshot");
       FileStatus[] snapshotItems = fs.listStatus(snapshotsDir);
       FileStatus[] snapshotItems = fs.listStatus(snapshotsDir);
-      assertTrue("Should have exactly one snapshot.",
-          snapshotItems.length == 1);
+      assertTrue(snapshotItems.length == 1,
+          "Should have exactly one snapshot.");
       String resultingSnapName = snapshotItems[0].getPath().getName();
       String resultingSnapName = snapshotItems[0].getPath().getName();
       if (snapshotName == null) {
       if (snapshotName == null) {
-        assertTrue("Snapshot auto generated name not matching pattern",
-            Pattern.matches("(s)(\\d{8})(-)(\\d{6})(\\.)(\\d{3})",
-                resultingSnapName));
+        assertTrue(Pattern.matches("(s)(\\d{8})(-)(\\d{6})(\\.)(\\d{3})",
+            resultingSnapName), "Snapshot auto generated name not matching pattern");
       } else {
       } else {
-        assertTrue("Snapshot name is not same as passed name.",
-            snapshotName.equals(resultingSnapName));
+        assertTrue(snapshotName.equals(resultingSnapName),
+            "Snapshot name is not same as passed name.");
       }
       }
       cleanSnapshotTests(snapshottablePath, resultingSnapName);
       cleanSnapshotTests(snapshottablePath, resultingSnapName);
     }
     }
@@ -1495,11 +1489,11 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
           "snap-new-name");
           "snap-new-name");
       Path snapshotsDir = new Path("/tmp/tmp-snap-test/.snapshot");
       Path snapshotsDir = new Path("/tmp/tmp-snap-test/.snapshot");
       FileStatus[] snapshotItems = fs.listStatus(snapshotsDir);
       FileStatus[] snapshotItems = fs.listStatus(snapshotsDir);
-      assertTrue("Should have exactly one snapshot.",
-          snapshotItems.length == 1);
+      assertTrue(snapshotItems.length == 1,
+          "Should have exactly one snapshot.");
       String resultingSnapName = snapshotItems[0].getPath().getName();
       String resultingSnapName = snapshotItems[0].getPath().getName();
-      assertTrue("Snapshot name is not same as passed name.",
-          "snap-new-name".equals(resultingSnapName));
+      assertTrue("snap-new-name".equals(resultingSnapName),
+          "Snapshot name is not same as passed name.");
       cleanSnapshotTests(snapshottablePath, resultingSnapName);
       cleanSnapshotTests(snapshottablePath, resultingSnapName);
     }
     }
   }
   }
@@ -1513,12 +1507,12 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       fs.createSnapshot(snapshottablePath, "snap-to-delete");
       fs.createSnapshot(snapshottablePath, "snap-to-delete");
       Path snapshotsDir = new Path("/tmp/tmp-snap-test/.snapshot");
       Path snapshotsDir = new Path("/tmp/tmp-snap-test/.snapshot");
       FileStatus[] snapshotItems = fs.listStatus(snapshotsDir);
       FileStatus[] snapshotItems = fs.listStatus(snapshotsDir);
-      assertTrue("Should have exactly one snapshot.",
-          snapshotItems.length == 1);
+      assertTrue(snapshotItems.length == 1,
+          "Should have exactly one snapshot.");
       fs.deleteSnapshot(snapshottablePath, "snap-to-delete");
       fs.deleteSnapshot(snapshottablePath, "snap-to-delete");
       snapshotItems = fs.listStatus(snapshotsDir);
       snapshotItems = fs.listStatus(snapshotsDir);
-      assertTrue("There should be no snapshot anymore.",
-          snapshotItems.length == 0);
+      assertTrue(snapshotItems.length == 0,
+          "There should be no snapshot anymore.");
       fs.delete(snapshottablePath, true);
       fs.delete(snapshottablePath, true);
     }
     }
   }
   }
@@ -1531,8 +1525,8 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       // Get the FileSystem instance that's being tested
       // Get the FileSystem instance that's being tested
       FileSystem fs = this.getHttpFSFileSystem();
       FileSystem fs = this.getHttpFSFileSystem();
       // Check FileStatus
       // Check FileStatus
-      assertFalse("Snapshot should be disallowed by default",
-          fs.getFileStatus(path).isSnapshotEnabled());
+      assertFalse(fs.getFileStatus(path).isSnapshotEnabled(),
+          "Snapshot should be disallowed by default");
       // Allow snapshot
       // Allow snapshot
       if (fs instanceof HttpFSFileSystem) {
       if (fs instanceof HttpFSFileSystem) {
         HttpFSFileSystem httpFS = (HttpFSFileSystem) fs;
         HttpFSFileSystem httpFS = (HttpFSFileSystem) fs;
@@ -1541,12 +1535,12 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
         WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) fs;
         WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) fs;
         webHdfsFileSystem.allowSnapshot(path);
         webHdfsFileSystem.allowSnapshot(path);
       } else {
       } else {
-        Assert.fail(fs.getClass().getSimpleName() +
+        fail(fs.getClass().getSimpleName() +
             " doesn't support allowSnapshot");
             " doesn't support allowSnapshot");
       }
       }
       // Check FileStatus
       // Check FileStatus
-      assertTrue("allowSnapshot failed",
-          fs.getFileStatus(path).isSnapshotEnabled());
+      assertTrue(fs.getFileStatus(path).isSnapshotEnabled(),
+          "allowSnapshot failed");
       // Cleanup
       // Cleanup
       fs.delete(path, true);
       fs.delete(path, true);
     }
     }
@@ -1560,8 +1554,8 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       // Get the FileSystem instance that's being tested
       // Get the FileSystem instance that's being tested
       FileSystem fs = this.getHttpFSFileSystem();
       FileSystem fs = this.getHttpFSFileSystem();
       // Check FileStatus
       // Check FileStatus
-      assertTrue("Snapshot should be allowed by DFS",
-          fs.getFileStatus(path).isSnapshotEnabled());
+      assertTrue(fs.getFileStatus(path).isSnapshotEnabled(),
+          "Snapshot should be allowed by DFS");
       // Disallow snapshot
       // Disallow snapshot
       if (fs instanceof HttpFSFileSystem) {
       if (fs instanceof HttpFSFileSystem) {
         HttpFSFileSystem httpFS = (HttpFSFileSystem) fs;
         HttpFSFileSystem httpFS = (HttpFSFileSystem) fs;
@@ -1570,12 +1564,12 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
         WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) fs;
         WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) fs;
         webHdfsFileSystem.disallowSnapshot(path);
         webHdfsFileSystem.disallowSnapshot(path);
       } else {
       } else {
-        Assert.fail(fs.getClass().getSimpleName() +
+        fail(fs.getClass().getSimpleName() +
             " doesn't support disallowSnapshot");
             " doesn't support disallowSnapshot");
       }
       }
       // Check FileStatus
       // Check FileStatus
-      assertFalse("disallowSnapshot failed",
-          fs.getFileStatus(path).isSnapshotEnabled());
+      assertFalse(fs.getFileStatus(path).isSnapshotEnabled(),
+          "disallowSnapshot failed");
       // Cleanup
       // Cleanup
       fs.delete(path, true);
       fs.delete(path, true);
     }
     }
@@ -1589,8 +1583,8 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       // Get the FileSystem instance that's being tested
       // Get the FileSystem instance that's being tested
       FileSystem fs = this.getHttpFSFileSystem();
       FileSystem fs = this.getHttpFSFileSystem();
       // Check FileStatus
       // Check FileStatus
-      assertTrue("Snapshot should be allowed by DFS",
-          fs.getFileStatus(path).isSnapshotEnabled());
+      assertTrue(fs.getFileStatus(path).isSnapshotEnabled(),
+          "Snapshot should be allowed by DFS");
       // Create some snapshots
       // Create some snapshots
       fs.createSnapshot(path, "snap-01");
       fs.createSnapshot(path, "snap-01");
       fs.createSnapshot(path, "snap-02");
       fs.createSnapshot(path, "snap-02");
@@ -1613,17 +1607,17 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
           // Expect SnapshotException
           // Expect SnapshotException
         }
         }
       } else {
       } else {
-        Assert.fail(fs.getClass().getSimpleName() +
+        fail(fs.getClass().getSimpleName() +
             " doesn't support disallowSnapshot");
             " doesn't support disallowSnapshot");
       }
       }
       if (disallowSuccess) {
       if (disallowSuccess) {
-        Assert.fail("disallowSnapshot doesn't throw SnapshotException when "
+        fail("disallowSnapshot doesn't throw SnapshotException when "
             + "disallowing snapshot on a directory with at least one snapshot");
             + "disallowing snapshot on a directory with at least one snapshot");
       }
       }
       // Check FileStatus, should still be enabled since
       // Check FileStatus, should still be enabled since
       // disallow snapshot should fail
       // disallow snapshot should fail
-      assertTrue("disallowSnapshot should not have succeeded",
-          fs.getFileStatus(path).isSnapshotEnabled());
+      assertTrue(fs.getFileStatus(path).isSnapshotEnabled(),
+          "disallowSnapshot should not have succeeded");
       // Cleanup
       // Cleanup
       fs.deleteSnapshot(path, "snap-02");
       fs.deleteSnapshot(path, "snap-02");
       fs.deleteSnapshot(path, "snap-01");
       fs.deleteSnapshot(path, "snap-01");
@@ -1639,7 +1633,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       // Get the FileSystem instance that's being tested
       // Get the FileSystem instance that's being tested
       FileSystem fs = this.getHttpFSFileSystem();
       FileSystem fs = this.getHttpFSFileSystem();
       // Check FileStatus
       // Check FileStatus
-      Assert.assertTrue(fs.getFileStatus(path).isSnapshotEnabled());
+      assertTrue(fs.getFileStatus(path).isSnapshotEnabled());
       // Create a file and take a snapshot
       // Create a file and take a snapshot
       Path file1 = new Path(path, "file1");
       Path file1 = new Path(path, "file1");
       testCreate(file1, false);
       testCreate(file1, false);
@@ -1659,13 +1653,13 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
           WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) fs;
           WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) fs;
           diffReport = webHdfsFileSystem.getSnapshotDiffReport(path, "snap1", "snap2");
           diffReport = webHdfsFileSystem.getSnapshotDiffReport(path, "snap1", "snap2");
         } else {
         } else {
-          Assert.fail(fs.getClass().getSimpleName() + " doesn't support getSnapshotDiff");
+          fail(fs.getClass().getSimpleName() + " doesn't support getSnapshotDiff");
         }
         }
         // Verify result with DFS
         // Verify result with DFS
         DistributedFileSystem dfs =
         DistributedFileSystem dfs =
             (DistributedFileSystem) FileSystem.get(path.toUri(), this.getProxiedFSConf());
             (DistributedFileSystem) FileSystem.get(path.toUri(), this.getProxiedFSConf());
         SnapshotDiffReport dfsDiffReport = dfs.getSnapshotDiffReport(path, "snap1", "snap2");
         SnapshotDiffReport dfsDiffReport = dfs.getSnapshotDiffReport(path, "snap1", "snap2");
-        Assert.assertEquals(diffReport.toString(), dfsDiffReport.toString());
+        assertEquals(diffReport.toString(), dfsDiffReport.toString());
       } finally {
       } finally {
         // Cleanup
         // Cleanup
         fs.deleteSnapshot(path, "snap2");
         fs.deleteSnapshot(path, "snap2");
@@ -1686,7 +1680,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
         webHdfsFileSystem.getSnapshotDiffReport(path, oldsnapshotname,
         webHdfsFileSystem.getSnapshotDiffReport(path, oldsnapshotname,
             snapshotname);
             snapshotname);
       } else {
       } else {
-        Assert.fail(fs.getClass().getSimpleName() +
+        fail(fs.getClass().getSimpleName() +
             " doesn't support getSnapshotDiff");
             " doesn't support getSnapshotDiff");
       }
       }
     } catch (SnapshotException|IllegalArgumentException|RemoteException e) {
     } catch (SnapshotException|IllegalArgumentException|RemoteException e) {
@@ -1694,12 +1688,12 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       // or RemoteException(IllegalArgumentException)
       // or RemoteException(IllegalArgumentException)
       if (e instanceof RemoteException) {
       if (e instanceof RemoteException) {
         // Check RemoteException class name, should be IllegalArgumentException
         // Check RemoteException class name, should be IllegalArgumentException
-        Assert.assertEquals(((RemoteException) e).getClassName()
+        assertEquals(((RemoteException) e).getClassName()
             .compareTo(java.lang.IllegalArgumentException.class.getName()), 0);
             .compareTo(java.lang.IllegalArgumentException.class.getName()), 0);
       }
       }
       return;
       return;
     }
     }
-    Assert.fail("getSnapshotDiff illegal param didn't throw Exception");
+    fail("getSnapshotDiff illegal param didn't throw Exception");
   }
   }
 
 
   private void testGetSnapshotDiffIllegalParam() throws Exception {
   private void testGetSnapshotDiffIllegalParam() throws Exception {
@@ -1710,9 +1704,9 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       // Get the FileSystem instance that's being tested
       // Get the FileSystem instance that's being tested
       FileSystem fs = this.getHttpFSFileSystem();
       FileSystem fs = this.getHttpFSFileSystem();
       // Check FileStatus
       // Check FileStatus
-      assertTrue("Snapshot should be allowed by DFS",
-          fs.getFileStatus(path).isSnapshotEnabled());
-      Assert.assertTrue(fs.getFileStatus(path).isSnapshotEnabled());
+      assertTrue(fs.getFileStatus(path).isSnapshotEnabled(),
+          "Snapshot should be allowed by DFS");
+      assertTrue(fs.getFileStatus(path).isSnapshotEnabled());
       // Get snapshot diff
       // Get snapshot diff
       testGetSnapshotDiffIllegalParamCase(fs, path, "", "");
       testGetSnapshotDiffIllegalParamCase(fs, path, "", "");
       testGetSnapshotDiffIllegalParamCase(fs, path, "snap1", "");
       testGetSnapshotDiffIllegalParamCase(fs, path, "snap1", "");
@@ -1734,12 +1728,12 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) fs;
       WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) fs;
       sds = webHdfsFileSystem.getSnapshottableDirectoryList();
       sds = webHdfsFileSystem.getSnapshottableDirectoryList();
     } else {
     } else {
-      Assert.fail(fs.getClass().getSimpleName() +
+      fail(fs.getClass().getSimpleName() +
           " doesn't support getSnapshottableDirListing");
           " doesn't support getSnapshottableDirListing");
     }
     }
     // Verify result with DFS
     // Verify result with DFS
     SnapshottableDirectoryStatus[] dfssds = dfs.getSnapshottableDirListing();
     SnapshottableDirectoryStatus[] dfssds = dfs.getSnapshottableDirListing();
-    Assert.assertEquals(JsonUtil.toJsonString(sds),
+    assertEquals(JsonUtil.toJsonString(sds),
         JsonUtil.toJsonString(dfssds));
         JsonUtil.toJsonString(dfssds));
   }
   }
 
 
@@ -1751,7 +1745,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       // Get the FileSystem instance that's being tested
       // Get the FileSystem instance that's being tested
       FileSystem fs = this.getHttpFSFileSystem();
       FileSystem fs = this.getHttpFSFileSystem();
       // Check FileStatus
       // Check FileStatus
-      Assert.assertTrue(fs.getFileStatus(path).isSnapshotEnabled());
+      assertTrue(fs.getFileStatus(path).isSnapshotEnabled());
       // Create a file and take a snapshot
       // Create a file and take a snapshot
       Path file1 = new Path(path, "file1");
       Path file1 = new Path(path, "file1");
       testCreate(file1, false);
       testCreate(file1, false);
@@ -1769,7 +1763,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
         WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) fs;
         WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) fs;
         snapshotStatus = webHdfsFileSystem.getSnapshotListing(path);
         snapshotStatus = webHdfsFileSystem.getSnapshotListing(path);
       } else {
       } else {
-        Assert.fail(fs.getClass().getSimpleName() +
+        fail(fs.getClass().getSimpleName() +
             " doesn't support getSnapshotDiff");
             " doesn't support getSnapshotDiff");
       }
       }
       // Verify result with DFS
       // Verify result with DFS
@@ -1777,7 +1771,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
           FileSystem.get(path.toUri(), this.getProxiedFSConf());
           FileSystem.get(path.toUri(), this.getProxiedFSConf());
       SnapshotStatus[] dfsStatus =
       SnapshotStatus[] dfsStatus =
           dfs.getSnapshotListing(path);
           dfs.getSnapshotListing(path);
-      Assert.assertEquals(JsonUtil.toJsonString(snapshotStatus),
+      assertEquals(JsonUtil.toJsonString(snapshotStatus),
           JsonUtil.toJsonString(dfsStatus));
           JsonUtil.toJsonString(dfsStatus));
       // Cleanup
       // Cleanup
       fs.deleteSnapshot(path, "snap2");
       fs.deleteSnapshot(path, "snap2");
@@ -1797,12 +1791,12 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       // Verify response when there is no snapshottable directory
       // Verify response when there is no snapshottable directory
       verifyGetSnapshottableDirListing(fs, dfs);
       verifyGetSnapshottableDirListing(fs, dfs);
       createSnapshotTestsPreconditions(path1);
       createSnapshotTestsPreconditions(path1);
-      Assert.assertTrue(fs.getFileStatus(path1).isSnapshotEnabled());
+      assertTrue(fs.getFileStatus(path1).isSnapshotEnabled());
       // Verify response when there is one snapshottable directory
       // Verify response when there is one snapshottable directory
       verifyGetSnapshottableDirListing(fs, dfs);
       verifyGetSnapshottableDirListing(fs, dfs);
       Path path2 = new Path("/tmp/tmp-snap-dirlist-test-2");
       Path path2 = new Path("/tmp/tmp-snap-dirlist-test-2");
       createSnapshotTestsPreconditions(path2);
       createSnapshotTestsPreconditions(path2);
-      Assert.assertTrue(fs.getFileStatus(path2).isSnapshotEnabled());
+      assertTrue(fs.getFileStatus(path2).isSnapshotEnabled());
       // Verify response when there are two snapshottable directories
       // Verify response when there are two snapshottable directories
       verifyGetSnapshottableDirListing(fs, dfs);
       verifyGetSnapshottableDirListing(fs, dfs);
 
 
@@ -1829,7 +1823,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
     FileSystem httpfs = getHttpFSFileSystem(conf);
     FileSystem httpfs = getHttpFSFileSystem(conf);
     if (!(httpfs instanceof WebHdfsFileSystem)
     if (!(httpfs instanceof WebHdfsFileSystem)
         && !(httpfs instanceof HttpFSFileSystem)) {
         && !(httpfs instanceof HttpFSFileSystem)) {
-      Assert.fail(httpfs.getClass().getSimpleName() +
+      fail(httpfs.getClass().getSimpleName() +
           " doesn't support custom user and group name pattern. "
           " doesn't support custom user and group name pattern. "
           + "Only WebHdfsFileSystem and HttpFSFileSystem support it.");
           + "Only WebHdfsFileSystem and HttpFSFileSystem support it.");
     }
     }
@@ -1857,8 +1851,8 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
     for (AclEntry aclEntry : httpfsAclStat.getEntries()) {
     for (AclEntry aclEntry : httpfsAclStat.getEntries()) {
       strEntries.add(aclEntry.toStringStable());
       strEntries.add(aclEntry.toStringStable());
     }
     }
-    Assert.assertTrue(strEntries.contains(aclUser));
-    Assert.assertTrue(strEntries.contains(aclGroup));
+    assertTrue(strEntries.contains(aclUser));
+    assertTrue(strEntries.contains(aclGroup));
     // Clean up
     // Clean up
     proxyFs.delete(new Path(dir), true);
     proxyFs.delete(new Path(dir), true);
   }
   }
@@ -1873,12 +1867,11 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) fs;
       WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) fs;
       sds = webHdfsFileSystem.getServerDefaults();
       sds = webHdfsFileSystem.getServerDefaults();
     } else {
     } else {
-      Assert.fail(
-          fs.getClass().getSimpleName() + " doesn't support getServerDefaults");
+      fail(fs.getClass().getSimpleName() + " doesn't support getServerDefaults");
     }
     }
     // Verify result with DFS
     // Verify result with DFS
     FsServerDefaults dfssds = dfs.getServerDefaults();
     FsServerDefaults dfssds = dfs.getServerDefaults();
-    Assert.assertEquals(JsonUtil.toJsonString(sds),
+    assertEquals(JsonUtil.toJsonString(sds),
         JsonUtil.toJsonString(dfssds));
         JsonUtil.toJsonString(dfssds));
   }
   }
 
 
@@ -1916,7 +1909,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) fs;
       WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) fs;
       webHdfsFileSystem.access(p1, FsAction.READ);
       webHdfsFileSystem.access(p1, FsAction.READ);
     } else {
     } else {
-      Assert.fail(fs.getClass().getSimpleName() + " doesn't support access");
+      fail(fs.getClass().getSimpleName() + " doesn't support access");
     }
     }
   }
   }
 
 
@@ -1942,7 +1935,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
         assertEquals(ecPolicy, ecPolicy1);
         assertEquals(ecPolicy, ecPolicy1);
         httpFS.unsetErasureCodingPolicy(p1);
         httpFS.unsetErasureCodingPolicy(p1);
         ecPolicy1 = httpFS.getErasureCodingPolicy(p1);
         ecPolicy1 = httpFS.getErasureCodingPolicy(p1);
-        Assert.assertNull(ecPolicy1);
+        assertNull(ecPolicy1);
       } else if (fs instanceof WebHdfsFileSystem) {
       } else if (fs instanceof WebHdfsFileSystem) {
         WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) fs;
         WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) fs;
         webHdfsFileSystem.setErasureCodingPolicy(p1, ecPolicyName);
         webHdfsFileSystem.setErasureCodingPolicy(p1, ecPolicyName);
@@ -1951,9 +1944,9 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
         assertEquals(ecPolicy, ecPolicy1);
         assertEquals(ecPolicy, ecPolicy1);
         webHdfsFileSystem.unsetErasureCodingPolicy(p1);
         webHdfsFileSystem.unsetErasureCodingPolicy(p1);
         ecPolicy1 = dfs.getErasureCodingPolicy(p1);
         ecPolicy1 = dfs.getErasureCodingPolicy(p1);
-        Assert.assertNull(ecPolicy1);
+        assertNull(ecPolicy1);
       } else {
       } else {
-        Assert.fail(fs.getClass().getSimpleName() + " doesn't support access");
+        fail(fs.getClass().getSimpleName() + " doesn't support access");
       }
       }
     }
     }
   }
   }
@@ -1988,7 +1981,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
         assertTrue(xAttrs
         assertTrue(xAttrs
             .containsKey(HdfsServerConstants.XATTR_SATISFY_STORAGE_POLICY));
             .containsKey(HdfsServerConstants.XATTR_SATISFY_STORAGE_POLICY));
       } else {
       } else {
-        Assert.fail(fs.getClass().getSimpleName() + " doesn't support access");
+        fail(fs.getClass().getSimpleName() + " doesn't support access");
       }
       }
       dfs.delete(path1, true);
       dfs.delete(path1, true);
     }
     }
@@ -2020,7 +2013,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
         blockLocations = webHdfsFileSystem.getFileBlockLocations(testFile, 0, 1);
         blockLocations = webHdfsFileSystem.getFileBlockLocations(testFile, 0, 1);
         assertNotNull(blockLocations);
         assertNotNull(blockLocations);
       } else {
       } else {
-        Assert.fail(fs.getClass().getSimpleName() + " doesn't support access");
+        fail(fs.getClass().getSimpleName() + " doesn't support access");
       }
       }
     }
     }
   }
   }
@@ -2033,7 +2026,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       // Get the FileSystem instance that's being tested
       // Get the FileSystem instance that's being tested
       FileSystem fs = this.getHttpFSFileSystem();
       FileSystem fs = this.getHttpFSFileSystem();
       // Check FileStatus
       // Check FileStatus
-      Assert.assertTrue(fs.getFileStatus(path).isSnapshotEnabled());
+      assertTrue(fs.getFileStatus(path).isSnapshotEnabled());
       // Create a file and take a snapshot
       // Create a file and take a snapshot
       Path file1 = new Path(path, "file1");
       Path file1 = new Path(path, "file1");
       testCreate(file1, false);
       testCreate(file1, false);
@@ -2056,7 +2049,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
               .getSnapshotDiffReportListing(path.toUri().getPath(), "snap1", "snap2", emptyBytes,
               .getSnapshotDiffReportListing(path.toUri().getPath(), "snap1", "snap2", emptyBytes,
                   -1);
                   -1);
         } else {
         } else {
-          Assert.fail(fs.getClass().getSimpleName() + " doesn't support getSnapshotDiff");
+          fail(fs.getClass().getSimpleName() + " doesn't support getSnapshotDiff");
         }
         }
         // Verify result with DFS
         // Verify result with DFS
         DistributedFileSystem dfs =
         DistributedFileSystem dfs =
@@ -2117,7 +2110,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       httpFs.close();
       httpFs.close();
       dfs.close();
       dfs.close();
     } else {
     } else {
-      Assert.fail(fs.getClass().getSimpleName() + " is not of type DistributedFileSystem.");
+      fail(fs.getClass().getSimpleName() + " is not of type DistributedFileSystem.");
     }
     }
   }
   }
 
 
@@ -2144,7 +2137,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
         WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) httpFs;
         WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) httpFs;
         diffErasureCodingPolicies = webHdfsFileSystem.getAllErasureCodingPolicies();
         diffErasureCodingPolicies = webHdfsFileSystem.getAllErasureCodingPolicies();
       } else {
       } else {
-        Assert.fail(fs.getClass().getSimpleName() +
+        fail(fs.getClass().getSimpleName() +
             " is not of type HttpFSFileSystem or WebHdfsFileSystem");
             " is not of type HttpFSFileSystem or WebHdfsFileSystem");
       }
       }
 
 
@@ -2152,7 +2145,7 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
       assertEquals(dfsAllErasureCodingPolicies.size(), diffErasureCodingPolicies.size());
       assertEquals(dfsAllErasureCodingPolicies.size(), diffErasureCodingPolicies.size());
       assertTrue(dfsAllErasureCodingPolicies.containsAll(diffErasureCodingPolicies));
       assertTrue(dfsAllErasureCodingPolicies.containsAll(diffErasureCodingPolicies));
     } else {
     } else {
-      Assert.fail(fs.getClass().getSimpleName() + " is not of type DistributedFileSystem.");
+      fail(fs.getClass().getSimpleName() + " is not of type DistributedFileSystem.");
     }
     }
   }
   }
 
 
@@ -2194,13 +2187,13 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
     Map<String, String> diffErasureCodingCodecs = diffErasureCodingCodecsRef.get();
     Map<String, String> diffErasureCodingCodecs = diffErasureCodingCodecsRef.get();
 
 
     //Validate testGetECCodecs are the same as DistributedFileSystem
     //Validate testGetECCodecs are the same as DistributedFileSystem
-    Assert.assertEquals(dfsErasureCodingCodecs.size(), diffErasureCodingCodecs.size());
+    assertEquals(dfsErasureCodingCodecs.size(), diffErasureCodingCodecs.size());
 
 
     for (Map.Entry<String, String> entry : dfsErasureCodingCodecs.entrySet()) {
     for (Map.Entry<String, String> entry : dfsErasureCodingCodecs.entrySet()) {
       String key = entry.getKey();
       String key = entry.getKey();
       String value = entry.getValue();
       String value = entry.getValue();
-      Assert.assertTrue(diffErasureCodingCodecs.containsKey(key));
-      Assert.assertEquals(value, diffErasureCodingCodecs.get(key));
+      assertTrue(diffErasureCodingCodecs.containsKey(key));
+      assertEquals(value, diffErasureCodingCodecs.get(key));
     }
     }
   }
   }
 
 
@@ -2232,38 +2225,38 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
         WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) httpFs;
         WebHdfsFileSystem webHdfsFileSystem = (WebHdfsFileSystem) httpFs;
         diffTrashRoots = webHdfsFileSystem.getTrashRoots(true);
         diffTrashRoots = webHdfsFileSystem.getTrashRoots(true);
       } else {
       } else {
-        Assert.fail(fs.getClass().getSimpleName() +
+        fail(fs.getClass().getSimpleName() +
             " is not of type HttpFSFileSystem or WebHdfsFileSystem");
             " is not of type HttpFSFileSystem or WebHdfsFileSystem");
       }
       }
 
 
       // Validate getTrashRoots are the same as DistributedFileSystem
       // Validate getTrashRoots are the same as DistributedFileSystem
       assertEquals(dfsTrashRoots.size(), diffTrashRoots.size());
       assertEquals(dfsTrashRoots.size(), diffTrashRoots.size());
     } else {
     } else {
-      Assert.fail(fs.getClass().getSimpleName() + " is not of type DistributedFileSystem.");
+      fail(fs.getClass().getSimpleName() + " is not of type DistributedFileSystem.");
     }
     }
   }
   }
 
 
   private void assertHttpFsReportListingWithDfsClient(SnapshotDiffReportListing diffReportListing,
   private void assertHttpFsReportListingWithDfsClient(SnapshotDiffReportListing diffReportListing,
       SnapshotDiffReportListing dfsDiffReportListing) {
       SnapshotDiffReportListing dfsDiffReportListing) {
-    Assert.assertEquals(diffReportListing.getCreateList().size(),
+    assertEquals(diffReportListing.getCreateList().size(),
         dfsDiffReportListing.getCreateList().size());
         dfsDiffReportListing.getCreateList().size());
-    Assert.assertEquals(diffReportListing.getDeleteList().size(),
+    assertEquals(diffReportListing.getDeleteList().size(),
         dfsDiffReportListing.getDeleteList().size());
         dfsDiffReportListing.getDeleteList().size());
-    Assert.assertEquals(diffReportListing.getModifyList().size(),
+    assertEquals(diffReportListing.getModifyList().size(),
         dfsDiffReportListing.getModifyList().size());
         dfsDiffReportListing.getModifyList().size());
-    Assert.assertEquals(diffReportListing.getIsFromEarlier(),
+    assertEquals(diffReportListing.getIsFromEarlier(),
         dfsDiffReportListing.getIsFromEarlier());
         dfsDiffReportListing.getIsFromEarlier());
-    Assert.assertEquals(diffReportListing.getLastIndex(), dfsDiffReportListing.getLastIndex());
-    Assert.assertEquals(DFSUtil.bytes2String(diffReportListing.getLastPath()),
+    assertEquals(diffReportListing.getLastIndex(), dfsDiffReportListing.getLastIndex());
+    assertEquals(DFSUtil.bytes2String(diffReportListing.getLastPath()),
         DFSUtil.bytes2String(dfsDiffReportListing.getLastPath()));
         DFSUtil.bytes2String(dfsDiffReportListing.getLastPath()));
     int i = 0;
     int i = 0;
     for (SnapshotDiffReportListing.DiffReportListingEntry entry : diffReportListing
     for (SnapshotDiffReportListing.DiffReportListingEntry entry : diffReportListing
         .getCreateList()) {
         .getCreateList()) {
       SnapshotDiffReportListing.DiffReportListingEntry dfsDiffEntry =
       SnapshotDiffReportListing.DiffReportListingEntry dfsDiffEntry =
           dfsDiffReportListing.getCreateList().get(i);
           dfsDiffReportListing.getCreateList().get(i);
-      Assert.assertEquals(entry.getDirId(), dfsDiffEntry.getDirId());
-      Assert.assertEquals(entry.getFileId(), dfsDiffEntry.getFileId());
-      Assert.assertArrayEquals(DFSUtilClient.byteArray2bytes(entry.getSourcePath()),
+      assertEquals(entry.getDirId(), dfsDiffEntry.getDirId());
+      assertEquals(entry.getFileId(), dfsDiffEntry.getFileId());
+      assertArrayEquals(DFSUtilClient.byteArray2bytes(entry.getSourcePath()),
           DFSUtilClient.byteArray2bytes(dfsDiffEntry.getSourcePath()));
           DFSUtilClient.byteArray2bytes(dfsDiffEntry.getSourcePath()));
       i++;
       i++;
     }
     }
@@ -2272,9 +2265,9 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
         .getDeleteList()) {
         .getDeleteList()) {
       SnapshotDiffReportListing.DiffReportListingEntry dfsDiffEntry =
       SnapshotDiffReportListing.DiffReportListingEntry dfsDiffEntry =
           dfsDiffReportListing.getDeleteList().get(i);
           dfsDiffReportListing.getDeleteList().get(i);
-      Assert.assertEquals(entry.getDirId(), dfsDiffEntry.getDirId());
-      Assert.assertEquals(entry.getFileId(), dfsDiffEntry.getFileId());
-      Assert.assertArrayEquals(DFSUtilClient.byteArray2bytes(entry.getSourcePath()),
+      assertEquals(entry.getDirId(), dfsDiffEntry.getDirId());
+      assertEquals(entry.getFileId(), dfsDiffEntry.getFileId());
+      assertArrayEquals(DFSUtilClient.byteArray2bytes(entry.getSourcePath()),
           DFSUtilClient.byteArray2bytes(dfsDiffEntry.getSourcePath()));
           DFSUtilClient.byteArray2bytes(dfsDiffEntry.getSourcePath()));
       i++;
       i++;
     }
     }
@@ -2283,9 +2276,9 @@ public abstract class BaseTestHttpFSWith extends HFSTestCase {
         .getModifyList()) {
         .getModifyList()) {
       SnapshotDiffReportListing.DiffReportListingEntry dfsDiffEntry =
       SnapshotDiffReportListing.DiffReportListingEntry dfsDiffEntry =
           dfsDiffReportListing.getModifyList().get(i);
           dfsDiffReportListing.getModifyList().get(i);
-      Assert.assertEquals(entry.getDirId(), dfsDiffEntry.getDirId());
-      Assert.assertEquals(entry.getFileId(), dfsDiffEntry.getFileId());
-      Assert.assertArrayEquals(DFSUtilClient.byteArray2bytes(entry.getSourcePath()),
+      assertEquals(entry.getDirId(), dfsDiffEntry.getDirId());
+      assertEquals(entry.getFileId(), dfsDiffEntry.getFileId());
+      assertArrayEquals(DFSUtilClient.byteArray2bytes(entry.getSourcePath()),
           DFSUtilClient.byteArray2bytes(dfsDiffEntry.getSourcePath()));
           DFSUtilClient.byteArray2bytes(dfsDiffEntry.getSourcePath()));
       i++;
       i++;
     }
     }

+ 3 - 7
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/TestHttpFSFWithSWebhdfsFileSystem.java

@@ -25,16 +25,13 @@ import org.apache.hadoop.hdfs.web.SWebHdfsFileSystem;
 import org.apache.hadoop.security.ssl.KeyStoreTestUtil;
 import org.apache.hadoop.security.ssl.KeyStoreTestUtil;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.TestJettyHelper;
 import org.apache.hadoop.test.TestJettyHelper;
-import org.junit.AfterClass;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterAll;
 
 
 import java.io.File;
 import java.io.File;
 import java.net.URI;
 import java.net.URI;
 import java.net.URL;
 import java.net.URL;
 import java.util.UUID;
 import java.util.UUID;
 
 
-@RunWith(value = Parameterized.class)
 public class TestHttpFSFWithSWebhdfsFileSystem
 public class TestHttpFSFWithSWebhdfsFileSystem
   extends TestHttpFSWithHttpFSFileSystem {
   extends TestHttpFSWithHttpFSFileSystem {
   private static String classpathDir;
   private static String classpathDir;
@@ -69,15 +66,14 @@ public class TestHttpFSFWithSWebhdfsFileSystem
         "serverP");
         "serverP");
   }
   }
 
 
-  @AfterClass
+  @AfterAll
   public static void cleanUp() throws Exception {
   public static void cleanUp() throws Exception {
     new File(classpathDir, "ssl-client.xml").delete();
     new File(classpathDir, "ssl-client.xml").delete();
     new File(classpathDir, "ssl-server.xml").delete();
     new File(classpathDir, "ssl-server.xml").delete();
     KeyStoreTestUtil.cleanupSSLConfig(keyStoreDir, classpathDir);
     KeyStoreTestUtil.cleanupSSLConfig(keyStoreDir, classpathDir);
   }
   }
 
 
-  public TestHttpFSFWithSWebhdfsFileSystem(Operation operation) {
-    super(operation);
+  public TestHttpFSFWithSWebhdfsFileSystem() {
   }
   }
 
 
   @Override
   @Override

+ 1 - 5
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/TestHttpFSFWithWebhdfsFileSystem.java

@@ -19,15 +19,11 @@
 package org.apache.hadoop.fs.http.client;
 package org.apache.hadoop.fs.http.client;
 
 
 import org.apache.hadoop.hdfs.web.WebHdfsFileSystem;
 import org.apache.hadoop.hdfs.web.WebHdfsFileSystem;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
 
 
-@RunWith(value = Parameterized.class)
 public class TestHttpFSFWithWebhdfsFileSystem
 public class TestHttpFSFWithWebhdfsFileSystem
   extends TestHttpFSWithHttpFSFileSystem {
   extends TestHttpFSWithHttpFSFileSystem {
 
 
-  public TestHttpFSFWithWebhdfsFileSystem(Operation operation) {
-    super(operation);
+  public TestHttpFSFWithWebhdfsFileSystem() {
   }
   }
 
 
   @Override
   @Override

+ 4 - 7
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/TestHttpFSFileSystemLocalFileSystem.java

@@ -27,13 +27,11 @@ import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.TestDirHelper;
 import org.apache.hadoop.test.TestDirHelper;
-import org.junit.Assert;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
 
 
 import java.io.File;
 import java.io.File;
 
 
-@RunWith(value = Parameterized.class)
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
 public class TestHttpFSFileSystemLocalFileSystem extends BaseTestHttpFSWith {
 public class TestHttpFSFileSystemLocalFileSystem extends BaseTestHttpFSWith {
 
 
   private static String PATH_PREFIX;
   private static String PATH_PREFIX;
@@ -45,8 +43,7 @@ public class TestHttpFSFileSystemLocalFileSystem extends BaseTestHttpFSWith {
     PATH_PREFIX = file.getAbsolutePath();
     PATH_PREFIX = file.getAbsolutePath();
   }
   }
 
 
-  public TestHttpFSFileSystemLocalFileSystem(Operation operation) {
-    super(operation);
+  public TestHttpFSFileSystemLocalFileSystem() {
   }
   }
 
 
   @Override
   @Override
@@ -86,7 +83,7 @@ public class TestHttpFSFileSystemLocalFileSystem extends BaseTestHttpFSWith {
       FileStatus status1 = fs.getFileStatus(path);
       FileStatus status1 = fs.getFileStatus(path);
       fs.close();
       fs.close();
       FsPermission permission2 = status1.getPermission();
       FsPermission permission2 = status1.getPermission();
-      Assert.assertEquals(permission2, permission1);
+      assertEquals(permission2, permission1);
 
 
       // sticky bit not supported on Windows with local file system, so the
       // sticky bit not supported on Windows with local file system, so the
       // subclass skips that part of the test
       // subclass skips that part of the test

+ 1 - 5
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/client/TestHttpFSWithHttpFSFileSystem.java

@@ -22,14 +22,10 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
 import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.test.TestHdfsHelper;
 import org.apache.hadoop.test.TestHdfsHelper;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
 
 
-@RunWith(value = Parameterized.class)
 public class TestHttpFSWithHttpFSFileSystem extends BaseTestHttpFSWith {
 public class TestHttpFSWithHttpFSFileSystem extends BaseTestHttpFSWith {
 
 
-  public TestHttpFSWithHttpFSFileSystem(Operation operation) {
-    super(operation);
+  public TestHttpFSWithHttpFSFileSystem() {
   }
   }
 
 
   @Override
   @Override

+ 1 - 1
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestCheckUploadContentTypeFilter.java

@@ -24,7 +24,7 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponse;
 
 
 import org.apache.hadoop.fs.http.client.HttpFSFileSystem;
 import org.apache.hadoop.fs.http.client.HttpFSFileSystem;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.mockito.Mockito;
 
 
 public class TestCheckUploadContentTypeFilter {
 public class TestCheckUploadContentTypeFilter {

+ 15 - 13
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSAccessControlled.java

@@ -29,8 +29,7 @@ import org.apache.hadoop.test.TestDir;
 import org.apache.hadoop.test.TestDirHelper;
 import org.apache.hadoop.test.TestDirHelper;
 import org.apache.hadoop.test.TestJetty;
 import org.apache.hadoop.test.TestJetty;
 import org.apache.hadoop.test.TestJettyHelper;
 import org.apache.hadoop.test.TestJettyHelper;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.webapp.WebAppContext;
 import org.eclipse.jetty.webapp.WebAppContext;
 
 
@@ -44,6 +43,9 @@ import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URL;
 import java.text.MessageFormat;
 import java.text.MessageFormat;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 /**
 /**
  * This test class ensures that everything works as expected when
  * This test class ensures that everything works as expected when
  * support with the access controlled HTTPFS file system.
  * support with the access controlled HTTPFS file system.
@@ -93,9 +95,9 @@ public class TestHttpFSAccessControlled extends HTestCase {
    */
    */
   private void createHttpFSServer() throws Exception {
   private void createHttpFSServer() throws Exception {
     File homeDir = TestDirHelper.getTestDir();
     File homeDir = TestDirHelper.getTestDir();
-    Assert.assertTrue(new File(homeDir, "conf").mkdir());
-    Assert.assertTrue(new File(homeDir, "log").mkdir());
-    Assert.assertTrue(new File(homeDir, "temp").mkdir());
+    assertTrue(new File(homeDir, "conf").mkdir());
+    assertTrue(new File(homeDir, "log").mkdir());
+    assertTrue(new File(homeDir, "temp").mkdir());
     HttpFSServerWebApp.setHomeDirForCurrentThread(homeDir.getAbsolutePath());
     HttpFSServerWebApp.setHomeDirForCurrentThread(homeDir.getAbsolutePath());
 
 
     File secretFile = new File(new File(homeDir, "conf"), "secret");
     File secretFile = new File(new File(homeDir, "conf"), "secret");
@@ -175,9 +177,9 @@ public class TestHttpFSAccessControlled extends HTestCase {
     conn.connect();
     conn.connect();
     int resp = conn.getResponseCode();
     int resp = conn.getResponseCode();
     if ( expectOK ) {
     if ( expectOK ) {
-      Assert.assertEquals( outMsg, HttpURLConnection.HTTP_OK, resp);
+      assertEquals(HttpURLConnection.HTTP_OK, resp, outMsg);
     } else {
     } else {
-      Assert.assertEquals(outMsg, HttpURLConnection.HTTP_FORBIDDEN, resp);
+      assertEquals(HttpURLConnection.HTTP_FORBIDDEN, resp, outMsg);
     }
     }
   }
   }
 
 
@@ -207,9 +209,9 @@ public class TestHttpFSAccessControlled extends HTestCase {
     conn.connect();
     conn.connect();
     int resp = conn.getResponseCode();
     int resp = conn.getResponseCode();
     if ( expectOK ) {
     if ( expectOK ) {
-      Assert.assertEquals(outMsg, HttpURLConnection.HTTP_OK, resp);
+      assertEquals(HttpURLConnection.HTTP_OK, resp, outMsg);
     } else {
     } else {
-      Assert.assertEquals(outMsg, HttpURLConnection.HTTP_FORBIDDEN, resp);
+      assertEquals(HttpURLConnection.HTTP_FORBIDDEN, resp, outMsg);
     }
     }
   }
   }
 
 
@@ -239,9 +241,9 @@ public class TestHttpFSAccessControlled extends HTestCase {
     conn.connect();
     conn.connect();
     int resp = conn.getResponseCode();
     int resp = conn.getResponseCode();
     if ( expectOK ) {
     if ( expectOK ) {
-      Assert.assertEquals(outMsg, HttpURLConnection.HTTP_OK, resp);
+      assertEquals(HttpURLConnection.HTTP_OK, resp, outMsg);
     } else {
     } else {
-      Assert.assertEquals(outMsg, HttpURLConnection.HTTP_FORBIDDEN, resp);
+      assertEquals(HttpURLConnection.HTTP_FORBIDDEN, resp, outMsg);
     }
     }
   }
   }
 
 
@@ -271,9 +273,9 @@ public class TestHttpFSAccessControlled extends HTestCase {
     conn.connect();
     conn.connect();
     int resp = conn.getResponseCode();
     int resp = conn.getResponseCode();
     if ( expectOK ) {
     if ( expectOK ) {
-      Assert.assertEquals(outMsg, HttpURLConnection.HTTP_OK, resp);
+      assertEquals(HttpURLConnection.HTTP_OK, resp, outMsg);
     } else {
     } else {
-      Assert.assertEquals(outMsg, HttpURLConnection.HTTP_FORBIDDEN, resp);
+      assertEquals(HttpURLConnection.HTTP_FORBIDDEN, resp, outMsg);
     }
     }
   }
   }
 
 

File diff suppressed because it is too large
+ 168 - 165
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServer.java


+ 17 - 15
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServerNoACLs.java

@@ -30,8 +30,7 @@ import org.apache.hadoop.test.TestDir;
 import org.apache.hadoop.test.TestDirHelper;
 import org.apache.hadoop.test.TestDirHelper;
 import org.apache.hadoop.test.TestJetty;
 import org.apache.hadoop.test.TestJetty;
 import org.apache.hadoop.test.TestJettyHelper;
 import org.apache.hadoop.test.TestJettyHelper;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.webapp.WebAppContext;
 import org.eclipse.jetty.webapp.WebAppContext;
 
 
@@ -47,6 +46,9 @@ import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URL;
 import java.text.MessageFormat;
 import java.text.MessageFormat;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 /**
 /**
  * This test class ensures that everything works as expected when ACL
  * This test class ensures that everything works as expected when ACL
  * support is turned off HDFS.  This is the default configuration.  The other
  * support is turned off HDFS.  This is the default configuration.  The other
@@ -99,9 +101,9 @@ public class TestHttpFSServerNoACLs extends HTestCase {
    */
    */
   private void createHttpFSServer() throws Exception {
   private void createHttpFSServer() throws Exception {
     File homeDir = TestDirHelper.getTestDir();
     File homeDir = TestDirHelper.getTestDir();
-    Assert.assertTrue(new File(homeDir, "conf").mkdir());
-    Assert.assertTrue(new File(homeDir, "log").mkdir());
-    Assert.assertTrue(new File(homeDir, "temp").mkdir());
+    assertTrue(new File(homeDir, "conf").mkdir());
+    assertTrue(new File(homeDir, "log").mkdir());
+    assertTrue(new File(homeDir, "temp").mkdir());
     HttpFSServerWebApp.setHomeDirForCurrentThread(homeDir.getAbsolutePath());
     HttpFSServerWebApp.setHomeDirForCurrentThread(homeDir.getAbsolutePath());
 
 
     File secretFile = new File(new File(homeDir, "conf"), "secret");
     File secretFile = new File(new File(homeDir, "conf"), "secret");
@@ -182,17 +184,17 @@ public class TestHttpFSServerNoACLs extends HTestCase {
     int resp = conn.getResponseCode();
     int resp = conn.getResponseCode();
     BufferedReader reader;
     BufferedReader reader;
     if (expectOK) {
     if (expectOK) {
-      Assert.assertEquals(HttpURLConnection.HTTP_OK, resp);
+      assertEquals(HttpURLConnection.HTTP_OK, resp);
       reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
       reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
       String res = reader.readLine();
       String res = reader.readLine();
-      Assert.assertTrue(!res.contains("aclBit"));
-      Assert.assertTrue(res.contains("owner")); // basic sanity check
+      assertTrue(!res.contains("aclBit"));
+      assertTrue(res.contains("owner")); // basic sanity check
     } else {
     } else {
-      Assert.assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, resp);
+      assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, resp);
       reader = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
       reader = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
       String res = reader.readLine();
       String res = reader.readLine();
-      Assert.assertTrue(res.contains("AclException"));
-      Assert.assertTrue(res.contains("Support for ACLs has been disabled"));
+      assertTrue(res.contains("AclException"));
+      assertTrue(res.contains("Support for ACLs has been disabled"));
     }
     }
   }
   }
 
 
@@ -219,14 +221,14 @@ public class TestHttpFSServerNoACLs extends HTestCase {
     conn.connect();
     conn.connect();
     int resp = conn.getResponseCode();
     int resp = conn.getResponseCode();
     if (expectOK) {
     if (expectOK) {
-      Assert.assertEquals(HttpURLConnection.HTTP_OK, resp);
+      assertEquals(HttpURLConnection.HTTP_OK, resp);
     } else {
     } else {
-      Assert.assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, resp);
+      assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, resp);
       BufferedReader reader;
       BufferedReader reader;
       reader = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
       reader = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
       String err = reader.readLine();
       String err = reader.readLine();
-      Assert.assertTrue(err.contains("AclException"));
-      Assert.assertTrue(err.contains("Support for ACLs has been disabled"));
+      assertTrue(err.contains("AclException"));
+      assertTrue(err.contains("Support for ACLs has been disabled"));
     }
     }
   }
   }
 
 

+ 15 - 13
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServerNoXAttrs.java

@@ -31,8 +31,7 @@ import org.apache.hadoop.test.TestDirHelper;
 import org.apache.hadoop.test.TestHdfs;
 import org.apache.hadoop.test.TestHdfs;
 import org.apache.hadoop.test.TestJetty;
 import org.apache.hadoop.test.TestJetty;
 import org.apache.hadoop.test.TestJettyHelper;
 import org.apache.hadoop.test.TestJettyHelper;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.webapp.WebAppContext;
 import org.eclipse.jetty.webapp.WebAppContext;
 
 
@@ -48,6 +47,9 @@ import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URL;
 import java.text.MessageFormat;
 import java.text.MessageFormat;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 /**
 /**
  * This test class ensures that everything works as expected when XAttr
  * This test class ensures that everything works as expected when XAttr
  * support is turned off HDFS.  This is the default configuration.  The other
  * support is turned off HDFS.  This is the default configuration.  The other
@@ -100,9 +102,9 @@ public class TestHttpFSServerNoXAttrs extends HTestCase {
    */
    */
   private void createHttpFSServer() throws Exception {
   private void createHttpFSServer() throws Exception {
     File homeDir = TestDirHelper.getTestDir();
     File homeDir = TestDirHelper.getTestDir();
-    Assert.assertTrue(new File(homeDir, "conf").mkdir());
-    Assert.assertTrue(new File(homeDir, "log").mkdir());
-    Assert.assertTrue(new File(homeDir, "temp").mkdir());
+    assertTrue(new File(homeDir, "conf").mkdir());
+    assertTrue(new File(homeDir, "log").mkdir());
+    assertTrue(new File(homeDir, "temp").mkdir());
     HttpFSServerWebApp.setHomeDirForCurrentThread(homeDir.getAbsolutePath());
     HttpFSServerWebApp.setHomeDirForCurrentThread(homeDir.getAbsolutePath());
 
 
     File secretFile = new File(new File(homeDir, "conf"), "secret");
     File secretFile = new File(new File(homeDir, "conf"), "secret");
@@ -181,12 +183,12 @@ public class TestHttpFSServerNoXAttrs extends HTestCase {
     conn.connect();
     conn.connect();
     int resp = conn.getResponseCode();
     int resp = conn.getResponseCode();
     BufferedReader reader;
     BufferedReader reader;
-    Assert.assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, resp);
+    assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, resp);
     reader = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
     reader = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
     String res = reader.readLine();
     String res = reader.readLine();
-    Assert.assertTrue(res.contains("RemoteException"));
-    Assert.assertTrue(res.contains("XAttr"));
-    Assert.assertTrue(res.contains("rejected"));
+    assertTrue(res.contains("RemoteException"));
+    assertTrue(res.contains("XAttr"));
+    assertTrue(res.contains("rejected"));
   }
   }
 
 
   /**
   /**
@@ -211,13 +213,13 @@ public class TestHttpFSServerNoXAttrs extends HTestCase {
     conn.setRequestMethod("PUT");
     conn.setRequestMethod("PUT");
     conn.connect();
     conn.connect();
     int resp = conn.getResponseCode();
     int resp = conn.getResponseCode();
-    Assert.assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, resp);
+    assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, resp);
     BufferedReader reader;
     BufferedReader reader;
     reader = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
     reader = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
     String err = reader.readLine();
     String err = reader.readLine();
-    Assert.assertTrue(err.contains("RemoteException"));
-    Assert.assertTrue(err.contains("XAttr"));
-    Assert.assertTrue(err.contains("rejected"));
+    assertTrue(err.contains("RemoteException"));
+    assertTrue(err.contains("XAttr"));
+    assertTrue(err.contains("rejected"));
   }
   }
   
   
   /**
   /**

+ 15 - 15
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServerWebServer.java

@@ -37,27 +37,26 @@ import org.apache.hadoop.security.authentication.util.SignerSecretProvider;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.HadoopUsersConfTestHelper;
 import org.apache.hadoop.test.HadoopUsersConfTestHelper;
 import org.apache.hadoop.util.Shell;
 import org.apache.hadoop.util.Shell;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.After;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.Timeout;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
 
 
 import static org.apache.hadoop.security.authentication.server.AuthenticationFilter.SIGNER_SECRET_PROVIDER_ATTRIBUTE;
 import static org.apache.hadoop.security.authentication.server.AuthenticationFilter.SIGNER_SECRET_PROVIDER_ATTRIBUTE;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 /**
 /**
  * Test {@link HttpFSServerWebServer}.
  * Test {@link HttpFSServerWebServer}.
  */
  */
+@Timeout(30)
 public class TestHttpFSServerWebServer {
 public class TestHttpFSServerWebServer {
 
 
-  @Rule
-  public Timeout timeout = new Timeout(30000);
-
   private File secretFile;
   private File secretFile;
   private HttpFSServerWebServer webServer;
   private HttpFSServerWebServer webServer;
 
 
-  @Before
+  @BeforeEach
   public void init() throws Exception {
   public void init() throws Exception {
     File homeDir = GenericTestUtils.setupTestRootDir(TestHttpFSServerWebServer.class);
     File homeDir = GenericTestUtils.setupTestRootDir(TestHttpFSServerWebServer.class);
     File confDir = new File(homeDir, "etc/hadoop");
     File confDir = new File(homeDir, "etc/hadoop");
@@ -85,7 +84,7 @@ public class TestHttpFSServerWebServer {
         "httpfs-signature-custom.secret");
         "httpfs-signature-custom.secret");
   }
   }
 
 
-  @After
+  @AfterEach
   public void teardown() throws Exception {
   public void teardown() throws Exception {
     if (webServer != null) {
     if (webServer != null) {
       webServer.stop();
       webServer.stop();
@@ -187,8 +186,9 @@ public class TestHttpFSServerWebServer {
     SignerSecretProvider secretProvider = (SignerSecretProvider)
     SignerSecretProvider secretProvider = (SignerSecretProvider)
         server.getWebAppContext().getServletContext()
         server.getWebAppContext().getServletContext()
             .getAttribute(SIGNER_SECRET_PROVIDER_ATTRIBUTE);
             .getAttribute(SIGNER_SECRET_PROVIDER_ATTRIBUTE);
-    Assert.assertNotNull("The secret provider must not be null", secretProvider);
-    Assert.assertEquals("The secret provider must match the following", expected, secretProvider.getClass());
+    assertNotNull(secretProvider, "The secret provider must not be null");
+    assertEquals(expected, secretProvider.getClass(),
+        "The secret provider must match the following");
   }
   }
 
 
   private void assertServiceRespondsWithOK(URL serviceURL)
   private void assertServiceRespondsWithOK(URL serviceURL)
@@ -197,7 +197,7 @@ public class TestHttpFSServerWebServer {
     URL url = new URL(serviceURL, MessageFormat.format(
     URL url = new URL(serviceURL, MessageFormat.format(
         "/webhdfs/v1/?user.name={0}&op=liststatus", user));
         "/webhdfs/v1/?user.name={0}&op=liststatus", user));
     HttpURLConnection conn = (HttpURLConnection) url.openConnection();
     HttpURLConnection conn = (HttpURLConnection) url.openConnection();
-    Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
+    assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
     try (BufferedReader reader = new BufferedReader(
     try (BufferedReader reader = new BufferedReader(
         new InputStreamReader(conn.getInputStream()))) {
         new InputStreamReader(conn.getInputStream()))) {
       reader.readLine();
       reader.readLine();
@@ -247,7 +247,7 @@ public class TestHttpFSServerWebServer {
   }
   }
 
 
   private void createSecretFile(String content) throws IOException {
   private void createSecretFile(String content) throws IOException {
-    Assert.assertTrue(secretFile.createNewFile());
+    assertTrue(secretFile.createNewFile());
     FileUtils.writeStringToFile(secretFile, content, StandardCharsets.UTF_8);
     FileUtils.writeStringToFile(secretFile, content, StandardCharsets.UTF_8);
   }
   }
 
 

+ 18 - 19
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSWithKerberos.java

@@ -38,9 +38,8 @@ import org.apache.hadoop.test.TestJetty;
 import org.apache.hadoop.test.TestJettyHelper;
 import org.apache.hadoop.test.TestJettyHelper;
 import org.json.simple.JSONObject;
 import org.json.simple.JSONObject;
 import org.json.simple.parser.JSONParser;
 import org.json.simple.parser.JSONParser;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.webapp.WebAppContext;
 import org.eclipse.jetty.webapp.WebAppContext;
 
 
@@ -56,9 +55,12 @@ import java.net.URL;
 import java.security.PrivilegedExceptionAction;
 import java.security.PrivilegedExceptionAction;
 import java.util.concurrent.Callable;
 import java.util.concurrent.Callable;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
 public class TestHttpFSWithKerberos extends HFSTestCase {
 public class TestHttpFSWithKerberos extends HFSTestCase {
 
 
-  @After
+  @AfterEach
   public void resetUGI() {
   public void resetUGI() {
     Configuration conf = new Configuration();
     Configuration conf = new Configuration();
     UserGroupInformation.setConfiguration(conf);
     UserGroupInformation.setConfiguration(conf);
@@ -66,9 +68,9 @@ public class TestHttpFSWithKerberos extends HFSTestCase {
 
 
   private void createHttpFSServer() throws Exception {
   private void createHttpFSServer() throws Exception {
     File homeDir = TestDirHelper.getTestDir();
     File homeDir = TestDirHelper.getTestDir();
-    Assert.assertTrue(new File(homeDir, "conf").mkdir());
-    Assert.assertTrue(new File(homeDir, "log").mkdir());
-    Assert.assertTrue(new File(homeDir, "temp").mkdir());
+    assertTrue(new File(homeDir, "conf").mkdir());
+    assertTrue(new File(homeDir, "log").mkdir());
+    assertTrue(new File(homeDir, "temp").mkdir());
     HttpFSServerWebApp.setHomeDirForCurrentThread(homeDir.getAbsolutePath());
     HttpFSServerWebApp.setHomeDirForCurrentThread(homeDir.getAbsolutePath());
 
 
     File secretFile = new File(new File(homeDir, "conf"), "secret");
     File secretFile = new File(new File(homeDir, "conf"), "secret");
@@ -125,7 +127,7 @@ public class TestHttpFSWithKerberos extends HFSTestCase {
         AuthenticatedURL aUrl = new AuthenticatedURL();
         AuthenticatedURL aUrl = new AuthenticatedURL();
         AuthenticatedURL.Token aToken = new AuthenticatedURL.Token();
         AuthenticatedURL.Token aToken = new AuthenticatedURL.Token();
         HttpURLConnection conn = aUrl.openConnection(url, aToken);
         HttpURLConnection conn = aUrl.openConnection(url, aToken);
-        Assert.assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
+        assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
         return null;
         return null;
       }
       }
     });
     });
@@ -141,8 +143,7 @@ public class TestHttpFSWithKerberos extends HFSTestCase {
     URL url = new URL(TestJettyHelper.getJettyURL(),
     URL url = new URL(TestJettyHelper.getJettyURL(),
                       "/webhdfs/v1/?op=GETHOMEDIRECTORY");
                       "/webhdfs/v1/?op=GETHOMEDIRECTORY");
     HttpURLConnection conn = (HttpURLConnection) url.openConnection();
     HttpURLConnection conn = (HttpURLConnection) url.openConnection();
-    Assert.assertEquals(conn.getResponseCode(),
-                        HttpURLConnection.HTTP_UNAUTHORIZED);
+    assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_UNAUTHORIZED);
   }
   }
 
 
   @Test
   @Test
@@ -161,7 +162,7 @@ public class TestHttpFSWithKerberos extends HFSTestCase {
         AuthenticatedURL aUrl = new AuthenticatedURL();
         AuthenticatedURL aUrl = new AuthenticatedURL();
         AuthenticatedURL.Token aToken = new AuthenticatedURL.Token();
         AuthenticatedURL.Token aToken = new AuthenticatedURL.Token();
         HttpURLConnection conn = aUrl.openConnection(url, aToken);
         HttpURLConnection conn = aUrl.openConnection(url, aToken);
-        Assert.assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
+        assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
         JSONObject json = (JSONObject) new JSONParser()
         JSONObject json = (JSONObject) new JSONParser()
           .parse(new InputStreamReader(conn.getInputStream()));
           .parse(new InputStreamReader(conn.getInputStream()));
         json =
         json =
@@ -175,22 +176,21 @@ public class TestHttpFSWithKerberos extends HFSTestCase {
                       "/webhdfs/v1/?op=GETHOMEDIRECTORY&delegation=" +
                       "/webhdfs/v1/?op=GETHOMEDIRECTORY&delegation=" +
                       tokenStr);
                       tokenStr);
         conn = (HttpURLConnection) url.openConnection();
         conn = (HttpURLConnection) url.openConnection();
-        Assert.assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
+        assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
 
 
         //try to renew the delegation token without SPNEGO credentials
         //try to renew the delegation token without SPNEGO credentials
         url = new URL(TestJettyHelper.getJettyURL(),
         url = new URL(TestJettyHelper.getJettyURL(),
                       "/webhdfs/v1/?op=RENEWDELEGATIONTOKEN&token=" + tokenStr);
                       "/webhdfs/v1/?op=RENEWDELEGATIONTOKEN&token=" + tokenStr);
         conn = (HttpURLConnection) url.openConnection();
         conn = (HttpURLConnection) url.openConnection();
         conn.setRequestMethod("PUT");
         conn.setRequestMethod("PUT");
-        Assert.assertEquals(conn.getResponseCode(),
-                            HttpURLConnection.HTTP_UNAUTHORIZED);
+        assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_UNAUTHORIZED);
 
 
         //renew the delegation token with SPNEGO credentials
         //renew the delegation token with SPNEGO credentials
         url = new URL(TestJettyHelper.getJettyURL(),
         url = new URL(TestJettyHelper.getJettyURL(),
                       "/webhdfs/v1/?op=RENEWDELEGATIONTOKEN&token=" + tokenStr);
                       "/webhdfs/v1/?op=RENEWDELEGATIONTOKEN&token=" + tokenStr);
         conn = aUrl.openConnection(url, aToken);
         conn = aUrl.openConnection(url, aToken);
         conn.setRequestMethod("PUT");
         conn.setRequestMethod("PUT");
-        Assert.assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
+        assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
 
 
         //cancel delegation token, no need for SPNEGO credentials
         //cancel delegation token, no need for SPNEGO credentials
         url = new URL(TestJettyHelper.getJettyURL(),
         url = new URL(TestJettyHelper.getJettyURL(),
@@ -198,15 +198,14 @@ public class TestHttpFSWithKerberos extends HFSTestCase {
                       tokenStr);
                       tokenStr);
         conn = (HttpURLConnection) url.openConnection();
         conn = (HttpURLConnection) url.openConnection();
         conn.setRequestMethod("PUT");
         conn.setRequestMethod("PUT");
-        Assert.assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
+        assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_OK);
 
 
         //try to access httpfs with the canceled delegation token
         //try to access httpfs with the canceled delegation token
         url = new URL(TestJettyHelper.getJettyURL(),
         url = new URL(TestJettyHelper.getJettyURL(),
                       "/webhdfs/v1/?op=GETHOMEDIRECTORY&delegation=" +
                       "/webhdfs/v1/?op=GETHOMEDIRECTORY&delegation=" +
                       tokenStr);
                       tokenStr);
         conn = (HttpURLConnection) url.openConnection();
         conn = (HttpURLConnection) url.openConnection();
-        Assert.assertEquals(conn.getResponseCode(),
-                            HttpURLConnection.HTTP_UNAUTHORIZED);
+        assertEquals(conn.getResponseCode(), HttpURLConnection.HTTP_UNAUTHORIZED);
         return null;
         return null;
       }
       }
     });
     });
@@ -224,7 +223,7 @@ public class TestHttpFSWithKerberos extends HFSTestCase {
     FileSystem fs = FileSystem.get(uri, conf);
     FileSystem fs = FileSystem.get(uri, conf);
     Token<?> tokens[] = fs.addDelegationTokens("foo", null);
     Token<?> tokens[] = fs.addDelegationTokens("foo", null);
     fs.close();
     fs.close();
-    Assert.assertEquals(1, tokens.length);
+    assertEquals(1, tokens.length);
     fs = FileSystem.get(uri, conf);
     fs = FileSystem.get(uri, conf);
     ((DelegationTokenRenewer.Renewable) fs).setDelegationToken(tokens[0]);
     ((DelegationTokenRenewer.Renewable) fs).setDelegationToken(tokens[0]);
     fs.listStatus(new Path("/"));
     fs.listStatus(new Path("/"));

+ 9 - 8
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/lang/TestRunnableCallable.java

@@ -19,13 +19,12 @@
 package org.apache.hadoop.lib.lang;
 package org.apache.hadoop.lib.lang;
 
 
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
 import java.util.concurrent.Callable;
 import java.util.concurrent.Callable;
 
 
 import org.apache.hadoop.test.HTestCase;
 import org.apache.hadoop.test.HTestCase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.*;
 
 
 public class TestRunnableCallable extends HTestCase {
 public class TestRunnableCallable extends HTestCase {
 
 
@@ -86,11 +85,13 @@ public class TestRunnableCallable extends HTestCase {
     assertEquals(rc.toString(), "C");
     assertEquals(rc.toString(), "C");
   }
   }
 
 
-  @Test(expected = RuntimeException.class)
+  @Test
   public void callableExRun() throws Exception {
   public void callableExRun() throws Exception {
-    CEx c = new CEx();
-    RunnableCallable rc = new RunnableCallable(c);
-    rc.run();
+    assertThrows(RuntimeException.class, ()->{
+      CEx c = new CEx();
+      RunnableCallable rc = new RunnableCallable(c);
+      rc.run();
+    });
   }
   }
 
 
 }
 }

+ 3 - 3
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/lang/TestXException.java

@@ -19,11 +19,11 @@
 package org.apache.hadoop.lib.lang;
 package org.apache.hadoop.lib.lang;
 
 
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 
 import org.apache.hadoop.test.HTestCase;
 import org.apache.hadoop.test.HTestCase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestXException extends HTestCase {
 public class TestXException extends HTestCase {
 
 

+ 4 - 4
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/server/TestBaseService.java

@@ -18,13 +18,13 @@
 
 
 package org.apache.hadoop.lib.server;
 package org.apache.hadoop.lib.server;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+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.HTestCase;
 import org.apache.hadoop.test.HTestCase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.mockito.Mockito;
 
 
 public class TestBaseService extends HTestCase {
 public class TestBaseService extends HTestCase {

+ 48 - 32
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/server/TestServer.java

@@ -18,12 +18,13 @@
 
 
 package org.apache.hadoop.lib.server;
 package org.apache.hadoop.lib.server;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-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.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+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 java.io.File;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.FileOutputStream;
@@ -43,7 +44,7 @@ import org.apache.hadoop.test.TestDir;
 import org.apache.hadoop.test.TestDirHelper;
 import org.apache.hadoop.test.TestDirHelper;
 import org.apache.hadoop.test.TestException;
 import org.apache.hadoop.test.TestException;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.util.StringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestServer extends HTestCase {
 public class TestServer extends HTestCase {
 
 
@@ -109,12 +110,14 @@ public class TestServer extends HTestCase {
   @TestException(exception = ServerException.class, msgRegExp = "S02.*")
   @TestException(exception = ServerException.class, msgRegExp = "S02.*")
   @TestDir
   @TestDir
   public void initHomeDirNotDir() throws Exception {
   public void initHomeDirNotDir() throws Exception {
-    File homeDir = new File(TestDirHelper.getTestDir(), "home");
-    new FileOutputStream(homeDir).close();
-    Configuration conf = new Configuration(false);
-    conf.set("server.services", TestService.class.getName());
-    Server server = new Server("server", homeDir.getAbsolutePath(), conf);
-    server.init();
+    assertThrows(ServerException.class, () -> {
+      File homeDir = new File(TestDirHelper.getTestDir(), "home");
+      new FileOutputStream(homeDir).close();
+      Configuration conf = new Configuration(false);
+      conf.set("server.services", TestService.class.getName());
+      Server server = new Server("server", homeDir.getAbsolutePath(), conf);
+      server.init();
+    });
   }
   }
 
 
   @Test
   @Test
@@ -283,13 +286,15 @@ public class TestServer extends HTestCase {
     server.destroy();
     server.destroy();
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   @TestDir
   @TestDir
   public void nonSeteableStatus() throws Exception {
   public void nonSeteableStatus() throws Exception {
-    Configuration conf = new Configuration(false);
-    Server server = createServer(conf);
-    server.init();
-    server.setStatus(Server.Status.SHUTDOWN);
+    assertThrows(IllegalArgumentException.class, ()->{
+      Configuration conf = new Configuration(false);
+      Server server = createServer(conf);
+      server.init();
+      server.setStatus(Server.Status.SHUTDOWN);
+    });
   }
   }
 
 
   public static class TestService implements Service {
   public static class TestService implements Service {
@@ -422,34 +427,45 @@ public class TestServer extends HTestCase {
     }
     }
   }
   }
 
 
-  @Test(expected = IllegalStateException.class)
+  @Test
   @TestDir
   @TestDir
   public void illegalState1() throws Exception {
   public void illegalState1() throws Exception {
-    Server server = new Server("server", TestDirHelper.getTestDir().getAbsolutePath(), new Configuration(false));
-    server.destroy();
+    assertThrows(IllegalStateException.class, ()->{
+      Server server = new Server("server",
+          TestDirHelper.getTestDir().getAbsolutePath(), new Configuration(false));
+      server.destroy();
+    });
   }
   }
 
 
-  @Test(expected = IllegalStateException.class)
+  @Test
   @TestDir
   @TestDir
   public void illegalState2() throws Exception {
   public void illegalState2() throws Exception {
-    Server server = new Server("server", TestDirHelper.getTestDir().getAbsolutePath(), new Configuration(false));
-    server.get(Object.class);
+    assertThrows(IllegalStateException.class, () -> {
+      Server server = new Server("server",
+          TestDirHelper.getTestDir().getAbsolutePath(), new Configuration(false));
+      server.get(Object.class);
+    });
   }
   }
 
 
-  @Test(expected = IllegalStateException.class)
+  @Test
   @TestDir
   @TestDir
   public void illegalState3() throws Exception {
   public void illegalState3() throws Exception {
-    Server server = new Server("server", TestDirHelper.getTestDir().getAbsolutePath(), new Configuration(false));
-    server.setService(null);
+    assertThrows(IllegalStateException.class, () -> {
+      Server server = new Server("server",
+          TestDirHelper.getTestDir().getAbsolutePath(), new Configuration(false));
+      server.setService(null);
+    });
   }
   }
 
 
-  @Test(expected = IllegalStateException.class)
+  @Test
   @TestDir
   @TestDir
   public void illegalState4() throws Exception {
   public void illegalState4() throws Exception {
-    String dir = TestDirHelper.getTestDir().getAbsolutePath();
-    Server server = new Server("server", dir, dir, dir, dir, new Configuration(false));
-    server.init();
-    server.init();
+    assertThrows(IllegalStateException.class, () -> {
+      String dir = TestDirHelper.getTestDir().getAbsolutePath();
+      Server server = new Server("server", dir, dir, dir, dir, new Configuration(false));
+      server.init();
+      server.init();
+    });
   }
   }
 
 
   private static List<String> ORDER = new ArrayList<String>();
   private static List<String> ORDER = new ArrayList<String>();

+ 20 - 17
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/server/TestServerConstructor.java

@@ -23,14 +23,13 @@ import java.util.Collection;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.test.HTestCase;
 import org.apache.hadoop.test.HTestCase;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
 
 
-@RunWith(value = Parameterized.class)
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 public class TestServerConstructor extends HTestCase {
 public class TestServerConstructor extends HTestCase {
 
 
-  @Parameterized.Parameters
   public static Collection constructorFailParams() {
   public static Collection constructorFailParams() {
     return Arrays.asList(new Object[][]{
     return Arrays.asList(new Object[][]{
       {null, null, null, null, null, null},
       {null, null, null, null, null, null},
@@ -57,20 +56,24 @@ public class TestServerConstructor extends HTestCase {
   private String tempDir;
   private String tempDir;
   private Configuration conf;
   private Configuration conf;
 
 
-  public TestServerConstructor(String name, String homeDir, String configDir, String logDir, String tempDir,
-                               Configuration conf) {
-    this.name = name;
-    this.homeDir = homeDir;
-    this.configDir = configDir;
-    this.logDir = logDir;
-    this.tempDir = tempDir;
-    this.conf = conf;
+  public void initTestServerConstructor(String pName, String pHomeDir,
+      String pConfigDir, String pLogDir, String pTempDir, Configuration pConf) {
+    this.name = pName;
+    this.homeDir = pHomeDir;
+    this.configDir = pConfigDir;
+    this.logDir = pLogDir;
+    this.tempDir = pTempDir;
+    this.conf = pConf;
   }
   }
 
 
-
-  @Test(expected = IllegalArgumentException.class)
-  public void constructorFail() {
-    new Server(name, homeDir, configDir, logDir, tempDir, conf);
+  @ParameterizedTest
+  @MethodSource("constructorFailParams")
+  public void constructorFail(String pName, String pHomeDir,
+      String pConfigDir, String pLogDir, String pTempDir, Configuration pConf) {
+    initTestServerConstructor(pName, pHomeDir, pConfigDir, pLogDir, pTempDir, pConf);
+    assertThrows(IllegalArgumentException.class, () -> {
+      new Server(name, homeDir, configDir, logDir, tempDir, conf);
+    });
   }
   }
 
 
 }
 }

+ 24 - 21
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/service/hadoop/TestFileSystemAccessService.java

@@ -41,9 +41,12 @@ import org.apache.hadoop.test.TestException;
 import org.apache.hadoop.test.TestHdfs;
 import org.apache.hadoop.test.TestHdfs;
 import org.apache.hadoop.test.TestHdfsHelper;
 import org.apache.hadoop.test.TestHdfsHelper;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.util.StringUtils;
-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 static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 public class TestFileSystemAccessService extends HFSTestCase {
 public class TestFileSystemAccessService extends HFSTestCase {
 
 
@@ -55,7 +58,7 @@ public class TestFileSystemAccessService extends HFSTestCase {
     os.close();
     os.close();
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void createHadoopConf() throws Exception {
   public void createHadoopConf() throws Exception {
     Configuration hadoopConf = new Configuration(false);
     Configuration hadoopConf = new Configuration(false);
     hadoopConf.set("foo", "FOO");
     hadoopConf.set("foo", "FOO");
@@ -74,7 +77,7 @@ public class TestFileSystemAccessService extends HFSTestCase {
     conf.set("server.services", services);
     conf.set("server.services", services);
     Server server = new Server("server", dir, dir, dir, dir, conf);
     Server server = new Server("server", dir, dir, dir, dir, conf);
     server.init();
     server.init();
-    Assert.assertNotNull(server.get(FileSystemAccess.class));
+    assertNotNull(server.get(FileSystemAccess.class));
     server.destroy();
     server.destroy();
   }
   }
 
 
@@ -161,7 +164,7 @@ public class TestFileSystemAccessService extends HFSTestCase {
     Server server = new Server("server", dir, dir, dir, dir, conf);
     Server server = new Server("server", dir, dir, dir, dir, conf);
     server.init();
     server.init();
     FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
     FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
-    Assert.assertEquals(fsAccess.serviceHadoopConf.get("foo"), "FOO");
+    assertEquals(fsAccess.serviceHadoopConf.get("foo"), "FOO");
     server.destroy();
     server.destroy();
   }
   }
 
 
@@ -189,7 +192,7 @@ public class TestFileSystemAccessService extends HFSTestCase {
     Server server = new Server("server", dir, dir, dir, dir, conf);
     Server server = new Server("server", dir, dir, dir, dir, conf);
     server.init();
     server.init();
     FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
     FileSystemAccessService fsAccess = (FileSystemAccessService) server.get(FileSystemAccess.class);
-    Assert.assertEquals(fsAccess.serviceHadoopConf.get("foo"), "BAR");
+    assertEquals(fsAccess.serviceHadoopConf.get("foo"), "BAR");
     server.destroy();
     server.destroy();
   }
   }
 
 
@@ -267,15 +270,15 @@ public class TestFileSystemAccessService extends HFSTestCase {
     server.init();
     server.init();
     FileSystemAccess hadoop = server.get(FileSystemAccess.class);
     FileSystemAccess hadoop = server.get(FileSystemAccess.class);
     FileSystem fs = hadoop.createFileSystem("u", hadoop.getFileSystemConfiguration());
     FileSystem fs = hadoop.createFileSystem("u", hadoop.getFileSystemConfiguration());
-    Assert.assertNotNull(fs);
+    assertNotNull(fs);
     fs.mkdirs(new Path("/tmp/foo"));
     fs.mkdirs(new Path("/tmp/foo"));
     hadoop.releaseFileSystem(fs);
     hadoop.releaseFileSystem(fs);
     try {
     try {
       fs.mkdirs(new Path("/tmp/foo"));
       fs.mkdirs(new Path("/tmp/foo"));
-      Assert.fail();
+      fail();
     } catch (IOException ex) {
     } catch (IOException ex) {
     } catch (Exception ex) {
     } catch (Exception ex) {
-      Assert.fail();
+      fail();
     }
     }
     server.destroy();
     server.destroy();
   }
   }
@@ -313,10 +316,10 @@ public class TestFileSystemAccessService extends HFSTestCase {
     });
     });
     try {
     try {
       fsa[0].mkdirs(new Path("/tmp/foo"));
       fsa[0].mkdirs(new Path("/tmp/foo"));
-      Assert.fail();
+      fail();
     } catch (IOException ex) {
     } catch (IOException ex) {
     } catch (Exception ex) {
     } catch (Exception ex) {
-      Assert.fail();
+      fail();
     }
     }
     server.destroy();
     server.destroy();
   }
   }
@@ -381,19 +384,19 @@ public class TestFileSystemAccessService extends HFSTestCase {
           throw new IOException();
           throw new IOException();
         }
         }
       });
       });
-      Assert.fail();
+      fail();
     } catch (FileSystemAccessException ex) {
     } catch (FileSystemAccessException ex) {
-      Assert.assertEquals(ex.getError(), FileSystemAccessException.ERROR.H03);
+      assertEquals(ex.getError(), FileSystemAccessException.ERROR.H03);
     } catch (Exception ex) {
     } catch (Exception ex) {
-      Assert.fail();
+      fail();
     }
     }
 
 
     try {
     try {
       fsa[0].mkdirs(new Path("/tmp/foo"));
       fsa[0].mkdirs(new Path("/tmp/foo"));
-      Assert.fail();
+      fail();
     } catch (IOException ex) {
     } catch (IOException ex) {
     } catch (Exception ex) {
     } catch (Exception ex) {
-      Assert.fail();
+      fail();
     }
     }
     server.destroy();
     server.destroy();
   }
   }
@@ -424,7 +427,7 @@ public class TestFileSystemAccessService extends HFSTestCase {
 
 
       FileSystem fs1 =
       FileSystem fs1 =
         hadoop.createFileSystem("u", hadoop.getFileSystemConfiguration());
         hadoop.createFileSystem("u", hadoop.getFileSystemConfiguration());
-      Assert.assertNotNull(fs1);
+      assertNotNull(fs1);
       fs1.mkdirs(new Path("/tmp/foo1"));
       fs1.mkdirs(new Path("/tmp/foo1"));
       hadoop.releaseFileSystem(fs1);
       hadoop.releaseFileSystem(fs1);
 
 
@@ -435,7 +438,7 @@ public class TestFileSystemAccessService extends HFSTestCase {
         hadoop.createFileSystem("u", hadoop.getFileSystemConfiguration());
         hadoop.createFileSystem("u", hadoop.getFileSystemConfiguration());
 
 
       //should be same instance because of caching
       //should be same instance because of caching
-      Assert.assertEquals(fs1, fs2);
+      assertEquals(fs1, fs2);
 
 
       Thread.sleep(4 * 1000);
       Thread.sleep(4 * 1000);
 
 
@@ -453,10 +456,10 @@ public class TestFileSystemAccessService extends HFSTestCase {
       //should not be around as lease count is 0
       //should not be around as lease count is 0
       try {
       try {
         fs2.mkdirs(new Path("/tmp/foo"));
         fs2.mkdirs(new Path("/tmp/foo"));
-        Assert.fail();
+        fail();
       } catch (IOException ex) {
       } catch (IOException ex) {
       } catch (Exception ex) {
       } catch (Exception ex) {
-        Assert.fail();
+        fail();
       }
       }
     } finally {
     } finally {
       server.destroy();
       server.destroy();

+ 5 - 5
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/service/instrumentation/TestInstrumentationService.java

@@ -18,10 +18,10 @@
 
 
 package org.apache.hadoop.lib.service.instrumentation;
 package org.apache.hadoop.lib.service.instrumentation;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-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.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 import java.io.StringWriter;
 import java.io.StringWriter;
 import java.util.Arrays;
 import java.util.Arrays;
@@ -39,7 +39,7 @@ import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.util.Time;
 import org.apache.hadoop.util.Time;
 import org.json.simple.JSONObject;
 import org.json.simple.JSONObject;
 import org.json.simple.parser.JSONParser;
 import org.json.simple.parser.JSONParser;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestInstrumentationService extends HTestCase {
 public class TestInstrumentationService extends HTestCase {
 
 

+ 2 - 2
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/service/scheduler/TestSchedulerService.java

@@ -18,7 +18,7 @@
 
 
 package org.apache.hadoop.lib.service.scheduler;
 package org.apache.hadoop.lib.service.scheduler;
 
 
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
 
 
@@ -30,7 +30,7 @@ import org.apache.hadoop.test.HTestCase;
 import org.apache.hadoop.test.TestDir;
 import org.apache.hadoop.test.TestDir;
 import org.apache.hadoop.test.TestDirHelper;
 import org.apache.hadoop.test.TestDirHelper;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.util.StringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestSchedulerService extends HTestCase {
 public class TestSchedulerService extends HTestCase {
 
 

+ 14 - 10
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/service/security/TestGroupsService.java

@@ -18,8 +18,9 @@
 
 
 package org.apache.hadoop.lib.service.security;
 package org.apache.hadoop.lib.service.security;
 
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.List;
 import java.util.List;
@@ -31,7 +32,7 @@ import org.apache.hadoop.test.HTestCase;
 import org.apache.hadoop.test.TestDir;
 import org.apache.hadoop.test.TestDir;
 import org.apache.hadoop.test.TestDirHelper;
 import org.apache.hadoop.test.TestDirHelper;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hadoop.util.StringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestGroupsService extends HTestCase {
 public class TestGroupsService extends HTestCase {
 
 
@@ -50,15 +51,18 @@ public class TestGroupsService extends HTestCase {
     server.destroy();
     server.destroy();
   }
   }
 
 
-  @Test(expected = RuntimeException.class)
+  @Test
   @TestDir
   @TestDir
   public void invalidGroupsMapping() throws Exception {
   public void invalidGroupsMapping() throws Exception {
-    String dir = TestDirHelper.getTestDir().getAbsolutePath();
-    Configuration conf = new Configuration(false);
-    conf.set("server.services", StringUtils.join(",", Arrays.asList(GroupsService.class.getName())));
-    conf.set("server.groups.hadoop.security.group.mapping", String.class.getName());
-    Server server = new Server("server", dir, dir, dir, dir, conf);
-    server.init();
+    assertThrows(RuntimeException.class, () -> {
+      String dir = TestDirHelper.getTestDir().getAbsolutePath();
+      Configuration conf = new Configuration(false);
+      conf.set("server.services", StringUtils.join(",",
+          Arrays.asList(GroupsService.class.getName())));
+      conf.set("server.groups.hadoop.security.group.mapping", String.class.getName());
+      Server server = new Server("server", dir, dir, dir, dir, conf);
+      server.init();
+    });
   }
   }
 
 
 }
 }

+ 3 - 3
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/servlet/TestHostnameFilter.java

@@ -18,8 +18,8 @@
 
 
 package org.apache.hadoop.lib.servlet;
 package org.apache.hadoop.lib.servlet;
 
 
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -31,7 +31,7 @@ import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.ServletResponse;
 
 
 import org.apache.hadoop.test.HTestCase;
 import org.apache.hadoop.test.HTestCase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.mockito.Mockito;
 
 
 
 

+ 4 - 4
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/servlet/TestMDCFilter.java

@@ -18,9 +18,9 @@
 
 
 package org.apache.hadoop.lib.servlet;
 package org.apache.hadoop.lib.servlet;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.security.Principal;
 import java.security.Principal;
@@ -34,7 +34,7 @@ import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 
 
 import org.apache.hadoop.test.HTestCase;
 import org.apache.hadoop.test.HTestCase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mockito;
 import org.mockito.Mockito;
 import org.slf4j.MDC;
 import org.slf4j.MDC;
 
 

+ 22 - 17
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/servlet/TestServerWebApp.java

@@ -18,22 +18,25 @@
 
 
 package org.apache.hadoop.lib.servlet;
 package org.apache.hadoop.lib.servlet;
 
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 
 import org.apache.hadoop.lib.server.Server;
 import org.apache.hadoop.lib.server.Server;
 import org.apache.hadoop.test.HTestCase;
 import org.apache.hadoop.test.HTestCase;
 import org.apache.hadoop.test.TestDir;
 import org.apache.hadoop.test.TestDir;
 import org.apache.hadoop.test.TestDirHelper;
 import org.apache.hadoop.test.TestDirHelper;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 
 
 import java.net.InetSocketAddress;
 import java.net.InetSocketAddress;
 
 
 public class TestServerWebApp extends HTestCase {
 public class TestServerWebApp extends HTestCase {
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void getHomeDirNotDef() {
   public void getHomeDirNotDef() {
-    ServerWebApp.getHomeDir("TestServerWebApp00");
+    assertThrows(IllegalArgumentException.class, () -> {
+      ServerWebApp.getHomeDir("TestServerWebApp00");
+    });
   }
   }
 
 
   @Test
   @Test
@@ -63,19 +66,21 @@ public class TestServerWebApp extends HTestCase {
     assertEquals(server.getStatus(), Server.Status.SHUTDOWN);
     assertEquals(server.getStatus(), Server.Status.SHUTDOWN);
   }
   }
 
 
-  @Test(expected = RuntimeException.class)
+  @Test
   @TestDir
   @TestDir
   public void failedInit() throws Exception {
   public void failedInit() throws Exception {
-    String dir = TestDirHelper.getTestDir().getAbsolutePath();
-    System.setProperty("TestServerWebApp2.home.dir", dir);
-    System.setProperty("TestServerWebApp2.config.dir", dir);
-    System.setProperty("TestServerWebApp2.log.dir", dir);
-    System.setProperty("TestServerWebApp2.temp.dir", dir);
-    System.setProperty("testserverwebapp2.services", "FOO");
-    ServerWebApp server = new ServerWebApp("TestServerWebApp2") {
-    };
+    assertThrows(RuntimeException.class, () -> {
+      String dir = TestDirHelper.getTestDir().getAbsolutePath();
+      System.setProperty("TestServerWebApp2.home.dir", dir);
+      System.setProperty("TestServerWebApp2.config.dir", dir);
+      System.setProperty("TestServerWebApp2.log.dir", dir);
+      System.setProperty("TestServerWebApp2.temp.dir", dir);
+      System.setProperty("testserverwebapp2.services", "FOO");
+      ServerWebApp server = new ServerWebApp("TestServerWebApp2") {
+      };
 
 
-    server.contextInitialized(null);
+      server.contextInitialized(null);
+    });
   }
   }
 
 
   @Test
   @Test
@@ -92,8 +97,8 @@ public class TestServerWebApp extends HTestCase {
     };
     };
 
 
     InetSocketAddress address = server.resolveAuthority();
     InetSocketAddress address = server.resolveAuthority();
-    Assert.assertEquals("localhost", address.getHostName());
-    Assert.assertEquals(14000, address.getPort());
+    Assertions.assertEquals("localhost", address.getHostName());
+    Assertions.assertEquals(14000, address.getPort());
   }
   }
 
 
 }
 }

+ 67 - 35
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/util/TestCheck.java

@@ -19,13 +19,14 @@
 package org.apache.hadoop.lib.util;
 package org.apache.hadoop.lib.util;
 
 
 
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
 
 
 import org.apache.hadoop.test.HTestCase;
 import org.apache.hadoop.test.HTestCase;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestCheck extends HTestCase {
 public class TestCheck extends HTestCase {
 
 
@@ -34,9 +35,11 @@ public class TestCheck extends HTestCase {
     assertEquals(Check.notNull("value", "name"), "value");
     assertEquals(Check.notNull("value", "name"), "value");
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void notNullNull() {
   public void notNullNull() {
-    Check.notNull(null, "name");
+    assertThrows(IllegalArgumentException.class, () -> {
+      Check.notNull(null, "name");
+    });
   }
   }
 
 
   @Test
   @Test
@@ -45,14 +48,18 @@ public class TestCheck extends HTestCase {
     Check.notNullElements(Arrays.asList("a"), "name");
     Check.notNullElements(Arrays.asList("a"), "name");
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void notNullElementsNullList() {
   public void notNullElementsNullList() {
-    Check.notNullElements(null, "name");
+    assertThrows(IllegalArgumentException.class, () -> {
+      Check.notNullElements(null, "name");
+    });
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void notNullElementsNullElements() {
   public void notNullElementsNullElements() {
-    Check.notNullElements(Arrays.asList("a", "", null), "name");
+    assertThrows(IllegalArgumentException.class, () -> {
+      Check.notNullElements(Arrays.asList("a", "", null), "name");
+    });
   }
   }
 
 
   @Test
   @Test
@@ -61,20 +68,25 @@ public class TestCheck extends HTestCase {
     Check.notEmptyElements(Arrays.asList("a"), "name");
     Check.notEmptyElements(Arrays.asList("a"), "name");
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void notEmptyElementsNullList() {
   public void notEmptyElementsNullList() {
-    Check.notEmptyElements(null, "name");
+    assertThrows(IllegalArgumentException.class, () -> {
+      Check.notEmptyElements(null, "name");
+    });
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void notEmptyElementsNullElements() {
   public void notEmptyElementsNullElements() {
-    Check.notEmptyElements(Arrays.asList("a", null), "name");
+    assertThrows(IllegalArgumentException.class, () -> {
+      Check.notEmptyElements(Arrays.asList("a", null), "name");
+    });
   }
   }
 
 
-
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void notEmptyElementsEmptyElements() {
   public void notEmptyElementsEmptyElements() {
-    Check.notEmptyElements(Arrays.asList("a", ""), "name");
+    assertThrows(IllegalArgumentException.class, () -> {
+      Check.notEmptyElements(Arrays.asList("a", ""), "name");
+    });
   }
   }
 
 
 
 
@@ -83,14 +95,18 @@ public class TestCheck extends HTestCase {
     assertEquals(Check.notEmpty("value", "name"), "value");
     assertEquals(Check.notEmpty("value", "name"), "value");
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void notEmptyNull() {
   public void notEmptyNull() {
-    Check.notEmpty(null, "name");
+    assertThrows(IllegalArgumentException.class, () -> {
+      Check.notEmpty(null, "name");
+    });
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void notEmptyEmpty() {
   public void notEmptyEmpty() {
-    Check.notEmpty("", "name");
+    assertThrows(IllegalArgumentException.class, () -> {
+      Check.notEmpty("", "name");
+    });
   }
   }
 
 
   @Test
   @Test
@@ -101,29 +117,39 @@ public class TestCheck extends HTestCase {
     assertEquals(Check.validIdentifier("_", 1, ""), "_");
     assertEquals(Check.validIdentifier("_", 1, ""), "_");
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void validIdentifierInvalid1() throws Exception {
   public void validIdentifierInvalid1() throws Exception {
-    Check.validIdentifier("!", 1, "");
+    assertThrows(IllegalArgumentException.class, () -> {
+      Check.validIdentifier("!", 1, "");
+    });
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void validIdentifierInvalid2() throws Exception {
   public void validIdentifierInvalid2() throws Exception {
-    Check.validIdentifier("a1", 1, "");
+    assertThrows(IllegalArgumentException.class, () -> {
+      Check.validIdentifier("a1", 1, "");
+    });
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void validIdentifierInvalid3() throws Exception {
   public void validIdentifierInvalid3() throws Exception {
-    Check.validIdentifier("1", 1, "");
+    assertThrows(IllegalArgumentException.class, () -> {
+      Check.validIdentifier("1", 1, "");
+    });
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void validIdentifierInvalid4() throws Exception {
   public void validIdentifierInvalid4() throws Exception {
-    Check.validIdentifier("`a", 2, "");
+    assertThrows(IllegalArgumentException.class, () -> {
+      Check.validIdentifier("`a", 2, "");
+    });
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void validIdentifierInvalid5() throws Exception {
   public void validIdentifierInvalid5() throws Exception {
-    Check.validIdentifier("[a", 2, "");
+    assertThrows(IllegalArgumentException.class, () -> {
+      Check.validIdentifier("[a", 2, "");
+    });
   }
   }
 
 
   @Test
   @Test
@@ -131,14 +157,18 @@ public class TestCheck extends HTestCase {
     assertEquals(Check.gt0(120, "test"), 120);
     assertEquals(Check.gt0(120, "test"), 120);
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void checkGTZeroZero() {
   public void checkGTZeroZero() {
-    Check.gt0(0, "test");
+    assertThrows(IllegalArgumentException.class, () -> {
+      Check.gt0(0, "test");
+    });
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void checkGTZeroLessThanZero() {
   public void checkGTZeroLessThanZero() {
-    Check.gt0(-1, "test");
+    assertThrows(IllegalArgumentException.class, () -> {
+      Check.gt0(-1, "test");
+    });
   }
   }
 
 
   @Test
   @Test
@@ -147,9 +177,11 @@ public class TestCheck extends HTestCase {
     assertEquals(Check.ge0(0, "test"), 0);
     assertEquals(Check.ge0(0, "test"), 0);
   }
   }
 
 
-  @Test(expected = IllegalArgumentException.class)
+  @Test
   public void checkGELessThanZero() {
   public void checkGELessThanZero() {
-    Check.ge0(-1, "test");
+    assertThrows(IllegalArgumentException.class, () -> {
+      Check.ge0(-1, "test");
+    });
   }
   }
 
 
 }
 }

+ 3 - 3
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/util/TestConfigurationUtils.java

@@ -18,15 +18,15 @@
 
 
 package org.apache.hadoop.lib.util;
 package org.apache.hadoop.lib.util;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
 
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStream;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestConfigurationUtils {
 public class TestConfigurationUtils {
 
 

+ 2 - 2
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/wsrs/TestInputStreamEntity.java

@@ -18,13 +18,13 @@
 
 
 package org.apache.hadoop.lib.wsrs;
 package org.apache.hadoop.lib.wsrs;
 
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
 import java.io.InputStream;
 
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestInputStreamEntity {
 public class TestInputStreamEntity {
 
 

+ 4 - 4
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/wsrs/TestJSONMapProvider.java

@@ -18,15 +18,15 @@
 
 
 package org.apache.hadoop.lib.wsrs;
 package org.apache.hadoop.lib.wsrs;
 
 
-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;
 
 
 import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayOutputStream;
 import java.util.Map;
 import java.util.Map;
 
 
 import org.json.simple.JSONObject;
 import org.json.simple.JSONObject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestJSONMapProvider {
 public class TestJSONMapProvider {
 
 

+ 4 - 4
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/wsrs/TestJSONProvider.java

@@ -18,14 +18,14 @@
 
 
 package org.apache.hadoop.lib.wsrs;
 package org.apache.hadoop.lib.wsrs;
 
 
-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;
 
 
 import java.io.ByteArrayOutputStream;
 import java.io.ByteArrayOutputStream;
 
 
 import org.json.simple.JSONObject;
 import org.json.simple.JSONObject;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestJSONProvider {
 public class TestJSONProvider {
 
 

+ 3 - 3
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/lib/wsrs/TestParam.java

@@ -18,12 +18,12 @@
 
 
 package org.apache.hadoop.lib.wsrs;
 package org.apache.hadoop.lib.wsrs;
 
 
-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.util.regex.Pattern;
 import java.util.regex.Pattern;
 
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 public class TestParam {
 public class TestParam {
 
 

+ 3 - 4
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/test/HFSTestCase.java

@@ -17,12 +17,11 @@
  */
  */
 package org.apache.hadoop.test;
 package org.apache.hadoop.test;
 
 
-import org.junit.Rule;
-import org.junit.rules.MethodRule;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 
 public abstract class HFSTestCase extends HTestCase {
 public abstract class HFSTestCase extends HTestCase {
 
 
-  @Rule
-  public MethodRule hdfsTestHelper = new TestHdfsHelper();
+  @RegisterExtension
+  public TestHdfsHelper hdfsTestHelper = new TestHdfsHelper();
 
 
 }
 }

+ 8 - 9
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/test/HTestCase.java

@@ -17,13 +17,12 @@
  */
  */
 package org.apache.hadoop.test;
 package org.apache.hadoop.test;
 
 
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 import java.text.MessageFormat;
 import java.text.MessageFormat;
 
 
 import org.apache.hadoop.util.Time;
 import org.apache.hadoop.util.Time;
-import org.junit.Rule;
-import org.junit.rules.MethodRule;
+import org.junit.jupiter.api.extension.RegisterExtension;
 
 
 public abstract class HTestCase {
 public abstract class HTestCase {
 
 
@@ -37,14 +36,14 @@ public abstract class HTestCase {
 
 
   private float waitForRatio = WAITFOR_RATIO_DEFAULT;
   private float waitForRatio = WAITFOR_RATIO_DEFAULT;
 
 
-  @Rule
-  public MethodRule testDir = new TestDirHelper();
+  @RegisterExtension
+  public TestDirHelper testDir = new TestDirHelper();
 
 
-  @Rule
-  public MethodRule jettyTestHelper = new TestJettyHelper();
+  @RegisterExtension
+  public TestJettyHelper jettyTestHelper = new TestJettyHelper();
 
 
-  @Rule
-  public MethodRule exceptionHelper = new TestExceptionHelper();
+  @RegisterExtension
+  public TestExceptionHelper exceptionHelper = new TestExceptionHelper();
 
 
   /**
   /**
    * Sets the 'wait for ratio' used in the {@link #sleep(long)},
    * Sets the 'wait for ratio' used in the {@link #sleep(long)},

+ 22 - 26
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/test/TestDirHelper.java

@@ -19,15 +19,16 @@ package org.apache.hadoop.test;
 
 
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
+import java.lang.reflect.Method;
 import java.text.MessageFormat;
 import java.text.MessageFormat;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicInteger;
 
 
-import org.junit.Test;
-import org.junit.rules.MethodRule;
-import org.junit.runners.model.FrameworkMethod;
-import org.junit.runners.model.Statement;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
 
 
-public class TestDirHelper implements MethodRule {
+public class TestDirHelper implements BeforeEachCallback, AfterEachCallback {
 
 
   @Test
   @Test
   public void dummy() {
   public void dummy() {
@@ -91,26 +92,6 @@ public class TestDirHelper implements MethodRule {
 
 
   private static final ThreadLocal<File> TEST_DIR_TL = new InheritableThreadLocal<File>();
   private static final ThreadLocal<File> TEST_DIR_TL = new InheritableThreadLocal<File>();
 
 
-  @Override
-  public Statement apply(final Statement statement, final FrameworkMethod frameworkMethod, final Object o) {
-    return new Statement() {
-      @Override
-      public void evaluate() throws Throwable {
-        File testDir = null;
-        TestDir testDirAnnotation = frameworkMethod.getAnnotation(TestDir.class);
-        if (testDirAnnotation != null) {
-          testDir = resetTestCaseDir(frameworkMethod.getName());
-        }
-        try {
-          TEST_DIR_TL.set(testDir);
-          statement.evaluate();
-        } finally {
-          TEST_DIR_TL.remove();
-        }
-      }
-    };
-  }
-
   /**
   /**
    * Returns the local test directory for the current test, only available when the
    * Returns the local test directory for the current test, only available when the
    * test method has been annotated with {@link TestDir}.
    * test method has been annotated with {@link TestDir}.
@@ -136,7 +117,7 @@ public class TestDirHelper implements MethodRule {
       delete(dir);
       delete(dir);
     } catch (IOException ex) {
     } catch (IOException ex) {
       throw new RuntimeException(MessageFormat.format("Could not delete test dir[{0}], {1}",
       throw new RuntimeException(MessageFormat.format("Could not delete test dir[{0}], {1}",
-                                                      dir, ex.getMessage()), ex);
+          dir, ex.getMessage()), ex);
     }
     }
     if (!dir.mkdirs()) {
     if (!dir.mkdirs()) {
       throw new RuntimeException(MessageFormat.format("Could not create test dir[{0}]", dir));
       throw new RuntimeException(MessageFormat.format("Could not create test dir[{0}]", dir));
@@ -144,4 +125,19 @@ public class TestDirHelper implements MethodRule {
     return dir;
     return dir;
   }
   }
 
 
+  @Override
+  public void beforeEach(ExtensionContext context) throws Exception {
+    Method testMethod = context.getRequiredTestMethod();
+    File testDir = null;
+    TestDir testDirAnnotation = testMethod.getAnnotation(TestDir.class);
+    if (testDirAnnotation != null) {
+      testDir = resetTestCaseDir(testMethod.getName());
+    }
+    TEST_DIR_TL.set(testDir);
+  }
+
+  @Override
+  public void afterEach(ExtensionContext extensionContext) throws Exception {
+    TEST_DIR_TL.remove();
+  }
 }
 }

+ 30 - 33
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/test/TestExceptionHelper.java

@@ -17,51 +17,48 @@
  */
  */
 package org.apache.hadoop.test;
 package org.apache.hadoop.test;
 
 
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
+import java.lang.reflect.Method;
 import java.util.regex.Pattern;
 import java.util.regex.Pattern;
 
 
-import org.junit.Test;
-import org.junit.rules.MethodRule;
-import org.junit.runners.model.FrameworkMethod;
-import org.junit.runners.model.Statement;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.TestExecutionExceptionHandler;
 
 
-public class TestExceptionHelper implements MethodRule {
+public class TestExceptionHelper implements TestExecutionExceptionHandler {
 
 
   @Test
   @Test
   public void dummy() {
   public void dummy() {
   }
   }
 
 
   @Override
   @Override
-  public Statement apply(final Statement statement, final FrameworkMethod frameworkMethod, final Object o) {
-    return new Statement() {
-      @Override
-      public void evaluate() throws Throwable {
-        TestException testExceptionAnnotation = frameworkMethod.getAnnotation(TestException.class);
-        try {
-          statement.evaluate();
-          if (testExceptionAnnotation != null) {
-            Class<? extends Throwable> klass = testExceptionAnnotation.exception();
-            fail("Expected Exception: " + klass.getSimpleName());
-          }
-        } catch (Throwable ex) {
-          if (testExceptionAnnotation != null) {
-            Class<? extends Throwable> klass = testExceptionAnnotation.exception();
-            if (klass.isInstance(ex)) {
-              String regExp = testExceptionAnnotation.msgRegExp();
-              Pattern pattern = Pattern.compile(regExp);
-              if (!pattern.matcher(ex.getMessage()).find()) {
-                fail("Expected Exception Message pattern: " + regExp + " got message: " + ex.getMessage());
-              }
-            } else {
-              fail("Expected Exception: " + klass.getSimpleName() + " got: " + ex.getClass().getSimpleName());
-            }
-          } else {
-            throw ex;
+  public void handleTestExecutionException(ExtensionContext context,
+      Throwable cause) throws Throwable {
+    Method testMethod = context.getRequiredTestMethod();
+    TestException testExceptionAnnotation = testMethod.getAnnotation(TestException.class);
+    try {
+      if (testExceptionAnnotation != null) {
+        Class<? extends Throwable> klass = testExceptionAnnotation.exception();
+        fail("Expected Exception: " + klass.getSimpleName());
+      }
+    } catch (Throwable ex) {
+      if (testExceptionAnnotation != null) {
+        Class<? extends Throwable> klass = testExceptionAnnotation.exception();
+        if (klass.isInstance(cause)) {
+          String regExp = testExceptionAnnotation.msgRegExp();
+          Pattern pattern = Pattern.compile(regExp);
+          if (!pattern.matcher(cause.getMessage()).find()) {
+            fail("Expected Exception Message pattern: " + regExp +
+                " got message: " + ex.getMessage());
           }
           }
+        } else {
+          fail("Expected Exception: " + klass.getSimpleName() + " got: " +
+              ex.getClass().getSimpleName());
         }
         }
+      } else {
+        throw ex;
       }
       }
-    };
+    }
   }
   }
-
 }
 }

+ 25 - 14
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/test/TestHFSTestCase.java

@@ -18,9 +18,6 @@
 
 
 package org.apache.hadoop.test;
 package org.apache.hadoop.test;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
 import java.io.BufferedReader;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStream;
@@ -39,34 +36,48 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.util.Time;
 import org.apache.hadoop.util.Time;
 import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletContextHandler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.Server;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 public class TestHFSTestCase extends HFSTestCase {
 public class TestHFSTestCase extends HFSTestCase {
 
 
-  @Test(expected = IllegalStateException.class)
+  @Test
   public void testDirNoAnnotation() throws Exception {
   public void testDirNoAnnotation() throws Exception {
-    TestDirHelper.getTestDir();
+    assertThrows(IllegalStateException.class, () -> {
+      TestDirHelper.getTestDir();
+    });
   }
   }
 
 
-  @Test(expected = IllegalStateException.class)
+  @Test
   public void testJettyNoAnnotation() throws Exception {
   public void testJettyNoAnnotation() throws Exception {
-    TestJettyHelper.getJettyServer();
+    assertThrows(IllegalStateException.class, () -> {
+      TestJettyHelper.getJettyServer();
+    });
   }
   }
 
 
-  @Test(expected = IllegalStateException.class)
+  @Test
   public void testJettyNoAnnotation2() throws Exception {
   public void testJettyNoAnnotation2() throws Exception {
-    TestJettyHelper.getJettyURL();
+    assertThrows(IllegalStateException.class, () -> {
+      TestJettyHelper.getJettyURL();
+    });
   }
   }
 
 
-  @Test(expected = IllegalStateException.class)
+  @Test
   public void testHdfsNoAnnotation() throws Exception {
   public void testHdfsNoAnnotation() throws Exception {
-    TestHdfsHelper.getHdfsConf();
+    assertThrows(IllegalStateException.class, () -> {
+      TestHdfsHelper.getHdfsConf();
+    });
   }
   }
 
 
-  @Test(expected = IllegalStateException.class)
+  @Test
   public void testHdfsNoAnnotation2() throws Exception {
   public void testHdfsNoAnnotation2() throws Exception {
-    TestHdfsHelper.getHdfsTestDir();
+    assertThrows(IllegalStateException.class, () -> {
+      TestHdfsHelper.getHdfsTestDir();
+    });
   }
   }
 
 
   @Test
   @Test

+ 17 - 10
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/test/TestHTestCase.java

@@ -18,9 +18,6 @@
 
 
 package org.apache.hadoop.test;
 package org.apache.hadoop.test;
 
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
 import java.io.BufferedReader;
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.InputStreamReader;
@@ -34,24 +31,34 @@ import javax.servlet.http.HttpServletResponse;
 
 
 import org.apache.hadoop.util.Time;
 import org.apache.hadoop.util.Time;
 import org.eclipse.jetty.servlet.ServletContextHandler;
 import org.eclipse.jetty.servlet.ServletContextHandler;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.Server;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
 public class TestHTestCase extends HTestCase {
 public class TestHTestCase extends HTestCase {
 
 
-  @Test(expected = IllegalStateException.class)
+  @Test
   public void testDirNoAnnotation() throws Exception {
   public void testDirNoAnnotation() throws Exception {
-    TestDirHelper.getTestDir();
+    assertThrows(IllegalStateException.class, () -> {
+      TestDirHelper.getTestDir();
+    });
   }
   }
 
 
-  @Test(expected = IllegalStateException.class)
+  @Test
   public void testJettyNoAnnotation() throws Exception {
   public void testJettyNoAnnotation() throws Exception {
-    TestJettyHelper.getJettyServer();
+    assertThrows(IllegalStateException.class, () -> {
+      TestJettyHelper.getJettyServer();
+    });
   }
   }
 
 
-  @Test(expected = IllegalStateException.class)
+  @Test
   public void testJettyNoAnnotation2() throws Exception {
   public void testJettyNoAnnotation2() throws Exception {
-    TestJettyHelper.getJettyURL();
+    assertThrows(IllegalStateException.class, () -> {
+      TestJettyHelper.getJettyURL();
+    });
   }
   }
 
 
   @Test
   @Test

+ 28 - 27
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/test/TestHdfsHelper.java

@@ -18,6 +18,7 @@
 package org.apache.hadoop.test;
 package org.apache.hadoop.test;
 
 
 import java.io.File;
 import java.io.File;
+import java.lang.reflect.Method;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicInteger;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
@@ -35,9 +36,8 @@ import org.apache.hadoop.hdfs.StripedFileTestUtil;
 import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
 import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
 import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy;
 import org.apache.hadoop.hdfs.protocol.ErasureCodingPolicy;
 import org.apache.hadoop.hdfs.protocol.HdfsConstants.StoragePolicySatisfierMode;
 import org.apache.hadoop.hdfs.protocol.HdfsConstants.StoragePolicySatisfierMode;
-import org.junit.Test;
-import org.junit.runners.model.FrameworkMethod;
-import org.junit.runners.model.Statement;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtensionContext;
 
 
 public class TestHdfsHelper extends TestDirHelper {
 public class TestHdfsHelper extends TestDirHelper {
 
 
@@ -54,27 +54,16 @@ public class TestHdfsHelper extends TestDirHelper {
 
 
   private static final ThreadLocal<Path> HDFS_TEST_DIR_TL = new InheritableThreadLocal<Path>();
   private static final ThreadLocal<Path> HDFS_TEST_DIR_TL = new InheritableThreadLocal<Path>();
 
 
-  @Override
-  public Statement apply(Statement statement, FrameworkMethod frameworkMethod, Object o) {
-    TestHdfs testHdfsAnnotation = frameworkMethod.getAnnotation(TestHdfs.class);
-    if (testHdfsAnnotation != null) {
-      this.statement = new HdfsStatement(statement, frameworkMethod.getName());
-      statement = this.statement;
-    }
-    return super.apply(statement, frameworkMethod, o);
-  }
-
   public MiniDFSCluster getMiniDFSCluster() {
   public MiniDFSCluster getMiniDFSCluster() {
     return statement.getMiniDFSCluster();
     return statement.getMiniDFSCluster();
   }
   }
 
 
-  private static class HdfsStatement extends Statement {
-    private Statement statement;
+  private static class HdfsStatement {
+
     private String testName;
     private String testName;
     private MiniDFSCluster miniHdfs = null;
     private MiniDFSCluster miniHdfs = null;
 
 
-    public HdfsStatement(Statement statement, String testName) {
-      this.statement = statement;
+    HdfsStatement(String testName) {
       this.testName = testName;
       this.testName = testName;
     }
     }
 
 
@@ -82,21 +71,15 @@ public class TestHdfsHelper extends TestDirHelper {
       return miniHdfs;
       return miniHdfs;
     }
     }
 
 
-    @Override
-    public void evaluate() throws Throwable {
+
+    public void evaluate() throws Exception {
       Configuration conf = HadoopUsersConfTestHelper.getBaseConf();
       Configuration conf = HadoopUsersConfTestHelper.getBaseConf();
       if (Boolean.parseBoolean(System.getProperty(HADOOP_MINI_HDFS, "true"))) {
       if (Boolean.parseBoolean(System.getProperty(HADOOP_MINI_HDFS, "true"))) {
         miniHdfs = startMiniHdfs(conf);
         miniHdfs = startMiniHdfs(conf);
         conf = miniHdfs.getConfiguration(0);
         conf = miniHdfs.getConfiguration(0);
       }
       }
-      try {
-        HDFS_CONF_TL.set(conf);
-        HDFS_TEST_DIR_TL.set(resetHdfsTestDir(conf));
-        statement.evaluate();
-      } finally {
-        HDFS_CONF_TL.remove();
-        HDFS_TEST_DIR_TL.remove();
-      }
+      HDFS_CONF_TL.set(conf);
+      HDFS_TEST_DIR_TL.set(resetHdfsTestDir(conf));
     }
     }
 
 
     private static AtomicInteger counter = new AtomicInteger();
     private static AtomicInteger counter = new AtomicInteger();
@@ -223,4 +206,22 @@ public class TestHdfsHelper extends TestDirHelper {
     return MINI_DFS;
     return MINI_DFS;
   }
   }
 
 
+  @Override
+  public void beforeEach(ExtensionContext context) throws Exception {
+    super.beforeEach(context);
+    Method testMethod = context.getRequiredTestMethod();
+    TestHdfs testHdfsAnnotation = testMethod.getAnnotation(TestHdfs.class);
+    if (testHdfsAnnotation != null) {
+      this.statement = new HdfsStatement(testMethod.getName());
+      this.statement.evaluate();
+    }
+  }
+
+  @Override
+  public void afterEach(ExtensionContext extensionContext) throws Exception {
+
+    super.afterEach(extensionContext);
+    HDFS_CONF_TL.remove();
+    HDFS_TEST_DIR_TL.remove();
+  }
 }
 }

+ 27 - 30
hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/test/TestJettyHelper.java

@@ -17,6 +17,7 @@
  */
  */
 package org.apache.hadoop.test;
 package org.apache.hadoop.test;
 
 
+import java.lang.reflect.Method;
 import java.net.InetAddress;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.InetSocketAddress;
 import java.net.MalformedURLException;
 import java.net.MalformedURLException;
@@ -34,11 +35,11 @@ import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.ServerConnector;
 import org.eclipse.jetty.server.ServerConnector;
 import org.eclipse.jetty.server.SslConnectionFactory;
 import org.eclipse.jetty.server.SslConnectionFactory;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
-import org.junit.rules.MethodRule;
-import org.junit.runners.model.FrameworkMethod;
-import org.junit.runners.model.Statement;
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
 
 
-public class TestJettyHelper implements MethodRule {
+public class TestJettyHelper implements BeforeEachCallback, AfterEachCallback {
   private boolean ssl;
   private boolean ssl;
   private String keyStoreType;
   private String keyStoreType;
   private String keyStore;
   private String keyStore;
@@ -60,32 +61,6 @@ public class TestJettyHelper implements MethodRule {
   private static final ThreadLocal<TestJettyHelper> TEST_JETTY_TL =
   private static final ThreadLocal<TestJettyHelper> TEST_JETTY_TL =
       new InheritableThreadLocal<TestJettyHelper>();
       new InheritableThreadLocal<TestJettyHelper>();
 
 
-  @Override
-  public Statement apply(final Statement statement, final FrameworkMethod frameworkMethod, final Object o) {
-    return new Statement() {
-      @Override
-      public void evaluate() throws Throwable {
-        TestJetty testJetty = frameworkMethod.getAnnotation(TestJetty.class);
-        if (testJetty != null) {
-          server = createJettyServer();
-        }
-        try {
-          TEST_JETTY_TL.set(TestJettyHelper.this);
-          statement.evaluate();
-        } finally {
-          TEST_JETTY_TL.remove();
-          if (server != null && server.isRunning()) {
-            try {
-              server.stop();
-            } catch (Exception ex) {
-              throw new RuntimeException("Could not stop embedded servlet container, " + ex.getMessage(), ex);
-            }
-          }
-        }
-      }
-    };
-  }
-
   private Server createJettyServer() {
   private Server createJettyServer() {
     try {
     try {
       InetAddress localhost = InetAddress.getByName("localhost");
       InetAddress localhost = InetAddress.getByName("localhost");
@@ -177,4 +152,26 @@ public class TestJettyHelper implements MethodRule {
     }
     }
   }
   }
 
 
+  @Override
+  public void afterEach(ExtensionContext context) throws Exception {
+    TEST_JETTY_TL.remove();
+    if (server != null && server.isRunning()) {
+      try {
+        server.stop();
+      } catch (Exception ex) {
+        throw new RuntimeException("Could not stop embedded servlet container, " +
+            ex.getMessage(), ex);
+      }
+    }
+  }
+
+  @Override
+  public void beforeEach(ExtensionContext context) throws Exception {
+    Method testMethod = context.getRequiredTestMethod();
+    TestJetty testJetty = testMethod.getAnnotation(TestJetty.class);
+    if (testJetty != null) {
+      server = createJettyServer();
+    }
+    TEST_JETTY_TL.set(TestJettyHelper.this);
+  }
 }
 }

Some files were not shown because too many files changed in this diff