Skip to content

Commit

Permalink
Add test coverage for pull request #69 (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-aws authored Jan 3, 2022
1 parent fb4305c commit 58fed25
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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>
```
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
@@ -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;
@@ -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);

0 comments on commit 58fed25

Please sign in to comment.