Skip to content

Add test coverage for pull request #69 #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ For more information on using the amazon-sqs-java-extended-client-lib, see our g
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>amazon-sqs-java-extended-client-lib</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
<type>jar</type>
</dependency>
```
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.amazonaws</groupId>
<artifactId>amazon-sqs-java-extended-client-lib</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
<packaging>jar</packaging>
<name>Amazon SQS Extended Client Library for Java</name>
<description>An extension to the Amazon SQS client that enables sending and receiving messages up to 2GB via Amazon S3.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import static com.amazon.sqs.javamessaging.AmazonSQSExtendedClient.USER_AGENT_NAME;
import static com.amazon.sqs.javamessaging.AmazonSQSExtendedClient.USER_AGENT_VERSION;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doThrow;
Expand Down Expand Up @@ -429,6 +430,34 @@ public void testWhenMessageBatchIsSentThenOnlyMessagesLargerThanThresholdAreStor
verify(mockS3, times(8)).putObject(isA(PutObjectRequest.class), isA(RequestBody.class));
}

@Test
public void testWhenMessageBatchIsLargeS3PointerIsCorrectlySentToSQSAndNotOriginalMessage() {
String messageBody = generateStringWithLength(LESS_THAN_SQS_SIZE_LIMIT);
ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration()
.withPayloadSupportEnabled(mockS3, S3_BUCKET_NAME).withAlwaysThroughS3(true);

SqsClient sqsExtended = spy(new AmazonSQSExtendedClient(mockSqsBackend, extendedClientConfiguration));

List<SendMessageBatchRequestEntry> batchEntries = new ArrayList<SendMessageBatchRequestEntry>();
for (int i = 0; i < 10; i++) {
SendMessageBatchRequestEntry entry = SendMessageBatchRequestEntry.builder()
.id("entry_" + i)
.messageBody(messageBody)
.build();
batchEntries.add(entry);
}
SendMessageBatchRequest batchRequest = SendMessageBatchRequest.builder().queueUrl(SQS_QUEUE_URL).entries(batchEntries).build();

sqsExtended.sendMessageBatch(batchRequest);

ArgumentCaptor<SendMessageBatchRequest> sendMessageRequestCaptor = ArgumentCaptor.forClass(SendMessageBatchRequest.class);
verify(mockSqsBackend).sendMessageBatch(sendMessageRequestCaptor.capture());

for (SendMessageBatchRequestEntry entry : sendMessageRequestCaptor.getValue().entries()) {
assertNotEquals(messageBody, entry.messageBody());
}
}

@Test
public void testWhenSmallMessageIsSentThenNoAttributeIsAdded() {
String messageBody = generateStringWithLength(LESS_THAN_SQS_SIZE_LIMIT);
Expand Down