Skip to content

Commit

Permalink
Fix SQS test (#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 committed May 9, 2024
1 parent abb0a67 commit c8dd200
Showing 1 changed file with 8 additions and 1 deletion.
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 c8dd200

Please sign in to comment.