diff --git a/hadoop-common-project/hadoop-auth/pom.xml b/hadoop-common-project/hadoop-auth/pom.xml
index 98173c16f7e79..089d3a44740db 100644
--- a/hadoop-common-project/hadoop-auth/pom.xml
+++ b/hadoop-common-project/hadoop-auth/pom.xml
@@ -41,11 +41,6 @@
hadoop-annotations
provided
-
- junit
- junit
- test
-
org.mockito
mockito-core
diff --git a/hadoop-common-project/hadoop-common/pom.xml b/hadoop-common-project/hadoop-common/pom.xml
index 6f5527757146c..5ca60246203af 100644
--- a/hadoop-common-project/hadoop-common/pom.xml
+++ b/hadoop-common-project/hadoop-common/pom.xml
@@ -162,11 +162,6 @@
reload4j
compile
-
- junit
- junit
- test
-
org.assertj
assertj-core
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractEtagTest.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractEtagTest.java
index 880cdfb9106e4..2624605ed254c 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractEtagTest.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/AbstractContractEtagTest.java
@@ -21,7 +21,6 @@
import java.nio.charset.StandardCharsets;
import org.assertj.core.api.Assertions;
-import org.junit.Assume;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,6 +33,7 @@
import static org.apache.hadoop.fs.CommonPathCapabilities.ETAGS_AVAILABLE;
import static org.apache.hadoop.fs.CommonPathCapabilities.ETAGS_PRESERVED_IN_RENAME;
+import static org.assertj.core.api.Assumptions.assumeThat;
/**
* For filesystems which support etags, validate correctness
@@ -132,9 +132,9 @@ public void testEtagConsistencyAcrossRename() throws Throwable {
describe("Verify that when a file is renamed, the etag remains unchanged");
final Path path = methodPath();
final FileSystem fs = getFileSystem();
- Assume.assumeTrue(
- "Filesystem does not declare that etags are preserved across renames",
- fs.hasPathCapability(path, ETAGS_PRESERVED_IN_RENAME));
+ assumeThat(fs.hasPathCapability(path, ETAGS_PRESERVED_IN_RENAME))
+ .withFailMessage("Filesystem does not declare that etags are preserved across renames")
+ .isTrue();
Path src = new Path(path, "src");
Path dest = new Path(path, "dest");
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/rawlocal/TestRawlocalContractAppend.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/rawlocal/TestRawlocalContractAppend.java
index 5e75f00b871df..9810b35222b0c 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/rawlocal/TestRawlocalContractAppend.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/contract/rawlocal/TestRawlocalContractAppend.java
@@ -18,13 +18,13 @@
package org.apache.hadoop.fs.contract.rawlocal;
-import org.junit.Assume;
-
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.contract.AbstractContractAppendTest;
import org.apache.hadoop.fs.contract.AbstractFSContract;
+import static org.assertj.core.api.Assumptions.assumeThat;
+
public class TestRawlocalContractAppend extends AbstractContractAppendTest {
@Override
@@ -36,7 +36,7 @@ protected AbstractFSContract createContract(Configuration conf) {
public void testRenameFileBeingAppended() throws Throwable {
// Renaming a file while its handle is open is not supported on Windows.
// Thus, this test should be skipped on Windows.
- Assume.assumeFalse(Path.WINDOWS);
+ assumeThat(Path.WINDOWS).isFalse();
super.testRenameFileBeingAppended();
}
diff --git a/hadoop-common-project/hadoop-kms/pom.xml b/hadoop-common-project/hadoop-kms/pom.xml
index f557481f7c756..951d77a732b09 100644
--- a/hadoop-common-project/hadoop-kms/pom.xml
+++ b/hadoop-common-project/hadoop-kms/pom.xml
@@ -38,11 +38,6 @@
hadoop-minikdc
test
-
- junit
- junit
- test
-
org.mockito
mockito-inline
diff --git a/hadoop-common-project/hadoop-kms/src/test/java/org/apache/hadoop/crypto/key/kms/server/TestKMSAudit.java b/hadoop-common-project/hadoop-kms/src/test/java/org/apache/hadoop/crypto/key/kms/server/TestKMSAudit.java
index 07962f4c56ee2..931e6e6ee22ca 100644
--- a/hadoop-common-project/hadoop-kms/src/test/java/org/apache/hadoop/crypto/key/kms/server/TestKMSAudit.java
+++ b/hadoop-common-project/hadoop-kms/src/test/java/org/apache/hadoop/crypto/key/kms/server/TestKMSAudit.java
@@ -118,7 +118,10 @@ public void testAggregation() throws Exception {
kmsAudit.evictCacheForTesting();
String out = getAndResetLogOutput();
System.out.println(out);
- boolean doesMatch = out.matches(
+ String cleanedOut =
+ out.replaceAll("fs\\.default\\.name in core-default\\.xml is deprecated\\. " +
+ "Instead, use fs\\.defaultFS", "");
+ boolean doesMatch = cleanedOut.matches(
"OK\\[op=DECRYPT_EEK, key=k1, user=luser@REALM, accessCount=1, "
+ "interval=[^m]{1,4}ms\\] testmsg"
// Not aggregated !!
@@ -156,11 +159,14 @@ public void testAggregationUnauth() throws Exception {
kmsAudit.evictCacheForTesting();
String out = getAndResetLogOutput();
System.out.println(out);
+ String cleanedOut =
+ out.replaceAll("fs\\.default\\.name in core-default\\.xml is deprecated\\. " +
+ "Instead, use fs\\.defaultFS", "");
// The UNAUTHORIZED will trigger cache invalidation, which then triggers
// the aggregated OK (accessCount=5). But the order of the UNAUTHORIZED and
// the aggregated OK is arbitrary - no correctness concerns, but flaky here.
- boolean doesMatch = out.matches(
+ boolean doesMatch = cleanedOut.matches(
"UNAUTHORIZED\\[op=GENERATE_EEK, key=k2, user=luser@REALM\\] "
+ "OK\\[op=GENERATE_EEK, key=k3, user=luser@REALM, accessCount=1,"
+ " interval=[^m]{1,4}ms\\] testmsg"
@@ -169,7 +175,7 @@ public void testAggregationUnauth() throws Exception {
+ "UNAUTHORIZED\\[op=GENERATE_EEK, key=k3, user=luser@REALM\\] "
+ "OK\\[op=GENERATE_EEK, key=k3, user=luser@REALM, accessCount=1,"
+ " interval=[^m]{1,4}ms\\] testmsg");
- doesMatch = doesMatch || out.matches(
+ doesMatch = doesMatch || cleanedOut.matches(
"UNAUTHORIZED\\[op=GENERATE_EEK, key=k2, user=luser@REALM\\] "
+ "OK\\[op=GENERATE_EEK, key=k3, user=luser@REALM, accessCount=1,"
+ " interval=[^m]{1,4}ms\\] testmsg"
diff --git a/hadoop-common-project/hadoop-minikdc/pom.xml b/hadoop-common-project/hadoop-minikdc/pom.xml
index b6f5f6784a9b1..2296a428e4690 100644
--- a/hadoop-common-project/hadoop-minikdc/pom.xml
+++ b/hadoop-common-project/hadoop-minikdc/pom.xml
@@ -68,11 +68,6 @@
junit-jupiter-engine
provided
-
- org.junit.vintage
- junit-vintage-engine
- provided
-
org.junit.platform
junit-platform-launcher
diff --git a/hadoop-common-project/hadoop-nfs/pom.xml b/hadoop-common-project/hadoop-nfs/pom.xml
index 28aaf90ce5274..c7e57bf6c925d 100644
--- a/hadoop-common-project/hadoop-nfs/pom.xml
+++ b/hadoop-common-project/hadoop-nfs/pom.xml
@@ -53,11 +53,6 @@
test
test-jar
-
- junit
- junit
- test
-
org.mockito
mockito-inline
@@ -97,6 +92,31 @@
assertj-core
test
+
+ org.assertj
+ assertj-core
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.platform
+ junit-platform-launcher
+ provided
+
diff --git a/hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/TestNfsExports.java b/hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/TestNfsExports.java
index 542975d1292b5..85bc522a18fdb 100644
--- a/hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/TestNfsExports.java
+++ b/hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/TestNfsExports.java
@@ -18,8 +18,8 @@
package org.apache.hadoop.nfs;
import org.apache.hadoop.nfs.nfs3.Nfs3Constant;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class TestNfsExports {
@@ -37,14 +37,14 @@ public class TestNfsExports {
@Test
public void testWildcardRW() {
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, "* rw");
- Assert.assertEquals(AccessPrivilege.READ_WRITE,
+ Assertions.assertEquals(AccessPrivilege.READ_WRITE,
matcher.getAccessPrivilege(address1, hostname1));
}
@Test
public void testWildcardRO() {
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, "* ro");
- Assert.assertEquals(AccessPrivilege.READ_ONLY,
+ Assertions.assertEquals(AccessPrivilege.READ_ONLY,
matcher.getAccessPrivilege(address1, hostname1));
}
@@ -52,33 +52,32 @@ public void testWildcardRO() {
public void testExactAddressRW() {
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, address1
+ " rw");
- Assert.assertEquals(AccessPrivilege.READ_WRITE,
+ Assertions.assertEquals(AccessPrivilege.READ_WRITE,
matcher.getAccessPrivilege(address1, hostname1));
- Assert.assertFalse(AccessPrivilege.READ_WRITE == matcher
+ Assertions.assertFalse(AccessPrivilege.READ_WRITE == matcher
.getAccessPrivilege(address2, hostname1));
}
@Test
public void testExactAddressRO() {
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, address1);
- Assert.assertEquals(AccessPrivilege.READ_ONLY,
+ Assertions.assertEquals(AccessPrivilege.READ_ONLY,
matcher.getAccessPrivilege(address1, hostname1));
- Assert.assertEquals(AccessPrivilege.NONE,
- matcher.getAccessPrivilege(address2, hostname1));
+ Assertions.assertEquals(AccessPrivilege.NONE, matcher.getAccessPrivilege(address2, hostname1));
}
@Test
public void testExactHostRW() {
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, hostname1
+ " rw");
- Assert.assertEquals(AccessPrivilege.READ_WRITE,
+ Assertions.assertEquals(AccessPrivilege.READ_WRITE,
matcher.getAccessPrivilege(address1, hostname1));
}
@Test
public void testExactHostRO() {
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, hostname1);
- Assert.assertEquals(AccessPrivilege.READ_ONLY,
+ Assertions.assertEquals(AccessPrivilege.READ_ONLY,
matcher.getAccessPrivilege(address1, hostname1));
}
@@ -86,70 +85,64 @@ public void testExactHostRO() {
public void testCidrShortRW() {
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
"192.168.0.0/22 rw");
- Assert.assertEquals(AccessPrivilege.READ_WRITE,
+ Assertions.assertEquals(AccessPrivilege.READ_WRITE,
matcher.getAccessPrivilege(address1, hostname1));
- Assert.assertEquals(AccessPrivilege.NONE,
- matcher.getAccessPrivilege(address2, hostname1));
+ Assertions.assertEquals(AccessPrivilege.NONE, matcher.getAccessPrivilege(address2, hostname1));
}
@Test
public void testCidrShortRO() {
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
"192.168.0.0/22");
- Assert.assertEquals(AccessPrivilege.READ_ONLY,
+ Assertions.assertEquals(AccessPrivilege.READ_ONLY,
matcher.getAccessPrivilege(address1, hostname1));
- Assert.assertEquals(AccessPrivilege.NONE,
- matcher.getAccessPrivilege(address2, hostname1));
+ Assertions.assertEquals(AccessPrivilege.NONE, matcher.getAccessPrivilege(address2, hostname1));
}
@Test
public void testCidrLongRW() {
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
"192.168.0.0/255.255.252.0 rw");
- Assert.assertEquals(AccessPrivilege.READ_WRITE,
+ Assertions.assertEquals(AccessPrivilege.READ_WRITE,
matcher.getAccessPrivilege(address1, hostname1));
- Assert.assertEquals(AccessPrivilege.NONE,
- matcher.getAccessPrivilege(address2, hostname1));
+ Assertions.assertEquals(AccessPrivilege.NONE, matcher.getAccessPrivilege(address2, hostname1));
}
@Test
public void testCidrLongRO() {
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
"192.168.0.0/255.255.252.0");
- Assert.assertEquals(AccessPrivilege.READ_ONLY,
+ Assertions.assertEquals(AccessPrivilege.READ_ONLY,
matcher.getAccessPrivilege(address1, hostname1));
- Assert.assertEquals(AccessPrivilege.NONE,
- matcher.getAccessPrivilege(address2, hostname1));
+ Assertions.assertEquals(AccessPrivilege.NONE, matcher.getAccessPrivilege(address2, hostname1));
}
@Test
public void testRegexIPRW() {
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
"192.168.0.[0-9]+ rw");
- Assert.assertEquals(AccessPrivilege.READ_WRITE,
+ Assertions.assertEquals(AccessPrivilege.READ_WRITE,
matcher.getAccessPrivilege(address1, hostname1));
- Assert.assertEquals(AccessPrivilege.NONE,
- matcher.getAccessPrivilege(address2, hostname1));
+ Assertions.assertEquals(AccessPrivilege.NONE, matcher.getAccessPrivilege(address2, hostname1));
}
@Test
public void testRegexIPRO() {
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
"192.168.0.[0-9]+");
- Assert.assertEquals(AccessPrivilege.READ_ONLY,
+ Assertions.assertEquals(AccessPrivilege.READ_ONLY,
matcher.getAccessPrivilege(address1, hostname1));
- Assert.assertEquals(AccessPrivilege.NONE,
- matcher.getAccessPrivilege(address2, hostname1));
+ Assertions.assertEquals(AccessPrivilege.NONE, matcher.getAccessPrivilege(address2, hostname1));
}
@Test
public void testRegexHostRW() {
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
"[a-z]+.b.com rw");
- Assert.assertEquals(AccessPrivilege.READ_WRITE,
+ Assertions.assertEquals(AccessPrivilege.READ_WRITE,
matcher.getAccessPrivilege(address1, hostname1));
// address1 will hit the cache
- Assert.assertEquals(AccessPrivilege.READ_WRITE,
+ Assertions.assertEquals(AccessPrivilege.READ_WRITE,
matcher.getAccessPrivilege(address1, hostname2));
}
@@ -157,10 +150,10 @@ public void testRegexHostRW() {
public void testRegexHostRO() {
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
"[a-z]+.b.com");
- Assert.assertEquals(AccessPrivilege.READ_ONLY,
+ Assertions.assertEquals(AccessPrivilege.READ_ONLY,
matcher.getAccessPrivilege(address1, hostname1));
// address1 will hit the cache
- Assert.assertEquals(AccessPrivilege.READ_ONLY,
+ Assertions.assertEquals(AccessPrivilege.READ_ONLY,
matcher.getAccessPrivilege(address1, hostname2));
}
@@ -168,17 +161,17 @@ public void testRegexHostRO() {
public void testRegexGrouping() {
NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
"192.168.0.(12|34)");
- Assert.assertEquals(AccessPrivilege.READ_ONLY,
+ Assertions.assertEquals(AccessPrivilege.READ_ONLY,
matcher.getAccessPrivilege(address1, hostname1));
// address1 will hit the cache
- Assert.assertEquals(AccessPrivilege.READ_ONLY,
+ Assertions.assertEquals(AccessPrivilege.READ_ONLY,
matcher.getAccessPrivilege(address1, hostname2));
matcher = new NfsExports(CacheSize, ExpirationPeriod, "\\w*.a.b.com");
- Assert.assertEquals(AccessPrivilege.READ_ONLY,
+ Assertions.assertEquals(AccessPrivilege.READ_ONLY,
matcher.getAccessPrivilege("1.2.3.4", "web.a.b.com"));
// address "1.2.3.4" will hit the cache
- Assert.assertEquals(AccessPrivilege.READ_ONLY,
+ Assertions.assertEquals(AccessPrivilege.READ_ONLY,
matcher.getAccessPrivilege("1.2.3.4", "email.a.b.org"));
}
@@ -187,16 +180,16 @@ public void testMultiMatchers() throws Exception {
long shortExpirationPeriod = 1 * 1000 * 1000 * 1000; // 1s
NfsExports matcher = new NfsExports(CacheSize, shortExpirationPeriod,
"192.168.0.[0-9]+;[a-z]+.b.com rw");
- Assert.assertEquals(AccessPrivilege.READ_ONLY,
+ Assertions.assertEquals(AccessPrivilege.READ_ONLY,
matcher.getAccessPrivilege(address1, hostname2));
- Assert.assertEquals(AccessPrivilege.READ_ONLY,
+ Assertions.assertEquals(AccessPrivilege.READ_ONLY,
matcher.getAccessPrivilege(address1, address1));
- Assert.assertEquals(AccessPrivilege.READ_ONLY,
+ Assertions.assertEquals(AccessPrivilege.READ_ONLY,
matcher.getAccessPrivilege(address1, hostname1));
- Assert.assertEquals(AccessPrivilege.READ_WRITE,
+ Assertions.assertEquals(AccessPrivilege.READ_WRITE,
matcher.getAccessPrivilege(address2, hostname1));
// address2 will hit the cache
- Assert.assertEquals(AccessPrivilege.READ_WRITE,
+ Assertions.assertEquals(AccessPrivilege.READ_WRITE,
matcher.getAccessPrivilege(address2, hostname2));
Thread.sleep(1000);
@@ -210,18 +203,20 @@ public void testMultiMatchers() throws Exception {
}
Thread.sleep(500);
} while ((System.nanoTime() - startNanos) / NanosPerMillis < 5000);
- Assert.assertEquals(AccessPrivilege.NONE, ap);
+ Assertions.assertEquals(AccessPrivilege.NONE, ap);
}
- @Test(expected=IllegalArgumentException.class)
+ @Test
public void testInvalidHost() {
- NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
- "foo#bar");
+ Assertions.assertThrows(IllegalArgumentException.class, () -> {
+ NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, "foo#bar");
+ });
}
- @Test(expected=IllegalArgumentException.class)
+ @Test
public void testInvalidSeparator() {
- NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod,
- "foo ro : bar rw");
+ Assertions.assertThrows(IllegalArgumentException.class, () -> {
+ NfsExports matcher = new NfsExports(CacheSize, ExpirationPeriod, "foo ro : bar rw");
+ });
}
}
diff --git a/hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/TestNfsTime.java b/hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/TestNfsTime.java
index a46051aaab848..4b71a36b64682 100644
--- a/hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/TestNfsTime.java
+++ b/hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/TestNfsTime.java
@@ -17,18 +17,18 @@
*/
package org.apache.hadoop.nfs;
-import org.junit.Assert;
+import org.junit.jupiter.api.Assertions;
import org.apache.hadoop.nfs.NfsTime;
import org.apache.hadoop.oncrpc.XDR;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TestNfsTime {
@Test
public void testConstructor() {
NfsTime nfstime = new NfsTime(1001);
- Assert.assertEquals(1, nfstime.getSeconds());
- Assert.assertEquals(1000000, nfstime.getNseconds());
+ Assertions.assertEquals(1, nfstime.getSeconds());
+ Assertions.assertEquals(1000000, nfstime.getNseconds());
}
@Test
@@ -42,6 +42,6 @@ public void testSerializeDeserialize() {
NfsTime t2 = NfsTime.deserialize(xdr.asReadOnlyWrap());
// Ensure the NfsTimes are equal
- Assert.assertEquals(t1, t2);
+ Assertions.assertEquals(t1, t2);
}
}
diff --git a/hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/nfs3/TestFileHandle.java b/hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/nfs3/TestFileHandle.java
index 70875c2913dd3..fb5a61ff54587 100644
--- a/hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/nfs3/TestFileHandle.java
+++ b/hadoop-common-project/hadoop-nfs/src/test/java/org/apache/hadoop/nfs/nfs3/TestFileHandle.java
@@ -18,7 +18,7 @@
package org.apache.hadoop.nfs.nfs3;
import org.apache.hadoop.oncrpc.XDR;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/hadoop-common-project/hadoop-registry/pom.xml b/hadoop-common-project/hadoop-registry/pom.xml
index 591cb60a756f9..35485304220bd 100644
--- a/hadoop-common-project/hadoop-registry/pom.xml
+++ b/hadoop-common-project/hadoop-registry/pom.xml
@@ -64,12 +64,6 @@
test
-
- junit
- junit
- test
-
-
org.apache.zookeeper
zookeeper
@@ -161,11 +155,6 @@
junit-jupiter-engine
test
-
- org.junit.vintage
- junit-vintage-engine
- test
-
org.junit.platform
junit-platform-launcher