Skip to content

Commit 389c6a6

Browse files
committed
HADOOP-19426. [JDK17] Upgrade JUnit from 4 to 5 in hadoop-azure-datalake.
1 parent 72939fe commit 389c6a6

13 files changed

+121
-121
lines changed

hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/TestAzureADTokenProvider.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@
4444
.AZURE_AD_TOKEN_PROVIDER_TYPE_KEY;
4545
import static org.apache.hadoop.fs.adl.AdlConfKeys.DEVICE_CODE_CLIENT_APP_ID;
4646
import static org.apache.hadoop.fs.adl.TokenProviderType.*;
47-
import static org.junit.Assert.assertEquals;
47+
import static org.junit.jupiter.api.Assertions.assertEquals;
4848

4949
import org.apache.hadoop.security.ProviderUtils;
5050
import org.apache.hadoop.security.alias.CredentialProvider;
5151
import org.apache.hadoop.security.alias.CredentialProviderFactory;
5252
import org.apache.hadoop.test.GenericTestUtils;
53-
import org.junit.Assert;
53+
import org.junit.jupiter.api.Assertions;
5454
import org.junit.Rule;
55-
import org.junit.Test;
55+
import org.junit.jupiter.api.Test;
5656
import org.junit.rules.TemporaryFolder;
5757

