Skip to content

Commit 001893e

Browse files
committed
HADOOP-19424. [S3A] Upgrade JUnit from 4 to 5 in hadoop-aws.
1 parent 09cd4a1 commit 001893e

File tree

9 files changed

+40
-52
lines changed

9 files changed

+40
-52
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: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030

3131
import org.junit.jupiter.api.AfterEach;
3232
import org.junit.jupiter.api.BeforeEach;
33-
import org.junit.Rule;
34-
import org.junit.rules.ExpectedException;
3533

3634

3735
/**
@@ -49,9 +47,6 @@ 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;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -644,10 +644,10 @@ public void testConcurrentAuthentication() throws Throwable {
644644

645645
for (Future<AwsCredentials> result : results) {
646646
AwsCredentials credentials = result.get();
647-
assertEquals("Access key from credential provider",
648-
"expectedAccessKey", credentials.accessKeyId());
649-
assertEquals("Secret key from credential provider",
650-
"expectedSecret", credentials.secretAccessKey());
647+
assertEquals("expectedAccessKey", credentials.accessKeyId(),
648+
"Access key from credential provider");
649+
assertEquals("expectedSecret", credentials.secretAccessKey(),
650+
"Secret key from credential provider");
651651
}
652652
} finally {
653653
pool.awaitTermination(TERMINATION_TIMEOUT, TimeUnit.SECONDS);

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,17 @@ public void testRoot() throws Exception {
131131

132132
@Test
133133
public void testNotFound() throws Exception {
134-
Path path = new Path("/dir");
135-
String key = path.toUri().getPath().substring(1);
136-
when(s3.headObject(argThat(correctGetMetadataRequest(BUCKET, key))))
137-
.thenThrow(NOT_FOUND);
138-
when(s3.headObject(argThat(
139-
correctGetMetadataRequest(BUCKET, key + "/")
140-
))).thenThrow(NOT_FOUND);
141-
setupListMocks(Collections.emptyList(), Collections.emptyList());
142-
exception.expect(FileNotFoundException.class);
143-
fs.getFileStatus(path);
134+
assertThrows(FileNotFoundException.class, () -> {
135+
Path path = new Path("/dir");
136+
String key = path.toUri().getPath().substring(1);
137+
when(s3.headObject(argThat(correctGetMetadataRequest(BUCKET, key))))
138+
.thenThrow(NOT_FOUND);
139+
when(s3.headObject(argThat(
140+
correctGetMetadataRequest(BUCKET, key + "/")
141+
))).thenThrow(NOT_FOUND);
142+
setupListMocks(Collections.emptyList(), Collections.emptyList());
143+
fs.getFileStatus(path);
144+
});
144145
}
145146

146147
private void setupListMocks(List<CommonPrefix> prefixes,

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

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

2121
import org.junit.jupiter.api.Assertions;
22-
import org.junit.jupiter.api.Test;
23-
import org.junit.runner.RunWith;
24-
import org.junit.runners.Parameterized;
22+
import org.junit.jupiter.params.ParameterizedTest;
23+
import org.junit.jupiter.params.provider.MethodSource;
2524

2625
import java.util.Arrays;
2726
import java.util.Collection;
2827

2928
/**
3029
* Unit test of the input policy logic, without making any S3 calls.
3130
*/
32-
@RunWith(Parameterized.class)
3331
public class TestS3AInputPolicies {
3432

3533
private S3AInputPolicy policy;
@@ -45,7 +43,7 @@ public class TestS3AInputPolicies {
4543
public static final long _1MB = 1024L * 1024;
4644
public static final long _10MB = _1MB * 10;
4745

48-
public TestS3AInputPolicies(S3AInputPolicy policy,
46+
public void initTestS3AInputPolicies(S3AInputPolicy policy,
4947
long targetPos,
5048
long length,
5149
long contentLength,
@@ -59,7 +57,6 @@ public TestS3AInputPolicies(S3AInputPolicy policy,
5957
this.expectedLimit = expectedLimit;
6058
}
6159

62-
@Parameterized.Parameters
6360
public static Collection<Object[]> data() {
6461
return Arrays.asList(new Object[][]{
6562
{S3AInputPolicy.Normal, 0, -1, 0, _64K, 0},
@@ -79,8 +76,12 @@ public static Collection<Object[]> data() {
7976
});
8077
}
8178

82-
@Test
83-
public void testInputPolicies() throws Throwable {
79+
@MethodSource("data")
80+
@ParameterizedTest
81+
public void testInputPolicies(S3AInputPolicy policy,
82+
long targetPos, long length, long contentLength,
83+
long readahead, long expectedLimit) throws Throwable {
84+
initTestS3AInputPolicies(policy, targetPos, length, contentLength, readahead, expectedLimit);
8485
Assertions.assertEquals(
8586
expectedLimit,
8687
S3AInputStream.calculateRequestLimit(policy, targetPos,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,8 +733,8 @@ private void validateContent(Path dir,
733733
expectedOutput.append(KEY_1).append("\n");
734734
expectedOutput.append(KEY_2).append('\t').append(VAL_2).append("\n");
735735
String output = readFile(expectedFile);
736-
assertEquals("Content of " + expectedFile,
737-
expectedOutput.toString(), output);
736+
assertEquals(expectedOutput.toString(), output,
737+
"Content of " + expectedFile);
738738
}
739739

740740
/**

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ public void testFinalDestinationRootMagic2() {
178178

179179
@Test
180180
public void testFinalDestinationMagicNoChild() {
181-
Assertions.assertThrows(IllegalArgumentException.class, () -> {
182-
finalDestination(l(MAGIC_PATH_PREFIX));
183-
});
181+
Assertions.assertThrows(IllegalArgumentException.class, () -> {
182+
finalDestination(l(MAGIC_PATH_PREFIX));
183+
});
184184
}
185185

186186
@Test
@@ -190,9 +190,9 @@ public void testFinalDestinationBaseDirectChild() {
190190

191191
@Test
192192
public void testFinalDestinationBaseNoChild() {
193-
Assertions.assertThrows(IllegalArgumentException.class, () -> {
194-
assertEquals(l(), finalDestination(l(MAGIC_PATH_PREFIX, BASE)));
195-
});
193+
Assertions.assertThrows(IllegalArgumentException.class, () -> {
194+
assertEquals(l(), finalDestination(l(MAGIC_PATH_PREFIX, BASE)));
195+
});
196196
}
197197

198198
@Test
@@ -239,8 +239,8 @@ public void assertChildren(String[] expected, List<String> elements) {
239239

240240
private void assertPathSplits(String pathString, String[] expected) {
241241
Path path = new Path(pathString);
242-
assertArrayEquals(expected
243-
, splitPathToElements(path).toArray(), "From path " + path);
242+
assertArrayEquals(expected,
243+
splitPathToElements(path).toArray(), "From path " + path);
244244
}
245245

246246
private void assertListEquals(String[] expected, List<String> actual) {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ public void testExtractTaskAttemptIdFromPath() {
5757
taskAttemptId);
5858
Path path = CommitUtilsWithMR
5959
.getBaseMagicTaskAttemptPath(taskAttemptContext, "00001", DEST_PATH);
60-
assertEquals(attemptId
61-
, MagicCommitTrackerUtils.extractTaskAttemptIdFromPath(path), "TaskAttemptId didn't match");
60+
assertEquals(attemptId,
61+
MagicCommitTrackerUtils.extractTaskAttemptIdFromPath(path),
62+
"TaskAttemptId didn't match");
6263

6364
}
6465
}

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/commit/magic/ITestMagicCommitProtocol.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ protected void validateTaskAttemptWorkingDirectory(
170170
final AbstractS3ACommitter committer,
171171
final TaskAttemptContext context) throws IOException {
172172
URI wd = committer.getWorkPath().toUri();
173-
assertEquals("Wrong schema for working dir " + wd
174-
+ " with committer " + committer,
175-
"s3a", wd.getScheme());
173+
assertEquals("s3a", wd.getScheme(),
174+
"Wrong schema for working dir " + wd
175+
+ " with committer " + committer);
176176
Assertions.assertThat(wd.getPath())
177177
.contains("/" + MAGIC_PATH_PREFIX + committer.getUUID() + "/");
178178
}

0 commit comments

Comments
 (0)