Skip to content

Commit 866e36a

Browse files
committed
Revert "MAPREDUCE-7422. Upgrade Junit 4 to 5 in hadoop-mapreduce-examples (#5029)"
This reverts commit dcde414.
1 parent 0b7f148 commit 866e36a

File tree

8 files changed

+119
-145
lines changed

8 files changed

+119
-145
lines changed

hadoop-mapreduce-project/hadoop-mapreduce-examples/pom.xml

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -70,40 +70,40 @@
7070
<scope>runtime</scope>
7171
</dependency>
7272
<dependency>
73-
<groupId>org.apache.hadoop</groupId>
74-
<artifactId>hadoop-hdfs</artifactId>
75-
<scope>test</scope>
76-
<type>test-jar</type>
77-
<exclusions>
78-
<exclusion>
79-
<groupId>org.ow2.asm</groupId>
80-
<artifactId>asm-commons</artifactId>
81-
</exclusion>
82-
</exclusions>
83-
</dependency>
84-
<dependency>
85-
<groupId>org.apache.hadoop</groupId>
86-
<artifactId>hadoop-yarn-server-tests</artifactId>
87-
<scope>test</scope>
88-
<type>test-jar</type>
89-
</dependency>
90-
<dependency>
91-
<groupId>org.apache.hadoop</groupId>
92-
<artifactId>hadoop-mapreduce-client-app</artifactId>
93-
<scope>provided</scope>
94-
</dependency>
95-
<dependency>
96-
<groupId>org.apache.hadoop</groupId>
97-
<artifactId>hadoop-mapreduce-client-app</artifactId>
98-
<type>test-jar</type>
99-
<scope>test</scope>
100-
</dependency>
73+
<groupId>org.apache.hadoop</groupId>
74+
<artifactId>hadoop-hdfs</artifactId>
75+
<scope>test</scope>
76+
<type>test-jar</type>
77+
<exclusions>
78+
<exclusion>
79+
<groupId>org.ow2.asm</groupId>
80+
<artifactId>asm-commons</artifactId>
81+
</exclusion>
82+
</exclusions>
83+
</dependency>
84+
<dependency>
85+
<groupId>org.apache.hadoop</groupId>
86+
<artifactId>hadoop-yarn-server-tests</artifactId>
87+
<scope>test</scope>
88+
<type>test-jar</type>
89+
</dependency>
90+
<dependency>
91+
<groupId>org.apache.hadoop</groupId>
92+
<artifactId>hadoop-mapreduce-client-app</artifactId>
93+
<scope>provided</scope>
94+
</dependency>
95+
<dependency>
96+
<groupId>org.apache.hadoop</groupId>
97+
<artifactId>hadoop-mapreduce-client-app</artifactId>
98+
<type>test-jar</type>
99+
<scope>test</scope>
100+
</dependency>
101101
<dependency>
102102
<groupId>com.sun.jersey.jersey-test-framework</groupId>
103103
<artifactId>jersey-test-framework-grizzly2</artifactId>
104104
<scope>test</scope>
105105
</dependency>
106-
<dependency>
106+
<dependency>
107107
<groupId>org.apache.hadoop</groupId>
108108
<artifactId>hadoop-mapreduce-client-hs</artifactId>
109109
<scope>test</scope>
@@ -118,7 +118,7 @@
118118
<groupId>org.apache.hadoop.thirdparty</groupId>
119119
<artifactId>hadoop-shaded-guava</artifactId>
120120
<scope>provided</scope>
121-
</dependency>
121+
</dependency>
122122
<dependency>
123123
<groupId>org.slf4j</groupId>
124124
<artifactId>slf4j-api</artifactId>
@@ -128,21 +128,6 @@
128128
<artifactId>assertj-core</artifactId>
129129
<scope>test</scope>
130130
</dependency>
131-
<dependency>
132-
<groupId>org.junit.jupiter</groupId>
133-
<artifactId>junit-jupiter-api</artifactId>
134-
<scope>test</scope>
135-
</dependency>
136-
<dependency>
137-
<groupId>org.junit.jupiter</groupId>
138-
<artifactId>junit-jupiter-engine</artifactId>
139-
<scope>test</scope>
140-
</dependency>
141-
<dependency>
142-
<groupId>org.junit.platform</groupId>
143-
<artifactId>junit-platform-launcher</artifactId>
144-
<scope>test</scope>
145-
</dependency>
146131
</dependencies>
147132

148133
<build>

hadoop-mapreduce-project/hadoop-mapreduce-examples/src/test/java/org/apache/hadoop/examples/TestAggregateWordCount.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
import java.io.IOException;
2222
import java.nio.charset.Charset;
2323

