1212import org .apache .commons .io .IOUtils ;
1313import org .bouncycastle .jce .provider .BouncyCastleProvider ;
1414import org .junit .jupiter .api .BeforeAll ;
15+ import org .junit .jupiter .api .BeforeEach ;
16+ import org .junit .jupiter .api .RepeatedTest ;
1517import org .junit .jupiter .api .Test ;
16- import org .junitpioneer .jupiter .RetryingTest ;
1718import software .amazon .awssdk .core .ResponseBytes ;
1819import software .amazon .awssdk .core .ResponseInputStream ;
1920import 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