Skip to content

Commit

Permalink
Test cases to check on Failure
Browse files Browse the repository at this point in the history
  • Loading branch information
joviegas committed Sep 8, 2023
1 parent 65ddbca commit 9247f21
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
5 changes: 5 additions & 0 deletions services-custom/s3-transfer-manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@
<version>${commons-codec.verion}</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>wiremock-jre8</artifactId>
<groupId>com.github.tomakehurst</groupId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletionException;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand All @@ -35,7 +34,6 @@
import software.amazon.awssdk.core.sync.ResponseTransformer;
import software.amazon.awssdk.services.s3.model.ChecksumAlgorithm;
import software.amazon.awssdk.services.s3.model.GetObjectResponse;
import software.amazon.awssdk.services.s3.model.NoSuchBucketException;
import software.amazon.awssdk.testutils.RandomTempFile;
import software.amazon.awssdk.transfer.s3.model.CompletedFileUpload;
import software.amazon.awssdk.transfer.s3.model.CompletedUpload;
Expand Down Expand Up @@ -148,20 +146,4 @@ void upload_file_Interupted_CancelsTheListener() throws IOException, Interrupted
assertThat(transferListener.getRatioTransferredList().get(transferListener.getRatioTransferredList().size() - 1))
.isNotEqualTo(100.0);
}

@Test
void upload_file_errorPropagatedToListener() throws IOException, InterruptedException {
Map<String, String> metadata = new HashMap<>();
CaptureTransferListener transferListener = new CaptureTransferListener();
metadata.put("x-amz-meta-foobar", "FOO BAR");
FileUpload fileUpload =
tm.uploadFile(u -> u.putObjectRequest(p -> p.bucket(TEST_BUCKET+TEST_BUCKET).key(TEST_KEY).metadata(metadata).checksumAlgorithm(ChecksumAlgorithm.CRC32))
.source(testFile.toPath())
.addTransferListener(LoggingTransferListener.create())
.addTransferListener(transferListener)
.build());
assertThatExceptionOfType(CompletionException.class).isThrownBy(
() -> fileUpload.completionFuture().join());
assertThat(transferListener.getExceptionCaught()).isInstanceOf(NoSuchBucketException.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ private void onErrorResponseComplete(byte[] errorPayload) {
}

private void failResponseHandlerAndFuture(Throwable exception) {
this.progressListener.subscriberOnError(exception);
resultFuture.completeExceptionally(exception);
runAndLogError(log.logger(), "Exception thrown in SdkAsyncHttpResponseHandler#onError, ignoring",
() -> responseHandler.onError(exception));
Expand Down

0 comments on commit 9247f21

Please sign in to comment.