24-
import org.junit.jupiter.api.AfterEach;
25-
import org.junit.jupiter.api.BeforeEach;
26-
import org.junit.jupiter.api.Test;
24+
import org.junit.After;
25+
import org.junit.Test;
2726

2827
import org.apache.commons.io.IOUtils;
2928
import org.apache.hadoop.fs.FSDataInputStream;
@@ -34,19 +33,14 @@
3433
import org.apache.hadoop.util.ExitUtil;
3534
import org.apache.hadoop.util.ExitUtil.ExitException;
3635

37-
import static org.junit.jupiter.api.Assertions.assertEquals;
36+
import static org.junit.Assert.assertEquals;
3837

3938
public class TestAggregateWordCount extends HadoopTestCase {
4039
public TestAggregateWordCount() throws IOException {
4140
super(LOCAL_MR, LOCAL_FS, 1, 1);
4241
}
4342

44-
@BeforeEach
45-
public void setUp() throws Exception {
46-
super.setUp();
47-
}
48-
49-
@AfterEach
43+
@After
5044
public void tearDown() throws Exception {
5145
FileSystem fs = getFileSystem();
5246
if (fs != null) {
@@ -64,7 +58,7 @@ public void tearDown() throws Exception {
6458
private static final Path OUTPUT_PATH = new Path(TEST_DIR, "outPath");
6559

6660
@Test
67-
void testAggregateTestCount()
61+
public void testAggregateTestCount()
6862
throws IOException, ClassNotFoundException, InterruptedException {
6963

7064
ExitUtil.disableSystemExit();
@@ -76,7 +70,7 @@ void testAggregateTestCount()
7670
FileUtil.write(fs, file2, "Hello Hadoop");
7771

7872
String[] args =
79-
new String[]{INPUT_PATH.toString(), OUTPUT_PATH.toString(), "1",
73+
new String[] {INPUT_PATH.toString(), OUTPUT_PATH.toString(), "1",
8074
"textinputformat"};
8175

8276
// Run AggregateWordCount Job.

hadoop-mapreduce-project/hadoop-mapreduce-examples/src/test/java/org/apache/hadoop/examples/TestBaileyBorweinPlouffe.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,35 @@
1818
package org.apache.hadoop.examples;
1919

2020
import java.math.BigInteger;
21-
import org.junit.jupiter.api.Test;
22-
23-
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import org.junit.Test;
22+
import org.junit.Assert;
2423

2524
/** Tests for BaileyBorweinPlouffe */
2625
public class TestBaileyBorweinPlouffe {
2726

2827
@Test
29-
void testMod() {
28+
public void testMod() {
3029
final BigInteger TWO = BigInteger.ONE.add(BigInteger.ONE);
31-
for (long n = 3; n < 100; n++) {
30+
for(long n = 3; n < 100; n++) {
3231
for (long e = 1; e < 100; e++) {
3332
final long r = TWO.modPow(
3433
BigInteger.valueOf(e), BigInteger.valueOf(n)).longValue();
35-
assertEquals(r, BaileyBorweinPlouffe
36-
.mod(e, n), "e=" + e + ", n=" + n);
34+
Assert.assertEquals("e=" + e + ", n=" + n, r, BaileyBorweinPlouffe
35+
.mod(e, n));
3736
}
3837
}
3938
}
4039

4140
@Test
42-
void testHexDigit() {
41+
public void testHexDigit() {
4342
final long[] answers = {0x43F6, 0xA308, 0x29B7, 0x49F1, 0x8AC8, 0x35EA};
4443
long d = 1;
45-
for (int i = 0; i < answers.length; i++) {
46-
assertEquals(answers[i], BaileyBorweinPlouffe
47-
.hexDigits(d), "d=" + d);
44+
for(int i = 0; i < answers.length; i++) {
45+
Assert.assertEquals("d=" + d, answers[i], BaileyBorweinPlouffe
46+
.hexDigits(d));
4847
d *= 10;
4948
}
5049

51-
assertEquals(0x243FL, BaileyBorweinPlouffe.hexDigits(0));
52-
}
50+
Assert.assertEquals(0x243FL, BaileyBorweinPlouffe.hexDigits(0));
51+
}
5352
}

hadoop-mapreduce-project/hadoop-mapreduce-examples/src/test/java/org/apache/hadoop/examples/TestWordStats.java

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

20+
import static org.junit.Assert.assertEquals;
21+
2022
import java.io.BufferedReader;
2123
import java.io.File;
2224
import java.io.IOException;
@@ -29,11 +31,9 @@
2931
import org.apache.hadoop.fs.FileSystem;
3032
import org.apache.hadoop.fs.Path;
3133
import org.apache.hadoop.util.ToolRunner;
32-
import org.junit.jupiter.api.AfterAll;
33-
import org.junit.jupiter.api.BeforeEach;
34-
import org.junit.jupiter.api.Test;
35-
36-
import static org.junit.jupiter.api.Assertions.assertEquals;
34+
import org.junit.AfterClass;
35+
import org.junit.Before;
36+
import org.junit.Test;
3737

3838
public class TestWordStats {
3939

@@ -241,14 +241,13 @@ public static boolean deleteDir(File dir) {
241241
return dir.delete();
242242
}
243243

244-
@BeforeEach public void setup() throws Exception {
244+
@Before public void setup() throws Exception {
245245
deleteDir(new File(MEAN_OUTPUT));
246246
deleteDir(new File(MEDIAN_OUTPUT));
247247
deleteDir(new File(STDDEV_OUTPUT));
248248
}
249249

250-
@Test
251-
void testGetTheMean() throws Exception {
250+
@Test public void testGetTheMean() throws Exception {
252251
String args[] = new String[2];
253252
args[0] = INPUT;
254253
args[1] = MEAN_OUTPUT;
@@ -262,8 +261,7 @@ void testGetTheMean() throws Exception {
262261
assertEquals(mean, wr.read(INPUT), 0.0);
263262
}
264263

265-
@Test
266-
void testGetTheMedian() throws Exception {
264+
@Test public void testGetTheMedian() throws Exception {
267265
String args[] = new String[2];
268266
args[0] = INPUT;
269267
args[1] = MEDIAN_OUTPUT;
@@ -277,8 +275,7 @@ void testGetTheMedian() throws Exception {
277275
assertEquals(median, wr.read(INPUT), 0.0);
278276
}
279277

280-
@Test
281-
void testGetTheStandardDeviation() throws Exception {
278+
@Test public void testGetTheStandardDeviation() throws Exception {
282279
String args[] = new String[2];
283280
args[0] = INPUT;
284281
args[1] = STDDEV_OUTPUT;
@@ -292,7 +289,7 @@ void testGetTheStandardDeviation() throws Exception {
292289
assertEquals(stddev, wr.read(INPUT), 0.0);
293290
}
294291

295-
@AfterAll public static void cleanup() throws Exception {
292+
@AfterClass public static void cleanup() throws Exception {
296293
deleteDir(new File(MEAN_OUTPUT));
297294
deleteDir(new File(MEDIAN_OUTPUT));
298295
deleteDir(new File(STDDEV_OUTPUT));

hadoop-mapreduce-project/hadoop-mapreduce-examples/src/test/java/org/apache/hadoop/examples/pi/math/TestLongLong.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919

2020
import java.math.BigInteger;
2121
import java.util.Random;
22-
import org.junit.jupiter.api.Test;
23-
24-
import static org.junit.jupiter.api.Assertions.assertEquals;
22+
import org.junit.Test;
23+
import org.junit.Assert;
2524

2625
public class TestLongLong {
2726

@@ -40,12 +39,12 @@ static void verifyMultiplication(long a, long b) {
4039
"\na = %x\nb = %x\nll= " + ll + "\nbi= " + bi.toString(16) + "\n", a,
4140
b);
4241
//System.out.println(s);
43-
assertEquals(bi, ll.toBigInteger(), s);
42+
Assert.assertEquals(s, bi, ll.toBigInteger());
4443
}
4544

4645
@Test
47-
void testMultiplication() {
48-
for (int i = 0; i < 100; i++) {
46+
public void testMultiplication() {
47+
for(int i = 0; i < 100; i++) {
4948
final long a = nextPositiveLong();
5049
final long b = nextPositiveLong();
5150
verifyMultiplication(a, b);
@@ -55,8 +54,8 @@ void testMultiplication() {
5554
}
5655

5756
@Test
58-
void testRightShift() {
59-
for (int i = 0; i < 1000; i++) {
57+
public void testRightShift() {
58+
for(int i = 0; i < 1000; i++) {
6059
final long a = nextPositiveLong();
6160
final long b = nextPositiveLong();
6261
verifyRightShift(a, b);
@@ -70,12 +69,12 @@ private static void verifyRightShift(long a, long b) {
7069
final String s = String.format(
7170
"\na = %x\nb = %x\nll= " + ll + "\nbi= " + bi.toString(16) + "\n", a,
7271
b);
73-
assertEquals(bi, ll.toBigInteger(), s);
72+
Assert.assertEquals(s, bi, ll.toBigInteger());
7473

7574
for (int i = 0; i < LongLong.SIZE >> 1; i++) {
7675
final long result = ll.shiftRight(i) & MASK;
7776
final long expected = bi.shiftRight(i).longValue() & MASK;
78-
assertEquals(expected, result, s);
77+
Assert.assertEquals(s, expected, result);
7978
}
8079
}
8180
}

0 commit comments

Comments
 (0)