[
https://issues.apache.org/jira/browse/HADOOP-19425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17925212#comment-17925212
]
ASF GitHub Bot commented on HADOOP-19425:
-----------------------------------------
slfan1989 commented on PR #7369:
URL: https://github.com/apache/hadoop/pull/7369#issuecomment-2645006747
I am trying to modify the code of hadoop-azure, this is part 1. I am syncing
the improvements so that it can be better reviewed:
### 1. TestName
In JUnit 5, the `org.junit.rules.TestName` class no longer exists.
We need to use `org.junit.jupiter.api.TestInfo.getDisplayName()` as a
replacement and pass `TestInfo` in the parameters of `setUp`, `tearDown`, and
`tests`.
Here is an example:
> setUp
```
@BeforeEach
@Override
public void setUp(TestInfo testInfo) throws Exception {
super.setUp(testInfo);
Configuration conf = new Configuration();
conf.setInt(AzureNativeFileSystemStore.KEY_INPUT_STREAM_VERSION, 1);
}
```
> tearDown
```
@AfterEach
public void tearDown(TestInfo info) throws Exception {
describe(info,"closing test account and filesystem");
testAccount = cleanupTestAccount(testAccount);
IOUtils.closeStream(fs);
fs = null;
}
```
> Junit Test
```
@Test
public void testBlobMd5StoreOffByDefault(TestInfo testInfo) throws Exception
{
testAccount = AzureBlobStorageTestAccount.create();
testStoreBlobMd5(false, testInfo);
}
```
### 2. Timeout
In JUnit 5, `@Timeou`t can be set on the test method or class to specify a
timeout, with the unit in seconds.
Here is an example:
> method
```
@Test
@Timeout(1)
void shouldFailAfterOneSecond() throws InterruptedException {
Thread.sleep(10_000);
}
```
> class
```
@Timeout(5)
class TimeoutUnitTest {
@Test
void shouldFailAfterOneSecond() throws InterruptedException {
Thread.sleep(10_000);
}
}
```
> [ABFS] Upgrade JUnit from 4 to 5 in hadoop-azure.
> -------------------------------------------------
>
> Key: HADOOP-19425
> URL: https://issues.apache.org/jira/browse/HADOOP-19425
> Project: Hadoop Common
> Issue Type: Sub-task
> Components: build, fs/azure, test
> Affects Versions: 3.5.0
> Reporter: Shilun Fan
> Assignee: Shilun Fan
> Priority: Major
> Labels: pull-request-available
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]