Skip to content

Commit 9665314

Browse files
committed
HADOOP-19617 - [JDK17] Remove JUnit4 Dependency.
1 parent 183b576 commit 9665314

13 files changed

Lines changed: 119 additions & 215 deletions

File tree

hadoop-client-modules/hadoop-client-minicluster/pom.xml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@
5151
<artifactId>hadoop-client-runtime</artifactId>
5252
<scope>runtime</scope>
5353
</dependency>
54-
<!-- Leave JUnit as a direct dependency -->
55-
<dependency>
56-
<groupId>junit</groupId>
57-
<artifactId>junit</artifactId>
58-
<scope>runtime</scope>
59-
</dependency>
6054
<!-- Adding hadoop-annotations so we can make it optional to remove from our transitive tree -->
6155
<dependency>
6256
<groupId>org.apache.hadoop</groupId>
@@ -629,6 +623,10 @@
629623
<groupId>jakarta.servlet</groupId>
630624
<artifactId>jakarta.servlet-api</artifactId>
631625
</exclusion>
626+
<exclusion>
627+
<artifactId>junit-jupiter</artifactId>
628+
<groupId>org.junit.jupiter</groupId>
629+
</exclusion>
632630
</exclusions>
633631
<optional>true</optional>
634632
</dependency>
@@ -640,6 +638,10 @@
640638
<groupId>jakarta.ws.rs</groupId>
641639
<artifactId>jakarta.ws.rs-api</artifactId>
642640
</exclusion>
641+
<exclusion>
642+
<artifactId>junit-jupiter</artifactId>
643+
<groupId>org.junit.jupiter</groupId>
644+
</exclusion>
643645
</exclusions>
644646
<optional>true</optional>
645647
</dependency>

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,26 @@
204204
<artifactId>assertj-core</artifactId>
205205
<scope>test</scope>
206206
</dependency>
207+
<dependency>
208+
<groupId>org.junit.jupiter</groupId>
209+
<artifactId>junit-jupiter-api</artifactId>
210+
<scope>test</scope>
211+
</dependency>
212+
<dependency>
213+
<groupId>org.junit.jupiter</groupId>
214+
<artifactId>junit-jupiter-engine</artifactId>
215+
<scope>test</scope>
216+
</dependency>
217+
<dependency>
218+
<groupId>org.junit.jupiter</groupId>
219+
<artifactId>junit-jupiter-params</artifactId>
220+
<scope>test</scope>
221+
</dependency>
222+
<dependency>
223+
<groupId>org.junit.platform</groupId>
224+
<artifactId>junit-platform-launcher</artifactId>
225+
<scope>test</scope>
226+
</dependency>
207227
</dependencies>
208228

209229
<build>

hadoop-common-project/hadoop-auth/src/test/java/org/apache/hadoop/security/authentication/util/TestZookeeperClientCreation.java

Lines changed: 58 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import org.apache.zookeeper.ZooDefs;
2525
import org.apache.zookeeper.client.ZKClientConfig;
2626
import org.apache.zookeeper.common.ClientX509Util;
27-
import org.hamcrest.Matcher;
28-
import org.hamcrest.core.IsNull;
2927
import org.junit.jupiter.api.BeforeEach;
3028
import org.junit.jupiter.api.Test;
3129
import org.mockito.ArgumentCaptor;
@@ -35,10 +33,7 @@
3533

3634
import java.util.Arrays;
3735

