|
5 | 5 | import org.apache.commons.io.IOUtils; |
6 | 6 | import org.bouncycastle.jce.provider.BouncyCastleProvider; |
7 | 7 | import org.junit.jupiter.api.BeforeAll; |
| 8 | +import org.junit.jupiter.api.BeforeEach; |
| 9 | +import org.junit.jupiter.api.RepeatedTest; |
8 | 10 | import org.junit.jupiter.api.Test; |
9 | 11 | import software.amazon.awssdk.core.ResponseBytes; |
10 | 12 | import software.amazon.awssdk.core.ResponseInputStream; |
|
52 | 54 |
|
53 | 55 | public class S3EncryptionClientMultipartUploadTest { |
54 | 56 | private static Provider PROVIDER; |
| 57 | + private static boolean testCasePassed = false; |
55 | 58 |
|
56 | 59 | @BeforeAll |
57 | 60 | public static void setUp() throws NoSuchAlgorithmException { |
58 | 61 | Security.addProvider(new BouncyCastleProvider()); |
59 | 62 | PROVIDER = Security.getProvider("BC"); |
60 | 63 | } |
61 | 64 |
|
62 | | - @Test |
| 65 | + @BeforeEach |
| 66 | + public void resetTestCasePassedFlag() { |
| 67 | + testCasePassed = false; |
| 68 | + } |
| 69 | + |
| 70 | + @RepeatedTest(3) |
63 | 71 | public void multipartPutObjectAsync() throws IOException { |
| 72 | + if(testCasePassed) { |
| 73 | + return; |
| 74 | + } |
64 | 75 | final String objectKey = appendTestSuffix("multipart-put-object-async"); |
65 | 76 |
|
66 | 77 | final long fileSizeLimit = 1024 * 1024 * 100; |
67 | 78 | final InputStream inputStream = new BoundedInputStream(fileSizeLimit); |
68 | 79 | final InputStream objectStreamForResult = new BoundedInputStream(fileSizeLimit); |
69 | 80 |
|
70 | | - |
71 | | - |
72 | 81 | S3AsyncClient v3Client = S3AsyncEncryptionClient.builder() |
73 | 82 | .kmsKeyId(KMS_KEY_ID) |
74 | 83 | .enableMultipartPutObject(true) |
@@ -100,6 +109,8 @@ public void multipartPutObjectAsync() throws IOException { |
100 | 109 |
|
101 | 110 | deleteObject(BUCKET, objectKey, v3Client); |
102 | 111 | v3Client.close(); |
| 112 | + |
| 113 | + testCasePassed = true; |
103 | 114 | } |
104 | 115 |
|
105 | 116 | @Test |
@@ -131,8 +142,11 @@ public void multipartPutObjectAsyncLargeObjectFails() { |
131 | 142 | singleThreadExecutor.shutdown(); |
132 | 143 | } |
133 | 144 |
|
134 | | - @Test |
| 145 | + @RepeatedTest(3) |
135 | 146 | public void multipartPutObject() throws IOException { |
| 147 | + if(testCasePassed) { |
| 148 | + return; |
| 149 | + } |
136 | 150 | final String objectKey = appendTestSuffix("multipart-put-object"); |
137 | 151 |
|
138 | 152 | final long fileSizeLimit = 1024 * 1024 * 100; |
@@ -164,6 +178,8 @@ public void multipartPutObject() throws IOException { |
164 | 178 |
|
165 | 179 | v3Client.deleteObject(builder -> builder.bucket(BUCKET).key(objectKey)); |
166 | 180 | v3Client.close(); |
| 181 | + |
| 182 | + testCasePassed = true; |
167 | 183 | } |
168 | 184 |
|
169 | 185 | /* |
|
0 commit comments