Skip to content

Commit 809b1b5

Browse files
slfan1989cnauroth
andauthored
HADOOP-19427. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-compat-bench. (#7619)
* HADOOP-19427. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-compat-bench. Co-authored-by: Chris Nauroth <cnauroth@apache.org> Reviewed-by: Chris Nauroth <cnauroth@apache.org> Signed-off-by: Shilun Fan <slfan1989@apache.org>
1 parent 91923fb commit 809b1b5

File tree

5 files changed

+54
-28
lines changed

5 files changed

+54
-28
lines changed

hadoop-tools/hadoop-compat-bench/pom.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,31 @@
6969
<artifactId>mockito-inline</artifactId>
7070
<scope>test</scope>
7171
</dependency>
72+
<dependency>
73+
<groupId>org.junit.jupiter</groupId>
74+
<artifactId>junit-jupiter-api</artifactId>
75+
<scope>test</scope>
76+
</dependency>
77+
<dependency>
78+
<groupId>org.junit.jupiter</groupId>
79+
<artifactId>junit-jupiter-engine</artifactId>
80+
<scope>test</scope>
81+
</dependency>
82+
<dependency>
83+
<groupId>org.junit.jupiter</groupId>
84+
<artifactId>junit-jupiter-params</artifactId>
85+
<scope>test</scope>
86+
</dependency>
87+
<dependency>
88+
<groupId>org.junit.platform</groupId>
89+
<artifactId>junit-platform-launcher</artifactId>
90+
<scope>test</scope>
91+
</dependency>
92+
<dependency>
93+
<groupId>org.junit.vintage</groupId>
94+
<artifactId>junit-vintage-engine</artifactId>
95+
<scope>test</scope>
96+
</dependency>
7297
</dependencies>
7398

7499
<build>

hadoop-tools/hadoop-compat-bench/src/test/java/org/apache/hadoop/fs/compat/common/TestHdfsCompatDefaultSuites.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
*/
1818
package org.apache.hadoop.fs.compat.common;
1919

20+
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
2022
import org.apache.hadoop.fs.compat.HdfsCompatTool;
2123
import org.apache.hadoop.fs.compat.hdfs.HdfsCompatMiniCluster;
2224
import org.apache.hadoop.fs.compat.hdfs.HdfsCompatTestCommand;
2325
import org.apache.hadoop.conf.Configuration;
24-
import org.junit.Assert;
25-
import org.junit.Test;
26+
import org.junit.jupiter.api.Test;
2627

2728
public class TestHdfsCompatDefaultSuites {
2829
@Test
@@ -35,7 +36,7 @@ public void testSuiteAll() throws Exception {
3536
HdfsCompatCommand cmd = new HdfsCompatTestCommand(uri, "ALL", conf);
3637
cmd.initialize();
3738
HdfsCompatReport report = cmd.apply();
38-
Assert.assertEquals(0, report.getFailedCase().size());
39+
assertEquals(0, report.getFailedCase().size());
3940
new HdfsCompatTool(conf).printReport(report, System.out);
4041
} finally {
4142
cluster.shutdown();
@@ -52,7 +53,7 @@ public void testSuiteTpcds() throws Exception {
5253
HdfsCompatCommand cmd = new HdfsCompatTestCommand(uri, "TPCDS", conf);
5354
cmd.initialize();
5455
HdfsCompatReport report = cmd.apply();
55-
Assert.assertEquals(0, report.getFailedCase().size());
56+
assertEquals(0, report.getFailedCase().size());
5657
new HdfsCompatTool(conf).printReport(report, System.out);
5758
} finally {
5859
cluster.shutdown();

hadoop-tools/hadoop-compat-bench/src/test/java/org/apache/hadoop/fs/compat/common/TestHdfsCompatFsCommand.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
package org.apache.hadoop.fs.compat.common;
1919

20+
import static org.junit.jupiter.api.Assertions.assertEquals;
2021

2122
import org.apache.hadoop.fs.compat.HdfsCompatTool;
2223
import org.apache.hadoop.fs.compat.hdfs.HdfsCompatMiniCluster;
@@ -25,8 +26,7 @@
2526
import org.apache.hadoop.fs.compat.cases.HdfsCompatMkdirTestCases;
2627
import org.apache.hadoop.fs.FileSystem;
2728
import org.apache.hadoop.fs.Path;
28-
import org.junit.Assert;
29-
import org.junit.Test;
29+
import org.junit.jupiter.api.Test;
3030

3131
import java.io.IOException;
3232
import java.lang.reflect.Field;
@@ -47,8 +47,8 @@ public void testDfsCompatibility() throws Exception {
4747
HdfsCompatCommand cmd = new TestCommand(uri, suite, conf);
4848
cmd.initialize();
4949
HdfsCompatReport report = cmd.apply();
50-
Assert.assertEquals(7, report.getPassedCase().size());
51-
Assert.assertEquals(0, report.getFailedCase().size());
50+
assertEquals(7, report.getPassedCase().size());
51+
assertEquals(0, report.getFailedCase().size());
5252
show(conf, report);
5353
} finally {
5454
if (cluster != null) {
@@ -65,8 +65,8 @@ public void testLocalFsCompatibility() throws Exception {
6565
HdfsCompatCommand cmd = new TestCommand(uri, suite, conf);
6666
cmd.initialize();
6767
HdfsCompatReport report = cmd.apply();
68-
Assert.assertEquals(1, report.getPassedCase().size());
69-
Assert.assertEquals(6, report.getFailedCase().size());
68+
assertEquals(1, report.getPassedCase().size());
69+
assertEquals(6, report.getFailedCase().size());
7070
show(conf, report);
7171
cleanup(cmd, conf);
7272
}
@@ -79,8 +79,8 @@ public void testFsCompatibilityWithSuite() throws Exception {
7979
HdfsCompatCommand cmd = new TestCommand(uri, suite, conf);
8080
cmd.initialize();
8181
HdfsCompatReport report = cmd.apply();
82-
Assert.assertEquals(0, report.getPassedCase().size());
83-
Assert.assertEquals(6, report.getFailedCase().size());
82+
assertEquals(0, report.getPassedCase().size());
83+
assertEquals(6, report.getFailedCase().size());
8484
show(conf, report);
8585
cleanup(cmd, conf);
8686
}

hadoop-tools/hadoop-compat-bench/src/test/java/org/apache/hadoop/fs/compat/common/TestHdfsCompatInterfaceCoverage.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,26 @@
1717
*/
1818
package org.apache.hadoop.fs.compat.common;
1919

20+
import static org.junit.jupiter.api.Assertions.assertTrue;
2021

2122
import org.apache.hadoop.fs.compat.cases.HdfsCompatBasics;
2223
import org.apache.hadoop.fs.FileSystem;
23-
import org.junit.Assert;
24-
import org.junit.Ignore;
25-
import org.junit.Test;
24+
import org.junit.jupiter.api.Test;
25+
import org.junit.jupiter.api.Disabled;
2626

2727
import java.lang.reflect.Method;
2828
import java.util.HashSet;
2929
import java.util.Set;
3030

3131
public class TestHdfsCompatInterfaceCoverage {
3232
@Test
33-
@Ignore
33+
@Disabled
3434
public void testFsCompatibility() {
3535
Set<String> publicMethods = getPublicInterfaces(FileSystem.class);
3636
Set<String> targets = getTargets(HdfsCompatBasics.class);
3737
for (String publicMethod : publicMethods) {
38-
Assert.assertTrue("Method not tested: " + publicMethod,
39-
targets.contains(publicMethod));
38+
assertTrue(targets.contains(publicMethod),
39+
"Method not tested: " + publicMethod);
4040
}
4141
}
4242

hadoop-tools/hadoop-compat-bench/src/test/java/org/apache/hadoop/fs/compat/common/TestHdfsCompatShellCommand.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
*/
1818
package org.apache.hadoop.fs.compat.common;
1919

20+
import static org.junit.jupiter.api.Assertions.assertEquals;
2021

2122
import org.apache.commons.io.FileUtils;
2223
import org.apache.hadoop.fs.compat.HdfsCompatTool;
2324
import org.apache.hadoop.fs.compat.hdfs.HdfsCompatMiniCluster;
2425
import org.apache.hadoop.fs.compat.hdfs.HdfsCompatTestCommand;
2526
import org.apache.hadoop.fs.compat.hdfs.HdfsCompatTestShellScope;
2627
import org.apache.hadoop.conf.Configuration;
27-
import org.junit.After;
28-
import org.junit.Assert;
29-
import org.junit.Before;
30-
import org.junit.Test;
28+
import org.junit.jupiter.api.AfterEach;
29+
import org.junit.jupiter.api.BeforeEach;
30+
import org.junit.jupiter.api.Test;
3131

3232
import java.io.File;
3333
import java.io.IOException;
@@ -36,13 +36,13 @@
3636
public class TestHdfsCompatShellCommand {
3737
private HdfsCompatMiniCluster cluster;
3838

39-
@Before
39+
@BeforeEach
4040
public void runCluster() throws IOException {
4141
this.cluster = new HdfsCompatMiniCluster();
4242
this.cluster.start();
4343
}
4444

45-
@After
45+
@AfterEach
4646
public void shutdownCluster() {
4747
this.cluster.shutdown();
4848
this.cluster = null;
@@ -55,8 +55,8 @@ public void testDfsCompatibility() throws Exception {
5555
HdfsCompatCommand cmd = new TestCommand(uri, conf);
5656
cmd.initialize();
5757
HdfsCompatReport report = cmd.apply();
58-
Assert.assertEquals(3, report.getPassedCase().size());
59-
Assert.assertEquals(0, report.getFailedCase().size());
58+
assertEquals(3, report.getPassedCase().size());
59+
assertEquals(0, report.getFailedCase().size());
6060
show(conf, report);
6161
}
6262

@@ -67,8 +67,8 @@ public void testSkipCompatibility() throws Exception {
6767
HdfsCompatCommand cmd = new TestSkipCommand(uri, conf);
6868
cmd.initialize();
6969
HdfsCompatReport report = cmd.apply();
70-
Assert.assertEquals(2, report.getPassedCase().size());
71-
Assert.assertEquals(0, report.getFailedCase().size());
70+
assertEquals(2, report.getPassedCase().size());
71+
assertEquals(0, report.getFailedCase().size());
7272
show(conf, report);
7373
}
7474

0 commit comments

Comments
 (0)