Skip to content

Commit f128870

Browse files
author
Anirav Kareddy
committed
could not use the RetryingTest dependency since it relies on Java 11 and we are relying on Java 8. Workaround was using RepeatedTests annotation and add a testCasePassed flag ... let's see if it works
1 parent ed79e25 commit f128870

File tree

3 files changed

+37
-13
lines changed

3 files changed

+37
-13
lines changed

pom.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,6 @@
134134
<scope>test</scope>
135135
</dependency>
136136

137-
<dependency>
138-
<groupId>org.junit-pioneer</groupId>
139-
<artifactId>junit-pioneer</artifactId>
140-
<version>2.3.0</version>
141-
<scope>test</scope>
142-
</dependency>
143-
144137
<dependency>
145138
<groupId>com.amazonaws</groupId>
146139
<artifactId>aws-java-sdk-kms</artifactId>

src/test/java/software/amazon/encryption/s3/S3EncryptionClientInstructionFileTest.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
import com.amazonaws.services.s3.model.KMSEncryptionMaterials;
1111
import com.amazonaws.services.s3.model.StaticEncryptionMaterialsProvider;
1212
import org.apache.commons.io.IOUtils;
13+
import org.junit.jupiter.api.BeforeEach;
14+
import org.junit.jupiter.api.RepeatedTest;
1315
import org.junit.jupiter.api.Test;
14-
import org.junitpioneer.jupiter.RetryingTest;
1516
import software.amazon.awssdk.core.ResponseBytes;
1617
import software.amazon.awssdk.core.ResponseInputStream;
1718
import software.amazon.awssdk.core.sync.RequestBody;
@@ -52,6 +53,12 @@
5253
import static software.amazon.encryption.s3.utils.S3EncryptionClientTestResources.deleteObject;
5354

5455
public class S3EncryptionClientInstructionFileTest {
56+
private static boolean testCasePassed = false;
57+
58+
@BeforeEach
59+
public void resetTestCasePassedFlag() {
60+
testCasePassed = false;
61+
}
5562

5663
@Test
5764
public void testInstructionFileExists() {
@@ -310,7 +317,7 @@ public void testPutWithInstructionFileV3ToV2Rsa() throws NoSuchAlgorithmExceptio
310317
s3Client.close();
311318
}
312319

313-
@RetryingTest(maxAttempts = 3)
320+
@RepeatedTest(3)
314321
public void testMultipartPutWithInstructionFile() throws IOException {
315322
final String object_key = appendTestSuffix("test-multipart-put-instruction-file");
316323

src/test/java/software/amazon/encryption/s3/S3EncryptionClientStreamTest.java

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
import org.apache.commons.io.IOUtils;
1313
import org.bouncycastle.jce.provider.BouncyCastleProvider;
1414
import org.junit.jupiter.api.BeforeAll;
15+
import org.junit.jupiter.api.BeforeEach;
16+
import org.junit.jupiter.api.RepeatedTest;
1517
import org.junit.jupiter.api.Test;
16-
import org.junitpioneer.jupiter.RetryingTest;
1718
import software.amazon.awssdk.core.ResponseBytes;
1819
import software.amazon.awssdk.core.ResponseInputStream;
1920
import software.amazon.awssdk.core.async.AsyncRequestBody;
@@ -61,6 +62,7 @@ public class S3EncryptionClientStreamTest {
6162

6263
private static final String BUCKET = S3EncryptionClientTestResources.BUCKET;
6364
private static final int DEFAULT_TEST_STREAM_LENGTH = (int) (Math.random() * 10000);
65+
private static boolean testCasePassed = false;
6466

6567
private static SecretKey AES_KEY;
6668

@@ -71,6 +73,11 @@ public static void setUp() throws NoSuchAlgorithmException {
7173
AES_KEY = keyGen.generateKey();
7274
}
7375

76+
@BeforeEach
77+
public void resetTestCasePassedFlag() {
78+
testCasePassed = false;
79+
}
80+
7481
@Test
7582
public void markResetInputStreamV3Encrypt() throws IOException {
7683
final String objectKey = appendTestSuffix("markResetInputStreamV3Encrypt");
@@ -307,8 +314,12 @@ public void failsWhenBothBufferSizeAndDelayedAuthModeEnabled() {
307314
.build());
308315
}
309316

310-
@RetryingTest(maxAttempts = 3)
317+
@RepeatedTest(3)
311318
public void customSetBufferSizeWithLargeObject() throws IOException {
319+
if (testCasePassed) {
320+
return;
321+
}
322+
312323
final String objectKey = appendTestSuffix("large-object-test-custom-buffer-size");
313324

314325
Security.addProvider(new BouncyCastleProvider());
@@ -357,10 +368,16 @@ public void customSetBufferSizeWithLargeObject() throws IOException {
357368
deleteObject(BUCKET, objectKey, v3ClientWithBuffer32MiB);
358369
v3ClientWithBuffer32MiB.close();
359370
v3ClientWithDelayedAuth.close();
371+
372+
testCasePassed = true;
360373
}
361374

362-
@RetryingTest(maxAttempts = 3)
375+
@RepeatedTest(3)
363376
public void customSetBufferSizeWithLargeObjectAsyncClient() throws IOException {
377+
if (testCasePassed) {
378+
return;
379+
}
380+
364381
final String objectKey = appendTestSuffix("large-object-test-custom-buffer-size-async");
365382

366383
Security.addProvider(new BouncyCastleProvider());
@@ -417,10 +434,15 @@ public void customSetBufferSizeWithLargeObjectAsyncClient() throws IOException {
417434
deleteObject(BUCKET, objectKey, v3ClientWithBuffer32MiB);
418435
v3ClientWithBuffer32MiB.close();
419436
v3ClientWithDelayedAuth.close();
437+
438+
testCasePassed = true;
420439
}
421440

422-
@RetryingTest(maxAttempts = 3)
441+
@RepeatedTest(3)
423442
public void delayedAuthModeWithLargeObject() throws IOException {
443+
if(testCasePassed) {
444+
return;
445+
}
424446
final String objectKey = appendTestSuffix("large-object-test");
425447

426448
Security.addProvider(new BouncyCastleProvider());
@@ -464,6 +486,8 @@ public void delayedAuthModeWithLargeObject() throws IOException {
464486
// Cleanup
465487
deleteObject(BUCKET, objectKey, v3Client);
466488
v3Client.close();
489+
490+
testCasePassed = true;
467491
}
468492

469493
@Test

0 commit comments

Comments
 (0)