RussellSpitzer commented on code in PR #5317:
URL: https://github.com/apache/iceberg/pull/5317#discussion_r926007484
##########
aws/src/test/java/org/apache/iceberg/aws/s3/TestS3OutputStream.java:
##########
@@ -119,24 +120,28 @@ public void testWrite() {
@Test
public void testAbortAfterFailedPartUpload() {
- doThrow(new
RuntimeException()).when(s3mock).uploadPart((UploadPartRequest) any(),
(RequestBody) any());
+ doThrow(new RuntimeException("mock uploadPart failure"))
+ .when(s3mock).uploadPart((UploadPartRequest) any(), (RequestBody)
any());
- try (S3OutputStream stream = new S3OutputStream(s3mock, randomURI(),
properties, nullMetrics())) {
- stream.write(randomData(10 * 1024 * 1024));
- } catch (Exception e) {
- verify(s3mock,
atLeastOnce()).abortMultipartUpload((AbortMultipartUploadRequest) any());
- }
+ Assertions.assertThrows(RuntimeException.class, ()->{
+ try (S3OutputStream stream = new S3OutputStream(s3mock, randomURI(),
properties, nullMetrics())) {
+ stream.write(randomData(10 * 1024 * 1024));
+ }
+ });
+ verify(s3mock,
atLeastOnce()).abortMultipartUpload((AbortMultipartUploadRequest) any());
}
@Test
public void testAbortMultipart() {
- doThrow(new
RuntimeException()).when(s3mock).completeMultipartUpload((CompleteMultipartUploadRequest)
any());
+ doThrow(new RuntimeException("mock completeMultipartUpload failure"))
+
.when(s3mock).completeMultipartUpload((CompleteMultipartUploadRequest) any());
- try (S3OutputStream stream = new S3OutputStream(s3mock, randomURI(),
properties, nullMetrics())) {
- stream.write(randomData(10 * 1024 * 1024));
- } catch (Exception e) {
- verify(s3mock).abortMultipartUpload((AbortMultipartUploadRequest) any());
- }
+ Assertions.assertThrows(RuntimeException.class, ()->{
+ try (S3OutputStream stream = new S3OutputStream(s3mock, randomURI(),
properties, nullMetrics())) {
+ stream.write(randomData(10 * 1024 * 1024));
+ }
+ });
Review Comment:
We should probably add checking the message since that was added as well,
Also please be sure to get that checkstyle running ```gradle build -x test -x
integrationTest``` should run all the static checks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]