Skip to content

Commit 6fdb4d9

Browse files
committed
HADOOP-19415. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-common Part8.
1 parent 26a0fda commit 6fdb4d9

File tree

42 files changed

+1455
-1238
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1455
-1238
lines changed

hadoop-cloud-storage-project/hadoop-huaweicloud/src/test/java/org/apache/hadoop/fs/obs/TestOBSFSMainOperations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void testRenameDirectoryToItself() {
7272

7373
@Override
7474
public void testGlobStatusThrowsExceptionForUnreadableDir() {
75-
Assume.assumeTrue("unspport.", false);
75+
assumeTrue(false, "unspport.");
7676
}
7777

7878
@Override

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FCStatisticsBaseTest.java

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.hadoop.fs;
2020

2121
import static org.apache.hadoop.fs.FileContextTestHelper.createFile;
22+
import static org.junit.jupiter.api.Assertions.assertEquals;
2223

2324
import java.io.IOException;
2425
import java.net.URI;
@@ -34,8 +35,8 @@
3435

3536
import org.apache.hadoop.fs.FileSystem.Statistics;
3637
import org.apache.hadoop.test.GenericTestUtils;
37-
import org.junit.Assert;
38-
import org.junit.Test;
38+
import org.junit.jupiter.api.Test;
39+
import org.junit.jupiter.api.Timeout;
3940

4041
import java.util.function.Supplier;
4142
import org.apache.hadoop.thirdparty.com.google.common.util.concurrent.Uninterruptibles;
@@ -59,17 +60,18 @@ public abstract class FCStatisticsBaseTest {
5960
//fc should be set appropriately by the deriving test.
6061
protected static FileContext fc = null;
6162

62-
@Test(timeout=60000)
63+
@Test
64+
@Timeout(value = 60)
6365
public void testStatisticsOperations() throws Exception {
6466
final Statistics stats = new Statistics("file");
65-
Assert.assertEquals(0L, stats.getBytesRead());
66-
Assert.assertEquals(0L, stats.getBytesWritten());
67-
Assert.assertEquals(0, stats.getWriteOps());
67+
assertEquals(0L, stats.getBytesRead());
68+
assertEquals(0L, stats.getBytesWritten());
69+
assertEquals(0, stats.getWriteOps());
6870
stats.incrementBytesWritten(1000);
69-
Assert.assertEquals(1000L, stats.getBytesWritten());
70-
Assert.assertEquals(0, stats.getWriteOps());
71+
assertEquals(1000L, stats.getBytesWritten());
72+
assertEquals(0, stats.getWriteOps());
7173
stats.incrementWriteOps(123);
72-
Assert.assertEquals(123, stats.getWriteOps());
74+
assertEquals(123, stats.getWriteOps());
7375

7476
Thread thread = new Thread() {
7577
@Override
@@ -79,33 +81,33 @@ public void run() {
7981
};
8082
thread.start();
8183
Uninterruptibles.joinUninterruptibly(thread);
82-
Assert.assertEquals(124, stats.getWriteOps());
84+
assertEquals(124, stats.getWriteOps());
8385
// Test copy constructor and reset function
8486
Statistics stats2 = new Statistics(stats);
8587
stats.reset();
86-
Assert.assertEquals(0, stats.getWriteOps());
87-
Assert.assertEquals(0L, stats.getBytesWritten());
88-
Assert.assertEquals(0L, stats.getBytesRead());
89-
Assert.assertEquals(124, stats2.getWriteOps());
90-
Assert.assertEquals(1000L, stats2.getBytesWritten());
91-
Assert.assertEquals(0L, stats2.getBytesRead());
88+
assertEquals(0, stats.getWriteOps());
89+
assertEquals(0L, stats.getBytesWritten());
90+
assertEquals(0L, stats.getBytesRead());
91+
assertEquals(124, stats2.getWriteOps());
92+
assertEquals(1000L, stats2.getBytesWritten());
93+
assertEquals(0L, stats2.getBytesRead());
9294
}
9395

9496
@Test
9597
public void testStatistics() throws IOException, URISyntaxException {
9698
URI fsUri = getFsUri();
9799
Statistics stats = FileContext.getStatistics(fsUri);
98-
Assert.assertEquals(0, stats.getBytesRead());
100+
assertEquals(0, stats.getBytesRead());
99101
Path filePath = fileContextTestHelper .getTestRootPath(fc, "file1");
100102
createFile(fc, filePath, numBlocks, blockSize);
101103

102-
Assert.assertEquals(0, stats.getBytesRead());
104+
assertEquals(0, stats.getBytesRead());
103105
verifyWrittenBytes(stats);
104106
FSDataInputStream fstr = fc.open(filePath);
105107
byte[] buf = new byte[blockSize];
106108
int bytesRead = fstr.read(buf, 0, blockSize);
107109
fstr.read(0, buf, 0, blockSize);
108-
Assert.assertEquals(blockSize, bytesRead);
110+
assertEquals(blockSize, bytesRead);
109111
verifyReadBytes(stats);
110112
verifyWrittenBytes(stats);
111113
verifyReadBytes(FileContext.getStatistics(getFsUri()));
@@ -115,7 +117,8 @@ public void testStatistics() throws IOException, URISyntaxException {
115117
fc.delete(filePath, true);
116118
}
117119

118-
@Test(timeout=70000)
120+
@Test
121+
@Timeout(value = 70)
119122
public void testStatisticsThreadLocalDataCleanUp() throws Exception {
120123
final Statistics stats = new Statistics("test");
121124
// create a small thread pool to test the statistics
@@ -136,8 +139,8 @@ public Boolean call() {
136139
// assert that the data size is exactly the number of threads
137140
final AtomicInteger allDataSize = new AtomicInteger(0);
138141
allDataSize.set(stats.getAllThreadLocalDataSize());
139-
Assert.assertEquals(size, allDataSize.get());
140-
Assert.assertEquals(size, stats.getReadOps());
142+
assertEquals(size, allDataSize.get());
143+
assertEquals(size, stats.getReadOps());
141144
// force the GC to collect the threads by shutting down the thread pool
142145
es.shutdownNow();
143146
es.awaitTermination(1, TimeUnit.MINUTES);
@@ -160,8 +163,8 @@ public Boolean get() {
160163
return false;
161164
}
162165
}, 500, 60*1000);
163-
Assert.assertEquals(0, allDataSize.get());
164-
Assert.assertEquals(size, stats.getReadOps());
166+
assertEquals(0, allDataSize.get());
167+
assertEquals(size, stats.getReadOps());
165168
}
166169

167170
/**

0 commit comments

Comments
 (0)