Skip to content

Commit 08ff51a

Browse files
author
fanshilun
committed
HADOOP-19415. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-common Part2.
1 parent 92afe16 commit 08ff51a

File tree

78 files changed

+984
-965
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+984
-965
lines changed

hadoop-common-project/hadoop-common/pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,26 @@
381381
<artifactId>lz4-java</artifactId>
382382
<scope>provided</scope>
383383
</dependency>
384+
<dependency>
385+
<groupId>org.junit.jupiter</groupId>
386+
<artifactId>junit-jupiter-api</artifactId>
387+
<scope>test</scope>
388+
</dependency>
389+
<dependency>
390+
<groupId>org.junit.jupiter</groupId>
391+
<artifactId>junit-jupiter-engine</artifactId>
392+
<scope>test</scope>
393+
</dependency>
394+
<dependency>
395+
<groupId>org.junit.jupiter</groupId>
396+
<artifactId>junit-jupiter-params</artifactId>
397+
<scope>test</scope>
398+
</dependency>
399+
<dependency>
400+
<groupId>org.junit.platform</groupId>
401+
<artifactId>junit-platform-launcher</artifactId>
402+
<scope>test</scope>
403+
</dependency>
384404
</dependencies>
385405

386406
<build>

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextTestHelper.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
2626
import org.apache.hadoop.fs.Options.CreateOpts.BlockSize;
2727
import org.apache.hadoop.io.IOUtils;
2828
import org.apache.hadoop.test.GenericTestUtils;
29-
30-
import static org.junit.jupiter.api.Assertions.assertEquals;
31-
import static org.junit.jupiter.api.Assertions.assertNotNull;
32-
import static org.junit.jupiter.api.Assertions.assertTrue;
29+
import org.junit.Assert;
3330

