2121import software .amazon .awssdk .services .s3 .model .GetObjectResponse ;
2222import software .amazon .awssdk .services .s3 .model .NoSuchBucketException ;
2323import software .amazon .awssdk .services .s3 .model .NoSuchKeyException ;
24+ import software .amazon .awssdk .services .s3 .model .NoSuchUploadException ;
2425import software .amazon .awssdk .services .s3 .model .ObjectIdentifier ;
2526import software .amazon .awssdk .services .s3 .model .PutObjectRequest ;
2627import software .amazon .awssdk .services .s3 .model .S3Exception ;
4445
4546import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
4647import static org .junit .jupiter .api .Assertions .assertEquals ;
48+ import static org .junit .jupiter .api .Assertions .assertInstanceOf ;
4749import static org .junit .jupiter .api .Assertions .assertThrows ;
4850import static org .junit .jupiter .api .Assertions .assertTrue ;
4951import static org .mockito .ArgumentMatchers .any ;
@@ -618,7 +620,7 @@ public void createMultipartUploadFailure() {
618620 v3Client .createMultipartUpload (builder -> builder .bucket ("NotMyBukkit" ).key ("InvalidKey" ).build ());
619621 } catch (S3EncryptionClientException exception ) {
620622 // Verify inner exception
621- assertTrue ( exception .getCause () instanceof NoSuchBucketException );
623+ assertInstanceOf ( NoSuchBucketException . class , exception .getCause ());
622624 }
623625
624626 v3Client .close ();
@@ -642,15 +644,15 @@ public void uploadPartFailure() {
642644 RequestBody .fromInputStream (new BoundedInputStream (16 ), 16 ));
643645 } catch (S3EncryptionClientException exception ) {
644646 // Verify inner exception
645- assertTrue ( exception .getCause () instanceof NoSuchBucketException );
647+ assertInstanceOf ( NoSuchBucketException . class , exception .getCause ());
646648 }
647649
648- // MPU was not completed, but delete to be safe
650+ // MPU was not completed, but abort and delete to be safe
651+ v3Client .abortMultipartUpload (builder -> builder .bucket (BUCKET ).key (objectKey ).uploadId (initiateResult .uploadId ()).build ());
649652 deleteObject (BUCKET , objectKey , v3Client );
650653 v3Client .close ();
651654 }
652655
653-
654656 @ Test
655657 public void completeMultipartUploadFailure () {
656658 // V3 Client
@@ -661,7 +663,26 @@ public void completeMultipartUploadFailure() {
661663 v3Client .completeMultipartUpload (builder -> builder .bucket ("NotMyBukkit" ).key ("InvalidKey" ).uploadId ("Invalid" ).build ());
662664 } catch (S3EncryptionClientException exception ) {
663665 // Verify inner exception
664- assertTrue (exception .getCause () instanceof NoSuchBucketException );
666+ assertInstanceOf (NoSuchBucketException .class , exception .getCause ());
667+ }
668+
669+ v3Client .close ();
670+ }
671+
672+ @ Test
673+ public void abortMultipartUploadFailure () {
674+ final String objectKey = appendTestSuffix ("abort-multipart-failure" );
675+
676+ // V3 Client
677+ S3Client v3Client = S3EncryptionClient .builder ()
678+ .aesKey (AES_KEY )
679+ .build ();
680+
681+ try {
682+ v3Client .abortMultipartUpload (builder -> builder .bucket (BUCKET ).key (objectKey ).uploadId ("invalid upload id" ).build ());
683+ } catch (S3EncryptionClientException exception ) {
684+ // Verify inner exception
685+ assertInstanceOf (NoSuchUploadException .class , exception .getCause ());
665686 }
666687
667688 v3Client .close ();
0 commit comments