-
Notifications
You must be signed in to change notification settings - Fork 8.9k
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
HADOOP-19425. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-azure Part1. #7369
base: trunk
Are you sure you want to change the base?
Changes from 5 commits
a44ce7d
b52214a
8852f97
92f15fb
8030686
859a45c
62847bb
8552fcd
919898b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ | |
import com.microsoft.azure.storage.OperationContext; | ||
import com.microsoft.azure.storage.SendingRequestEvent; | ||
import com.microsoft.azure.storage.StorageEvent; | ||
import org.junit.Test; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.fs.FileStatus; | ||
|
@@ -41,7 +41,7 @@ | |
|
||
import static org.apache.hadoop.fs.azure.AzureNativeFileSystemStore.NO_ACCESS_TO_CONTAINER_MSG; | ||
import static org.apache.hadoop.test.LambdaTestUtils.intercept; | ||
import static org.junit.Assume.assumeNotNull; | ||
import static org.junit.jupiter.api.Assumptions.assumeTrue; | ||
|
||
/** | ||
* Error handling. | ||
|
@@ -76,7 +76,7 @@ public void testAccessUnauthorizedPublicContainer() throws Exception { | |
try { | ||
FileSystem.get(noAccessPath.toUri(), new Configuration()) | ||
.open(noAccessPath); | ||
assertTrue("Should've thrown.", false); | ||
assertTrue(false, "Should've thrown."); | ||
} catch (AzureException ex) { | ||
GenericTestUtils.assertExceptionContains( | ||
String.format(NO_ACCESS_TO_CONTAINER_MSG, account, container), ex); | ||
|
@@ -157,7 +157,7 @@ public void testTransientErrorOnDelete() throws Exception { | |
// Need to do this test against a live storage account | ||
AzureBlobStorageTestAccount testAccount = | ||
AzureBlobStorageTestAccount.create(); | ||
assumeNotNull(testAccount); | ||
assumeTrue(testAccount != null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: would it be better to define a accessible method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for your suggestions! I will try to improve this part of the code. |
||
try { | ||
NativeAzureFileSystem fs = testAccount.getFileSystem(); | ||
injectTransientError(fs, new ConnectionRecognizer() { | ||
|
@@ -200,7 +200,7 @@ public void testTransientErrorOnCommitBlockList() throws Exception { | |
// Need to do this test against a live storage account | ||
AzureBlobStorageTestAccount testAccount = | ||
AzureBlobStorageTestAccount.create(); | ||
assumeNotNull(testAccount); | ||
assumeTrue(testAccount != null); | ||
try { | ||
NativeAzureFileSystem fs = testAccount.getFileSystem(); | ||
injectTransientError(fs, new ConnectionRecognizer() { | ||
|
@@ -224,7 +224,7 @@ public void testTransientErrorOnRead() throws Exception { | |
// Need to do this test against a live storage account | ||
AzureBlobStorageTestAccount testAccount = | ||
AzureBlobStorageTestAccount.create(); | ||
assumeNotNull(testAccount); | ||
assumeTrue(testAccount != null); | ||
try { | ||
NativeAzureFileSystem fs = testAccount.getFileSystem(); | ||
Path testFile = new Path("/a/b"); | ||
|
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.
why is Junit 5 trying to ruin our lives. Everything worked.
setup should be caching that testinfo for the current suite, and all these helper methods just using that to derive values. we shouldn't be passing it down
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.
Thank you for raising this issue! In JUnit 5,
org.junit.rules.TestName
has been removed, and it is recommended to useTestInfo
to get the test method name. TestInfo can be used as a parameter, applied insetup
or test methods, but it cannot be declared as a class-level variable.Your suggestion made me think of a new solution: we can implement a method to retrieve the test method name and register it using the
@RegisterExtension
annotation. This method will retrieve the current test method name during the execution of@BeforeEach
.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.
@cnauroth @anujmodi2021 @steveloughran I have improved the code again. Could you please help review this PR?
Thank you very much!