Skip to content

Commit 0b05102

Browse files
zhtttylzslfan1989
andauthored
HADOOP-19415. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-common Part13. (#7944)
* HADOOP-19415. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-common Part13. Co-authored-by: Shilun Fan <[email protected]> Reviewed-by: Shilun Fan <[email protected]> Signed-off-by: Shilun Fan <[email protected]>
1 parent 171ad67 commit 0b05102

File tree

7 files changed

+16
-29
lines changed

7 files changed

+16
-29
lines changed

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/crypto/key/TestKeyProviderCryptoExtension.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.ArrayList;
2626
import java.util.Arrays;
2727
import java.util.List;
28-
import java.util.concurrent.TimeUnit;
2928

3029
import javax.crypto.Cipher;
3130
import javax.crypto.spec.IvParameterSpec;
@@ -34,9 +33,8 @@
3433
import org.apache.hadoop.conf.Configuration;
3534
import org.apache.hadoop.crypto.key.KeyProviderCryptoExtension.EncryptedKeyVersion;
3635
import org.junit.jupiter.api.BeforeAll;
37-
import org.junit.Rule;
3836
import org.junit.jupiter.api.Test;
39-
import org.junit.rules.Timeout;
37+
import org.junit.jupiter.api.Timeout;
4038

4139
import static org.apache.hadoop.crypto.key.KeyProvider.KeyVersion;
4240
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
@@ -46,6 +44,7 @@
4644
import static org.junit.jupiter.api.Assertions.assertTrue;
4745
import static org.junit.jupiter.api.Assertions.fail;
4846

47+
@Timeout(180)
4948
public class TestKeyProviderCryptoExtension {
5049

5150
private static final String CIPHER = "AES";
@@ -57,9 +56,6 @@ public class TestKeyProviderCryptoExtension {
5756
private static KeyProvider.Options options;
5857
private static KeyVersion encryptionKey;
5958

60-
@Rule
61-
public Timeout testTimeout = new Timeout(180000, TimeUnit.MILLISECONDS);
62-
6359
@BeforeAll
6460
public static void setup() throws Exception {
6561
conf = new Configuration();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import static org.junit.jupiter.api.Assertions.assertFalse;
2323
import static org.junit.jupiter.api.Assertions.assertTrue;
2424
import static org.junit.jupiter.api.Assertions.fail;
25-
import static org.junit.Assume.assumeTrue;
25+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
2626

2727
import java.io.File;
2828
import java.io.FileNotFoundException;

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/shell/find/TestResult.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,12 @@
1919

2020
import static org.junit.jupiter.api.Assertions.*;
2121

22-
import org.junit.Rule;
23-
import org.junit.rules.Timeout;
2422
import org.junit.jupiter.api.Test;
23+
import org.junit.jupiter.api.Timeout;
2524

26-
import java.util.concurrent.TimeUnit;
27-
25+
@Timeout(10)
2826
public class TestResult {
2927

30-
@Rule
31-
public Timeout globalTimeout = new Timeout(10000, TimeUnit.MILLISECONDS);
32-
3328
// test the PASS value
3429
@Test
3530
public void testPass() {

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/ipc/TestProtoBufRpc.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
import static org.apache.hadoop.test.MetricsAsserts.getMetrics;
5454
import static org.assertj.core.api.Assertions.assertThat;
5555
import static org.junit.jupiter.api.Assertions.fail;
56-
import static org.junit.Assume.assumeFalse;
56+
import static org.junit.jupiter.api.Assumptions.assumeFalse;
5757

5858
/**
5959
* Test for testing protocol buffer based RPC mechanism.

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestJNIGroupsMapping.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
* limitations under the License.
1717
*/
1818
package org.apache.hadoop.security;
19-
import static org.junit.Assume.assumeTrue;
2019
import static org.junit.jupiter.api.Assertions.fail;
20+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
2121

2222
import java.util.Arrays;
2323
import java.util.List;

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/authorize/TestDefaultImpersonationProvider.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,14 @@
2424
import org.apache.hadoop.test.LambdaTestUtils;
2525
import org.junit.jupiter.api.AfterEach;
2626
import org.junit.jupiter.api.BeforeEach;
27-
import org.junit.Rule;
2827
import org.junit.jupiter.api.Test;
29-
import org.junit.rules.Timeout;
28+
import org.junit.jupiter.api.Timeout;
3029
import org.mockito.Mockito;
3130

32-
import java.util.concurrent.TimeUnit;
33-
3431
/**
3532
* Test class for @DefaultImpersonationProvider
3633
*/
34+
@Timeout(10)
3735
public class TestDefaultImpersonationProvider {
3836

3937
private String proxyUser;
@@ -44,8 +42,6 @@ public class TestDefaultImpersonationProvider {
4442
private UserGroupInformation realUserUGI = Mockito
4543
.mock(UserGroupInformation.class);
4644
private Configuration conf;
47-
@Rule
48-
public Timeout globalTimeout = new Timeout(10000, TimeUnit.MILLISECONDS);
4945

5046
@BeforeEach
5147
public void setup() {

hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/ssl/TestDelegatingSSLSocketFactory.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.apache.hadoop.util.NativeCodeLoader;
2727

2828
import static org.assertj.core.api.Assertions.assertThat;
29-
import static org.junit.Assume.assumeTrue;
29+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
3030

3131
/**
3232
* Tests for {@link DelegatingSSLSocketFactory}.
@@ -35,10 +35,10 @@ public class TestDelegatingSSLSocketFactory {
3535

3636
@Test
3737
public void testOpenSSL() throws IOException {
38-
assumeTrue("Unable to load native libraries",
39-
NativeCodeLoader.isNativeCodeLoaded());
40-
assumeTrue("Build was not compiled with support for OpenSSL",
41-
NativeCodeLoader.buildSupportsOpenssl());
38+
assumeTrue(NativeCodeLoader.isNativeCodeLoaded(),
39+
"Unable to load native libraries");
40+
assumeTrue(NativeCodeLoader.buildSupportsOpenssl(),
41+
"Build was not compiled with support for OpenSSL");
4242
DelegatingSSLSocketFactory.initializeDefaultFactory(
4343
DelegatingSSLSocketFactory.SSLChannelMode.OpenSSL);
4444
assertThat(DelegatingSSLSocketFactory.getDefaultFactory()
@@ -47,8 +47,8 @@ public void testOpenSSL() throws IOException {
4747

4848
@Test
4949
public void testJSEENoGCMJava8() throws IOException {
50-
assumeTrue("Not running on Java 8",
51-
System.getProperty("java.version").startsWith("1.8"));
50+
assumeTrue(System.getProperty("java.version").startsWith("1.8"),
51+
"Not running on Java 8");
5252
DelegatingSSLSocketFactory.initializeDefaultFactory(
5353
DelegatingSSLSocketFactory.SSLChannelMode.Default_JSSE);
5454
assertThat(Arrays.stream(DelegatingSSLSocketFactory.getDefaultFactory()

0 commit comments

Comments
 (0)