You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by sl...@apache.org on 2025/04/23 11:17:13 UTC
(hadoop) branch trunk updated: HADOOP-19411. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-cos. (#7640)
This is an automated email from the ASF dual-hosted git repository.
slfan1989 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new 1293a0ec28c HADOOP-19411. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-cos. (#7640)
1293a0ec28c is described below
commit 1293a0ec28c2a37d897b5d8547656dc5045f5902
Author: slfan1989 <55...@users.noreply.github.com>
AuthorDate: Wed Apr 23 19:17:04 2025 +0800
HADOOP-19411. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-cos. (#7640)
* HADOOP-19411. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-cos.
Co-authored-by: He Xiaoqiao <he...@apache.org>
Reviewed-by: He Xiaoqiao <he...@apache.org>
Signed-off-by: Shilun Fan <sl...@apache.org>
---
.../apache/hadoop/fs/cosn/TestCosCredentials.java | 8 ++---
.../apache/hadoop/fs/cosn/TestCosNInputStream.java | 36 ++++++++++++----------
.../hadoop/fs/cosn/TestCosNOutputStream.java | 17 +++++-----
3 files changed, 31 insertions(+), 30 deletions(-)
diff --git a/hadoop-cloud-storage-project/hadoop-cos/src/test/java/org/apache/hadoop/fs/cosn/TestCosCredentials.java b/hadoop-cloud-storage-project/hadoop-cos/src/test/java/org/apache/hadoop/fs/cosn/TestCosCredentials.java
index 8b74f3639dd..6dfd32b2d3e 100644
--- a/hadoop-cloud-storage-project/hadoop-cos/src/test/java/org/apache/hadoop/fs/cosn/TestCosCredentials.java
+++ b/hadoop-cloud-storage-project/hadoop-cos/src/test/java/org/apache/hadoop/fs/cosn/TestCosCredentials.java
@@ -20,7 +20,7 @@
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.auth.COSCredentialsProvider;
import org.apache.hadoop.conf.Configuration;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -28,8 +28,8 @@
import java.net.URI;
import java.net.URISyntaxException;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
public class TestCosCredentials {
private static final Logger LOG =
@@ -76,7 +76,7 @@ private void validateCredentials(URI uri, Configuration configuration)
COSCredentialsProvider credentialsProvider =
CosNUtils.createCosCredentialsProviderSet(uri, configuration);
COSCredentials cosCredentials = credentialsProvider.getCredentials();
- assertNotNull("The cos credentials obtained is null.", cosCredentials);
+ assertNotNull(cosCredentials, "The cos credentials obtained is null.");
if (configuration.get(
CosNConfigKeys.COSN_CREDENTIALS_PROVIDER).compareToIgnoreCase(
"org.apache.hadoop.fs.cosn.EnvironmentVariableCredentialsProvider")
diff --git a/hadoop-cloud-storage-project/hadoop-cos/src/test/java/org/apache/hadoop/fs/cosn/TestCosNInputStream.java b/hadoop-cloud-storage-project/hadoop-cos/src/test/java/org/apache/hadoop/fs/cosn/TestCosNInputStream.java
index 79884bad070..e5d05b120d5 100644
--- a/hadoop-cloud-storage-project/hadoop-cos/src/test/java/org/apache/hadoop/fs/cosn/TestCosNInputStream.java
+++ b/hadoop-cloud-storage-project/hadoop-cos/src/test/java/org/apache/hadoop/fs/cosn/TestCosNInputStream.java
@@ -23,11 +23,14 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.contract.ContractTestUtils;
import org.apache.hadoop.io.IOUtils;
-import org.junit.*;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.util.Random;
@@ -43,7 +46,7 @@ public class TestCosNInputStream {
private Path testRootDir;
- @Before
+ @BeforeEach
public void setUp() throws IOException {
Configuration configuration = new Configuration();
this.fs = CosNTestUtils.createTestFileSystem(configuration);
@@ -51,7 +54,7 @@ public void setUp() throws IOException {
LOG.info("test root dir: " + this.testRootDir);
}
- @After
+ @AfterEach
public void tearDown() throws IOException {
if (null != this.fs) {
this.fs.delete(this.testRootDir, true);
@@ -76,9 +79,9 @@ public void testSeek() throws Exception {
for (int i = 0; i != seekTimes; i++) {
long pos = fileSize / (seekTimes - i) - 1;
inputStream.seek(pos);
- assertTrue("expected position at: " +
- pos + ", but got: " + inputStream.getPos(),
- inputStream.getPos() == pos);
+ assertTrue(inputStream.getPos() == pos,
+ "expected position at: " +
+ pos + ", but got: " + inputStream.getPos());
LOG.info("completed seeking at pos: " + inputStream.getPos());
}
LOG.info("begin to random position seeking test...");
@@ -87,9 +90,9 @@ public void testSeek() throws Exception {
long pos = Math.abs(random.nextLong()) % fileSize;
LOG.info("seeking for pos: " + pos);
inputStream.seek(pos);
- assertTrue("expected position at: " +
- pos + ", but got: " + inputStream.getPos(),
- inputStream.getPos() == pos);
+ assertTrue(inputStream.getPos() == pos,
+ "expected position at: " +
+ pos + ", but got: " + inputStream.getPos());
LOG.info("completed seeking at pos: " + inputStream.getPos());
}
}
@@ -110,16 +113,16 @@ public void testGetPos() throws Exception {
Random random = new Random();
long pos = Math.abs(random.nextLong()) % fileSize;
inputStream.seek(pos);
- assertTrue("expected position at: " +
- pos + ", but got: " + inputStream.getPos(),
- inputStream.getPos() == pos);
+ assertTrue(inputStream.getPos() == pos,
+ "expected position at: " +
+ pos + ", but got: " + inputStream.getPos());
LOG.info("completed get pos tests.");
}
/**
* Method: seekToNewSource(long targetPos).
*/
- @Ignore("Not ready yet")
+ @Disabled("Not ready yet")
public void testSeekToNewSource() throws Exception {
LOG.info("Currently it is not supported to " +
"seek the offset in a new source.");
@@ -154,8 +157,9 @@ public void testRead() throws Exception {
if (bytesRead % (1 * Unit.MB) == 0) {
int available = inputStream.available();
- assertTrue("expected remaining: " + (fileSize - bytesRead) +
- " but got: " + available, (fileSize - bytesRead) == available);
+ assertTrue((fileSize - bytesRead) == available,
+ "expected remaining: " + (fileSize - bytesRead) +
+ " but got: " + available);
LOG.info("Bytes read: " +
Math.round((double) bytesRead / Unit.MB) + "MB");
}
diff --git a/hadoop-cloud-storage-project/hadoop-cos/src/test/java/org/apache/hadoop/fs/cosn/TestCosNOutputStream.java b/hadoop-cloud-storage-project/hadoop-cos/src/test/java/org/apache/hadoop/fs/cosn/TestCosNOutputStream.java
index 7fd88976d62..d71408aab37 100644
--- a/hadoop-cloud-storage-project/hadoop-cos/src/test/java/org/apache/hadoop/fs/cosn/TestCosNOutputStream.java
+++ b/hadoop-cloud-storage-project/hadoop-cos/src/test/java/org/apache/hadoop/fs/cosn/TestCosNOutputStream.java
@@ -21,11 +21,10 @@
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.contract.ContractTestUtils;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.Before;
-import org.junit.After;
-import org.junit.rules.Timeout;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
import java.io.IOException;
@@ -34,14 +33,12 @@
* <p>
* If the test.fs.cosn.name property is not set, all test case will fail.
*/
+@Timeout(3600)
public class TestCosNOutputStream {
private FileSystem fs;
private Path testRootDir;
- @Rule
- public Timeout timeout = new Timeout(3600 * 1000);
-
- @Before
+ @BeforeEach
public void setUp() throws Exception {
Configuration configuration = new Configuration();
configuration.setInt(
@@ -53,7 +50,7 @@ public void setUp() throws Exception {
this.testRootDir = new Path("/test");
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org