38-
import static org.hamcrest.CoreMatchers.anyOf;
39-
import static org.hamcrest.CoreMatchers.containsString;
40-
import static org.hamcrest.CoreMatchers.is;
41-
import static org.hamcrest.MatcherAssert.assertThat;
36+
import static org.assertj.core.api.Assertions.assertThat;
4237
import static org.junit.jupiter.api.Assertions.assertThrows;
4338
import static org.mockito.ArgumentCaptor.forClass;
4439
import static org.mockito.ArgumentMatchers.isA;
@@ -219,14 +214,18 @@ public void testSSLConfiguration() {
219214
verify(cfBuilder).zkClientConfig(clientConfCaptor.capture());
220215
ZKClientConfig conf = clientConfCaptor.getValue();
221216

222-
assertThat(conf.getProperty(ZKClientConfig.SECURE_CLIENT), is("true"));
223-
assertThat(conf.getProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET),
224-
is("org.apache.zookeeper.ClientCnxnSocketNetty"));
217+
assertThat(conf.getProperty(ZKClientConfig.SECURE_CLIENT)).isEqualTo("true");
218+
assertThat(conf.getProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET))
219+
.isEqualTo("org.apache.zookeeper.ClientCnxnSocketNetty");
225220
try (ClientX509Util sslOpts = new ClientX509Util()) {
226-
assertThat(conf.getProperty(sslOpts.getSslKeystoreLocationProperty()), is("keystoreLoc"));
227-
assertThat(conf.getProperty(sslOpts.getSslKeystorePasswdProperty()), is("ksPass"));
228-
assertThat(conf.getProperty(sslOpts.getSslTruststoreLocationProperty()), is("truststoreLoc"));
229-
assertThat(conf.getProperty(sslOpts.getSslTruststorePasswdProperty()), is("tsPass"));
221+
assertThat(conf.getProperty(sslOpts.getSslKeystoreLocationProperty()))
222+
.isEqualTo("keystoreLoc");
223+
assertThat(conf.getProperty(sslOpts.getSslKeystorePasswdProperty()))
224+
.isEqualTo("ksPass");
225+
assertThat(conf.getProperty(sslOpts.getSslTruststoreLocationProperty()))
226+
.isEqualTo("truststoreLoc");
227+
assertThat(conf.getProperty(sslOpts.getSslTruststorePasswdProperty()))
228+
.isEqualTo("tsPass");
230229
}
231230

232231
verifyDummyConnectionString();
@@ -244,39 +243,39 @@ public void testNoConnectionString(){
244243
clientConfigurer.withConnectionString(null);
245244

246245
Throwable t = assertThrows(NullPointerException.class, () -> clientConfigurer.create());
247-
assertThat(t.getMessage(), containsString("Zookeeper connection string cannot be null!"));
246+
assertThat(t.getMessage()).contains("Zookeeper connection string cannot be null!");
248247
}
249248

250249
@Test
251250
public void testNoRetryPolicy() {
252251
clientConfigurer.withRetryPolicy(null);
253252

254253
Throwable t = assertThrows(NullPointerException.class, () -> clientConfigurer.create());
255-
assertThat(t.getMessage(), containsString("Zookeeper connection retry policy cannot be null!"));
254+
assertThat(t.getMessage()).contains("Zookeeper connection retry policy cannot be null!");
256255
}
257256

258257
@Test
259258
public void testNoAuthType() {
260259
clientConfigurer.withAuthType(null);
261260

262261
Throwable t = assertThrows(NullPointerException.class, () -> clientConfigurer.create());
263-
assertThat(t.getMessage(), containsString("Zookeeper authType cannot be null!"));
262+
assertThat(t.getMessage()).contains("Zookeeper authType cannot be null!");
264263
}
265264

266265
@Test
267266
public void testUnrecognizedAuthType() {
268267
clientConfigurer.withAuthType("something");
269268

270269
Throwable t = assertThrows(IllegalArgumentException.class, () -> clientConfigurer.create());
271-
assertThat(t.getMessage(), is("Zookeeper authType must be one of [none, sasl]!"));
270+
assertThat(t.getMessage()).isEqualTo("Zookeeper authType must be one of [none, sasl]!");
272271
}
273272

274273
@Test
275274
public void testSaslAuthTypeWithoutKeytab() {
276275
clientConfigurer.withAuthType("sasl");
277276

278277
Throwable t = assertThrows(IllegalArgumentException.class, () -> clientConfigurer.create());
279-
assertThat(t.getMessage(), is("Zookeeper client's Kerberos Keytab must be specified!"));
278+
assertThat(t.getMessage()).isEqualTo("Zookeeper client's Kerberos Keytab must be specified!");
280279
}
281280