5858
/**
@@ -81,7 +81,7 @@ public void testRefreshTokenProvider()
8181
AdlFileSystem fileSystem = new AdlFileSystem();
8282
fileSystem.initialize(uri, conf);
8383
AccessTokenProvider tokenProvider = fileSystem.getTokenProvider();
84-
Assert.assertTrue(tokenProvider instanceof RefreshTokenBasedTokenProvider);
84+
Assertions.assertTrue(tokenProvider instanceof RefreshTokenBasedTokenProvider);
8585
}
8686

8787
@Test
@@ -97,7 +97,7 @@ public void testClientCredTokenProvider()
9797
AdlFileSystem fileSystem = new AdlFileSystem();
9898
fileSystem.initialize(uri, conf);
9999
AccessTokenProvider tokenProvider = fileSystem.getTokenProvider();
100-
Assert.assertTrue(tokenProvider instanceof ClientCredsTokenProvider);
100+
Assertions.assertTrue(tokenProvider instanceof ClientCredsTokenProvider);
101101
}
102102

103103
@Test
@@ -110,7 +110,7 @@ public void testMSITokenProvider()
110110
AdlFileSystem fileSystem = new AdlFileSystem();
111111
fileSystem.initialize(uri, conf);
112112
AccessTokenProvider tokenProvider = fileSystem.getTokenProvider();
113-
Assert.assertTrue(tokenProvider instanceof MsiTokenProvider);
113+
Assertions.assertTrue(tokenProvider instanceof MsiTokenProvider);
114114
}
115115

116116
@Test
@@ -129,7 +129,7 @@ public void testDeviceCodeTokenProvider()
129129
AdlFileSystem fileSystem = new AdlFileSystem();
130130
fileSystem.initialize(uri, conf);
131131
AccessTokenProvider tokenProvider = fileSystem.getTokenProvider();
132-
Assert.assertTrue(tokenProvider instanceof DeviceCodeTokenProvider);
132+
Assertions.assertTrue(tokenProvider instanceof DeviceCodeTokenProvider);
133133
}
134134
}
135135

@@ -145,7 +145,7 @@ public void testCustomCredTokenProvider()
145145
AdlFileSystem fileSystem = new AdlFileSystem();
146146
fileSystem.initialize(uri, conf);
147147
AccessTokenProvider tokenProvider = fileSystem.getTokenProvider();
148-
Assert.assertTrue(tokenProvider instanceof SdkTokenProviderAdapter);
148+
Assertions.assertTrue(tokenProvider instanceof SdkTokenProviderAdapter);
149149
}
150150

151151
@Test
@@ -157,7 +157,7 @@ public void testInvalidProviderConfigurationForType()
157157
AdlFileSystem fileSystem = new AdlFileSystem();
158158
try {
159159
fileSystem.initialize(uri, conf);
160-
Assert.fail("Initialization should have failed due no token provider "
160+
Assertions.fail("Initialization should have failed due no token provider "
161161
+ "configuration");
162162
} catch (IllegalArgumentException e) {
163163
GenericTestUtils.assertExceptionContains(
@@ -179,10 +179,10 @@ public void testInvalidProviderConfigurationForClassPath()
179179
"wrong.classpath.CustomMockTokenProvider");
180180
try {
181181
fileSystem.initialize(uri, conf);
182-
Assert.fail("Initialization should have failed due invalid provider "
182+
Assertions.fail("Initialization should have failed due invalid provider "
183183
+ "configuration");
184184
} catch (RuntimeException e) {
185-
Assert.assertTrue(
185+
Assertions.assertTrue(
186186
e.getMessage().contains("wrong.classpath.CustomMockTokenProvider"));
187187
}
188188
}
@@ -217,7 +217,7 @@ public void testRefreshTokenWithCredentialProvider()
217217
fileSystem.initialize(uri, conf);
218218
RefreshTokenBasedTokenProvider expected =
219219
new RefreshTokenBasedTokenProvider(CLIENT_ID, REFRESH_TOKEN);
220-
Assert.assertTrue(EqualsBuilder.reflectionEquals(expected,
220+
Assertions.assertTrue(EqualsBuilder.reflectionEquals(expected,
221221
fileSystem.getTokenProvider()));
222222
}
223223

@@ -236,7 +236,7 @@ public void testRefreshTokenWithCredentialProviderFallback()
236236
fileSystem.initialize(uri, conf);
237237
RefreshTokenBasedTokenProvider expected =
238238
new RefreshTokenBasedTokenProvider(CLIENT_ID, REFRESH_TOKEN);
239-
Assert.assertTrue(EqualsBuilder.reflectionEquals(expected,
239+
Assertions.assertTrue(EqualsBuilder.reflectionEquals(expected,
240240
fileSystem.getTokenProvider()));
241241
}
242242

@@ -263,7 +263,7 @@ public void testClientCredWithCredentialProvider()
263263
fileSystem.initialize(uri, conf);
264264
ClientCredsTokenProvider expected = new ClientCredsTokenProvider(
265265
REFRESH_URL, CLIENT_ID, CLIENT_SECRET);
266-
Assert.assertTrue(EqualsBuilder.reflectionEquals(expected,
266+
Assertions.assertTrue(EqualsBuilder.reflectionEquals(expected,
267267
fileSystem.getTokenProvider()));
268268
}
269269

@@ -283,7 +283,7 @@ public void testClientCredWithCredentialProviderFallback()
283283
fileSystem.initialize(uri, conf);
284284
ClientCredsTokenProvider expected = new ClientCredsTokenProvider(
285285
REFRESH_URL, CLIENT_ID, CLIENT_SECRET);
286-
Assert.assertTrue(EqualsBuilder.reflectionEquals(expected,
286+
Assertions.assertTrue(EqualsBuilder.reflectionEquals(expected,
287287
fileSystem.getTokenProvider()));
288288
}
289289

hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/TestRelativePathFormation.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020

2121
import org.apache.hadoop.conf.Configuration;
2222
import org.apache.hadoop.fs.Path;
23-
import org.junit.Assert;
24-
import org.junit.Test;
23+
import org.junit.jupiter.api.Assertions;
24+
import org.junit.jupiter.api.Test;
2525

2626
import java.io.IOException;
2727
import java.net.URI;
@@ -48,17 +48,17 @@ public void testToRelativePath() throws URISyntaxException, IOException {
4848

4949
fs.initialize(new URI("adl://temp.account.net"), configuration);
5050

51-
Assert.assertEquals("/usr", fs.toRelativeFilePath(new Path("/usr")));
52-
Assert.assertEquals("/usr",
51+
Assertions.assertEquals("/usr", fs.toRelativeFilePath(new Path("/usr")));
52+
Assertions.assertEquals("/usr",
5353
fs.toRelativeFilePath(new Path("adl://temp.account.net/usr")));
5454

5555
// When working directory is set.
5656
fs.setWorkingDirectory(new Path("/a/b/"));
57-
Assert.assertEquals("/usr", fs.toRelativeFilePath(new Path("/usr")));
58-
Assert.assertEquals("/a/b/usr", fs.toRelativeFilePath(new Path("usr")));
59-
Assert.assertEquals("/usr",
57+
Assertions.assertEquals("/usr", fs.toRelativeFilePath(new Path("/usr")));
58+
Assertions.assertEquals("/a/b/usr", fs.toRelativeFilePath(new Path("usr")));
59+
Assertions.assertEquals("/usr",
6060
fs.toRelativeFilePath(new Path("adl://temp.account.net/usr")));
61-
Assert.assertEquals("/usr",
61+
Assertions.assertEquals("/usr",
6262
fs.toRelativeFilePath(new Path("wasb://temp.account.net/usr")));
6363
}
6464

hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/TestValidateConfiguration.java

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

2121
import org.apache.hadoop.conf.Configuration;
2222
import org.apache.hadoop.test.GenericTestUtils;
23-
import org.junit.Test;
23+
import org.junit.jupiter.api.Test;
2424

2525
import static org.apache.hadoop.fs.adl.AdlConfKeys.ADL_BLOCK_SIZE;
2626
import static org.apache.hadoop.fs.adl.AdlConfKeys
@@ -57,7 +57,7 @@
5757
.TOKEN_PROVIDER_TYPE_REFRESH_TOKEN;
5858
import static org.apache.hadoop.fs.adl.AdlConfKeys.WRITE_BUFFER_SIZE_KEY;
5959

60-
import static org.junit.Assert.assertEquals;
60+
import static org.junit.jupiter.api.Assertions.assertEquals;
6161

6262
import java.io.File;
6363
import java.io.FileOutputStream;

hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/live/TestAdlContractAppendLive.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.apache.hadoop.fs.contract.AbstractContractAppendTest;
2424
import org.apache.hadoop.fs.contract.AbstractFSContract;
2525
import org.apache.hadoop.fs.contract.ContractTestUtils;
26-
import org.junit.Test;
26+
import org.junit.jupiter.api.Test;
2727

2828
/**
2929
* Test Append on Adl file system.

hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/live/TestAdlContractConcatLive.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.apache.hadoop.fs.Path;
2424
import org.apache.hadoop.fs.contract.AbstractContractConcatTest;
2525
import org.apache.hadoop.fs.contract.AbstractFSContract;
26-
import org.junit.Test;
26+
import org.junit.jupiter.api.Test;
2727

2828
import static org.apache.hadoop.fs.contract.ContractTestUtils.touch;
2929

hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/live/TestAdlDifferentSizeWritesLive.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
import org.apache.hadoop.fs.FileSystem;
2525
import org.apache.hadoop.fs.Path;
2626
import org.apache.hadoop.fs.adl.common.Parallelized;
27-
import org.junit.Assert;
28-
import org.junit.Before;
29-
import org.junit.BeforeClass;
30-
import org.junit.Test;
27+
import org.junit.jupiter.api.Assertions;
28+
import org.junit.jupiter.api.BeforeEach;
29+
import org.junit.jupiter.api.BeforeAll;
30+
import org.junit.jupiter.api.Test;
3131
import org.junit.runner.RunWith;
3232
import org.junit.runners.Parameterized;
3333

@@ -71,7 +71,7 @@ public static Collection testDataForIntegrityTest() {
7171
{10 * 1024, 8 * 1024}});
7272
}
7373

74-
@BeforeClass
74+
@BeforeAll
7575
public static void cleanUpParent() throws IOException, URISyntaxException {
7676
if (AdlStorageConfiguration.isContractTestEnabled()) {
7777
Path path = new Path("/test/dataIntegrityCheck/");
@@ -80,7 +80,7 @@ public static void cleanUpParent() throws IOException, URISyntaxException {
8080
}
8181
}
8282

83-
@Before
83+
@BeforeEach
8484
public void setup() throws Exception {
8585
org.junit.Assume
8686
.assumeTrue(AdlStorageConfiguration.isContractTestEnabled());
@@ -117,7 +117,7 @@ public void testDataIntegrity() throws IOException {
117117
FSDataInputStream in = fs.open(path);
118118
in.readFully(0, actualData);
119119
in.close();
120-
Assert.assertArrayEquals(expectedData, actualData);
121-
Assert.assertTrue(fs.delete(path, true));
120+
Assertions.assertArrayEquals(expectedData, actualData);
121+
Assertions.assertTrue(fs.delete(path, true));
122122
}
123123
}

hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/live/TestAdlFileContextCreateMkdirLive.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.apache.hadoop.fs.FileContextTestHelper;
2727
import org.apache.hadoop.fs.FileSystem;
2828
import org.junit.Assume;
29-
import org.junit.BeforeClass;
29+
import org.junit.jupiter.api.BeforeAll;
3030

3131
import java.net.URI;
3232
import java.util.UUID;
@@ -38,7 +38,7 @@ public class TestAdlFileContextCreateMkdirLive
3838
extends FileContextCreateMkdirBaseTest {
3939
private static final String KEY_FILE_SYSTEM = "test.fs.adl.name";
4040

41-
@BeforeClass
41+
@BeforeAll
4242
public static void skipTestCheck() {
4343
Assume.assumeTrue(AdlStorageConfiguration.isContractTestEnabled());
4444
}

hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/live/TestAdlFileContextMainOperationsLive.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import org.apache.hadoop.conf.Configuration;
2323
import org.apache.hadoop.fs.*;
2424
import org.junit.Assume;
25-
import org.junit.BeforeClass;
26-
import org.junit.Test;
25+
import org.junit.jupiter.api.BeforeAll;
26+
import org.junit.jupiter.api.Test;
2727

2828
import java.io.IOException;
2929
import java.net.URI;
@@ -39,7 +39,7 @@ public class TestAdlFileContextMainOperationsLive
3939

4040
private static final String KEY_FILE_SYSTEM = "test.fs.adl.name";
4141

42-
@BeforeClass
42+
@BeforeAll
4343
public static void skipTestCheck() {
4444
Assume.assumeTrue(AdlStorageConfiguration.isContractTestEnabled());
4545
}

hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/live/TestAdlFileSystemContractLive.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
import org.apache.hadoop.fs.FileSystem;
2323
import org.apache.hadoop.fs.FileSystemContractBaseTest;
2424
import org.apache.hadoop.fs.Path;
25-
import org.junit.After;
25+
import org.junit.jupiter.api.AfterEach;
2626
import static org.junit.Assume.*;
27-
import org.junit.Before;
27+
import org.junit.jupiter.api.BeforeEach;
2828

2929
import java.io.IOException;
3030

@@ -34,7 +34,7 @@
3434
public class TestAdlFileSystemContractLive extends FileSystemContractBaseTest {
3535
private FileSystem adlStore;
3636

37-
@Before
37+
@BeforeEach
3838
public void setUp() throws Exception {
3939
skipTestCheck();
4040
adlStore = AdlStorageConfiguration.createStorageConnector();
@@ -44,7 +44,7 @@ public void setUp() throws Exception {
4444
assumeNotNull(fs);
4545
}
4646

47-
@After
47+
@AfterEach
4848
public void tearDown() throws Exception {
4949
if (AdlStorageConfiguration.isContractTestEnabled()) {
5050
cleanup();

hadoop-tools/hadoop-azure-datalake/src/test/java/org/apache/hadoop/fs/adl/live/TestAdlInternalCreateNonRecursive.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
import org.apache.hadoop.fs.Path;
2626
import org.apache.hadoop.fs.adl.common.Parallelized;
2727
import org.apache.hadoop.fs.permission.FsPermission;
28-
import org.junit.Assert;
28+
import org.junit.jupiter.api.Assertions;
2929
import org.junit.Assume;
30-
import org.junit.Before;
31-
import org.junit.Test;
30+
import org.junit.jupiter.api.BeforeEach;
31+
import org.junit.jupiter.api.Test;
3232
import org.junit.runner.RunWith;
3333
import org.junit.runners.Parameterized;
3434

@@ -92,7 +92,7 @@ public static Collection adlCreateNonRecursiveTestData()
9292
IOException.class }*/});
9393
}
9494

95-
@Before
95+
@BeforeEach
9696
public void setUp() throws Exception {
9797
Assume.assumeTrue(AdlStorageConfiguration.isContractTestEnabled());
9898
adlStore = AdlStorageConfiguration.createStorageConnector();
@@ -122,12 +122,12 @@ public void testCreateNonRecursiveFunctionality() throws IOException {
122122
throw e;
123123
}
124124

125-
Assert.assertEquals(expectedExceptionType, e.getClass());
125+
Assertions.assertEquals(expectedExceptionType, e.getClass());
126126
return;
127127
}
128128

129129
if (expectedExceptionType != null) {
130-
Assert.fail("CreateNonRecursive should have failed with exception "
130+
Assertions.fail("CreateNonRecursive should have failed with exception "
131131
+ expectedExceptionType.getName());
132132
}
133133
}

0 commit comments

Comments
 (0)