Skip to content

Commit f099f08

Browse files
authored
HADOOP-19424. [S3A] [JDK17] Upgrade JUnit from 4 to 5 in hadoop-aws. (#7752)
Contributed by Shilun Fan.
1 parent c199c73 commit f099f08

36 files changed

+256
-270
lines changed

hadoop-tools/hadoop-aws/pom.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,6 @@
499499
<artifactId>wildfly-openssl</artifactId>
500500
<scope>runtime</scope>
501501
</dependency>
502-
<dependency>
503-
<groupId>junit</groupId>
504-
<artifactId>junit</artifactId>
505-
<scope>test</scope>
506-
</dependency>
507502
<dependency>
508503
<groupId>org.mockito</groupId>
509504
<artifactId>mockito-inline</artifactId>
@@ -618,10 +613,5 @@
618613
<artifactId>junit-platform-launcher</artifactId>
619614
<scope>test</scope>
620615
</dependency>
621-
<dependency>
622-
<groupId>org.junit.vintage</groupId>
623-
<artifactId>junit-vintage-engine</artifactId>
624-
<scope>test</scope>
625-
</dependency>
626616
</dependencies>
627617
</project>

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/AbstractS3AMockTest.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828

2929
import org.apache.hadoop.conf.Configuration;
3030

31-
import org.junit.After;
32-
import org.junit.Before;
33-
import org.junit.Rule;
34-
import org.junit.rules.ExpectedException;
31+
import org.junit.jupiter.api.AfterEach;
32+
import org.junit.jupiter.api.BeforeEach;
3533

3634

3735
/**
@@ -49,14 +47,11 @@ public abstract class AbstractS3AMockTest {
4947
.build())
5048
.build();
5149

52-
@Rule
53-
public ExpectedException exception = ExpectedException.none();
54-
5550
protected S3AFileSystem fs;
5651
protected S3Client s3;
5752
protected Configuration conf;
5853

59-
@Before
54+
@BeforeEach
6055
public void setup() throws Exception {
6156
conf = createConfiguration();
6257
fs = new S3AFileSystem();
@@ -97,7 +92,7 @@ public S3Client getS3Client() {
9792
return s3;
9893
}
9994

100-
@After
95+
@AfterEach
10196
public void teardown() throws Exception {
10297
if (fs != null) {
10398
fs.close();

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestBlockingThreadPoolExecutorService.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@
2222
import org.apache.hadoop.util.SemaphoredDelegatingExecutor;
2323
import org.apache.hadoop.util.StopWatch;
2424

25-
import org.junit.AfterClass;
26-
import org.junit.Rule;
27-
import org.junit.Test;
28-
import org.junit.rules.Timeout;
25+
import org.junit.jupiter.api.AfterAll;
26+
import org.junit.jupiter.api.Test;
27+
import org.junit.jupiter.api.Timeout;
2928
import org.slf4j.Logger;
3029
import org.slf4j.LoggerFactory;
3130

@@ -35,11 +34,12 @@
3534
import java.util.concurrent.Future;
3635
import java.util.concurrent.TimeUnit;
3736

38-
import static org.junit.Assert.assertEquals;
37+
import static org.junit.jupiter.api.Assertions.assertEquals;
3938

4039
/**
4140
* Basic test for S3A's blocking executor service.
4241
*/
42+
@Timeout(60)
4343
public class ITestBlockingThreadPoolExecutorService {
4444

4545
private static final Logger LOG = LoggerFactory.getLogger(
@@ -56,10 +56,7 @@ public class ITestBlockingThreadPoolExecutorService {
5656

5757
private static BlockingThreadPoolExecutorService tpe;
5858

59-
@Rule
60-
public Timeout testTimeout = new Timeout(60, TimeUnit.SECONDS);
61-
62-
@AfterClass
59+
@AfterAll
6360
public static void afterClass() throws Exception {
6461
ensureDestroyed();
6562
}

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestEMRFSCompatibility.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
package org.apache.hadoop.fs.s3a;
2020

2121
import org.assertj.core.api.Assertions;
22-
import org.junit.Test;
22+
import org.junit.jupiter.api.Test;
2323

2424
import org.apache.hadoop.fs.Path;
2525

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AAWSCredentialsProvider.java

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

2121
import java.io.IOException;
2222
import java.nio.file.AccessDeniedException;
23-
import java.util.concurrent.TimeUnit;
2423

2524
import org.apache.hadoop.conf.Configuration;
2625
import org.apache.hadoop.fs.FileStatus;
@@ -29,10 +28,9 @@
2928
import org.apache.hadoop.fs.s3a.impl.InstantiationIOException;
3029

3130
import org.assertj.core.api.Assertions;
32-
import org.junit.Rule;
33-
import org.junit.Test;
34-
import org.junit.rules.Timeout;
31+
import org.junit.jupiter.api.Test;
3532

33+
import org.junit.jupiter.api.Timeout;
3634
import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
3735
import software.amazon.awssdk.auth.credentials.AwsCredentials;
3836
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
@@ -46,19 +44,18 @@
4644
import static org.apache.hadoop.fs.s3a.test.PublicDatasetTestUtils.getExternalData;
4745
import static org.apache.hadoop.fs.s3a.test.PublicDatasetTestUtils.isUsingDefaultExternalDataFile;
4846
import static org.apache.hadoop.test.LambdaTestUtils.intercept;
49-
import static org.junit.Assert.*;
47+
import static org.junit.jupiter.api.Assertions.assertEquals;
48+
import static org.junit.jupiter.api.Assertions.fail;
5049

5150
/**
5251
* Integration tests for {@link Constants#AWS_CREDENTIALS_PROVIDER} logic
5352
* through the S3A Filesystem instantiation process.
5453
*/
54+
@Timeout(60)
5555
public class ITestS3AAWSCredentialsProvider {
5656
private static final Logger LOG =
5757
LoggerFactory.getLogger(ITestS3AAWSCredentialsProvider.class);
5858

59-
@Rule
60-
public Timeout testTimeout = new Timeout(60_1000, TimeUnit.MILLISECONDS);
61-
6259
/**
6360
* Expecting a wrapped ClassNotFoundException.
6461
*/
@@ -219,9 +216,8 @@ public void testAnonymousProvider() throws Exception {
219216
.describedAs("Filesystem")
220217
.isNotNull();
221218
FileStatus stat = fs.getFileStatus(testFile);
222-
assertEquals(
223-
"The qualified path returned by getFileStatus should be same as the original file",
224-
testFile, stat.getPath());
219+
assertEquals(testFile, stat.getPath(),
220+
"The qualified path returned by getFileStatus should be same as the original file");
225221
}
226222
}
227223

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AAnalyticsAcceleratorStreamReading.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
import java.io.IOException;
2424
import java.io.InputStream;
2525

26-
import org.junit.Before;
27-
import org.junit.Test;
26+
import org.junit.jupiter.api.BeforeEach;
27+
import org.junit.jupiter.api.Test;
2828
import org.assertj.core.api.Assertions;
2929

3030
import org.apache.hadoop.conf.Configuration;
@@ -67,7 +67,7 @@ public class ITestS3AAnalyticsAcceleratorStreamReading extends AbstractS3ATestBa
6767

6868
private Path externalTestFile;
6969

70-
@Before
70+
@BeforeEach
7171
public void setUp() throws Exception {
7272
super.setup();
7373
skipIfClientSideEncryption();

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AChecksum.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.io.IOException;
2222

2323
import org.assertj.core.api.Assertions;
24-
import org.junit.Test;
24+
import org.junit.jupiter.api.Test;
2525
import software.amazon.awssdk.services.s3.model.ChecksumAlgorithm;
2626
import software.amazon.awssdk.services.s3.model.ChecksumMode;
2727
import software.amazon.awssdk.services.s3.model.HeadObjectRequest;

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3ADSSEEncryptionWithDefaultS3Settings.java

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

2121
import java.io.IOException;
2222

23-
import org.junit.Ignore;
2423
import org.junit.jupiter.api.BeforeEach;
24+
import org.junit.jupiter.api.Disabled;
2525
import org.junit.jupiter.api.Test;
2626

2727
import org.apache.commons.lang3.StringUtils;
@@ -96,13 +96,13 @@ protected void assertEncrypted(Path path) throws IOException {
9696
}
9797

9898
@Override
99-
@Ignore
99+
@Disabled
100100
@Test
101101
public void testEncryptionSettingPropagation() throws Throwable {
102102
}
103103

104104
@Override
105-
@Ignore
105+
@Disabled
106106
@Test
107107
public void testEncryption() throws Throwable {
108108
}

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3ATestUtils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
package org.apache.hadoop.fs.s3a;
2020

2121
import org.apache.hadoop.conf.Configuration;
22-
import org.junit.Assert;
23-
import org.junit.Before;
24-
import org.junit.Test;
22+
import org.junit.jupiter.api.Assertions;
23+
import org.junit.jupiter.api.BeforeEach;
24+
import org.junit.jupiter.api.Test;
2525
import org.slf4j.Logger;
2626
import org.slf4j.LoggerFactory;
2727

@@ -31,12 +31,12 @@
3131
* Test the test utils. Why an integration test? it's needed to
3232
* verify property pushdown.
3333
*/
34-
public class ITestS3ATestUtils extends Assert {
34+
public class ITestS3ATestUtils extends Assertions {
3535
private static final Logger LOG =
3636
LoggerFactory.getLogger(ITestS3ATestUtils.class);
3737
public static final String KEY = "undefined.property";
3838

39-
@Before
39+
@BeforeEach
4040
public void clear() {
4141
System.clearProperty(KEY);
4242
}

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/MultipartTestUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.apache.hadoop.fs.s3a.impl.PutObjectOptions;
2828
import org.apache.hadoop.fs.store.audit.AuditSpan;
2929

30-
import org.junit.Assert;
30+
import org.junit.jupiter.api.Assertions;
3131
import org.slf4j.Logger;
3232
import org.slf4j.LoggerFactory;
3333

@@ -45,6 +45,7 @@
4545
import static org.apache.hadoop.fs.contract.ContractTestUtils.createFile;
4646
import static org.apache.hadoop.fs.contract.ContractTestUtils.dataset;
4747
import static org.apache.hadoop.fs.s3a.commit.CommitConstants.MAGIC_PATH_PREFIX;
48+
import static org.junit.jupiter.api.Assertions.assertFalse;
4849

4950
/**
5051
* Utilities for S3A multipart upload tests.
@@ -80,8 +81,7 @@ static void cleanupParts(S3AFileSystem fs, Set <IdKey> keySet) {
8081
anyFailure = true;
8182
}
8283
}
83-
Assert.assertFalse("Failure aborting multipart upload(s), see log.",
84-
anyFailure);
84+
assertFalse(anyFailure, "Failure aborting multipart upload(s), see log.");
8585
}
8686

8787
public static IdKey createPartUpload(S3AFileSystem fs, String key, int len,
@@ -116,7 +116,7 @@ public static void assertNoUploadsAt(S3AFileSystem fs, Path path) throws
116116
RemoteIterator<MultipartUpload> uploads = fs.listUploads(key);
117117
while (uploads.hasNext()) {
118118
MultipartUpload upload = uploads.next();
119-
Assert.fail("Found unexpected upload " + upload.key() + " " +
119+
Assertions.fail("Found unexpected upload " + upload.key() + " " +
120120
truncatedUploadId(upload.uploadId()));
121121
}
122122
}

0 commit comments

Comments
 (0)