Skip to content

Commit c8dd200

Browse files
authored
Fix SQS test (#5203)
- Set explicit region in test clients - Add type inference to HashMap
1 parent abb0a67 commit c8dd200

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

services/sqs/src/test/java/software/amazon/awssdk/services/sqs/MessageMD5ChecksumValidationDisableTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import software.amazon.awssdk.http.AbortableInputStream;
3030
import software.amazon.awssdk.http.HttpExecuteResponse;
3131
import software.amazon.awssdk.http.SdkHttpResponse;
32+
import software.amazon.awssdk.regions.Region;
3233
import software.amazon.awssdk.services.sqs.internal.MessageMD5ChecksumInterceptor;
3334
import software.amazon.awssdk.services.sqs.model.MessageAttributeValue;
3435
import software.amazon.awssdk.services.sqs.model.SendMessageResponse;
@@ -43,6 +44,7 @@
4344
*/
4445
public class MessageMD5ChecksumValidationDisableTest {
4546
private static final AwsBasicCredentials CLIENT_CREDENTIALS = AwsBasicCredentials.create("ca", "cs");
47+
private static final Region CLIENT_REGION = Region.US_WEST_2;
4648
private static final String MESSAGE_ID = "0f433476-621e-4638-811a-112d2c2e41d7";
4749

4850
private MockAsyncHttpClient asyncHttpClient;
@@ -65,6 +67,7 @@ public void md5ValidationEnabled_default_md5InResponse_Works() {
6567
asyncHttpClient.stubResponses(responseWithMd5());
6668
SqsAsyncClient client = SqsAsyncClient.builder()
6769
.credentialsProvider(StaticCredentialsProvider.create(CLIENT_CREDENTIALS))
70+
.region(CLIENT_REGION)
6871
.httpClient(asyncHttpClient)
6972
.build();
7073

@@ -79,6 +82,7 @@ public void md5ValidationEnabled_default_noMd5InResponse_throwsException() {
7982
asyncHttpClient.stubResponses(responseWithoutMd5());
8083
SqsAsyncClient client = SqsAsyncClient.builder()
8184
.credentialsProvider(StaticCredentialsProvider.create(CLIENT_CREDENTIALS))
85+
.region(CLIENT_REGION)
8286
.httpClient(asyncHttpClient)
8387
.build();
8488

@@ -93,6 +97,7 @@ public void md5ValidationDisabled_md5InResponse_Works() {
9397
asyncHttpClient.stubResponses(responseWithMd5());
9498
SqsAsyncClient client = SqsAsyncClient.builder()
9599
.credentialsProvider(StaticCredentialsProvider.create(CLIENT_CREDENTIALS))
100+
.region(CLIENT_REGION)
96101
.httpClient(asyncHttpClient)
97102
.checksumValidationEnabled(false)
98103
.build();
@@ -108,6 +113,7 @@ public void md5ValidationDisabled_noMd5InResponse_Works() {
108113
asyncHttpClient.stubResponses(responseWithoutMd5());
109114
SqsAsyncClient client = SqsAsyncClient.builder()
110115
.credentialsProvider(StaticCredentialsProvider.create(CLIENT_CREDENTIALS))
116+
.region(CLIENT_REGION)
111117
.httpClient(asyncHttpClient)
112118
.checksumValidationEnabled(false)
113119
.build();
@@ -123,6 +129,7 @@ public void sync_md5ValidationDisabled_noMd5InResponse_Works() {
123129
syncHttpClient.stubResponses(responseWithoutMd5());
124130
SqsClient client = SqsClient.builder()
125131
.credentialsProvider(StaticCredentialsProvider.create(CLIENT_CREDENTIALS))
132+
.region(CLIENT_REGION)
126133
.httpClient(syncHttpClient)
127134
.checksumValidationEnabled(false)
128135
.build();
@@ -154,7 +161,7 @@ private static HttpExecuteResponse responseWithoutMd5() {
154161
}
155162

156163
protected static Map<String, MessageAttributeValue> createAttributeValues() {
157-
Map<String, MessageAttributeValue> attrs = new HashMap();
164+
Map<String, MessageAttributeValue> attrs = new HashMap<>();
158165
attrs.put("attribute-1", MessageAttributeValue.builder().dataType("String").stringValue("tmp").build());
159166
return Collections.unmodifiableMap(attrs);
160167
}

0 commit comments

Comments
 (0)