Skip to content

Commit 991382a

Browse files
HADOOP-19425. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-azure Part3. (#7674)
* HADOOP-19425. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-azure Part3. Co-authored-by: Anuj Modi <[email protected]> Reviewed-by: Anuj Modi <[email protected]> Signed-off-by: Shilun Fan <[email protected]>
1 parent 744088a commit 991382a

File tree

112 files changed

+1804
-1814
lines changed

Some content is hidden

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

112 files changed

+1804
-1814
lines changed

hadoop-tools/hadoop-azure/pom.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,6 @@
214214
<scope>provided</scope>
215215
</dependency>
216216

217-
<!-- dependencies use for test only -->
218-
<dependency>
219-
<groupId>junit</groupId>
220-
<artifactId>junit</artifactId>
221-
<scope>test</scope>
222-
</dependency>
223-
224217
<dependency>
225218
<groupId>org.apache.hadoop</groupId>
226219
<artifactId>hadoop-common</artifactId>
@@ -367,11 +360,6 @@
367360
<artifactId>junit-jupiter-params</artifactId>
368361
<scope>test</scope>
369362
</dependency>
370-
<dependency>
371-
<groupId>org.junit.platform</groupId>
372-
<artifactId>junit-platform-launcher</artifactId>
373-
<scope>test</scope>
374-
</dependency>
375363
<dependency>
376364
<groupId>org.junit.vintage</groupId>
377365
<artifactId>junit-vintage-engine</artifactId>

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/AbstractWasbTestWithTimeout.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
import java.util.concurrent.TimeUnit;
3030

31-
import static org.junit.jupiter.api.Assumptions.assumeTrue;
31+
import static org.assertj.core.api.Assumptions.assumeThat;
3232

3333
/**
3434
* Base class for any Wasb test with timeouts & named threads.
@@ -69,10 +69,10 @@ protected int getTestTimeoutMillis() {
6969
}
7070

7171
public static void assumeNotNull(Object objects) {
72-
assumeTrue(objects != null);
72+
assumeThat(objects).isNotNull();
7373
}
7474

7575
public static void assumeNotNull(Object objects, String message) {
76-
assumeTrue(objects != null, message);
76+
assumeThat(objects).as(message).isNotNull();
7777
}
7878
}

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/ITestContainerChecks.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
package org.apache.hadoop.fs.azure;
2020

21-
import static org.junit.jupiter.api.Assumptions.assumeFalse;
21+
import static org.assertj.core.api.Assumptions.assumeThat;
2222

2323
import java.io.FileNotFoundException;
2424
import java.util.EnumSet;
@@ -169,7 +169,7 @@ public String call() throws Exception {
169169
@Test
170170
public void testContainerChecksWithSas() throws Exception {
171171

172-
assumeFalse(runningInSASMode);
172+
assumeThat(runningInSASMode).isFalse();
173173
testAccount = AzureBlobStorageTestAccount.create("",
174174
EnumSet.of(CreateOptions.UseSas));
175175
assumeNotNull(testAccount);

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/ITestListPerformance.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
import org.apache.hadoop.fs.azure.integration.AzureTestUtils;
4949
import org.apache.hadoop.fs.contract.ContractTestUtils;
5050

51-
import static org.junit.jupiter.api.Assumptions.assumeFalse;
51+
import static org.assertj.core.api.Assumptions.assumeThat;
5252

5353
/**
5454
* Test list performance.
@@ -99,7 +99,7 @@ protected AzureBlobStorageTestAccount createTestAccount() throws Exception {
9999

100100
@Test
101101
public void test_0101_CreateDirectoryWithFiles() throws Exception {
102-
assumeFalse(fs.exists(TEST_DIR_PATH), "Test path exists; skipping");
102+
assumeThat(fs.exists(TEST_DIR_PATH)).as("Test path exists; skipping").isFalse();
103103

104104
ExecutorService executorService = Executors.newFixedThreadPool(threads);
105105
CloudBlobContainer container = testAccount.getRealContainer();

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/ITestNativeAzureFileSystemContractEmulator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
package org.apache.hadoop.fs.azure;
2020

21-
import static org.junit.jupiter.api.Assumptions.assumeTrue;
21+
import static org.assertj.core.api.Assumptions.assumeThat;
2222

2323
import org.apache.hadoop.fs.FileSystemContractBaseTest;
2424
import org.apache.hadoop.fs.Path;
@@ -50,7 +50,9 @@ public void setUp() throws Exception {
5050
if (testAccount != null) {
5151
fs = testAccount.getFileSystem();
5252
}
53-
assumeTrue(fs != null);
53+
assumeThat(fs)
54+
.as("FileSystem must not be null for this test")
55+
.isNotNull();
5456
basePath = fs.makeQualified(
5557
AzureTestUtils.createTestPath(
5658
new Path("ITestNativeAzureFileSystemContractEmulator")));

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/ITestNativeAzureFileSystemContractLive.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
package org.apache.hadoop.fs.azure;
2020

21-
import static org.junit.jupiter.api.Assumptions.assumeTrue;
21+
import static org.assertj.core.api.Assumptions.assumeThat;
2222

2323
import org.apache.hadoop.fs.FileSystemContractBaseTest;
2424
import org.apache.hadoop.fs.Path;
@@ -53,7 +53,7 @@ public void setUp() throws Exception {
5353
if (testAccount != null) {
5454
fs = testAccount.getFileSystem();
5555
}
56-
assumeTrue(fs != null);
56+
assumeThat(fs).isNotNull();
5757
basePath = fs.makeQualified(
5858
AzureTestUtils.createTestPath(
5959
new Path("NativeAzureFileSystemContractLive")));

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/ITestNativeAzureFileSystemContractPageBlobLive.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
package org.apache.hadoop.fs.azure;
2020

21-
import static org.junit.jupiter.api.Assumptions.assumeTrue;
21+
import static org.assertj.core.api.Assumptions.assumeThat;
2222

2323
import org.apache.hadoop.conf.Configuration;
2424
import org.apache.hadoop.fs.FileSystemContractBaseTest;
@@ -63,7 +63,7 @@ private AzureBlobStorageTestAccount createTestAccount()
6363
@BeforeEach
6464
public void setUp() throws Exception {
6565
testAccount = createTestAccount();
66-
assumeTrue(testAccount != null);
66+
assumeThat(testAccount).isNotNull();
6767
fs = testAccount.getFileSystem();
6868
basePath = AzureTestUtils.pathForTests(fs, "filesystemcontractpageblob");
6969
}

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/ITestWasbRemoteCallHelper.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
import static org.mockito.Mockito.atLeast;
4848
import static org.mockito.Mockito.times;
4949

50-
import static org.junit.jupiter.api.Assumptions.assumeTrue;
50+
import static org.assertj.core.api.Assumptions.assumeThat;
5151

5252
/**
5353
* Test class to hold all WasbRemoteCallHelper tests.
@@ -72,8 +72,9 @@ public void setUp() throws Exception {
7272
boolean useSecureMode = fs.getConf().getBoolean(KEY_USE_SECURE_MODE, false);
7373
boolean useAuthorization = fs.getConf()
7474
.getBoolean(NativeAzureFileSystem.KEY_AZURE_AUTHORIZATION, false);
75-
assumeTrue(useSecureMode && useAuthorization,
76-
"Test valid when both SecureMode and Authorization are enabled .. skipping");
75+
assumeThat(useSecureMode && useAuthorization)
76+
.as("Test valid when both SecureMode and Authorization are enabled .. skipping")
77+
.isTrue();
7778
}
7879

7980
/**

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/ITestWasbUriAndConfiguration.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY;
2222
import static org.apache.hadoop.fs.azure.NativeAzureFileSystem.RETURN_URI_AS_CANONICAL_SERVICE_NAME_PROPERTY_NAME;
2323
import static org.apache.hadoop.test.LambdaTestUtils.intercept;
24-
import static org.junit.jupiter.api.Assumptions.assumeFalse;
24+
import static org.assertj.core.api.Assumptions.assumeThat;
2525

2626
import java.io.ByteArrayInputStream;
2727
import java.io.DataInputStream;
@@ -132,7 +132,7 @@ public void testConnectUsingKey() throws Exception {
132132
@Test
133133
public void testConnectUsingSAS() throws Exception {
134134

135-
assumeFalse(runningInSASMode);
135+
assumeThat(runningInSASMode).isFalse();
136136
// Create the test account with SAS credentials.
137137
testAccount = AzureBlobStorageTestAccount.create("",
138138
EnumSet.of(CreateOptions.UseSas, CreateOptions.CreateContainer));
@@ -148,7 +148,7 @@ public void testConnectUsingSAS() throws Exception {
148148
@Test
149149
public void testConnectUsingSASReadonly() throws Exception {
150150

151-
assumeFalse(runningInSASMode);
151+
assumeThat(runningInSASMode).isFalse();
152152
// Create the test account with SAS credentials.
153153
testAccount = AzureBlobStorageTestAccount.create("", EnumSet.of(
154154
CreateOptions.UseSas, CreateOptions.CreateContainer,
@@ -378,7 +378,7 @@ public void testDefaultKeyProvider() throws Exception {
378378
public void testCredsFromCredentialProvider(@TempDir java.nio.file.Path tempDir)
379379
throws Exception {
380380

381-
assumeFalse(runningInSASMode);
381+
assumeThat(runningInSASMode).isFalse();
382382
String account = "testacct";
383383
String key = "testkey";
384384
// set up conf to have a cred provider

hadoop-tools/hadoop-azure/src/test/java/org/apache/hadoop/fs/azure/TestNativeAzureFileSystemAuthorization.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.apache.hadoop.security.UserGroupInformation;
3939
import org.apache.hadoop.test.GenericTestUtils;
4040
import org.apache.hadoop.test.LambdaTestUtils;
41-
import org.apache.hadoop.util.StringUtils;
4241

4342
import org.junit.jupiter.api.BeforeEach;
4443
import org.junit.jupiter.api.Test;
@@ -48,7 +47,7 @@
4847
import static org.apache.hadoop.fs.azure.AzureNativeFileSystemStore.KEY_USE_SECURE_MODE;
4948
import static org.apache.hadoop.fs.azure.CachingAuthorizer.KEY_AUTH_SERVICE_CACHING_ENABLE;
5049
import static org.apache.hadoop.fs.contract.ContractTestUtils.*;
51-
import static org.junit.jupiter.api.Assumptions.assumeTrue;
50+
import static org.assertj.core.api.Assumptions.assumeThat;
5251

5352
/**
5453
* Test class to hold all WASB authorization tests.
@@ -92,8 +91,9 @@ public void setUp() throws Exception {
9291
super.setUp();
9392
boolean useSecureMode = fs.getConf().getBoolean(KEY_USE_SECURE_MODE, false);
9493
boolean useAuthorization = fs.getConf().getBoolean(NativeAzureFileSystem.KEY_AZURE_AUTHORIZATION, false);
95-
assumeTrue((useSecureMode && useAuthorization),
96-
"Test valid when both SecureMode and Authorization are enabled .. skipping");
94+
assumeThat((useSecureMode && useAuthorization))
95+
.as("Test valid when both SecureMode and Authorization are enabled .. skipping")
96+
.isTrue();
9797

9898
authorizer = new MockWasbAuthorizerImpl(fs);
9999
authorizer.init(fs.getConf());
@@ -1544,8 +1544,9 @@ public void testSetOwnerSucceedsForAuthorisedUsers() throws Throwable {
15441544
ContractTestUtils.assertPathExists(fs, "test path does not exist", testPath);
15451545

15461546
String owner = fs.getFileStatus(testPath).getOwner();
1547-
assumeTrue(!StringUtils.equalsIgnoreCase(owner, newOwner),
1548-
"changing owner requires original and new owner to be different");
1547+
assumeThat(owner)
1548+
.as("changing owner requires original and new owner to be different")
1549+
.isNotEqualToIgnoringCase(newOwner);
15491550

15501551
authorisedUser.doAs(new PrivilegedExceptionAction<Void>() {
15511552
@Override
@@ -1587,8 +1588,9 @@ public void testSetOwnerSucceedsForAnyUserWhenWildCardIsSpecified() throws Throw
15871588
ContractTestUtils.assertPathExists(fs, "test path does not exist", testPath);
15881589

15891590
String owner = fs.getFileStatus(testPath).getOwner();
1590-
assumeTrue(!StringUtils.equalsIgnoreCase(owner, newOwner),
1591-
"changing owner requires original and new owner to be different");
1591+
assumeThat(owner)
1592+
.as("changing owner requires original and new owner to be different")
1593+
.isNotEqualToIgnoringCase(newOwner);
15921594

15931595
user.doAs(new PrivilegedExceptionAction<Void>() {
15941596
@Override

0 commit comments

Comments
 (0)