From 872ebda81d4a5c6013ea8114f1759b12be0537f1 Mon Sep 17 00:00:00 2001 From: slfan1989 <55643692+slfan1989@users.noreply.github.com> Date: Thu, 6 Feb 2025 05:10:57 +0800 Subject: [PATCH] MAPREDUCE-7415. [JDK17] Upgrade Junit 4 to 5 in hadoop-mapreduce-client-nativetask. (#7349) Co-authored-by: Chris Nauroth Reviewed-by: Chris Nauroth Signed-off-by: Shilun Fan --- .../mapred/nativetask/TestTaskContext.java | 13 ++++--- .../nativetask/buffer/TestBufferPushPull.java | 17 +++++---- .../buffer/TestByteBufferReadWrite.java | 2 +- .../nativetask/buffer/TestInputBuffer.java | 2 +- .../nativetask/buffer/TestOutputBuffer.java | 2 +- .../nativetask/combinertest/CombinerTest.java | 18 +++++---- .../combinertest/LargeKVCombinerTest.java | 17 +++++---- .../combinertest/OldAPICombinerTest.java | 16 ++++---- .../nativetask/compresstest/CompressTest.java | 16 ++++---- .../handlers/TestCombineHandler.java | 6 +-- .../TestNativeCollectorOnlyHandler.java | 23 +++++------ .../mapred/nativetask/kvtest/KVTest.java | 38 +++++++++---------- .../mapred/nativetask/kvtest/LargeKVTest.java | 25 ++++++------ .../nativetask/nonsorttest/NonSortTest.java | 16 ++++---- .../nativetask/serde/TestKVSerializer.java | 23 +++++------ .../serde/TestNativeSerialization.java | 12 +++--- .../nativetask/testutil/ResultVerifier.java | 20 +++++----- .../nativetask/utils/TestBytesUtil.java | 17 +++++---- .../nativetask/utils/TestReadWriteBuffer.java | 2 +- .../nativetask/utils/TestSizedWritable.java | 10 +++-- 20 files changed, 152 insertions(+), 143 deletions(-) diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/TestTaskContext.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/TestTaskContext.java index 471c68f01699b..8ba3a60267f26 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/TestTaskContext.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/TestTaskContext.java @@ -22,8 +22,9 @@ import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; -import org.junit.Test; -import org.junit.Assert; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; public class TestTaskContext { @@ -33,19 +34,19 @@ public void testTaskContext() { null); context.setInputKeyClass(IntWritable.class); - Assert.assertEquals(IntWritable.class.getName(), context.getInputKeyClass + assertEquals(IntWritable.class.getName(), context.getInputKeyClass ().getName()); context.setInputValueClass(Text.class); - Assert.assertEquals(Text.class.getName(), context.getInputValueClass() + assertEquals(Text.class.getName(), context.getInputValueClass() .getName()); context.setOutputKeyClass(LongWritable.class); - Assert.assertEquals(LongWritable.class.getName(), context + assertEquals(LongWritable.class.getName(), context .getOutputKeyClass().getName()); context.setOutputValueClass(FloatWritable.class); - Assert.assertEquals(FloatWritable.class.getName(), context + assertEquals(FloatWritable.class.getName(), context .getOutputValueClass().getName()); } } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestBufferPushPull.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestBufferPushPull.java index 1c77aa850fa6c..24543fee86b69 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestBufferPushPull.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestBufferPushPull.java @@ -39,9 +39,10 @@ import org.apache.hadoop.mapred.nativetask.testutil.TestInput.KV; import org.apache.hadoop.util.Progress; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; @SuppressWarnings({ "rawtypes", "unchecked"}) public class TestBufferPushPull { @@ -50,7 +51,7 @@ public class TestBufferPushPull { public static int INPUT_KV_COUNT = 1000; private KV[] dataInput; - @Before + @BeforeEach public void setUp() { this.dataInput = TestInput.getMapInputs(INPUT_KV_COUNT); } @@ -70,8 +71,8 @@ public void testPush() throws Exception { @Override public void write(BytesWritable key, BytesWritable value) throws IOException { final KV expect = dataInput[count++]; - Assert.assertEquals(expect.key.toString(), key.toString()); - Assert.assertEquals(expect.value.toString(), value.toString()); + assertEquals(expect.key.toString(), key.toString()); + assertEquals(expect.value.toString(), value.toString()); } }; @@ -130,8 +131,8 @@ public void testPull() throws Exception { keyBytes.readFields(key); valueBytes.readFields(value); - Assert.assertEquals(dataInput[count].key.toString(), keyBytes.toString()); - Assert.assertEquals(dataInput[count].value.toString(), valueBytes.toString()); + assertEquals(dataInput[count].key.toString(), keyBytes.toString()); + assertEquals(dataInput[count].value.toString(), valueBytes.toString()); count++; } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestByteBufferReadWrite.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestByteBufferReadWrite.java index 8dfa5322e84e6..262b7d97681ee 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestByteBufferReadWrite.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestByteBufferReadWrite.java @@ -23,7 +23,7 @@ import org.apache.hadoop.mapred.nativetask.NativeDataTarget; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestInputBuffer.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestInputBuffer.java index 27fcec1b6f0a6..53ed140f7efd7 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestInputBuffer.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestInputBuffer.java @@ -18,7 +18,7 @@ package org.apache.hadoop.mapred.nativetask.buffer; import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestOutputBuffer.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestOutputBuffer.java index eb303ed58946f..336e7eb896773 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestOutputBuffer.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/buffer/TestOutputBuffer.java @@ -17,7 +17,7 @@ */ package org.apache.hadoop.mapred.nativetask.buffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/combinertest/CombinerTest.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/combinertest/CombinerTest.java index 94249e2a37e98..fbbadf9aab353 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/combinertest/CombinerTest.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/combinertest/CombinerTest.java @@ -35,14 +35,16 @@ import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; import org.apache.hadoop.util.NativeCodeLoader; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + public class CombinerTest { private FileSystem fs; private String inputpath; @@ -66,10 +68,10 @@ public void testWordCountCombiner() throws Exception { ResultVerifier.verifyCounters(normaljob, nativejob, true); } - @Before + @BeforeEach public void startUp() throws Exception { - Assume.assumeTrue(NativeCodeLoader.isNativeCodeLoaded()); - Assume.assumeTrue(NativeRuntime.isNativeLibraryLoaded()); + assumeTrue(NativeCodeLoader.isNativeCodeLoaded()); + assumeTrue(NativeRuntime.isNativeLibraryLoaded()); final ScenarioConfiguration conf = new ScenarioConfiguration(); conf.addcombinerConf(); @@ -90,7 +92,7 @@ public void startUp() throws Exception { "/normalwordcount"; } - @AfterClass + @AfterAll public static void cleanUp() throws IOException { final FileSystem fs = FileSystem.get(new ScenarioConfiguration()); fs.delete(new Path(TestConstants.NATIVETASK_COMBINER_TEST_DIR), true); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/combinertest/LargeKVCombinerTest.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/combinertest/LargeKVCombinerTest.java index 0595f3ea72567..b4a169fb31455 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/combinertest/LargeKVCombinerTest.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/combinertest/LargeKVCombinerTest.java @@ -30,24 +30,25 @@ import org.apache.hadoop.mapred.nativetask.testutil.ScenarioConfiguration; import org.apache.hadoop.mapred.nativetask.testutil.TestConstants; import org.apache.hadoop.mapreduce.Job; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; import org.apache.hadoop.util.NativeCodeLoader; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + public class LargeKVCombinerTest { private static final Logger LOG = LoggerFactory.getLogger(LargeKVCombinerTest.class); - @Before + @BeforeEach public void startUp() throws Exception { - Assume.assumeTrue(NativeCodeLoader.isNativeCodeLoaded()); - Assume.assumeTrue(NativeRuntime.isNativeLibraryLoaded()); + assumeTrue(NativeCodeLoader.isNativeCodeLoaded()); + assumeTrue(NativeRuntime.isNativeLibraryLoaded()); } @Test @@ -102,7 +103,7 @@ public void testLargeValueCombiner() throws Exception { fs.close(); } - @AfterClass + @AfterAll public static void cleanUp() throws IOException { final FileSystem fs = FileSystem.get(new ScenarioConfiguration()); fs.delete(new Path(TestConstants.NATIVETASK_COMBINER_TEST_DIR), true); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/combinertest/OldAPICombinerTest.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/combinertest/OldAPICombinerTest.java index 23bf0a40b320c..dee9f63982ecf 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/combinertest/OldAPICombinerTest.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/combinertest/OldAPICombinerTest.java @@ -18,6 +18,7 @@ package org.apache.hadoop.mapred.nativetask.combinertest; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; @@ -38,11 +39,10 @@ import org.apache.hadoop.mapred.nativetask.testutil.TestConstants; import org.apache.hadoop.mapreduce.Counter; import org.apache.hadoop.mapreduce.TaskCounter; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; import org.apache.hadoop.util.NativeCodeLoader; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; @@ -83,10 +83,10 @@ public void testWordCountCombinerWithOldAPI() throws Exception { .isEqualTo(normalReduceGroups.getValue()); } - @Before + @BeforeEach public void startUp() throws Exception { - Assume.assumeTrue(NativeCodeLoader.isNativeCodeLoaded()); - Assume.assumeTrue(NativeRuntime.isNativeLibraryLoaded()); + assumeTrue(NativeCodeLoader.isNativeCodeLoaded()); + assumeTrue(NativeRuntime.isNativeLibraryLoaded()); final ScenarioConfiguration conf = new ScenarioConfiguration(); conf.addcombinerConf(); this.fs = FileSystem.get(conf); @@ -99,7 +99,7 @@ public void startUp() throws Exception { } } - @AfterClass + @AfterAll public static void cleanUp() throws IOException { final FileSystem fs = FileSystem.get(new ScenarioConfiguration()); fs.delete(new Path(TestConstants.NATIVETASK_COMBINER_TEST_DIR), true); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/compresstest/CompressTest.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/compresstest/CompressTest.java index 0e91161051f5f..35c2222ca0940 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/compresstest/CompressTest.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/compresstest/CompressTest.java @@ -18,6 +18,7 @@ package org.apache.hadoop.mapred.nativetask.compresstest; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; @@ -30,11 +31,10 @@ import org.apache.hadoop.mapred.nativetask.testutil.TestConstants; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.MRJobConfig; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; import org.apache.hadoop.util.NativeCodeLoader; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.io.IOException; @@ -125,10 +125,10 @@ public void testLz4Compress() throws Exception { ResultVerifier.verifyCounters(hadoopJob, nativeJob); } - @Before + @BeforeEach public void startUp() throws Exception { - Assume.assumeTrue(NativeCodeLoader.isNativeCodeLoaded()); - Assume.assumeTrue(NativeRuntime.isNativeLibraryLoaded()); + assumeTrue(NativeCodeLoader.isNativeCodeLoaded()); + assumeTrue(NativeRuntime.isNativeLibraryLoaded()); final ScenarioConfiguration conf = new ScenarioConfiguration(); final FileSystem fs = FileSystem.get(conf); final Path path = new Path(TestConstants.NATIVETASK_COMPRESS_TEST_INPUTDIR); @@ -142,7 +142,7 @@ public void startUp() throws Exception { fs.close(); } - @AfterClass + @AfterAll public static void cleanUp() throws IOException { final FileSystem fs = FileSystem.get(new ScenarioConfiguration()); fs.delete(new Path(TestConstants.NATIVETASK_COMPRESS_TEST_DIR), true); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/handlers/TestCombineHandler.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/handlers/TestCombineHandler.java index a601e5bce3b53..76e5b0df78fc2 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/handlers/TestCombineHandler.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/handlers/TestCombineHandler.java @@ -24,8 +24,8 @@ import org.apache.hadoop.mapred.nativetask.INativeHandler; import org.apache.hadoop.mapred.nativetask.buffer.BufferType; import org.apache.hadoop.mapred.nativetask.buffer.InputBuffer; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mockito; import static org.assertj.core.api.Assertions.assertThat; @@ -40,7 +40,7 @@ public class TestCombineHandler { private BufferPuller puller; private CombinerRunner combinerRunner; - @Before + @BeforeEach public void setUp() throws IOException { this.nativeHandler = Mockito.mock(INativeHandler.class); this.pusher = Mockito.mock(BufferPusher.class); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/handlers/TestNativeCollectorOnlyHandler.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/handlers/TestNativeCollectorOnlyHandler.java index e66984b9b2173..c59c18ef6e110 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/handlers/TestNativeCollectorOnlyHandler.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/handlers/TestNativeCollectorOnlyHandler.java @@ -35,12 +35,13 @@ import org.apache.hadoop.mapred.nativetask.util.OutputUtil; import org.apache.hadoop.mapred.nativetask.util.ReadWriteBuffer; import org.apache.hadoop.util.StringUtils; -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.mockito.Mockito; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; @@ -54,7 +55,7 @@ public class TestNativeCollectorOnlyHandler { private TaskContext taskContext; private static final String LOCAL_DIR = TestConstants.NATIVETASK_TEST_DIR + "/local"; - @Before + @BeforeEach public void setUp() throws IOException { this.nativeHandler = Mockito.mock(INativeHandler.class); this.pusher = Mockito.mock(BufferPusher.class); @@ -74,7 +75,7 @@ public void setUp() throws IOException { new InputBuffer(BufferType.HEAP_BUFFER, 100)); } - @After + @AfterEach public void tearDown() throws IOException { FileSystem.getLocal(new Configuration()).delete(new Path(LOCAL_DIR)); } @@ -100,7 +101,7 @@ public void testGetCombiner() throws IOException { Mockito.when(combiner.getId()).thenReturn(100L); final ReadWriteBuffer result = handler.onCall( NativeCollectorOnlyHandler.GET_COMBINE_HANDLER, null); - Assert.assertEquals(100L, result.readLong()); + assertEquals(100L, result.readLong()); } @Test @@ -112,7 +113,7 @@ public void testOnCall() throws IOException { } catch(final IOException e) { thrown = true; } - Assert.assertTrue("exception thrown", thrown); + assertTrue(thrown, "exception thrown"); final String expectedOutputPath = StringUtils.join(File.separator, new String[] {LOCAL_DIR, "output", "file.out"}); @@ -123,14 +124,14 @@ public void testOnCall() throws IOException { final String outputPath = handler.onCall( NativeCollectorOnlyHandler.GET_OUTPUT_PATH, null).readString(); - Assert.assertEquals(expectedOutputPath, outputPath); + assertEquals(expectedOutputPath, outputPath); final String outputIndexPath = handler.onCall( NativeCollectorOnlyHandler.GET_OUTPUT_INDEX_PATH, null).readString(); - Assert.assertEquals(expectedOutputIndexPath, outputIndexPath); + assertEquals(expectedOutputIndexPath, outputIndexPath); final String spillPath = handler.onCall( NativeCollectorOnlyHandler.GET_SPILL_PATH, null).readString(); - Assert.assertEquals(expectedSpillPath, spillPath); + assertEquals(expectedSpillPath, spillPath); } } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/kvtest/KVTest.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/kvtest/KVTest.java index 0771c669148ee..a92562ab48894 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/kvtest/KVTest.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/kvtest/KVTest.java @@ -18,6 +18,7 @@ package org.apache.hadoop.mapred.nativetask.kvtest; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.io.IOException; import java.util.List; @@ -31,20 +32,16 @@ import org.apache.hadoop.mapred.nativetask.testutil.ScenarioConfiguration; import org.apache.hadoop.mapred.nativetask.testutil.TestConstants; import org.apache.hadoop.util.Lists; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; import org.apache.hadoop.util.NativeCodeLoader; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.hadoop.thirdparty.com.google.common.base.Splitter; -@RunWith(Parameterized.class) public class KVTest { private static final Logger LOG = LoggerFactory.getLogger(KVTest.class); @@ -73,7 +70,6 @@ private static List> parseClassNames(String spec) { /** * Parameterize the test with the specified key and value types. */ - @Parameters(name = "key:{0}\nvalue:{1}") public static Iterable[]> data() throws Exception { // Parse the config. final String valueClassesStr = nativekvtestconf @@ -98,22 +94,24 @@ public static Iterable[]> data() throws Exception { return pairs; } - private final Class keyclass; - private final Class valueclass; + private Class keyclass; + private Class valueclass; - public KVTest(Class keyclass, Class valueclass) { - this.keyclass = keyclass; - this.valueclass = valueclass; + public void initKVTest(Class paramKeyclass, Class paramValueclass) { + this.keyclass = paramKeyclass; + this.valueclass = paramValueclass; } - @Before + @BeforeEach public void startUp() throws Exception { - Assume.assumeTrue(NativeCodeLoader.isNativeCodeLoaded()); - Assume.assumeTrue(NativeRuntime.isNativeLibraryLoaded()); + assumeTrue(NativeCodeLoader.isNativeCodeLoaded()); + assumeTrue(NativeRuntime.isNativeLibraryLoaded()); } - @Test - public void testKVCompability() throws Exception { + @MethodSource("data") + @ParameterizedTest(name = "key:{0}\nvalue:{1}") + public void testKVCompatibility(Class pkeyclass, Class pValueclass) throws Exception { + initKVTest(pkeyclass, pValueclass); final FileSystem fs = FileSystem.get(nativekvtestconf); final String jobName = "Test:" + keyclass.getSimpleName() + "--" + valueclass.getSimpleName(); @@ -148,7 +146,7 @@ public void testKVCompability() throws Exception { fs.close(); } - @AfterClass + @AfterAll public static void cleanUp() throws IOException { final FileSystem fs = FileSystem.get(new ScenarioConfiguration()); fs.delete(new Path(TestConstants.NATIVETASK_KVTEST_DIR), true); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/kvtest/LargeKVTest.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/kvtest/LargeKVTest.java index 4a7b96377d037..b3f01356a430b 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/kvtest/LargeKVTest.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/kvtest/LargeKVTest.java @@ -17,8 +17,8 @@ */ package org.apache.hadoop.mapred.nativetask.kvtest; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; @@ -31,21 +31,20 @@ import org.apache.hadoop.mapred.nativetask.testutil.ResultVerifier; import org.apache.hadoop.mapred.nativetask.testutil.ScenarioConfiguration; import org.apache.hadoop.mapred.nativetask.testutil.TestConstants; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; import org.apache.hadoop.util.NativeCodeLoader; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class LargeKVTest { private static final Logger LOG = LoggerFactory.getLogger(LargeKVTest.class); - @Before + @BeforeEach public void startUp() throws Exception { - Assume.assumeTrue(NativeCodeLoader.isNativeCodeLoaded()); - Assume.assumeTrue(NativeRuntime.isNativeLibraryLoaded()); + assumeTrue(NativeCodeLoader.isNativeCodeLoaded()); + assumeTrue(NativeRuntime.isNativeLibraryLoaded()); } private static Configuration nativeConf = ScenarioConfiguration.getNativeConfiguration(); @@ -67,7 +66,7 @@ public void testValueSize() throws Exception { runKVSizeTests(IntWritable.class, Text.class); } - @AfterClass + @AfterAll public static void cleanUp() throws IOException { final FileSystem fs = FileSystem.get(new ScenarioConfiguration()); fs.delete(new Path(TestConstants.NATIVETASK_KVTEST_DIR), true); @@ -106,7 +105,7 @@ public void runKVSizeTests(Class keyClass, Class valueClass) throws Except final KVJob nativeJob = new KVJob("Test Large Value Size:" + String.valueOf(i), nativeConf, keyClass, valueClass, inputPath, nativeOutputPath); - assertTrue("job should complete successfully", nativeJob.runJob()); + assertTrue(nativeJob.runJob(), "job should complete successfully"); final String normalOutputPath = TestConstants.NATIVETASK_KVTEST_NORMAL_OUTPUTDIR + "/LargeKV/" + keyClass.getName() + "/" + valueClass.getName(); @@ -114,7 +113,7 @@ public void runKVSizeTests(Class keyClass, Class valueClass) throws Except fs.delete(new Path(normalOutputPath), true); final KVJob normalJob = new KVJob("Test Large Key Size:" + String.valueOf(i), normalConf, keyClass, valueClass, inputPath, normalOutputPath); - assertTrue("job should complete successfully", normalJob.runJob()); + assertTrue(normalJob.runJob(), "job should complete successfully"); final boolean compareRet = ResultVerifier.verify(normalOutputPath, nativeOutputPath); @@ -123,7 +122,7 @@ public void runKVSizeTests(Class keyClass, Class valueClass) throws Except + (keyClass.equals(Text.class) ? "key" : "value") + ", min size: " + min + ", max size: " + max + ", normal out: " + normalOutputPath + ", native Out: " + nativeOutputPath; - assertEquals(reason, true, compareRet); + assertTrue(compareRet, reason); ResultVerifier.verifyCounters(normalJob.job, nativeJob.job); } fs.close(); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/nonsorttest/NonSortTest.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/nonsorttest/NonSortTest.java index 7f2f4bbddbf50..063d0bd826d67 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/nonsorttest/NonSortTest.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/nonsorttest/NonSortTest.java @@ -18,6 +18,7 @@ package org.apache.hadoop.mapred.nativetask.nonsorttest; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assumptions.assumeTrue; import java.io.IOException; @@ -37,11 +38,10 @@ import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat; -import org.junit.AfterClass; +import org.junit.jupiter.api.AfterAll; import org.apache.hadoop.util.NativeCodeLoader; -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class NonSortTest { @@ -72,10 +72,10 @@ public void nonSortTest() throws Exception { ResultVerifier.verifyCounters(hadoopWithSort, nativeNonSort); } - @Before + @BeforeEach public void startUp() throws Exception { - Assume.assumeTrue(NativeCodeLoader.isNativeCodeLoaded()); - Assume.assumeTrue(NativeRuntime.isNativeLibraryLoaded()); + assumeTrue(NativeCodeLoader.isNativeCodeLoaded()); + assumeTrue(NativeRuntime.isNativeLibraryLoaded()); final ScenarioConfiguration conf = new ScenarioConfiguration(); conf.addNonSortTestConf(); final FileSystem fs = FileSystem.get(conf); @@ -88,7 +88,7 @@ public void startUp() throws Exception { fs.close(); } - @AfterClass + @AfterAll public static void cleanUp() throws IOException { final FileSystem fs = FileSystem.get(new ScenarioConfiguration()); fs.delete(new Path(TestConstants.NATIVETASK_NONSORT_TEST_DIR), true); diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/serde/TestKVSerializer.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/serde/TestKVSerializer.java index c4a1a9ae58b60..f7422aecba73d 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/serde/TestKVSerializer.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/serde/TestKVSerializer.java @@ -20,8 +20,8 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.apache.hadoop.io.BytesWritable; import org.apache.hadoop.mapred.nativetask.Constants; @@ -30,16 +30,17 @@ import org.apache.hadoop.mapred.nativetask.testutil.TestInput; import org.apache.hadoop.mapred.nativetask.testutil.TestInput.KV; import org.apache.hadoop.mapred.nativetask.util.SizedWritable; -import org.junit.Assert; import org.mockito.Mockito; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; @SuppressWarnings({ "rawtypes", "unchecked" }) public class TestKVSerializer { - int inputArraySize = 1000; // 1000 bytesWriable elements + private int inputArraySize = 1000; // 1000 bytes Writable elements int bufferSize = 100; // bytes private KV[] inputArray; @@ -48,7 +49,7 @@ public class TestKVSerializer { private SizedWritable value; private KVSerializer serializer; - @Before + @BeforeEach public void setUp() throws IOException { this.inputArray = TestInput.getMapInputs(inputArraySize); this.key = new SizedWritable(BytesWritable.class); @@ -72,7 +73,7 @@ public void testUpdateLength() throws IOException { serializer.updateLength(key, value); // verify whether the size increase - Assert.assertTrue(key.length + value.length > kvLength); + assertTrue(key.length + value.length > kvLength); kvLength = key.length + value.length; } } @@ -92,7 +93,7 @@ public void testSerializeKV() throws IOException { Mockito.verify(dataOut, Mockito.times(2)).write(any(byte[].class), anyInt(), anyInt()); - Assert.assertEquals(written, key.length + value.length + Constants.SIZEOF_KV_LENGTH); + assertEquals(written, key.length + value.length + Constants.SIZEOF_KV_LENGTH); } @Test @@ -110,7 +111,7 @@ public void testSerializeNoFlush() throws IOException { Mockito.verify(dataOut, Mockito.times(2)).write(any(byte[].class), anyInt(), anyInt()); - Assert.assertEquals(written, key.length + value.length + Constants.SIZEOF_KV_LENGTH); + assertEquals(written, key.length + value.length + Constants.SIZEOF_KV_LENGTH); } @Test @@ -131,7 +132,7 @@ public void testSerializePartitionKV() throws IOException { Mockito.verify(dataOut, Mockito.times(2)).write(any(byte[].class), anyInt(), anyInt()); - Assert.assertEquals(written, key.length + value.length + Constants.SIZEOF_KV_LENGTH + assertEquals(written, key.length + value.length + Constants.SIZEOF_KV_LENGTH + Constants.SIZEOF_PARTITION_LENGTH); } @@ -139,14 +140,14 @@ public void testSerializePartitionKV() throws IOException { public void testDeserializerNoData() throws IOException { final DataInputStream in = Mockito.mock(DataInputStream.class); Mockito.when(in.hasUnReadData()).thenReturn(false); - Assert.assertEquals(0, serializer.deserializeKV(in, key, value)); + assertEquals(0, serializer.deserializeKV(in, key, value)); } @Test public void testDeserializer() throws IOException { final DataInputStream in = Mockito.mock(DataInputStream.class); Mockito.when(in.hasUnReadData()).thenReturn(true); - Assert.assertTrue(serializer.deserializeKV(in, key, value) > 0); + assertTrue(serializer.deserializeKV(in, key, value) > 0); Mockito.verify(in, Mockito.times(4)).readInt(); Mockito.verify(in, Mockito.times(2)).readFully(any(byte[].class), diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/serde/TestNativeSerialization.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/serde/TestNativeSerialization.java index 5666cc36c64db..da44684d526d4 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/serde/TestNativeSerialization.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/serde/TestNativeSerialization.java @@ -23,8 +23,10 @@ import org.apache.hadoop.io.Writable; import org.apache.hadoop.mapred.nativetask.INativeComparable; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; @SuppressWarnings({ "rawtypes" }) public class TestNativeSerialization { @@ -36,10 +38,10 @@ public void testRegisterAndGet() throws IOException { serialization.register(WritableKey.class.getName(), ComparableKeySerializer.class); INativeSerializer serializer = serialization.getSerializer(WritableKey.class); - Assert.assertEquals(ComparableKeySerializer.class.getName(), serializer.getClass().getName()); + assertEquals(ComparableKeySerializer.class.getName(), serializer.getClass().getName()); serializer = serialization.getSerializer(WritableValue.class); - Assert.assertEquals(DefaultSerializer.class.getName(), serializer.getClass().getName()); + assertEquals(DefaultSerializer.class.getName(), serializer.getClass().getName()); boolean ioExceptionThrown = false; try { @@ -47,7 +49,7 @@ public void testRegisterAndGet() throws IOException { } catch (final IOException e) { ioExceptionThrown = true; } - Assert.assertTrue(ioExceptionThrown); + assertTrue(ioExceptionThrown); } public static class WritableKey implements Writable { diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/testutil/ResultVerifier.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/testutil/ResultVerifier.java index 5749691b4b4b8..342689b5b5b58 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/testutil/ResultVerifier.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/testutil/ResultVerifier.java @@ -17,7 +17,7 @@ */ package org.apache.hadoop.mapred.nativetask.testutil; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; import java.util.zip.CRC32; @@ -143,16 +143,16 @@ public static void verifyCounters(Job normalJob, Job nativeJob, boolean hasCombi throws IOException { Counters normalCounters = normalJob.getCounters(); Counters nativeCounters = nativeJob.getCounters(); - assertEquals("Counter MAP_OUTPUT_RECORDS should be equal", - normalCounters.findCounter(TaskCounter.MAP_OUTPUT_RECORDS).getValue(), - nativeCounters.findCounter(TaskCounter.MAP_OUTPUT_RECORDS).getValue()); - assertEquals("Counter REDUCE_INPUT_GROUPS should be equal", - normalCounters.findCounter(TaskCounter.REDUCE_INPUT_GROUPS).getValue(), - nativeCounters.findCounter(TaskCounter.REDUCE_INPUT_GROUPS).getValue()); + assertEquals(normalCounters.findCounter(TaskCounter.MAP_OUTPUT_RECORDS).getValue(), + nativeCounters.findCounter(TaskCounter.MAP_OUTPUT_RECORDS).getValue(), + "Counter MAP_OUTPUT_RECORDS should be equal"); + assertEquals(normalCounters.findCounter(TaskCounter.REDUCE_INPUT_GROUPS).getValue(), + nativeCounters.findCounter(TaskCounter.REDUCE_INPUT_GROUPS).getValue(), + "Counter REDUCE_INPUT_GROUPS should be equal"); if (!hasCombiner) { - assertEquals("Counter REDUCE_INPUT_RECORDS should be equal", - normalCounters.findCounter(TaskCounter.REDUCE_INPUT_RECORDS).getValue(), - nativeCounters.findCounter(TaskCounter.REDUCE_INPUT_RECORDS).getValue()); + assertEquals(normalCounters.findCounter(TaskCounter.REDUCE_INPUT_RECORDS).getValue(), + nativeCounters.findCounter(TaskCounter.REDUCE_INPUT_RECORDS).getValue(), + "Counter REDUCE_INPUT_RECORDS should be equal"); } } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/utils/TestBytesUtil.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/utils/TestBytesUtil.java index 5bae67b471eea..e480b36ae3784 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/utils/TestBytesUtil.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/utils/TestBytesUtil.java @@ -20,11 +20,12 @@ import org.apache.hadoop.thirdparty.com.google.common.primitives.Ints; import org.apache.hadoop.thirdparty.com.google.common.primitives.Longs; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.apache.hadoop.mapred.nativetask.util.BytesUtil; +import static org.junit.Assert.assertEquals; + public class TestBytesUtil { @Test @@ -32,7 +33,7 @@ public void testBytesIntConversion() { final int a = 1000; final byte[] intBytes = Ints.toByteArray(a); - Assert.assertEquals(a, BytesUtil.toInt(intBytes, 0)); + assertEquals(a, BytesUtil.toInt(intBytes, 0)); } @Test @@ -40,7 +41,7 @@ public void testBytesLongConversion() { final long l = 1000000L; final byte[] longBytes = Longs.toByteArray(l); - Assert.assertEquals(l, BytesUtil.toLong(longBytes, 0)); + assertEquals(l, BytesUtil.toLong(longBytes, 0)); } @Test @@ -48,7 +49,7 @@ public void testBytesFloatConversion() { final float f = 3.14f; final byte[] floatBytes = BytesUtil.toBytes(f); - Assert.assertEquals(f, BytesUtil.toFloat(floatBytes), 0.0f); + assertEquals(f, BytesUtil.toFloat(floatBytes), 0.0f); } @Test @@ -56,14 +57,14 @@ public void testBytesDoubleConversion() { final double d = 3.14; final byte[] doubleBytes = BytesUtil.toBytes(d); - Assert.assertEquals(d, BytesUtil.toDouble(doubleBytes), 0.0); + assertEquals(d, BytesUtil.toDouble(doubleBytes), 0.0); } @Test public void testToStringBinary() { - Assert.assertEquals("\\x01\\x02ABC", + assertEquals("\\x01\\x02ABC", BytesUtil.toStringBinary(new byte[] { 1, 2, 65, 66, 67 })); - Assert.assertEquals("\\x10\\x11", + assertEquals("\\x10\\x11", BytesUtil.toStringBinary(new byte[] { 16, 17 })); } } diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/utils/TestReadWriteBuffer.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/utils/TestReadWriteBuffer.java index aeb93830d95bb..a5a4929898188 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/utils/TestReadWriteBuffer.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/utils/TestReadWriteBuffer.java @@ -17,7 +17,7 @@ */ package org.apache.hadoop.mapred.nativetask.utils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.apache.hadoop.mapred.nativetask.util.ReadWriteBuffer; diff --git a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/utils/TestSizedWritable.java b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/utils/TestSizedWritable.java index a6e43ed7977fb..1d21bda9cefb4 100644 --- a/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/utils/TestSizedWritable.java +++ b/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-nativetask/src/test/java/org/apache/hadoop/mapred/nativetask/utils/TestSizedWritable.java @@ -17,11 +17,13 @@ */ package org.apache.hadoop.mapred.nativetask.utils; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.apache.hadoop.io.BytesWritable; import org.apache.hadoop.mapred.nativetask.util.SizedWritable; -import org.junit.Assert; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; @SuppressWarnings({ "rawtypes", "unchecked" }) public class TestSizedWritable { @@ -29,7 +31,7 @@ public class TestSizedWritable { @Test public void testSizedWritable() { final SizedWritable w = new SizedWritable(BytesWritable.class); - Assert.assertTrue(w.length == SizedWritable.INVALID_LENGTH); - Assert.assertFalse(w.v == null); + assertTrue(w.length == SizedWritable.INVALID_LENGTH); + assertFalse(w.v == null); } }