3431
/**
3532
* Helper class for unit tests.
@@ -223,28 +220,28 @@ public enum fileType {isDir, isFile, isSymlink};
223220
public static void checkFileStatus(FileContext aFc, String path,
224221
fileType expectedType) throws IOException {
225222
FileStatus s = aFc.getFileStatus(new Path(path));
226-
assertNotNull(s);
223+
Assert.assertNotNull(s);
227224
if (expectedType == fileType.isDir) {
228-
assertTrue(s.isDirectory());
225+
Assert.assertTrue(s.isDirectory());
229226
} else if (expectedType == fileType.isFile) {
230-
assertTrue(s.isFile());
227+
Assert.assertTrue(s.isFile());
231228
} else if (expectedType == fileType.isSymlink) {
232-
assertTrue(s.isSymlink());
229+
Assert.assertTrue(s.isSymlink());
233230
}
234-
assertEquals(aFc.makeQualified(new Path(path)), s.getPath());
231+
Assert.assertEquals(aFc.makeQualified(new Path(path)), s.getPath());
235232
}
236233

237234
public static void checkFileLinkStatus(FileContext aFc, String path,
238235
fileType expectedType) throws IOException {
239236
FileStatus s = aFc.getFileLinkStatus(new Path(path));
240-
assertNotNull(s);
237+
Assert.assertNotNull(s);
241238
if (expectedType == fileType.isDir) {
242-
assertTrue(s.isDirectory());
239+
Assert.assertTrue(s.isDirectory());
243240
} else if (expectedType == fileType.isFile) {
244-
assertTrue(s.isFile());
241+
Assert.assertTrue(s.isFile());
245242
} else if (expectedType == fileType.isSymlink) {
246-
assertTrue(s.isSymlink());
243+
Assert.assertTrue(s.isSymlink());
247244
}
248-
assertEquals(aFc.makeQualified(new Path(path)), s.getPath());
245+
Assert.assertEquals(aFc.makeQualified(new Path(path)), s.getPath());
249246
}
250247
}

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileContextTestWrapper.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@
2828
import org.apache.hadoop.fs.permission.FsPermission;
2929
import org.apache.hadoop.io.IOUtils;
3030
import org.apache.hadoop.security.AccessControlException;
31-
32-
import static org.junit.jupiter.api.Assertions.assertEquals;
33-
import static org.junit.jupiter.api.Assertions.assertNotNull;
34-
import static org.junit.jupiter.api.Assertions.assertTrue;
31+
import org.junit.Assert;
3532

3633
/**
3734
* Helper class for unit tests.
@@ -172,29 +169,29 @@ public FileStatus containsPath(String path, FileStatus[] dirList)
172169
public void checkFileStatus(String path, fileType expectedType)
173170
throws IOException {
174171
FileStatus s = fc.getFileStatus(new Path(path));
175-
assertNotNull(s);
172+
Assert.assertNotNull(s);
176173
if (expectedType == fileType.isDir) {
177-
assertTrue(s.isDirectory());
174+
Assert.assertTrue(s.isDirectory());
178175
} else if (expectedType == fileType.isFile) {
179-
assertTrue(s.isFile());
176+
Assert.assertTrue(s.isFile());
180177
} else if (expectedType == fileType.isSymlink) {
181-
assertTrue(s.isSymlink());
178+
Assert.assertTrue(s.isSymlink());
182179
}
183-
assertEquals(fc.makeQualified(new Path(path)), s.getPath());
180+
Assert.assertEquals(fc.makeQualified(new Path(path)), s.getPath());
184181
}
185182

186183
public void checkFileLinkStatus(String path, fileType expectedType)
187184
throws IOException {
188185
FileStatus s = fc.getFileLinkStatus(new Path(path));
189-
assertNotNull(s);
186+
Assert.assertNotNull(s);
190187
if (expectedType == fileType.isDir) {
191-
assertTrue(s.isDirectory());
188+
Assert.assertTrue(s.isDirectory());
192189
} else if (expectedType == fileType.isFile) {
193-
assertTrue(s.isFile());
190+
Assert.assertTrue(s.isFile());
194191
} else if (expectedType == fileType.isSymlink) {
195-
assertTrue(s.isSymlink());
192+
Assert.assertTrue(s.isSymlink());
196193
}
197-
assertEquals(fc.makeQualified(new Path(path)), s.getPath());
194+
Assert.assertEquals(fc.makeQualified(new Path(path)), s.getPath());
198195
}
199196

200197
//

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestHelper.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@
2525
import org.apache.hadoop.conf.Configuration;
2626
import org.apache.hadoop.security.token.Token;
2727
import org.apache.hadoop.test.GenericTestUtils;
28+
import org.junit.Assert;
2829

29-
import static org.junit.jupiter.api.Assertions.assertEquals;
30-
import static org.junit.jupiter.api.Assertions.assertNotNull;
31-
import static org.junit.jupiter.api.Assertions.assertTrue;
30+
import static org.junit.Assert.*;
3231
import static org.mockito.Mockito.mock;
3332

3433
/**
@@ -242,15 +241,15 @@ public enum fileType {isDir, isFile, isSymlink};
242241
public static void checkFileStatus(FileSystem aFs, String path,
243242
fileType expectedType) throws IOException {
244243
FileStatus s = aFs.getFileStatus(new Path(path));
245-
assertNotNull(s);
244+
Assert.assertNotNull(s);
246245
if (expectedType == fileType.isDir) {
247-
assertTrue(s.isDirectory());
246+
Assert.assertTrue(s.isDirectory());
248247
} else if (expectedType == fileType.isFile) {
249-
assertTrue(s.isFile());
248+
Assert.assertTrue(s.isFile());
250249
} else if (expectedType == fileType.isSymlink) {
251-
assertTrue(s.isSymlink());
250+
Assert.assertTrue(s.isSymlink());
252251
}
253-
assertEquals(aFs.makeQualified(new Path(path)), s.getPath());
252+
Assert.assertEquals(aFs.makeQualified(new Path(path)), s.getPath());
254253
}
255254

256255
/**

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/FileSystemTestWrapper.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import org.apache.hadoop.io.IOUtils;
3030
import org.apache.hadoop.security.AccessControlException;
3131
import org.apache.hadoop.util.Progressable;
32-
import org.junit.jupiter.api.Assertions;
32+
import org.junit.Assert;
3333

3434
/**
3535
* Helper class for unit tests.
@@ -170,29 +170,29 @@ public FileStatus containsPath(String path, FileStatus[] dirList)
170170
public void checkFileStatus(String path, fileType expectedType)
171171
throws IOException {
172172
FileStatus s = fs.getFileStatus(new Path(path));
173-
Assertions.assertNotNull(s);
173+
Assert.assertNotNull(s);
174174
if (expectedType == fileType.isDir) {
175-
Assertions.assertTrue(s.isDirectory());
175+
Assert.assertTrue(s.isDirectory());
176176
} else if (expectedType == fileType.isFile) {
177-
Assertions.assertTrue(s.isFile());
177+
Assert.assertTrue(s.isFile());
178178
} else if (expectedType == fileType.isSymlink) {
179-
Assertions.assertTrue(s.isSymlink());
179+
Assert.assertTrue(s.isSymlink());
180180
}
181-
Assertions.assertEquals(fs.makeQualified(new Path(path)), s.getPath());
181+
Assert.assertEquals(fs.makeQualified(new Path(path)), s.getPath());
182182
}
183183

184184
public void checkFileLinkStatus(String path, fileType expectedType)
185185
throws IOException {
186186
FileStatus s = fs.getFileLinkStatus(new Path(path));
187-
Assertions.assertNotNull(s);
187+
Assert.assertNotNull(s);
188188
if (expectedType == fileType.isDir) {
189-
Assertions.assertTrue(s.isDirectory());
189+
Assert.assertTrue(s.isDirectory());
190190
} else if (expectedType == fileType.isFile) {
191-
Assertions.assertTrue(s.isFile());
191+
Assert.assertTrue(s.isFile());
192192
} else if (expectedType == fileType.isSymlink) {
193-
Assertions.assertTrue(s.isSymlink());
193+
Assert.assertTrue(s.isSymlink());
194194
}
195-
Assertions.assertEquals(fs.makeQualified(new Path(path)), s.getPath());
195+
Assert.assertEquals(fs.makeQualified(new Path(path)), s.getPath());
196196
}
197197

198198
//

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestAvroFSInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.apache.hadoop.test.GenericTestUtils;
2626

2727
import org.junit.jupiter.api.Test;
28-
import static org.junit.jupiter.api.Assertions.*;
28+
import static org.junit.jupiter.api.Assertions.assertEquals;
2929

3030
public class TestAvroFSInput {
3131

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestChecksumFileSystem.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929
import org.junit.jupiter.api.BeforeEach;
3030
import org.junit.jupiter.api.Test;
3131

32-
import static org.junit.jupiter.api.Assertions.*;
32+
import static org.junit.jupiter.api.Assertions.assertEquals;
33+
import static org.junit.jupiter.api.Assertions.assertFalse;
34+
import static org.junit.jupiter.api.Assertions.assertNotNull;
35+
import static org.junit.jupiter.api.Assertions.assertTrue;
36+
import static org.junit.jupiter.api.Assertions.fail;
3337

3438
public class TestChecksumFileSystem {
3539
static final String TEST_ROOT_DIR =

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestCommandFormat.java

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

20-
21-
import static org.junit.jupiter.api.Assertions.*;
20+
import static org.junit.jupiter.api.Assertions.assertEquals;
2221

2322
import java.util.ArrayList;
2423
import java.util.Arrays;

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestContentSummary.java

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

20-
import static org.junit.jupiter.api.Assertions.*;
21-
import static org.mockito.Mockito.*;
20+
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.mockito.Mockito.inOrder;
22+
import static org.mockito.Mockito.mock;
23+
import static org.mockito.Mockito.when;
2224

2325
import java.io.DataInput;
2426
import java.io.DataOutput;

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDFVariations.java

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

2020
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertTrue;
2122
import static org.junit.jupiter.api.Assertions.fail;
22-
2323
import java.io.BufferedReader;
2424
import java.io.File;
2525
import java.io.FileNotFoundException;
@@ -34,8 +34,6 @@
3434
import org.junit.jupiter.api.Test;
3535
import org.junit.jupiter.api.Timeout;
3636

37-
import static org.junit.jupiter.api.Assertions.*;
38-
3937
public class TestDFVariations {
4038
private static final String TEST_ROOT_DIR =
4139
GenericTestUtils.getTestDir("testdfvariations").getAbsolutePath();
@@ -165,12 +163,11 @@ public void testGetMountCurrentDirectory() throws Exception {
165163
DF df = new DF(new File(workingDir), 0L);
166164
String mountPath = df.getMount();
167165
File mountDir = new File(mountPath);
168-
assertTrue(
169-
mountDir.exists(), "Mount dir ["+mountDir.getAbsolutePath()+"] should exist.");
170-
assertTrue(
171-
mountDir.isDirectory(), "Mount dir ["+mountDir.getAbsolutePath()+"] should be directory.");
172-
assertTrue(
173-
workingDir.startsWith(mountPath), "Working dir ["+workingDir+"] should start with ["+mountPath+"].");
166+
assertTrue(mountDir.exists(), "Mount dir ["+mountDir.getAbsolutePath()+"] should exist.");
167+
assertTrue(mountDir.isDirectory(),
168+
"Mount dir ["+mountDir.getAbsolutePath()+"] should be directory.");
169+
assertTrue(workingDir.startsWith(mountPath),
170+
"Working dir ["+workingDir+"] should start with ["+mountPath+"].");
174171
}
175172
}
176173

0 commit comments

Comments
 (0)