282281
@Test
@@ -286,7 +285,8 @@ public void testSaslAuthTypeWithEmptyKeytab() {
286285
.withKeytab("");
287286

288287
Throwable t = assertThrows(IllegalArgumentException.class, () -> clientConfigurer.create());
289-
assertThat(t.getMessage(), is("Zookeeper client's Kerberos Keytab must be specified!"));
288+
289+
assertThat(t.getMessage()).isEqualTo("Zookeeper client's Kerberos Keytab must be specified!");
290290
}
291291

292292
@Test
@@ -296,7 +296,7 @@ public void testSaslAuthTypeWithoutPrincipal() {
296296
.withKeytab("keytabLoc");
297297

298298
Throwable t = assertThrows(IllegalArgumentException.class, () -> clientConfigurer.create());
299-
assertThat(t.getMessage(), is("Zookeeper client's Kerberos Principal must be specified!"));
299+
assertThat(t.getMessage()).isEqualTo("Zookeeper client's Kerberos Principal must be specified!");
300300
}
301301

302302
@Test
@@ -307,7 +307,7 @@ public void testSaslAuthTypeWithEmptyPrincipal() {
307307
.withPrincipal("");
308308

309309
Throwable t = assertThrows(IllegalArgumentException.class, () -> clientConfigurer.create());
310-
assertThat(t.getMessage(), is("Zookeeper client's Kerberos Principal must be specified!"));
310+
assertThat(t.getMessage()).isEqualTo("Zookeeper client's Kerberos Principal must be specified!");
311311
}
312312

313313
@Test
@@ -319,7 +319,7 @@ public void testSaslAuthTypeWithoutJaasLoginEntryName() {
319319
.withJaasLoginEntryName(null);
320320

321321
Throwable t = assertThrows(IllegalArgumentException.class, () -> clientConfigurer.create());
322-
assertThat(t.getMessage(), is("JAAS Login Entry name must be specified!"));
322+
assertThat(t.getMessage()).isEqualTo("JAAS Login Entry name must be specified!");
323323
}
324324

325325
@Test
@@ -331,7 +331,7 @@ public void testSaslAuthTypeWithEmptyJaasLoginEntryName() {
331331
.withJaasLoginEntryName("");
332332

333333
Throwable t = assertThrows(IllegalArgumentException.class, () -> clientConfigurer.create());
334-
assertThat(t.getMessage(), is("JAAS Login Entry name must be specified!"));
334+
assertThat(t.getMessage()).isEqualTo("JAAS Login Entry name must be specified!");
335335
}
336336

337337
@Test
@@ -340,8 +340,7 @@ public void testSSLWithoutKeystore() {
340340
.enableSSL(true);
341341

342342
Throwable t = assertThrows(IllegalArgumentException.class, () -> clientConfigurer.create());
343-
assertThat(t.getMessage(),
344-
is("The keystore location parameter is empty for the ZooKeeper client connection."));
343+
assertThat(t.getMessage()).isEqualTo("The keystore location parameter is empty for the ZooKeeper client connection.");
345344
}
346345

347346
@Test
@@ -351,8 +350,7 @@ public void testSSLWithEmptyKeystore() {
351350
.withKeystore("");
352351

353352
Throwable t = assertThrows(IllegalArgumentException.class, () -> clientConfigurer.create());
354-
assertThat(t.getMessage(),
355-
is("The keystore location parameter is empty for the ZooKeeper client connection."));
353+
assertThat(t.getMessage()).isEqualTo("The keystore location parameter is empty for the ZooKeeper client connection.");
356354
}
357355

358356
@Test
@@ -362,8 +360,7 @@ public void testSSLWithoutTruststore() {
362360
.withKeystore("keyStoreLoc");
363361

364362
Throwable t = assertThrows(IllegalArgumentException.class, () -> clientConfigurer.create());
365-
assertThat(t.getMessage(),
366-
is("The truststore location parameter is empty for the ZooKeeper client connection."));
363+
assertThat(t.getMessage()).isEqualTo("The truststore location parameter is empty for the ZooKeeper client connection.");
367364
}
368365

