Skip to content

Commit 21b0dfe

Browse files
committed
HADOOP-19646. Use AssertJ.
1 parent 6ca49d5 commit 21b0dfe

File tree

5 files changed

+23
-13
lines changed

5 files changed

+23
-13
lines changed

hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3ABlockOutputDisk.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.s3a;
2020

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

2323
/**
2424
* Use {@link Constants#FAST_UPLOAD_BUFFER_DISK} for buffering.
@@ -36,7 +36,9 @@ protected String getBlockOutputBufferName() {
3636
* @return null
3737
*/
3838
protected S3ADataBlocks.BlockFactory createFactory(S3AFileSystem fileSystem) {
39-
Assumptions.assumeTrue(false, "mark/reset not supported");
39+
assumeThat(false)
40+
.as("mark/reset not supported")
41+
.isTrue();
4042
return null;
4143
}
4244
}

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.apache.hadoop.fs.s3a.impl.ChangeDetectionPolicy.Source;
2727
import org.apache.hadoop.test.LambdaTestUtils;
2828

29-
import org.junit.jupiter.api.Assumptions;
3029
import org.junit.jupiter.api.Test;
3130

3231
import java.io.FileNotFoundException;
@@ -36,6 +35,7 @@
3635
import static org.apache.hadoop.fs.s3a.Constants.RETRY_INTERVAL;
3736
import static org.apache.hadoop.fs.s3a.Constants.RETRY_LIMIT;
3837
import static org.apache.hadoop.fs.s3a.S3ATestUtils.removeBaseAndBucketOverrides;
38+
import static org.assertj.core.api.Assumptions.assumeThat;
3939

4040
/**
4141
* Tests behavior of a FileNotFound error that happens after open(), i.e. on
@@ -68,8 +68,9 @@ public void testNotFoundFirstRead() throws Exception {
6868
S3AFileSystem fs = getFileSystem();
6969
ChangeDetectionPolicy changeDetectionPolicy =
7070
fs.getChangeDetectionPolicy();
71-
Assumptions.assumeFalse(changeDetectionPolicy.getSource() == Source.VersionId,
72-
"FNF not expected when using a bucket with object versioning");
71+
assumeThat(changeDetectionPolicy.getSource())
72+
.as("FNF not expected when using a bucket with object versioning")
73+
.isNotEqualTo(Source.VersionId);
7374

7475
Path p = path("some-file");
7576
ContractTestUtils.createFile(fs, p, false, new byte[] {20, 21, 22});

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
import static org.apache.hadoop.util.functional.FunctionalIO.uncheckIOExceptions;
127127
import static org.apache.hadoop.util.functional.RemoteIterators.mappingRemoteIterator;
128128
import static org.apache.hadoop.util.functional.RemoteIterators.toList;
129+
import static org.assertj.core.api.Assumptions.assumeThat;
129130
import static org.junit.jupiter.api.Assertions.assertEquals;
130131
import static org.junit.jupiter.api.Assertions.assertFalse;
131132
import static org.junit.jupiter.api.Assertions.assertNotEquals;
@@ -233,7 +234,9 @@ public static S3AFileSystem createTestFileSystem(Configuration conf,
233234
}
234235
// This doesn't work with our JUnit 3 style test cases, so instead we'll
235236
// make this whole class not run by default
236-
Assumptions.assumeThat(liveTest).isTrue().as("No test filesystem in " + TEST_FS_S3A_NAME);
237+
assumeThat(liveTest)
238+
.as("No test filesystem in " + TEST_FS_S3A_NAME)
239+
.isTrue();
237240

238241
S3AFileSystem fs1 = new S3AFileSystem();
239242
//enable purging in tests
@@ -274,7 +277,9 @@ public static FileContext createTestFileContext(Configuration conf)
274277
}
275278
// This doesn't work with our JUnit 3 style test cases, so instead we'll
276279
// make this whole class not run by default
277-
Assumptions.assumeThat(liveTest).isTrue().as("No test filesystem in " + TEST_FS_S3A_NAME);
280+
assumeThat(liveTest)
281+
.as("No test filesystem in " + TEST_FS_S3A_NAME)
282+
.isTrue();
278283
FileContext fc = FileContext.getFileContext(testURI, conf);
279284
return fc;
280285
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.util.stream.IntStream;
2727

2828
import com.fasterxml.jackson.core.JsonProcessingException;
29-
import org.junit.jupiter.api.Assumptions;
3029
import org.slf4j.Logger;
3130
import org.slf4j.LoggerFactory;
3231

@@ -46,6 +45,7 @@
4645
import static org.apache.hadoop.fs.s3a.auth.RolePolicies.*;
4746
import static org.apache.hadoop.fs.s3a.auth.delegation.DelegationConstants.DELEGATION_TOKEN_BINDING;
4847
import static org.apache.hadoop.test.LambdaTestUtils.intercept;
48+
import static org.assertj.core.api.Assumptions.assumeThat;
4949
import static org.junit.jupiter.api.Assertions.assertEquals;
5050
import static org.junit.jupiter.api.Assertions.assertTrue;
5151

@@ -212,7 +212,9 @@ public static <T> AccessDeniedException forbidden(
212212
*/
213213
public static String probeForAssumedRoleARN(Configuration conf) {
214214
String arn = conf.getTrimmed(ASSUMED_ROLE_ARN, "");
215-
Assumptions.assumeTrue(!arn.isEmpty(), "No ARN defined in " + ASSUMED_ROLE_ARN);
215+
assumeThat(arn)
216+
.as("No ARN defined in " + ASSUMED_ROLE_ARN)
217+
.isNotEmpty();
216218
return arn;
217219
}
218220

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

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

1919
package org.apache.hadoop.fs.s3a.test;
2020

21-
import org.junit.jupiter.api.Assumptions;
22-
2321
import org.apache.hadoop.classification.InterfaceAudience;
2422
import org.apache.hadoop.classification.InterfaceStability;
2523
import org.apache.hadoop.conf.Configuration;
@@ -29,6 +27,7 @@
2927

3028
import static org.apache.hadoop.fs.s3a.S3ATestConstants.KEY_BUCKET_WITH_MANY_OBJECTS;
3129
import static org.apache.hadoop.fs.s3a.S3ATestConstants.KEY_REQUESTER_PAYS_FILE;
30+
import static org.assertj.core.api.Assumptions.assumeThat;
3231

3332
/**
3433
* Provides S3A filesystem URIs for public data sets for specific use cases.
@@ -128,8 +127,9 @@ public static Path requireAnonymousDataPath(Configuration conf) {
128127
*/
129128
public static String requireDefaultExternalDataFile(Configuration conf) {
130129
String filename = getExternalData(conf).toUri().toString();
131-
Assumptions.assumeTrue(DEFAULT_EXTERNAL_FILE.equals(filename),
132-
"External test file is not the default");
130+
assumeThat(filename)
131+
.as("External test file is not the default")
132+
.isEqualTo(DEFAULT_EXTERNAL_FILE);
133133
return filename;
134134
}
135135

0 commit comments

Comments
 (0)