Skip to content

Commit 872ebda

Browse files
slfan1989cnauroth
andauthored
MAPREDUCE-7415. [JDK17] Upgrade Junit 4 to 5 in hadoop-mapreduce-client-nativetask. (#7349)
Co-authored-by: Chris Nauroth <[email protected]> Reviewed-by: Chris Nauroth <[email protected]> Signed-off-by: Shilun Fan <[email protected]>
1 parent b5cbca3 commit 872ebda

File tree

20 files changed

+152
-143
lines changed

20 files changed

+152
-143
lines changed

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/TestTaskContext.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
import org.apache.hadoop.io.LongWritable;
2323
import org.apache.hadoop.io.Text;
2424

25-
import org.junit.Test;
26-
import org.junit.Assert;
25+
import org.junit.jupiter.api.Test;
26+
27+
import static org.junit.jupiter.api.Assertions.assertEquals;
2728

2829
public class TestTaskContext {
2930

@@ -33,19 +34,19 @@ public void testTaskContext() {
3334
null);
3435

3536
context.setInputKeyClass(IntWritable.class);
36-
Assert.assertEquals(IntWritable.class.getName(), context.getInputKeyClass
37+
assertEquals(IntWritable.class.getName(), context.getInputKeyClass
3738
().getName());
3839

3940
context.setInputValueClass(Text.class);
40-
Assert.assertEquals(Text.class.getName(), context.getInputValueClass()
41+
assertEquals(Text.class.getName(), context.getInputValueClass()
4142
.getName());
4243

4344
context.setOutputKeyClass(LongWritable.class);
44-
Assert.assertEquals(LongWritable.class.getName(), context
45+
assertEquals(LongWritable.class.getName(), context
4546
.getOutputKeyClass().getName());
4647

4748
context.setOutputValueClass(FloatWritable.class);
48-
Assert.assertEquals(FloatWritable.class.getName(), context
49+
assertEquals(FloatWritable.class.getName(), context
4950
.getOutputValueClass().getName());
5051
}
5152
}

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestBufferPushPull.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@
3939
import org.apache.hadoop.mapred.nativetask.testutil.TestInput.KV;
4040
import org.apache.hadoop.util.Progress;
4141

42-
import org.junit.Assert;
43-
import org.junit.Before;
44-
import org.junit.Test;
42+
import org.junit.jupiter.api.BeforeEach;
43+
import org.junit.jupiter.api.Test;
44+
45+
import static org.junit.jupiter.api.Assertions.assertEquals;
4546

4647
@SuppressWarnings({ "rawtypes", "unchecked"})
4748
public class TestBufferPushPull {
@@ -50,7 +51,7 @@ public class TestBufferPushPull {
5051
public static int INPUT_KV_COUNT = 1000;
5152
private KV<BytesWritable, BytesWritable>[] dataInput;
5253

53-
@Before
54+
@BeforeEach
5455
public void setUp() {
5556
this.dataInput = TestInput.getMapInputs(INPUT_KV_COUNT);
5657
}
@@ -70,8 +71,8 @@ public void testPush() throws Exception {
7071
@Override
7172
public void write(BytesWritable key, BytesWritable value) throws IOException {
7273
final KV expect = dataInput[count++];
73-
Assert.assertEquals(expect.key.toString(), key.toString());
74-
Assert.assertEquals(expect.value.toString(), value.toString());
74+
assertEquals(expect.key.toString(), key.toString());
75+
assertEquals(expect.value.toString(), value.toString());
7576
}
7677
};
7778

@@ -130,8 +131,8 @@ public void testPull() throws Exception {
130131
keyBytes.readFields(key);
131132
valueBytes.readFields(value);
132133

133-
Assert.assertEquals(dataInput[count].key.toString(), keyBytes.toString());
134-
Assert.assertEquals(dataInput[count].value.toString(), valueBytes.toString());
134+
assertEquals(dataInput[count].key.toString(), keyBytes.toString());
135+
assertEquals(dataInput[count].value.toString(), valueBytes.toString());
135136

136137
count++;
137138
}

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestByteBufferReadWrite.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
import org.apache.hadoop.mapred.nativetask.NativeDataTarget;
2525

26-
import org.junit.Test;
26+
import org.junit.jupiter.api.Test;
2727

2828
import org.mockito.Mockito;
2929

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestInputBuffer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package org.apache.hadoop.mapred.nativetask.buffer;
1919

2020
import java.io.IOException;
21-
import org.junit.Test;
21+
import org.junit.jupiter.api.Test;
2222

2323
import static org.assertj.core.api.Assertions.assertThat;
2424

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestOutputBuffer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818
package org.apache.hadoop.mapred.nativetask.buffer;
1919

20-
import org.junit.Test;
20+
import org.junit.jupiter.api.Test;
2121

2222
import static org.assertj.core.api.Assertions.assertThat;
2323

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/combinertest/CombinerTest.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@
3535
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
3636
import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat;
3737
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
38-
import org.junit.AfterClass;
38+
import org.junit.jupiter.api.AfterAll;
3939
import org.apache.hadoop.util.NativeCodeLoader;
40-
import org.junit.Assume;
41-
import org.junit.Before;
42-
import org.junit.Test;
40+
41+
import org.junit.jupiter.api.BeforeEach;
42+
import org.junit.jupiter.api.Test;
4343

4444
import java.io.IOException;
4545

46+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
47+
4648
public class CombinerTest {
4749
private FileSystem fs;
4850
private String inputpath;
@@ -66,10 +68,10 @@ public void testWordCountCombiner() throws Exception {
6668
ResultVerifier.verifyCounters(normaljob, nativejob, true);
6769
}
6870

69-
@Before
71+
@BeforeEach
7072
public void startUp() throws Exception {
71-
Assume.assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
72-
Assume.assumeTrue(NativeRuntime.isNativeLibraryLoaded());
73+
assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
74+
assumeTrue(NativeRuntime.isNativeLibraryLoaded());
7375
final ScenarioConfiguration conf = new ScenarioConfiguration();
7476
conf.addcombinerConf();
7577

@@ -90,7 +92,7 @@ public void startUp() throws Exception {
9092
"/normalwordcount";
9193
}
9294

93-
@AfterClass
95+
@AfterAll
9496
public static void cleanUp() throws IOException {
9597
final FileSystem fs = FileSystem.get(new ScenarioConfiguration());
9698
fs.delete(new Path(TestConstants.NATIVETASK_COMBINER_TEST_DIR), true);

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/combinertest/LargeKVCombinerTest.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,25 @@
3030
import org.apache.hadoop.mapred.nativetask.testutil.ScenarioConfiguration;
3131
import org.apache.hadoop.mapred.nativetask.testutil.TestConstants;
3232
import org.apache.hadoop.mapreduce.Job;
33-
import org.junit.AfterClass;
33+
import org.junit.jupiter.api.AfterAll;
3434
import org.apache.hadoop.util.NativeCodeLoader;
35-
import org.junit.Assume;
36-
import org.junit.Before;
37-
import org.junit.Test;
35+
import org.junit.jupiter.api.BeforeEach;
36+
import org.junit.jupiter.api.Test;
3837
import org.slf4j.Logger;
3938
import org.slf4j.LoggerFactory;
4039

4140
import java.io.IOException;
4241

42+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
43+
4344
public class LargeKVCombinerTest {
4445
private static final Logger LOG =
4546
LoggerFactory.getLogger(LargeKVCombinerTest.class);
4647

47-
@Before
48+
@BeforeEach
4849
public void startUp() throws Exception {
49-
Assume.assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
50-
Assume.assumeTrue(NativeRuntime.isNativeLibraryLoaded());
50+
assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
51+
assumeTrue(NativeRuntime.isNativeLibraryLoaded());
5152
}
5253

5354
@Test
@@ -102,7 +103,7 @@ public void testLargeValueCombiner() throws Exception {
102103
fs.close();
103104
}
104105

105-
@AfterClass
106+
@AfterAll
106107
public static void cleanUp() throws IOException {
107108
final FileSystem fs = FileSystem.get(new ScenarioConfiguration());
108109
fs.delete(new Path(TestConstants.NATIVETASK_COMBINER_TEST_DIR), true);

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/combinertest/OldAPICombinerTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.hadoop.mapred.nativetask.combinertest;
1919

2020
import static org.assertj.core.api.Assertions.assertThat;
21+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
2122

2223
import org.apache.hadoop.conf.Configuration;
2324
import org.apache.hadoop.fs.FileSystem;
@@ -38,11 +39,10 @@
3839
import org.apache.hadoop.mapred.nativetask.testutil.TestConstants;
3940
import org.apache.hadoop.mapreduce.Counter;
4041
import org.apache.hadoop.mapreduce.TaskCounter;
41-
import org.junit.AfterClass;
42+
import org.junit.jupiter.api.AfterAll;
4243
import org.apache.hadoop.util.NativeCodeLoader;
43-
import org.junit.Assume;
44-
import org.junit.Before;
45-
import org.junit.Test;
44+
import org.junit.jupiter.api.BeforeEach;
45+
import org.junit.jupiter.api.Test;
4646

4747
import java.io.IOException;
4848

@@ -83,10 +83,10 @@ public void testWordCountCombinerWithOldAPI() throws Exception {
8383
.isEqualTo(normalReduceGroups.getValue());
8484
}
8585

86-
@Before
86+
@BeforeEach
8787
public void startUp() throws Exception {
88-
Assume.assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
89-
Assume.assumeTrue(NativeRuntime.isNativeLibraryLoaded());
88+
assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
89+
assumeTrue(NativeRuntime.isNativeLibraryLoaded());
9090
final ScenarioConfiguration conf = new ScenarioConfiguration();
9191
conf.addcombinerConf();
9292
this.fs = FileSystem.get(conf);
@@ -99,7 +99,7 @@ public void startUp() throws Exception {
9999
}
100100
}
101101

102-
@AfterClass
102+
@AfterAll
103103
public static void cleanUp() throws IOException {
104104
final FileSystem fs = FileSystem.get(new ScenarioConfiguration());
105105
fs.delete(new Path(TestConstants.NATIVETASK_COMBINER_TEST_DIR), true);

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/compresstest/CompressTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.hadoop.mapred.nativetask.compresstest;
1919

2020
import static org.assertj.core.api.Assertions.assertThat;
21+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
2122

2223
import org.apache.hadoop.conf.Configuration;
2324
import org.apache.hadoop.fs.FileSystem;
@@ -30,11 +31,10 @@
3031
import org.apache.hadoop.mapred.nativetask.testutil.TestConstants;
3132
import org.apache.hadoop.mapreduce.Job;
3233
import org.apache.hadoop.mapreduce.MRJobConfig;
33-
import org.junit.AfterClass;
34+
import org.junit.jupiter.api.AfterAll;
3435
import org.apache.hadoop.util.NativeCodeLoader;
35-
import org.junit.Assume;
36-
import org.junit.Before;
37-
import org.junit.Test;
36+
import org.junit.jupiter.api.BeforeEach;
37+
import org.junit.jupiter.api.Test;
3838

3939
import java.io.IOException;
4040

@@ -125,10 +125,10 @@ public void testLz4Compress() throws Exception {
125125
ResultVerifier.verifyCounters(hadoopJob, nativeJob);
126126
}
127127

128-
@Before
128+
@BeforeEach
129129
public void startUp() throws Exception {
130-
Assume.assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
131-
Assume.assumeTrue(NativeRuntime.isNativeLibraryLoaded());
130+
assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
131+
assumeTrue(NativeRuntime.isNativeLibraryLoaded());
132132
final ScenarioConfiguration conf = new ScenarioConfiguration();
133133
final FileSystem fs = FileSystem.get(conf);
134134
final Path path = new Path(TestConstants.NATIVETASK_COMPRESS_TEST_INPUTDIR);
@@ -142,7 +142,7 @@ public void startUp() throws Exception {
142142
fs.close();
143143
}
144144

145-
@AfterClass
145+
@AfterAll
146146
public static void cleanUp() throws IOException {
147147
final FileSystem fs = FileSystem.get(new ScenarioConfiguration());
148148
fs.delete(new Path(TestConstants.NATIVETASK_COMPRESS_TEST_DIR), true);

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/handlers/TestCombineHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import org.apache.hadoop.mapred.nativetask.INativeHandler;
2525
import org.apache.hadoop.mapred.nativetask.buffer.BufferType;
2626
import org.apache.hadoop.mapred.nativetask.buffer.InputBuffer;
27-
import org.junit.Before;
28-
import org.junit.Test;
27+
import org.junit.jupiter.api.BeforeEach;
28+
import org.junit.jupiter.api.Test;
2929
import org.mockito.Mockito;
3030

3131
import static org.assertj.core.api.Assertions.assertThat;
@@ -40,7 +40,7 @@ public class TestCombineHandler {
4040
private BufferPuller puller;
4141
private CombinerRunner combinerRunner;
4242

43-
@Before
43+
@BeforeEach
4444
public void setUp() throws IOException {
4545
this.nativeHandler = Mockito.mock(INativeHandler.class);
4646
this.pusher = Mockito.mock(BufferPusher.class);

0 commit comments

Comments
 (0)