369366
@Test
@@ -374,8 +371,7 @@ public void testSSLWithEmptyTruststore() {
374371
.withTruststore("");
375372

376373
Throwable t = assertThrows(IllegalArgumentException.class, () -> clientConfigurer.create());
377-
assertThat(t.getMessage(),
378-
is("The truststore location parameter is empty for the ZooKeeper client connection."));
374+
assertThat(t.getMessage()).isEqualTo("The truststore location parameter is empty for the ZooKeeper client connection.");
379375
}
380376

381377
private void testSaslAuthType(String vendor) {
@@ -395,36 +391,37 @@ private void testSaslAuthType(String vendor) {
395391
verify(cfBuilder).aclProvider(aclProviderCaptor.capture());
396392
SASLOwnerACLProvider aclProvider = aclProviderCaptor.getValue();
397393

398-
assertThat(aclProvider.getDefaultAcl().size(), is(1));
399-
assertThat(aclProvider.getDefaultAcl().get(0).getId().getScheme(), is("sasl"));
400-
assertThat(aclProvider.getDefaultAcl().get(0).getId().getId(), is("principal"));
401-
assertThat(aclProvider.getDefaultAcl().get(0).getPerms(), is(ZooDefs.Perms.ALL));
394+
assertThat(aclProvider.getDefaultAcl().size()).isEqualTo(1);
395+
assertThat(aclProvider.getDefaultAcl().get(0).getId().getScheme()).isEqualTo("sasl");
396+
assertThat(aclProvider.getDefaultAcl().get(0).getId().getId()).isEqualTo("principal");
397+
assertThat(aclProvider.getDefaultAcl().get(0).getPerms()).isEqualTo(ZooDefs.Perms.ALL);
402398

403399
Arrays.stream(new String[] {"/", "/foo", "/foo/bar/baz", "/random/path"})
404400
.forEach(s -> {
405-
assertThat(aclProvider.getAclForPath(s).size(), is(1));
406-
assertThat(aclProvider.getAclForPath(s).get(0).getId().getScheme(), is("sasl"));
407-
assertThat(aclProvider.getAclForPath(s).get(0).getId().getId(), is("principal"));
408-
assertThat(aclProvider.getAclForPath(s).get(0).getPerms(), is(ZooDefs.Perms.ALL));
401+
assertThat(aclProvider.getAclForPath(s).size()).isEqualTo(1);
402+
assertThat(aclProvider.getAclForPath(s).get(0).getId().getScheme()).isEqualTo("sasl");
403+
assertThat(aclProvider.getAclForPath(s).get(0).getId().getId()).isEqualTo("principal");
404+
assertThat(aclProvider.getAclForPath(s).get(0).getPerms()).isEqualTo(ZooDefs.Perms.ALL);
409405
});
410406

411-
assertThat(System.getProperty(ZKClientConfig.LOGIN_CONTEXT_NAME_KEY), is("TestEntry"));
412-
assertThat(System.getProperty("zookeeper.authProvider.1"),
413-
is("org.apache.zookeeper.server.auth.SASLAuthenticationProvider"));
407+
assertThat(System.getProperty(ZKClientConfig.LOGIN_CONTEXT_NAME_KEY)).isEqualTo("TestEntry");
408+
assertThat(System.getProperty("zookeeper.authProvider.1")).isEqualTo(
409+
"org.apache.zookeeper.server.auth.SASLAuthenticationProvider");
414410

415411
Configuration config = Configuration.getConfiguration();
416-
assertThat(config.getAppConfigurationEntry("TestEntry").length, is(1));
412+
assertThat(config.getAppConfigurationEntry("TestEntry").length).isEqualTo(1);
417413
AppConfigurationEntry entry = config.getAppConfigurationEntry("TestEntry")[0];
418-
assertThat(entry.getOptions().get("keyTab"), is("keytabLoc"));
419-
assertThat(entry.getOptions().get("principal"), is("principal@some.host/SOME.REALM"));
420-
assertThat(entry.getOptions().get("useKeyTab"), is("true"));
421-
assertThat(entry.getOptions().get("storeKey"), is("true"));
422-
assertThat(entry.getOptions().get("useTicketCache"), is("false"));
423-
assertThat(entry.getOptions().get("refreshKrb5Config"), is("true"));
414+
assertThat(entry.getOptions().get("keyTab")).isEqualTo("keytabLoc");
415+
assertThat(entry.getOptions().get("principal")).isEqualTo("principal@some.host/SOME.REALM");
416+
assertThat(entry.getOptions().get("useKeyTab")).isEqualTo("true");
417+
assertThat(entry.getOptions().get("storeKey")).isEqualTo("true");
418+
assertThat(entry.getOptions().get("useTicketCache")).isEqualTo("false");
419+
assertThat(entry.getOptions().get("refreshKrb5Config")).isEqualTo("true");
420+
424421
if (System.getProperty("java.vendor").contains("IBM")){
425-
assertThat(entry.getLoginModuleName(), is("com.ibm.security.auth.module.Krb5LoginModule"));
422+
assertThat(entry.getLoginModuleName()).isEqualTo("com.ibm.security.auth.module.Krb5LoginModule");
426423
} else {
427-
assertThat(entry.getLoginModuleName(), is("com.sun.security.auth.module.Krb5LoginModule"));
424+
assertThat(entry.getLoginModuleName()).isEqualTo("com.sun.security.auth.module.Krb5LoginModule");
428425
}
429426
} finally {
430427
Configuration.setConfiguration(origConf);
@@ -465,8 +462,8 @@ private void verifyDefaultRetryPolicy() {
465462
verify(cfBuilder).retryPolicy(retry.capture());
466463
ExponentialBackoffRetry policy = retry.getValue();
467464

468-
assertThat(policy.getBaseSleepTimeMs(), is(1000));
469-
assertThat(policy.getN(), is(3));
465+
assertThat(policy.getBaseSleepTimeMs()).isEqualTo(1000);
466+
assertThat(policy.getN()).isEqualTo(3);
470467
}
471468

472469
private void verifyDefaultAclProvider() {
@@ -478,21 +475,16 @@ private void verifyDefaultZKClientConfig() {
478475
verify(cfBuilder).zkClientConfig(clientConfCaptor.capture());
479476
ZKClientConfig conf = clientConfCaptor.getValue();
480477

481-
assertThat(conf.getProperty(ZKClientConfig.SECURE_CLIENT), isEmptyOrFalse());
478+
assertThat(conf.getProperty(ZKClientConfig.SECURE_CLIENT))
479+
.satisfiesAnyOf(value -> assertThat(value).isNullOrEmpty(),
480+
value -> assertThat(value).isEqualTo("false"));
481+
482482
try (ClientX509Util sslOpts = new ClientX509Util()) {
483-
assertThat(conf.getProperty(sslOpts.getSslKeystoreLocationProperty()), isEmpty());
484-
assertThat(conf.getProperty(sslOpts.getSslKeystorePasswdProperty()), isEmpty());
485-
assertThat(conf.getProperty(sslOpts.getSslTruststoreLocationProperty()), isEmpty());
486-
assertThat(conf.getProperty(sslOpts.getSslTruststorePasswdProperty()), isEmpty());
483+
assertThat(conf.getProperty(sslOpts.getSslKeystoreLocationProperty())).isNullOrEmpty();
484+
assertThat(conf.getProperty(sslOpts.getSslKeystorePasswdProperty())).isNullOrEmpty();
485+
assertThat(conf.getProperty(sslOpts.getSslTruststoreLocationProperty())).isNullOrEmpty();
486+
assertThat(conf.getProperty(sslOpts.getSslTruststorePasswdProperty())).isNullOrEmpty();
487487
}
488488
}
489489

490-
private Matcher<String> isEmptyOrFalse() {
491-
return anyOf(isEmpty(), is("false"));
492-
}
493-
494-
private Matcher<String> isEmpty() {
495-
return anyOf(new IsNull<>(), is(""));
496-
}
497-
498490
}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@
4343
<artifactId>slf4j-reload4j</artifactId>
4444
<scope>compile</scope>
4545
</dependency>
46-
<dependency>
47-
<groupId>junit</groupId>
48-
<artifactId>junit</artifactId>
49-
<scope>compile</scope>
50-
</dependency>
5146
<dependency>
5247
<groupId>org.assertj</groupId>
5348
<artifactId>assertj-core</artifactId>

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/diskbalancer/DiskBalancerResultVerifier.java

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)