Browse Source

HADOOP-19426. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-azure-datalake Part1. (#7652)

* HADOOP-19426. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-azure-datalake Part1.

Co-authored-by: Anuj Modi <anujmodi2011@gmail.com>
Reviewed-by: Anuj Modi <anujmodi2011@gmail.com>
Signed-off-by: Shilun Fan <slfan1989@apache.org>
slfan1989 2 months ago
parent
commit
90a6f3b202

+ 21 - 20
hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/TestAzureADTokenProvider.java

@@ -22,6 +22,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URISyntaxException;
+import java.nio.file.Path;
 
 
 import com.microsoft.azure.datalake.store.oauth2.DeviceCodeTokenProvider;
 import com.microsoft.azure.datalake.store.oauth2.DeviceCodeTokenProvider;
 import com.microsoft.azure.datalake.store.oauth2.MsiTokenProvider;
 import com.microsoft.azure.datalake.store.oauth2.MsiTokenProvider;
@@ -44,16 +45,16 @@ import static org.apache.hadoop.fs.adl.AdlConfKeys
     .AZURE_AD_TOKEN_PROVIDER_TYPE_KEY;
     .AZURE_AD_TOKEN_PROVIDER_TYPE_KEY;
 import static org.apache.hadoop.fs.adl.AdlConfKeys.DEVICE_CODE_CLIENT_APP_ID;
 import static org.apache.hadoop.fs.adl.AdlConfKeys.DEVICE_CODE_CLIENT_APP_ID;
 import static org.apache.hadoop.fs.adl.TokenProviderType.*;
 import static org.apache.hadoop.fs.adl.TokenProviderType.*;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
 
 
 import org.apache.hadoop.security.ProviderUtils;
 import org.apache.hadoop.security.ProviderUtils;
 import org.apache.hadoop.security.alias.CredentialProvider;
 import org.apache.hadoop.security.alias.CredentialProvider;
 import org.apache.hadoop.security.alias.CredentialProviderFactory;
 import org.apache.hadoop.security.alias.CredentialProviderFactory;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
 
 
 /**
 /**
  * Test appropriate token provider is loaded as per configuration.
  * Test appropriate token provider is loaded as per configuration.
@@ -65,8 +66,8 @@ public class TestAzureADTokenProvider {
   private static final String CLIENT_SECRET = "MY_CLIENT_SECRET";
   private static final String CLIENT_SECRET = "MY_CLIENT_SECRET";
   private static final String REFRESH_URL = "http://localhost:8080/refresh";
   private static final String REFRESH_URL = "http://localhost:8080/refresh";
 
 
-  @Rule
-  public final TemporaryFolder tempDir = new TemporaryFolder();
+  @TempDir
+  private Path tempDir;
 
 
   @Test
   @Test
   public void testRefreshTokenProvider()
   public void testRefreshTokenProvider()
@@ -81,7 +82,7 @@ public class TestAzureADTokenProvider {
     AdlFileSystem fileSystem = new AdlFileSystem();
     AdlFileSystem fileSystem = new AdlFileSystem();
     fileSystem.initialize(uri, conf);
     fileSystem.initialize(uri, conf);
     AccessTokenProvider tokenProvider = fileSystem.getTokenProvider();
     AccessTokenProvider tokenProvider = fileSystem.getTokenProvider();
-    Assert.assertTrue(tokenProvider instanceof RefreshTokenBasedTokenProvider);
+    assertTrue(tokenProvider instanceof RefreshTokenBasedTokenProvider);
   }
   }
 
 
   @Test
   @Test
@@ -97,7 +98,7 @@ public class TestAzureADTokenProvider {
     AdlFileSystem fileSystem = new AdlFileSystem();
     AdlFileSystem fileSystem = new AdlFileSystem();
     fileSystem.initialize(uri, conf);
     fileSystem.initialize(uri, conf);
     AccessTokenProvider tokenProvider = fileSystem.getTokenProvider();
     AccessTokenProvider tokenProvider = fileSystem.getTokenProvider();
-    Assert.assertTrue(tokenProvider instanceof ClientCredsTokenProvider);
+    assertTrue(tokenProvider instanceof ClientCredsTokenProvider);
   }
   }
 
 
   @Test
   @Test
@@ -110,7 +111,7 @@ public class TestAzureADTokenProvider {
     AdlFileSystem fileSystem = new AdlFileSystem();
     AdlFileSystem fileSystem = new AdlFileSystem();
     fileSystem.initialize(uri, conf);
     fileSystem.initialize(uri, conf);
     AccessTokenProvider tokenProvider = fileSystem.getTokenProvider();
     AccessTokenProvider tokenProvider = fileSystem.getTokenProvider();
-    Assert.assertTrue(tokenProvider instanceof MsiTokenProvider);
+    assertTrue(tokenProvider instanceof MsiTokenProvider);
   }
   }
 
 
   @Test
   @Test
@@ -129,7 +130,7 @@ public class TestAzureADTokenProvider {
       AdlFileSystem fileSystem = new AdlFileSystem();
       AdlFileSystem fileSystem = new AdlFileSystem();
       fileSystem.initialize(uri, conf);
       fileSystem.initialize(uri, conf);
       AccessTokenProvider tokenProvider = fileSystem.getTokenProvider();
       AccessTokenProvider tokenProvider = fileSystem.getTokenProvider();
-      Assert.assertTrue(tokenProvider instanceof DeviceCodeTokenProvider);
+      assertTrue(tokenProvider instanceof DeviceCodeTokenProvider);
     }
     }
   }
   }
 
 
@@ -145,7 +146,7 @@ public class TestAzureADTokenProvider {
     AdlFileSystem fileSystem = new AdlFileSystem();
     AdlFileSystem fileSystem = new AdlFileSystem();
     fileSystem.initialize(uri, conf);
     fileSystem.initialize(uri, conf);
     AccessTokenProvider tokenProvider = fileSystem.getTokenProvider();
     AccessTokenProvider tokenProvider = fileSystem.getTokenProvider();
-    Assert.assertTrue(tokenProvider instanceof SdkTokenProviderAdapter);
+    assertTrue(tokenProvider instanceof SdkTokenProviderAdapter);
   }
   }
 
 
   @Test
   @Test
@@ -157,7 +158,7 @@ public class TestAzureADTokenProvider {
     AdlFileSystem fileSystem = new AdlFileSystem();
     AdlFileSystem fileSystem = new AdlFileSystem();
     try {
     try {
       fileSystem.initialize(uri, conf);
       fileSystem.initialize(uri, conf);
-      Assert.fail("Initialization should have failed due no token provider "
+      fail("Initialization should have failed due no token provider "
           + "configuration");
           + "configuration");
     } catch (IllegalArgumentException e) {
     } catch (IllegalArgumentException e) {
       GenericTestUtils.assertExceptionContains(
       GenericTestUtils.assertExceptionContains(
@@ -179,17 +180,17 @@ public class TestAzureADTokenProvider {
         "wrong.classpath.CustomMockTokenProvider");
         "wrong.classpath.CustomMockTokenProvider");
     try {
     try {
       fileSystem.initialize(uri, conf);
       fileSystem.initialize(uri, conf);
-      Assert.fail("Initialization should have failed due invalid provider "
+      fail("Initialization should have failed due invalid provider "
           + "configuration");
           + "configuration");
     } catch (RuntimeException e) {
     } catch (RuntimeException e) {
-      Assert.assertTrue(
+      assertTrue(
           e.getMessage().contains("wrong.classpath.CustomMockTokenProvider"));
           e.getMessage().contains("wrong.classpath.CustomMockTokenProvider"));
     }
     }
   }
   }
 
 
   private CredentialProvider createTempCredProvider(Configuration conf)
   private CredentialProvider createTempCredProvider(Configuration conf)
       throws URISyntaxException, IOException {
       throws URISyntaxException, IOException {
-    final File file = tempDir.newFile("test.jks");
+    final File file = tempDir.resolve("test.jks").toFile();
     final URI jks = ProviderUtils.nestURIForLocalJavaKeyStoreProvider(
     final URI jks = ProviderUtils.nestURIForLocalJavaKeyStoreProvider(
         file.toURI());
         file.toURI());
     conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH,
     conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH,
@@ -217,7 +218,7 @@ public class TestAzureADTokenProvider {
     fileSystem.initialize(uri, conf);
     fileSystem.initialize(uri, conf);
     RefreshTokenBasedTokenProvider expected =
     RefreshTokenBasedTokenProvider expected =
         new RefreshTokenBasedTokenProvider(CLIENT_ID, REFRESH_TOKEN);
         new RefreshTokenBasedTokenProvider(CLIENT_ID, REFRESH_TOKEN);
-    Assert.assertTrue(EqualsBuilder.reflectionEquals(expected,
+    assertTrue(EqualsBuilder.reflectionEquals(expected,
         fileSystem.getTokenProvider()));
         fileSystem.getTokenProvider()));
   }
   }
 
 
@@ -236,7 +237,7 @@ public class TestAzureADTokenProvider {
     fileSystem.initialize(uri, conf);
     fileSystem.initialize(uri, conf);
     RefreshTokenBasedTokenProvider expected =
     RefreshTokenBasedTokenProvider expected =
         new RefreshTokenBasedTokenProvider(CLIENT_ID, REFRESH_TOKEN);
         new RefreshTokenBasedTokenProvider(CLIENT_ID, REFRESH_TOKEN);
-    Assert.assertTrue(EqualsBuilder.reflectionEquals(expected,
+    assertTrue(EqualsBuilder.reflectionEquals(expected,
         fileSystem.getTokenProvider()));
         fileSystem.getTokenProvider()));
   }
   }
 
 
@@ -263,7 +264,7 @@ public class TestAzureADTokenProvider {
     fileSystem.initialize(uri, conf);
     fileSystem.initialize(uri, conf);
     ClientCredsTokenProvider expected = new ClientCredsTokenProvider(
     ClientCredsTokenProvider expected = new ClientCredsTokenProvider(
         REFRESH_URL, CLIENT_ID, CLIENT_SECRET);
         REFRESH_URL, CLIENT_ID, CLIENT_SECRET);
-    Assert.assertTrue(EqualsBuilder.reflectionEquals(expected,
+    assertTrue(EqualsBuilder.reflectionEquals(expected,
         fileSystem.getTokenProvider()));
         fileSystem.getTokenProvider()));
   }
   }
 
 
@@ -283,7 +284,7 @@ public class TestAzureADTokenProvider {
     fileSystem.initialize(uri, conf);
     fileSystem.initialize(uri, conf);
     ClientCredsTokenProvider expected = new ClientCredsTokenProvider(
     ClientCredsTokenProvider expected = new ClientCredsTokenProvider(
         REFRESH_URL, CLIENT_ID, CLIENT_SECRET);
         REFRESH_URL, CLIENT_ID, CLIENT_SECRET);
-    Assert.assertTrue(EqualsBuilder.reflectionEquals(expected,
+    assertTrue(EqualsBuilder.reflectionEquals(expected,
         fileSystem.getTokenProvider()));
         fileSystem.getTokenProvider()));
   }
   }
 
 

+ 8 - 8
hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/TestRelativePathFormation.java

@@ -20,8 +20,7 @@ package org.apache.hadoop.fs.adl;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URI;
@@ -31,6 +30,7 @@ import static org.apache.hadoop.fs.adl.AdlConfKeys
     .AZURE_AD_TOKEN_PROVIDER_CLASS_KEY;
     .AZURE_AD_TOKEN_PROVIDER_CLASS_KEY;
 import static org.apache.hadoop.fs.adl.AdlConfKeys
 import static org.apache.hadoop.fs.adl.AdlConfKeys
     .AZURE_AD_TOKEN_PROVIDER_TYPE_KEY;
     .AZURE_AD_TOKEN_PROVIDER_TYPE_KEY;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 /**
 /**
  * This class verifies path conversion to SDK.
  * This class verifies path conversion to SDK.
@@ -48,17 +48,17 @@ public class TestRelativePathFormation {
 
 
     fs.initialize(new URI("adl://temp.account.net"), configuration);
     fs.initialize(new URI("adl://temp.account.net"), configuration);
 
 
-    Assert.assertEquals("/usr", fs.toRelativeFilePath(new Path("/usr")));
-    Assert.assertEquals("/usr",
+    assertEquals("/usr", fs.toRelativeFilePath(new Path("/usr")));
+    assertEquals("/usr",
         fs.toRelativeFilePath(new Path("adl://temp.account.net/usr")));
         fs.toRelativeFilePath(new Path("adl://temp.account.net/usr")));
 
 
     // When working directory is set.
     // When working directory is set.
     fs.setWorkingDirectory(new Path("/a/b/"));
     fs.setWorkingDirectory(new Path("/a/b/"));
-    Assert.assertEquals("/usr", fs.toRelativeFilePath(new Path("/usr")));
-    Assert.assertEquals("/a/b/usr", fs.toRelativeFilePath(new Path("usr")));
-    Assert.assertEquals("/usr",
+    assertEquals("/usr", fs.toRelativeFilePath(new Path("/usr")));
+    assertEquals("/a/b/usr", fs.toRelativeFilePath(new Path("usr")));
+    assertEquals("/usr",
         fs.toRelativeFilePath(new Path("adl://temp.account.net/usr")));
         fs.toRelativeFilePath(new Path("adl://temp.account.net/usr")));
-    Assert.assertEquals("/usr",
+    assertEquals("/usr",
         fs.toRelativeFilePath(new Path("wasb://temp.account.net/usr")));
         fs.toRelativeFilePath(new Path("wasb://temp.account.net/usr")));
   }
   }
 
 

+ 2 - 2
hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/TestValidateConfiguration.java

@@ -20,7 +20,7 @@ package org.apache.hadoop.fs.adl;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.test.GenericTestUtils;
 import org.apache.hadoop.test.GenericTestUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import static org.apache.hadoop.fs.adl.AdlConfKeys.ADL_BLOCK_SIZE;
 import static org.apache.hadoop.fs.adl.AdlConfKeys.ADL_BLOCK_SIZE;
 import static org.apache.hadoop.fs.adl.AdlConfKeys
 import static org.apache.hadoop.fs.adl.AdlConfKeys
@@ -57,7 +57,7 @@ import static org.apache.hadoop.fs.adl.AdlConfKeys
     .TOKEN_PROVIDER_TYPE_REFRESH_TOKEN;
     .TOKEN_PROVIDER_TYPE_REFRESH_TOKEN;
 import static org.apache.hadoop.fs.adl.AdlConfKeys.WRITE_BUFFER_SIZE_KEY;
 import static org.apache.hadoop.fs.adl.AdlConfKeys.WRITE_BUFFER_SIZE_KEY;
 
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 
 import java.io.File;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.FileOutputStream;

+ 19 - 21
hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/live/TestAdlDifferentSizeWritesLive.java

@@ -23,13 +23,10 @@ import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FSDataOutputStream;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.adl.common.Parallelized;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.net.URISyntaxException;
@@ -39,19 +36,21 @@ import java.util.Random;
 import java.util.UUID;
 import java.util.UUID;
 
 
 import static org.apache.hadoop.fs.adl.AdlConfKeys.WRITE_BUFFER_SIZE_KEY;
 import static org.apache.hadoop.fs.adl.AdlConfKeys.WRITE_BUFFER_SIZE_KEY;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
 
 
 /**
 /**
  * Verify data integrity with different data sizes with buffer size.
  * Verify data integrity with different data sizes with buffer size.
  */
  */
-@RunWith(Parallelized.class)
 public class TestAdlDifferentSizeWritesLive {
 public class TestAdlDifferentSizeWritesLive {
   private static Random rand = new Random();
   private static Random rand = new Random();
   private int totalSize;
   private int totalSize;
   private int chunkSize;
   private int chunkSize;
 
 
-  public TestAdlDifferentSizeWritesLive(int totalSize, int chunkSize) {
-    this.totalSize = totalSize;
-    this.chunkSize = chunkSize;
+  public void initTestAdlDifferentSizeWritesLive(int pTotalSize, int pChunkSize) {
+    this.totalSize = pTotalSize;
+    this.chunkSize = pChunkSize;
   }
   }
 
 
   public static byte[] getRandomByteArrayData(int size) {
   public static byte[] getRandomByteArrayData(int size) {
@@ -60,8 +59,6 @@ public class TestAdlDifferentSizeWritesLive {
     return b;
     return b;
   }
   }
 
 
-  @Parameterized.Parameters(name = "{index}: Data Size [{0}] ; Chunk Size "
-      + "[{1}]")
   public static Collection testDataForIntegrityTest() {
   public static Collection testDataForIntegrityTest() {
     return Arrays.asList(
     return Arrays.asList(
         new Object[][] {{4 * 1024, 1 * 1024}, {4 * 1024, 7 * 1024},
         new Object[][] {{4 * 1024, 1 * 1024}, {4 * 1024, 7 * 1024},
@@ -71,7 +68,7 @@ public class TestAdlDifferentSizeWritesLive {
             {10 * 1024, 8 * 1024}});
             {10 * 1024, 8 * 1024}});
   }
   }
 
 
-  @BeforeClass
+  @BeforeAll
   public static void cleanUpParent() throws IOException, URISyntaxException {
   public static void cleanUpParent() throws IOException, URISyntaxException {
     if (AdlStorageConfiguration.isContractTestEnabled()) {
     if (AdlStorageConfiguration.isContractTestEnabled()) {
       Path path = new Path("/test/dataIntegrityCheck/");
       Path path = new Path("/test/dataIntegrityCheck/");
@@ -80,14 +77,15 @@ public class TestAdlDifferentSizeWritesLive {
     }
     }
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void setup() throws Exception {
   public void setup() throws Exception {
-    org.junit.Assume
-        .assumeTrue(AdlStorageConfiguration.isContractTestEnabled());
+    assumeTrue(AdlStorageConfiguration.isContractTestEnabled());
   }
   }
 
 
-  @Test
-  public void testDataIntegrity() throws IOException {
+  @MethodSource("testDataForIntegrityTest")
+  @ParameterizedTest(name = "{index}: Data Size [{0}] ; Chunk Size [{1}]")
+  public void testDataIntegrity(int pTotalSize, int pChunkSize) throws IOException {
+    initTestAdlDifferentSizeWritesLive(pTotalSize, pChunkSize);
     Path path = new Path(
     Path path = new Path(
         "/test/dataIntegrityCheck/" + UUID.randomUUID().toString());
         "/test/dataIntegrityCheck/" + UUID.randomUUID().toString());
     FileSystem fs = null;
     FileSystem fs = null;
@@ -117,7 +115,7 @@ public class TestAdlDifferentSizeWritesLive {
     FSDataInputStream in = fs.open(path);
     FSDataInputStream in = fs.open(path);
     in.readFully(0, actualData);
     in.readFully(0, actualData);
     in.close();
     in.close();
-    Assert.assertArrayEquals(expectedData, actualData);
-    Assert.assertTrue(fs.delete(path, true));
+    assertArrayEquals(expectedData, actualData);
+    assertTrue(fs.delete(path, true));
   }
   }
 }
 }

+ 19 - 17
hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/live/TestAdlInternalCreateNonRecursive.java

@@ -23,14 +23,9 @@ import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
 import org.apache.hadoop.fs.FileAlreadyExistsException;
 import org.apache.hadoop.fs.FileAlreadyExistsException;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.adl.common.Parallelized;
 import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.fs.permission.FsPermission;
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.io.UnsupportedEncodingException;
@@ -38,10 +33,13 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collection;
 import java.util.UUID;
 import java.util.UUID;
 
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
+
 /**
 /**
  * Test createNonRecursive API.
  * Test createNonRecursive API.
  */
  */
-@RunWith(Parallelized.class)
 public class TestAdlInternalCreateNonRecursive {
 public class TestAdlInternalCreateNonRecursive {
   private Path inputFileName;
   private Path inputFileName;
   private FsPermission inputPermission;
   private FsPermission inputPermission;
@@ -51,9 +49,9 @@ public class TestAdlInternalCreateNonRecursive {
   private Class<IOException> expectedExceptionType;
   private Class<IOException> expectedExceptionType;
   private FileSystem adlStore;
   private FileSystem adlStore;
 
 
-  public TestAdlInternalCreateNonRecursive(String testScenario, String fileName,
+  public void initTestAdlInternalCreateNonRecursive(String testScenario, String fileName,
       FsPermission permission, boolean override, boolean fileAlreadyExist,
       FsPermission permission, boolean override, boolean fileAlreadyExist,
-      boolean parentAlreadyExist, Class<IOException> exceptionType) {
+      boolean parentAlreadyExist, Class<IOException> exceptionType) throws Exception {
 
 
     // Random parent path for each test so that parallel execution does not fail
     // Random parent path for each test so that parallel execution does not fail
     // other running test.
     // other running test.
@@ -64,9 +62,9 @@ public class TestAdlInternalCreateNonRecursive {
     inputOverride = override;
     inputOverride = override;
     inputParentAlreadyExist = parentAlreadyExist;
     inputParentAlreadyExist = parentAlreadyExist;
     expectedExceptionType = exceptionType;
     expectedExceptionType = exceptionType;
+    setUp();
   }
   }
 
 
-  @Parameterized.Parameters(name = "{0}")
   public static Collection adlCreateNonRecursiveTestData()
   public static Collection adlCreateNonRecursiveTestData()
       throws UnsupportedEncodingException {
       throws UnsupportedEncodingException {
     /*
     /*
@@ -92,14 +90,18 @@ public class TestAdlInternalCreateNonRecursive {
             IOException.class }*/});
             IOException.class }*/});
   }
   }
 
 
-  @Before
   public void setUp() throws Exception {
   public void setUp() throws Exception {
-    Assume.assumeTrue(AdlStorageConfiguration.isContractTestEnabled());
+    assumeTrue(AdlStorageConfiguration.isContractTestEnabled());
     adlStore = AdlStorageConfiguration.createStorageConnector();
     adlStore = AdlStorageConfiguration.createStorageConnector();
   }
   }
 
 
-  @Test
-  public void testCreateNonRecursiveFunctionality() throws IOException {
+  @MethodSource("adlCreateNonRecursiveTestData")
+  @ParameterizedTest(name = "{0}")
+  public void testCreateNonRecursiveFunctionality(String testScenario, String fileName,
+      FsPermission permission, boolean override, boolean fileAlreadyExist,
+      boolean parentAlreadyExist, Class<IOException> exceptionType) throws Exception {
+    initTestAdlInternalCreateNonRecursive(testScenario, fileName, permission,
+        override, fileAlreadyExist, parentAlreadyExist, exceptionType);
     if (inputFileAlreadyExist) {
     if (inputFileAlreadyExist) {
       FileSystem.create(adlStore, inputFileName, inputPermission);
       FileSystem.create(adlStore, inputFileName, inputPermission);
     }
     }
@@ -122,12 +124,12 @@ public class TestAdlInternalCreateNonRecursive {
         throw e;
         throw e;
       }
       }
 
 
-      Assert.assertEquals(expectedExceptionType, e.getClass());
+      assertEquals(expectedExceptionType, e.getClass());
       return;
       return;
     }
     }
 
 
     if (expectedExceptionType != null) {
     if (expectedExceptionType != null) {
-      Assert.fail("CreateNonRecursive should have failed with exception "
+      fail("CreateNonRecursive should have failed with exception "
           + expectedExceptionType.getName());
           + expectedExceptionType.getName());
     }
     }
   }
   }

+ 12 - 11
hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/live/TestAdlSdkConfiguration.java

@@ -23,15 +23,16 @@ import com.microsoft.azure.datalake.store.SSLSocketFactoryEx.SSLChannelMode;
 
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.adl.AdlFileSystem;
 import org.apache.hadoop.fs.adl.AdlFileSystem;
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.net.URISyntaxException;
 import java.net.URISyntaxException;
 
 
 import static org.apache.hadoop.fs.adl.AdlConfKeys.ADL_HTTP_TIMEOUT;
 import static org.apache.hadoop.fs.adl.AdlConfKeys.ADL_HTTP_TIMEOUT;
 import static org.apache.hadoop.fs.adl.AdlConfKeys.ADL_SSL_CHANNEL_MODE;
 import static org.apache.hadoop.fs.adl.AdlConfKeys.ADL_SSL_CHANNEL_MODE;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
 
 
 /**
 /**
  * Tests interactions with SDK and ensures configuration is having the desired
  * Tests interactions with SDK and ensures configuration is having the desired
@@ -55,10 +56,10 @@ public class TestAdlSdkConfiguration {
     }
     }
 
 
     // Skip this test if we can't get a real FS
     // Skip this test if we can't get a real FS
-    Assume.assumeNotNull(fs);
+    assumeTrue(fs != null);
     effectiveTimeout = fs.getAdlClient().getDefaultTimeout();
     effectiveTimeout = fs.getAdlClient().getDefaultTimeout();
-    Assert.assertFalse("A negative timeout is not supposed to take effect",
-        effectiveTimeout < 0);
+    assertFalse(effectiveTimeout < 0,
+        "A negative timeout is not supposed to take effect");
 
 
     conf = AdlStorageConfiguration.getConfiguration();
     conf = AdlStorageConfiguration.getConfiguration();
     conf.setInt(ADL_HTTP_TIMEOUT, 17);
     conf.setInt(ADL_HTTP_TIMEOUT, 17);
@@ -71,8 +72,8 @@ public class TestAdlSdkConfiguration {
     }
     }
 
 
     effectiveTimeout = fs.getAdlClient().getDefaultTimeout();
     effectiveTimeout = fs.getAdlClient().getDefaultTimeout();
-    Assert.assertEquals("Timeout is getting set",
-        effectiveTimeout, 17);
+    assertEquals(
+        effectiveTimeout, 17, "Timeout is getting set");
 
 
     // The default value may vary by SDK, so that value is not tested here.
     // The default value may vary by SDK, so that value is not tested here.
   }
   }
@@ -98,11 +99,11 @@ public class TestAdlSdkConfiguration {
     conf = AdlStorageConfiguration.getConfiguration();
     conf = AdlStorageConfiguration.getConfiguration();
     conf.set(ADL_SSL_CHANNEL_MODE, sslChannelModeConfigValue);
     conf.set(ADL_SSL_CHANNEL_MODE, sslChannelModeConfigValue);
     fs = (AdlFileSystem) (AdlStorageConfiguration.createStorageConnector(conf));
     fs = (AdlFileSystem) (AdlStorageConfiguration.createStorageConnector(conf));
-    Assume.assumeNotNull(fs);
+    assumeTrue(fs != null);
 
 
     SSLChannelMode sslChannelMode = fs.getAdlClient().getSSLChannelMode();
     SSLChannelMode sslChannelMode = fs.getAdlClient().getSSLChannelMode();
-    Assert.assertEquals(
+    assertEquals(expectedMode, sslChannelMode,
         "Unexpected SSL Channel Mode for adl.ssl.channel.mode config value : "
         "Unexpected SSL Channel Mode for adl.ssl.channel.mode config value : "
-            + sslChannelModeConfigValue, expectedMode, sslChannelMode);
+        + sslChannelModeConfigValue);
   }
   }
 }
 }

+ 49 - 54
hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/live/TestAdlSupportedCharsetInPath.java

@@ -19,16 +19,17 @@
 
 
 package org.apache.hadoop.fs.adl.live;
 package org.apache.hadoop.fs.adl.live;
 
 
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
+
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.adl.common.Parallelized;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -41,7 +42,6 @@ import java.util.*;
  * Test supported ASCII, UTF-8 character set supported by Adl storage file
  * Test supported ASCII, UTF-8 character set supported by Adl storage file
  * system on file/folder operation.
  * system on file/folder operation.
  */
  */
-@RunWith(Parallelized.class)
 public class TestAdlSupportedCharsetInPath {
 public class TestAdlSupportedCharsetInPath {
 
 
   private static final String TEST_ROOT = "/test/";
   private static final String TEST_ROOT = "/test/";
@@ -49,11 +49,10 @@ public class TestAdlSupportedCharsetInPath {
       .getLogger(TestAdlSupportedCharsetInPath.class);
       .getLogger(TestAdlSupportedCharsetInPath.class);
   private String path;
   private String path;
 
 
-  public TestAdlSupportedCharsetInPath(String filePath) {
+  public void initTestAdlSupportedCharsetInPath(String filePath) {
     path = filePath;
     path = filePath;
   }
   }
 
 
-  @Parameterized.Parameters(name = "{0}")
   public static Collection<Object[]> adlCharTestData()
   public static Collection<Object[]> adlCharTestData()
       throws UnsupportedEncodingException {
       throws UnsupportedEncodingException {
 
 
@@ -246,7 +245,7 @@ public class TestAdlSupportedCharsetInPath {
     filePathList.add("bobτ");
     filePathList.add("bobτ");
   }
   }
 
 
-  @AfterClass
+  @AfterAll
   public static void testReport() throws IOException, URISyntaxException {
   public static void testReport() throws IOException, URISyntaxException {
     if (!AdlStorageConfiguration.isContractTestEnabled()) {
     if (!AdlStorageConfiguration.isContractTestEnabled()) {
       return;
       return;
@@ -256,23 +255,22 @@ public class TestAdlSupportedCharsetInPath {
     fs.delete(new Path(TEST_ROOT), true);
     fs.delete(new Path(TEST_ROOT), true);
   }
   }
 
 
-  @Test
-  public void testAllowedSpecialCharactersMkdir()
+  @MethodSource("adlCharTestData")
+  @ParameterizedTest(name = "filePath {0}")
+  public void testAllowedSpecialCharactersMkdir(String filePath)
       throws IOException, URISyntaxException {
       throws IOException, URISyntaxException {
+    initTestAdlSupportedCharsetInPath(filePath);
     Path parentPath = new Path(TEST_ROOT, UUID.randomUUID().toString() + "/");
     Path parentPath = new Path(TEST_ROOT, UUID.randomUUID().toString() + "/");
     Path specialFile = new Path(parentPath, path);
     Path specialFile = new Path(parentPath, path);
     FileSystem fs = AdlStorageConfiguration.createStorageConnector();
     FileSystem fs = AdlStorageConfiguration.createStorageConnector();
 
 
-    Assert.assertTrue("Mkdir failed : " + specialFile, fs.mkdirs(specialFile));
-    Assert.assertTrue("File not Found after Mkdir success" + specialFile,
-        fs.exists(specialFile));
-    Assert.assertTrue("Not listed under parent " + parentPath,
-        contains(fs.listStatus(parentPath),
-            fs.makeQualified(specialFile).toString()));
-    Assert.assertTrue("Delete failed : " + specialFile,
-            fs.delete(specialFile, true));
-    Assert.assertFalse("File still exist after delete " + specialFile,
-        fs.exists(specialFile));
+    assertTrue(fs.mkdirs(specialFile), "Mkdir failed : " + specialFile);
+    assertTrue(fs.exists(specialFile),
+        "File not Found after Mkdir success" + specialFile);
+    assertTrue(contains(fs.listStatus(parentPath),
+        fs.makeQualified(specialFile).toString()), "Not listed under parent " + parentPath);
+    assertTrue(fs.delete(specialFile, true), "Delete failed : " + specialFile);
+    assertFalse(fs.exists(specialFile), "File still exist after delete " + specialFile);
   }
   }
 
 
   private boolean contains(FileStatus[] statuses, String remotePath) {
   private boolean contains(FileStatus[] statuses, String remotePath) {
@@ -286,49 +284,46 @@ public class TestAdlSupportedCharsetInPath {
     return false;
     return false;
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void setup() throws Exception {
   public void setup() throws Exception {
-    org.junit.Assume
-        .assumeTrue(AdlStorageConfiguration.isContractTestEnabled());
+    assumeTrue(AdlStorageConfiguration.isContractTestEnabled());
   }
   }
 
 
-  @Test
-  public void testAllowedSpecialCharactersRename()
+  @MethodSource("adlCharTestData")
+  @ParameterizedTest(name = "filePath {0}")
+  public void testAllowedSpecialCharactersRename(String filePath)
       throws IOException, URISyntaxException {
       throws IOException, URISyntaxException {
-
+    initTestAdlSupportedCharsetInPath(filePath);
     String parentPath = TEST_ROOT + UUID.randomUUID().toString() + "/";
     String parentPath = TEST_ROOT + UUID.randomUUID().toString() + "/";
     Path specialFile = new Path(parentPath + path);
     Path specialFile = new Path(parentPath + path);
     Path anotherLocation = new Path(parentPath + UUID.randomUUID().toString());
     Path anotherLocation = new Path(parentPath + UUID.randomUUID().toString());
     FileSystem fs = AdlStorageConfiguration.createStorageConnector();
     FileSystem fs = AdlStorageConfiguration.createStorageConnector();
 
 
-    Assert.assertTrue("Could not create " + specialFile.toString(),
-        fs.createNewFile(specialFile));
-    Assert.assertTrue(
-        "Failed to rename " + specialFile.toString() + " --> " + anotherLocation
-            .toString(), fs.rename(specialFile, anotherLocation));
-    Assert.assertFalse("File should not be present after successful rename : "
-        + specialFile.toString(), fs.exists(specialFile));
-    Assert.assertTrue("File should be present after successful rename : "
-        + anotherLocation.toString(), fs.exists(anotherLocation));
-    Assert.assertFalse(
-        "Listed under parent whereas expected not listed : " + parentPath,
-        contains(fs.listStatus(new Path(parentPath)),
-            fs.makeQualified(specialFile).toString()));
+    assertTrue(fs.createNewFile(specialFile),
+        "Could not create " + specialFile.toString());
+    assertTrue(fs.rename(specialFile, anotherLocation),
+        "Failed to rename " + specialFile.toString() + " --> " + anotherLocation.toString());
+    assertFalse(fs.exists(specialFile), "File should not be present after successful rename : "
+        + specialFile.toString());
+    assertTrue(fs.exists(anotherLocation), "File should be present after successful rename : "
+        + anotherLocation.toString());
+    assertFalse(contains(fs.listStatus(new Path(parentPath)),
+        fs.makeQualified(specialFile).toString()),
+        "Listed under parent whereas expected not listed : " + parentPath);
 
 
-    Assert.assertTrue(
+    assertTrue(fs.rename(anotherLocation, specialFile),
         "Failed to rename " + anotherLocation.toString() + " --> " + specialFile
         "Failed to rename " + anotherLocation.toString() + " --> " + specialFile
-            .toString(), fs.rename(anotherLocation, specialFile));
-    Assert.assertTrue(
-        "File should be present after successful rename : " + "" + specialFile
-            .toString(), fs.exists(specialFile));
-    Assert.assertFalse("File should not be present after successful rename : "
-        + anotherLocation.toString(), fs.exists(anotherLocation));
+        .toString());
+    assertTrue(fs.exists(specialFile),
+        "File should be present after successful rename : " + "" + specialFile.toString());
+    assertFalse(fs.exists(anotherLocation),
+        "File should not be present after successful rename : "
+        + anotherLocation.toString());
 
 
-    Assert.assertTrue("Not listed under parent " + parentPath,
-        contains(fs.listStatus(new Path(parentPath)),
-            fs.makeQualified(specialFile).toString()));
+    assertTrue(contains(fs.listStatus(new Path(parentPath)),
+        fs.makeQualified(specialFile).toString()), "Not listed under parent " + parentPath);
 
 
-    Assert.assertTrue("Failed to delete " + parentPath,
-        fs.delete(new Path(parentPath), true));
+    assertTrue(fs.delete(new Path(parentPath), true),
+        "Failed to delete " + parentPath);
   }
   }
 }
 }

+ 24 - 24
hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/live/TestMetadata.java

@@ -23,17 +23,18 @@ import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.adl.AdlFileSystem;
 import org.apache.hadoop.fs.adl.AdlFileSystem;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 
 import java.io.IOException;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.OutputStream;
 import java.util.UUID;
 import java.util.UUID;
 
 
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
 
 
 /**
 /**
  * This class is responsible for testing ContentSummary, ListStatus on
  * This class is responsible for testing ContentSummary, ListStatus on
@@ -48,13 +49,13 @@ public class TestMetadata {
     parent = new Path("test");
     parent = new Path("test");
   }
   }
 
 
-  @Before
+  @BeforeEach
   public void setUp() throws Exception {
   public void setUp() throws Exception {
-    Assume.assumeTrue(AdlStorageConfiguration.isContractTestEnabled());
+    assumeTrue(AdlStorageConfiguration.isContractTestEnabled());
     adlStore = AdlStorageConfiguration.createStorageConnector();
     adlStore = AdlStorageConfiguration.createStorageConnector();
   }
   }
 
 
-  @After
+  @AfterEach
   public void cleanUp() throws Exception {
   public void cleanUp() throws Exception {
     if (AdlStorageConfiguration.isContractTestEnabled()) {
     if (AdlStorageConfiguration.isContractTestEnabled()) {
       adlStore.delete(parent, true);
       adlStore.delete(parent, true);
@@ -72,12 +73,12 @@ public class TestMetadata {
     }
     }
     out.close();
     out.close();
 
 
-    Assert.assertTrue(adlStore.isFile(testFile));
+    assertTrue(adlStore.isFile(testFile));
     ContentSummary summary = adlStore.getContentSummary(testFile);
     ContentSummary summary = adlStore.getContentSummary(testFile);
-    Assert.assertEquals(1024, summary.getSpaceConsumed());
-    Assert.assertEquals(1, summary.getFileCount());
-    Assert.assertEquals(0, summary.getDirectoryCount());
-    Assert.assertEquals(1024, summary.getLength());
+    assertEquals(1024, summary.getSpaceConsumed());
+    assertEquals(1, summary.getFileCount());
+    assertEquals(0, summary.getDirectoryCount());
+    assertEquals(1024, summary.getLength());
   }
   }
 
 
   @Test
   @Test
@@ -91,12 +92,12 @@ public class TestMetadata {
     }
     }
     out.close();
     out.close();
 
 
-    Assert.assertTrue(adlStore.isFile(testFile));
+    assertTrue(adlStore.isFile(testFile));
     ContentSummary summary = adlStore.getContentSummary(parent);
     ContentSummary summary = adlStore.getContentSummary(parent);
-    Assert.assertEquals(1024, summary.getSpaceConsumed());
-    Assert.assertEquals(1, summary.getFileCount());
-    Assert.assertEquals(1, summary.getDirectoryCount());
-    Assert.assertEquals(1024, summary.getLength());
+    assertEquals(1024, summary.getSpaceConsumed());
+    assertEquals(1, summary.getFileCount());
+    assertEquals(1, summary.getDirectoryCount());
+    assertEquals(1024, summary.getLength());
   }
   }
 
 
   @Test
   @Test
@@ -104,11 +105,10 @@ public class TestMetadata {
     Path path = new Path(parent, "a.txt");
     Path path = new Path(parent, "a.txt");
     FileSystem fs = adlStore;
     FileSystem fs = adlStore;
     fs.createNewFile(path);
     fs.createNewFile(path);
-    Assert.assertTrue(fs.isFile(path));
+    assertTrue(fs.isFile(path));
     FileStatus[] statuses = fs.listStatus(path);
     FileStatus[] statuses = fs.listStatus(path);
-    Assert
-        .assertEquals(path.makeQualified(fs.getUri(), fs.getWorkingDirectory()),
-            statuses[0].getPath());
+    assertEquals(path.makeQualified(fs.getUri(), fs.getWorkingDirectory()),
+        statuses[0].getPath());
   }
   }
 
 
   @Test
   @Test
@@ -122,7 +122,7 @@ public class TestMetadata {
     // That is non GUID value.
     // That is non GUID value.
     fs.setUserGroupRepresentationAsUPN(false);
     fs.setUserGroupRepresentationAsUPN(false);
     fs.createNewFile(path);
     fs.createNewFile(path);
-    Assert.assertTrue(fs.isFile(path));
+    assertTrue(fs.isFile(path));
     FileStatus fileStatus = fs.getFileStatus(path);
     FileStatus fileStatus = fs.getFileStatus(path);
     UUID.fromString(fileStatus.getGroup());
     UUID.fromString(fileStatus.getGroup());
     UUID.fromString(fileStatus.getOwner());
     UUID.fromString(fileStatus.getOwner());