-
Notifications
You must be signed in to change notification settings - Fork 9.2k
HADOOP-19426. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-azure-datalake Part2. #7757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -24,12 +24,11 @@ | |||||
| import org.apache.hadoop.fs.FileStatus; | ||||||
| import org.apache.hadoop.fs.FileSystem; | ||||||
| import org.apache.hadoop.fs.Path; | ||||||
| import org.apache.hadoop.fs.adl.common.Parallelized; | ||||||
| import org.apache.hadoop.fs.permission.FsAction; | ||||||
| import org.apache.hadoop.fs.permission.FsPermission; | ||||||
| import org.junit.*; | ||||||
| import org.junit.runner.RunWith; | ||||||
| import org.junit.runners.Parameterized; | ||||||
| import org.junit.jupiter.api.AfterAll; | ||||||
| import org.junit.jupiter.params.ParameterizedTest; | ||||||
| import org.junit.jupiter.params.provider.MethodSource; | ||||||
|
|
||||||
| import java.io.IOException; | ||||||
| import java.io.UnsupportedEncodingException; | ||||||
|
|
@@ -38,22 +37,25 @@ | |||||
| import java.util.Collection; | ||||||
| import java.util.UUID; | ||||||
|
|
||||||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||||||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||||||
| import static org.junit.jupiter.api.Assumptions.assumeTrue; | ||||||
|
|
||||||
| /** | ||||||
| * Test ACL permission on file/folder on Adl file system. | ||||||
| */ | ||||||
| @RunWith(Parallelized.class) | ||||||
| public class TestAdlPermissionLive { | ||||||
|
|
||||||
| private static Path testRoot = new Path("/test"); | ||||||
| private FsPermission permission; | ||||||
| private Path path; | ||||||
| private FileSystem adlStore; | ||||||
|
|
||||||
| public TestAdlPermissionLive(FsPermission testPermission) { | ||||||
| permission = testPermission; | ||||||
| public void initTestAdlPermissionLive(FsPermission pTestPermission) throws Exception { | ||||||
| permission = pTestPermission; | ||||||
| setUp(); | ||||||
| } | ||||||
|
|
||||||
| @Parameterized.Parameters(name = "{0}") | ||||||
| public static Collection adlCreateNonRecursiveTestData() | ||||||
| throws UnsupportedEncodingException { | ||||||
| /* | ||||||
|
|
@@ -71,22 +73,23 @@ public static Collection adlCreateNonRecursiveTestData() | |||||
| return datas; | ||||||
| } | ||||||
|
|
||||||
| @AfterClass | ||||||
| @AfterAll | ||||||
| public static void cleanUp() throws IOException, URISyntaxException { | ||||||
| if (AdlStorageConfiguration.isContractTestEnabled()) { | ||||||
| Assert.assertTrue(AdlStorageConfiguration.createStorageConnector() | ||||||
| assertTrue(AdlStorageConfiguration.createStorageConnector() | ||||||
| .delete(testRoot, true)); | ||||||
|
||||||
| .delete(testRoot, true)); | |
| .delete(testRoot, true), "Failed to clean up testRoot directory during cleanup."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need @beforeeach here after removing @before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anujmodi2021 Thank you for your question! ParameterizedTest in JUnit 5 is a special type of unit test. Unlike JUnit 4, ParameterizedTest requires the initialization of certain parameters directly in the test method, so the setup function is executed at that point. If we add @BeforeEach, the variables in setup would not be initialized yet. Therefore, we don't need to add @BeforeEach; instead, we should call setup within initTestAdlPermissionLive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a parameterized generic return type
Collection<FsPermission>for the data provider to avoid raw-type warnings and improve type safety.