From ab608457969a47d0d546275d413b1e6f09f8a271 Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Fri, 25 Apr 2025 11:05:15 +0800 Subject: [PATCH] HADOOP-19410. Upgrade JUnit from 4 to 5 in hadoop-client-integration-tests. --- .../hadoop-client-integration-tests/pom.xml | 20 +++++++++++++++++++ .../hadoop/example/ITUseHadoopCodecs.java | 10 +++++----- .../hadoop/example/ITUseMiniCluster.java | 15 +++++++------- 3 files changed, 33 insertions(+), 12 deletions(-) diff --git a/hadoop-client-modules/hadoop-client-integration-tests/pom.xml b/hadoop-client-modules/hadoop-client-integration-tests/pom.xml index f66b7e4b187f6..db4091a61f9c9 100644 --- a/hadoop-client-modules/hadoop-client-integration-tests/pom.xml +++ b/hadoop-client-modules/hadoop-client-integration-tests/pom.xml @@ -47,6 +47,26 @@ junit test + + org.junit.jupiter + junit-jupiter-api + test + + + org.junit.jupiter + junit-jupiter-engine + test + + + org.junit.jupiter + junit-jupiter-params + test + + + org.junit.platform + junit-platform-launcher + test + org.lz4 lz4-java diff --git a/hadoop-client-modules/hadoop-client-integration-tests/src/test/java/org/apache/hadoop/example/ITUseHadoopCodecs.java b/hadoop-client-modules/hadoop-client-integration-tests/src/test/java/org/apache/hadoop/example/ITUseHadoopCodecs.java index fd0effa143b95..cc1f133fed570 100644 --- a/hadoop-client-modules/hadoop-client-integration-tests/src/test/java/org/apache/hadoop/example/ITUseHadoopCodecs.java +++ b/hadoop-client-modules/hadoop-client-integration-tests/src/test/java/org/apache/hadoop/example/ITUseHadoopCodecs.java @@ -20,8 +20,8 @@ package org.apache.hadoop.example; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import java.io.*; import java.util.Arrays; @@ -37,7 +37,7 @@ import org.apache.hadoop.io.compress.CompressionOutputStream; import org.apache.hadoop.io.compress.zlib.ZlibFactory; import org.apache.hadoop.util.ReflectionUtils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -134,8 +134,8 @@ private void codecTest(Configuration conf, int seed, int count, String codecClas int expected; do { expected = originalIn.read(); - assertEquals("Inflated stream read by byte does not match", - expected, inflateFilter.read()); + assertEquals(expected, inflateFilter.read(), + "Inflated stream read by byte does not match"); } while (expected != -1); } diff --git a/hadoop-client-modules/hadoop-client-integration-tests/src/test/java/org/apache/hadoop/example/ITUseMiniCluster.java b/hadoop-client-modules/hadoop-client-integration-tests/src/test/java/org/apache/hadoop/example/ITUseMiniCluster.java index 2e304861babbd..7f0b150d73625 100644 --- a/hadoop-client-modules/hadoop-client-integration-tests/src/test/java/org/apache/hadoop/example/ITUseMiniCluster.java +++ b/hadoop-client-modules/hadoop-client-integration-tests/src/test/java/org/apache/hadoop/example/ITUseMiniCluster.java @@ -20,13 +20,14 @@ package org.apache.hadoop.example; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.IOException; import java.net.URISyntaxException; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -69,7 +70,7 @@ public class ITUseMiniCluster { + "fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident," + " sunt in culpa qui officia deserunt mollit anim id est laborum."; - @Before + @BeforeEach public void clusterUp() throws IOException { final Configuration conf = new HdfsConfiguration(); cluster = new MiniDFSCluster.Builder(conf) @@ -84,7 +85,7 @@ public void clusterUp() throws IOException { yarnCluster.start(); } - @After + @AfterEach public void clusterDown() { if (cluster != null) { cluster.close(); @@ -111,7 +112,7 @@ public void simpleReadAfterWrite(final FileSystem fs) throws IOException { } try (FSDataInputStream in = fs.open(path)) { final String result = in.readUTF(); - Assert.assertEquals("Didn't read back text we wrote.", TEXT, result); + assertEquals(TEXT, result, "Didn't read back text we wrote."); } }