@@ -150,6 +150,110 @@ public void asyncCustomConfiguration() {
150150 s3Client .close ();
151151 }
152152
153+ @ Test
154+ public void asyncWrappedMultipartUploadString () {
155+ final String objectKey = appendTestSuffix ("wrapped-multipart-upload-async" );
156+
157+ S3AsyncClient wrappedClient = S3AsyncClient .builder ()
158+ .multipartEnabled (true )
159+ .multipartConfiguration (MultipartConfiguration .builder ().build ())
160+ .build ();
161+
162+ S3AsyncClient s3Client = S3AsyncEncryptionClient .builder ()
163+ .region (Region .of (KMS_REGION .toString ()))
164+ .kmsKeyId (KMS_KEY_ID )
165+ .build ();
166+
167+ S3AsyncClient s3ClientWithMultipart = S3AsyncEncryptionClient .builder ()
168+ .region (Region .of (KMS_REGION .toString ()))
169+ .kmsKeyId (KMS_KEY_ID )
170+ .wrappedClient (wrappedClient )
171+ .build ();
172+
173+ final String input = "SimpleTestOfV3EncryptionClientAsync" ;
174+
175+ s3ClientWithMultipart .putObject (builder -> builder
176+ .bucket (BUCKET )
177+ .key (objectKey )
178+ .build (),
179+ AsyncRequestBody .fromString (input )).join ();
180+
181+ try {
182+ s3ClientWithMultipart .getObject (builder -> builder
183+ .bucket (BUCKET )
184+ .key (objectKey )
185+ .build (), AsyncResponseTransformer .toBytes ()).join ();
186+ } catch (CompletionException exception ) {
187+ assertEquals (S3EncryptionClientException .class , exception .getCause ().getClass ());
188+ }
189+
190+ ResponseBytes <GetObjectResponse > objectResponse = s3Client .getObject (builder -> builder
191+ .bucket (BUCKET )
192+ .key (objectKey )
193+ .build (), AsyncResponseTransformer .toBytes ()).join ();
194+
195+ String output = objectResponse .asUtf8String ();
196+ assertEquals (input , output );
197+
198+ // Cleanup
199+ deleteObject (BUCKET , objectKey , s3ClientWithMultipart );
200+ s3ClientWithMultipart .close ();
201+ }
202+
203+ @ Test
204+ public void asyncWrappedMultipartUploadStream () throws IOException {
205+ final String objectKey = appendTestSuffix ("wrapped-multipart-upload-async-stream" );
206+
207+ S3AsyncClient wrappedClient = S3AsyncClient .builder ()
208+ .multipartEnabled (true )
209+ .multipartConfiguration (MultipartConfiguration .builder ().build ())
210+ .build ();
211+
212+ S3AsyncClient s3Client = S3AsyncEncryptionClient .builder ()
213+ .region (Region .of (KMS_REGION .toString ()))
214+ .kmsKeyId (KMS_KEY_ID )
215+ .enableDelayedAuthenticationMode (true )
216+ .build ();
217+
218+ S3AsyncClient s3ClientWithMultipart = S3AsyncEncryptionClient .builder ()
219+ .region (Region .of (KMS_REGION .toString ()))
220+ .kmsKeyId (KMS_KEY_ID )
221+ .wrappedClient (wrappedClient )
222+ .build ();
223+
224+ final long fileSizeLimit = 1024 * 1024 * 100 ;
225+ final InputStream inputStream = new BoundedInputStream (fileSizeLimit );
226+ final InputStream objectStreamForResult = new BoundedInputStream (fileSizeLimit );
227+
228+ ExecutorService singleThreadExecutor = Executors .newSingleThreadExecutor ();
229+ s3ClientWithMultipart .putObject (builder -> builder
230+ .bucket (BUCKET )
231+ .key (objectKey )
232+ .build (),
233+ AsyncRequestBody .fromInputStream (inputStream , fileSizeLimit , singleThreadExecutor )).join ();
234+ singleThreadExecutor .shutdown ();
235+
236+ try {
237+ s3ClientWithMultipart .getObject (builder -> builder
238+ .bucket (BUCKET )
239+ .key (objectKey )
240+ .build (), AsyncResponseTransformer .toBlockingInputStream ()).join ();
241+ } catch (CompletionException exception ) {
242+ assertEquals (S3EncryptionClientException .class , exception .getCause ().getClass ());
243+ }
244+
245+ ResponseInputStream <GetObjectResponse > objectResponse = s3Client .getObject (builder -> builder
246+ .bucket (BUCKET )
247+ .key (objectKey )
248+ .build (), AsyncResponseTransformer .toBlockingInputStream ()).join ();
249+
250+ assertTrue (IOUtils .contentEquals (objectStreamForResult , objectResponse ));
251+
252+ // Cleanup
253+ deleteObject (BUCKET , objectKey , s3ClientWithMultipart );
254+ s3ClientWithMultipart .close ();
255+ }
256+
153257 @ Test
154258 public void transferManagerUploadString () {
155259 final String objectKey = appendTestSuffix ("tm-string" );
@@ -193,7 +297,6 @@ public void transferManagerUploadStream() throws IOException {
193297
194298 final long fileSizeLimit = 1024 * 1024 * 100 ;
195299 final InputStream inputStream = new BoundedInputStream (fileSizeLimit );
196- final InputStream objectStreamForResult = new BoundedInputStream (fileSizeLimit );
197300 final InputStream objectStreamForResultTm = new BoundedInputStream (fileSizeLimit );
198301
199302 S3AsyncClient v3AsyncClient = S3AsyncEncryptionClient .builder ()
@@ -241,7 +344,6 @@ public void transferManagerUploadStreamCrt() throws ExecutionException, Interrup
241344
242345 final long fileSizeLimit = 1024 * 1024 * 100 ;
243346 final InputStream inputStream = new BoundedInputStream (fileSizeLimit );
244- final InputStream objectStreamForResult = new BoundedInputStream (fileSizeLimit );
245347 final InputStream objectStreamForResultTm = new BoundedInputStream (fileSizeLimit );
246348
247349 S3AsyncClient wrappedCrt = S3AsyncClient .crtBuilder ()
0 commit comments