Skip to content

Commit

Permalink
Fix SQS test (aws#5203)
Browse files Browse the repository at this point in the history
- Set explicit region in test clients
 - Add type inference to HashMap
  • Loading branch information
dagnir authored and akidambisrinivasan committed Jun 28, 2024
1 parent bc68e71 commit 0fffec3
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import software.amazon.awssdk.http.AbortableInputStream;
import software.amazon.awssdk.http.HttpExecuteResponse;
import software.amazon.awssdk.http.SdkHttpResponse;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sqs.internal.MessageMD5ChecksumInterceptor;
import software.amazon.awssdk.services.sqs.model.MessageAttributeValue;
import software.amazon.awssdk.services.sqs.model.SendMessageResponse;
Expand All @@ -43,6 +44,7 @@
*/
public class MessageMD5ChecksumValidationDisableTest {
private static final AwsBasicCredentials CLIENT_CREDENTIALS = AwsBasicCredentials.create("ca", "cs");
private static final Region CLIENT_REGION = Region.US_WEST_2;
private static final String MESSAGE_ID = "0f433476-621e-4638-811a-112d2c2e41d7";

private MockAsyncHttpClient asyncHttpClient;
Expand All @@ -65,6 +67,7 @@ public void md5ValidationEnabled_default_md5InResponse_Works() {
asyncHttpClient.stubResponses(responseWithMd5());
SqsAsyncClient client = SqsAsyncClient.builder()
.credentialsProvider(StaticCredentialsProvider.create(CLIENT_CREDENTIALS))
.region(CLIENT_REGION)
.httpClient(asyncHttpClient)
.build();

Expand All @@ -79,6 +82,7 @@ public void md5ValidationEnabled_default_noMd5InResponse_throwsException() {
asyncHttpClient.stubResponses(responseWithoutMd5());
SqsAsyncClient client = SqsAsyncClient.builder()
.credentialsProvider(StaticCredentialsProvider.create(CLIENT_CREDENTIALS))
.region(CLIENT_REGION)
.httpClient(asyncHttpClient)
.build();

Expand All @@ -93,6 +97,7 @@ public void md5ValidationDisabled_md5InResponse_Works() {
asyncHttpClient.stubResponses(responseWithMd5());
SqsAsyncClient client = SqsAsyncClient.builder()
.credentialsProvider(StaticCredentialsProvider.create(CLIENT_CREDENTIALS))
.region(CLIENT_REGION)
.httpClient(asyncHttpClient)
.checksumValidationEnabled(false)
.build();
Expand All @@ -108,6 +113,7 @@ public void md5ValidationDisabled_noMd5InResponse_Works() {
asyncHttpClient.stubResponses(responseWithoutMd5());
SqsAsyncClient client = SqsAsyncClient.builder()
.credentialsProvider(StaticCredentialsProvider.create(CLIENT_CREDENTIALS))
.region(CLIENT_REGION)
.httpClient(asyncHttpClient)
.checksumValidationEnabled(false)
.build();
Expand All @@ -123,6 +129,7 @@ public void sync_md5ValidationDisabled_noMd5InResponse_Works() {
syncHttpClient.stubResponses(responseWithoutMd5());
SqsClient client = SqsClient.builder()
.credentialsProvider(StaticCredentialsProvider.create(CLIENT_CREDENTIALS))
.region(CLIENT_REGION)
.httpClient(syncHttpClient)
.checksumValidationEnabled(false)
.build();
Expand Down Expand Up @@ -154,7 +161,7 @@ private static HttpExecuteResponse responseWithoutMd5() {
}

protected static Map<String, MessageAttributeValue> createAttributeValues() {
Map<String, MessageAttributeValue> attrs = new HashMap();
Map<String, MessageAttributeValue> attrs = new HashMap<>();
attrs.put("attribute-1", MessageAttributeValue.builder().dataType("String").stringValue("tmp").build());
return Collections.unmodifiableMap(attrs);
}
Expand Down

0 comments on commit 0fffec3

Please sign in to comment.