diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..e1d1cc7
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,10 @@
+version: 2
+updates:
+ - package-ecosystem: "maven"
+ directory: "/"
+ schedule:
+ interval: "weekly"
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "weekly"
diff --git a/README.md b/README.md
index 6c71d9c..09caffa 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ For more information on using the amazon-sqs-java-extended-client-lib, see our g
com.amazonaws
amazon-sqs-java-extended-client-lib
- 1.2.3
+ 1.2.4
jar
```
diff --git a/pom.xml b/pom.xml
index d6226b1..38e9e05 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.amazonaws
amazon-sqs-java-extended-client-lib
- 1.2.3
+ 1.2.4
jar
Amazon SQS Extended Client Library for Java
An extension to the Amazon SQS client that enables sending and receiving messages up to 2GB via Amazon S3.
@@ -55,19 +55,19 @@
software.amazon.payloadoffloading
payloadoffloading-common
- 1.1.0
+ 1.1.2
- junit
- junit
- 4.13.1
+ org.junit.jupiter
+ junit-jupiter
+ 5.9.2
test
org.mockito
mockito-core
- 1.10.19
+ 5.2.0
test
@@ -77,7 +77,7 @@
org.apache.maven.plugins
maven-compiler-plugin
- 3.2
+ 3.11.0
1.8
@@ -100,10 +100,15 @@
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0
+
org.apache.maven.plugins
maven-javadoc-plugin
- 2.9.1
+ 3.5.0
attach-javadocs
@@ -111,11 +116,7 @@
jar
-
- -Xdoclint:none
+ none
@@ -123,7 +124,7 @@
org.sonatype.plugins
nexus-staging-maven-plugin
- 1.6.7
+ 1.6.13
true
ossrh
diff --git a/src/main/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClient.java b/src/main/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClient.java
index 452fa8a..4249dec 100644
--- a/src/main/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClient.java
+++ b/src/main/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClient.java
@@ -15,10 +15,6 @@
package com.amazon.sqs.javamessaging;
-import java.nio.ByteBuffer;
-import java.util.*;
-import java.util.Map.Entry;
-
import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.sqs.AmazonSQS;
@@ -53,10 +49,21 @@
import com.amazonaws.services.sqs.model.SendMessageRequest;
import com.amazonaws.services.sqs.model.SendMessageResult;
import com.amazonaws.services.sqs.model.TooManyEntriesInBatchRequestException;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import software.amazon.payloadoffloading.*;
+import software.amazon.payloadoffloading.PayloadS3Pointer;
+import software.amazon.payloadoffloading.PayloadStore;
+import software.amazon.payloadoffloading.S3BackedPayloadStore;
+import software.amazon.payloadoffloading.S3Dao;
+import software.amazon.payloadoffloading.Util;
+
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Optional;
/**
diff --git a/src/main/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClientBase.java b/src/main/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClientBase.java
index 70edbae..8530c6d 100644
--- a/src/main/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClientBase.java
+++ b/src/main/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClientBase.java
@@ -104,7 +104,7 @@ public AmazonSQSExtendedClientBase(AmazonSQS sqsClient) {
* IMPORTANT: The following list shows the characters (in
* Unicode) allowed in your message, according to the W3C XML
* specification. For more information, go to
- * http://www.w3.org/TR/REC-xml/#charsets If you send any characters not
+ * ... If you send any characters not
* included in the list, your request will be rejected. #x9 | #xA | #xD |
* [#x20 to #xD7FF] | [#xE000 to #xFFFD] | [#x10000 to #x10FFFF]
*
diff --git a/src/test/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClientTest.java b/src/test/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClientTest.java
index 0975183..1351db3 100644
--- a/src/test/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClientTest.java
+++ b/src/test/java/com/amazon/sqs/javamessaging/AmazonSQSExtendedClientTest.java
@@ -15,36 +15,56 @@
package com.amazon.sqs.javamessaging;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-
import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.s3.AmazonS3;
-import com.amazonaws.services.s3.model.*;
+import com.amazonaws.services.s3.model.CannedAccessControlList;
+import com.amazonaws.services.s3.model.GetObjectRequest;
+import com.amazonaws.services.s3.model.PutObjectRequest;
+import com.amazonaws.services.s3.model.S3Object;
+import com.amazonaws.services.s3.model.SSEAwsKeyManagementParams;
import com.amazonaws.services.sqs.AmazonSQS;
import com.amazonaws.services.sqs.AmazonSQSClient;
-import com.amazonaws.services.sqs.model.*;
-
+import com.amazonaws.services.sqs.model.DeleteMessageBatchRequest;
+import com.amazonaws.services.sqs.model.DeleteMessageBatchRequestEntry;
+import com.amazonaws.services.sqs.model.DeleteMessageRequest;
+import com.amazonaws.services.sqs.model.Message;
+import com.amazonaws.services.sqs.model.MessageAttributeValue;
+import com.amazonaws.services.sqs.model.ReceiveMessageRequest;
+import com.amazonaws.services.sqs.model.ReceiveMessageResult;
+import com.amazonaws.services.sqs.model.SendMessageBatchRequest;
+import com.amazonaws.services.sqs.model.SendMessageBatchRequestEntry;
+import com.amazonaws.services.sqs.model.SendMessageRequest;
import com.amazonaws.util.StringInputStream;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import software.amazon.payloadoffloading.PayloadS3Pointer;
-import static org.mockito.Matchers.eq;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doThrow;
-import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.isA;
-import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyString;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoInteractions;
+import static org.mockito.Mockito.when;
/**
* Tests the AmazonSQSExtendedClient class.
@@ -69,7 +89,7 @@ public class AmazonSQSExtendedClientTest {
// should be > 1 and << SQS_SIZE_LIMIT
private static final int ARBITRARY_SMALLER_THRESHOLD = 500;
- @Before
+ @BeforeEach
public void setupClients() {
mockS3 = mock(AmazonS3.class);
mockSqsBackend = mock(AmazonSQS.class);
@@ -89,8 +109,7 @@ public void setupClients() {
ExtendedClientConfiguration extendedClientConfigurationWithGenericReservedAttributeName = new ExtendedClientConfiguration()
.withPayloadSupportEnabled(mockS3, S3_BUCKET_NAME).withLegacyReservedAttributeNameDisabled();
- ExtendedClientConfiguration extendedClientConfigurationDeprecated = new ExtendedClientConfiguration()
- .withLargePayloadSupportEnabled(mockS3, S3_BUCKET_NAME);
+ ExtendedClientConfiguration extendedClientConfigurationDeprecated = new ExtendedClientConfiguration().withPayloadSupportEnabled(mockS3, S3_BUCKET_NAME);
extendedSqsWithDefaultConfig = spy(new AmazonSQSExtendedClient(mockSqsBackend, extendedClientConfiguration));
extendedSqsWithCustomKMS = spy(new AmazonSQSExtendedClient(mockSqsBackend, extendedClientConfigurationWithCustomKMS));
@@ -101,10 +120,8 @@ public void setupClients() {
@Test
public void testWhenSendMessageWithLargePayloadSupportDisabledThenS3IsNotUsedAndSqsBackendIsResponsibleToFailItWithDeprecatedMethod() {
- int messageLength = MORE_THAN_SQS_SIZE_LIMIT;
- String messageBody = generateStringWithLength(messageLength);
- ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration()
- .withLargePayloadSupportDisabled();
+ String messageBody = generateStringWithLength(MORE_THAN_SQS_SIZE_LIMIT);
+ ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration().withPayloadSupportDisabled();
AmazonSQS sqsExtended = spy(new AmazonSQSExtendedClient(mockSqsBackend, extendedClientConfiguration));
SendMessageRequest messageRequest = new SendMessageRequest(SQS_QUEUE_URL, messageBody);
@@ -116,10 +133,8 @@ public void testWhenSendMessageWithLargePayloadSupportDisabledThenS3IsNotUsedAnd
@Test
public void testWhenSendMessageWithAlwaysThroughS3AndMessageIsSmallThenItIsStillStoredInS3WithDeprecatedMethod() {
- int messageLength = LESS_THAN_SQS_SIZE_LIMIT;
- String messageBody = generateStringWithLength(messageLength);
- ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration()
- .withLargePayloadSupportEnabled(mockS3, S3_BUCKET_NAME).withAlwaysThroughS3(true);
+ String messageBody = generateStringWithLength(LESS_THAN_SQS_SIZE_LIMIT);
+ ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration().withPayloadSupportEnabled(mockS3, S3_BUCKET_NAME).withAlwaysThroughS3(true);
AmazonSQS sqsExtended = spy(new AmazonSQSExtendedClient(mock(AmazonSQSClient.class), extendedClientConfiguration));
SendMessageRequest messageRequest = new SendMessageRequest(SQS_QUEUE_URL, messageBody);
@@ -132,8 +147,7 @@ public void testWhenSendMessageWithAlwaysThroughS3AndMessageIsSmallThenItIsStill
public void testWhenSendMessageWithSetMessageSizeThresholdThenThresholdIsHonoredWithDeprecatedMethod() {
int messageLength = ARBITRARY_SMALLER_THRESHOLD * 2;
String messageBody = generateStringWithLength(messageLength);
- ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration()
- .withLargePayloadSupportEnabled(mockS3, S3_BUCKET_NAME).withMessageSizeThreshold(ARBITRARY_SMALLER_THRESHOLD);
+ ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration().withPayloadSupportEnabled(mockS3, S3_BUCKET_NAME).withPayloadSizeThreshold(ARBITRARY_SMALLER_THRESHOLD);
AmazonSQS sqsExtended = spy(new AmazonSQSExtendedClient(mock(AmazonSQSClient.class), extendedClientConfiguration));
@@ -144,8 +158,7 @@ public void testWhenSendMessageWithSetMessageSizeThresholdThenThresholdIsHonored
@Test
public void testReceiveMessageMultipleTimesDoesNotAdditionallyAlterReceiveMessageRequestWithDeprecatedMethod() {
- ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration()
- .withLargePayloadSupportEnabled(mockS3, S3_BUCKET_NAME);
+ ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration().withPayloadSupportEnabled(mockS3, S3_BUCKET_NAME);
AmazonSQS sqsExtended = spy(new AmazonSQSExtendedClient(mockSqsBackend, extendedClientConfiguration));
when(mockSqsBackend.receiveMessage(isA(ReceiveMessageRequest.class))).thenReturn(new ReceiveMessageResult());
@@ -154,10 +167,10 @@ public void testReceiveMessageMultipleTimesDoesNotAdditionallyAlterReceiveMessag
.withMessageAttributeNames(AmazonSQSExtendedClient.LEGACY_RESERVED_ATTRIBUTE_NAME, SQSExtendedClientConstants.RESERVED_ATTRIBUTE_NAME);
sqsExtended.receiveMessage(messageRequest);
- Assert.assertEquals(expectedRequest, messageRequest);
+ assertEquals(expectedRequest, messageRequest);
sqsExtended.receiveMessage(messageRequest);
- Assert.assertEquals(expectedRequest, messageRequest);
+ assertEquals(expectedRequest, messageRequest);
}
@Test
@@ -180,8 +193,8 @@ public void testWhenSendLargeMessage_WithoutKMS_ThenPayloadIsStoredInS3AndKMSKey
ArgumentCaptor putObjectRequestArgumentCaptor = ArgumentCaptor.forClass(PutObjectRequest.class);
verify(mockS3, times(1)).putObject(putObjectRequestArgumentCaptor.capture());
- Assert.assertNull(putObjectRequestArgumentCaptor.getValue().getSSEAwsKeyManagementParams());
- Assert.assertEquals(putObjectRequestArgumentCaptor.getValue().getBucketName(), S3_BUCKET_NAME);
+ assertNull(putObjectRequestArgumentCaptor.getValue().getSSEAwsKeyManagementParams());
+ assertEquals(putObjectRequestArgumentCaptor.getValue().getBucketName(), S3_BUCKET_NAME);
}
@Test
@@ -194,9 +207,9 @@ public void testWhenSendLargeMessage_WithCustomKMS_ThenPayloadIsStoredInS3AndCor
ArgumentCaptor putObjectRequestArgumentCaptor = ArgumentCaptor.forClass(PutObjectRequest.class);
verify(mockS3, times(1)).putObject(putObjectRequestArgumentCaptor.capture());
- Assert.assertEquals(putObjectRequestArgumentCaptor.getValue().getSSEAwsKeyManagementParams()
+ assertEquals(putObjectRequestArgumentCaptor.getValue().getSSEAwsKeyManagementParams()
.getAwsKmsKeyId(), S3_SERVER_SIDE_ENCRYPTION_KMS_KEY_ID);
- Assert.assertEquals(putObjectRequestArgumentCaptor.getValue().getBucketName(), S3_BUCKET_NAME);
+ assertEquals(putObjectRequestArgumentCaptor.getValue().getBucketName(), S3_BUCKET_NAME);
}
@Test
@@ -209,15 +222,14 @@ public void testWhenSendLargeMessage_WithDefaultKMS_ThenPayloadIsStoredInS3AndCo
ArgumentCaptor putObjectRequestArgumentCaptor = ArgumentCaptor.forClass(PutObjectRequest.class);
verify(mockS3, times(1)).putObject(putObjectRequestArgumentCaptor.capture());
- Assert.assertTrue(putObjectRequestArgumentCaptor.getValue().getSSEAwsKeyManagementParams() != null &&
+ assertTrue(putObjectRequestArgumentCaptor.getValue().getSSEAwsKeyManagementParams() != null &&
putObjectRequestArgumentCaptor.getValue().getSSEAwsKeyManagementParams().getAwsKmsKeyId() == null);
- Assert.assertEquals(putObjectRequestArgumentCaptor.getValue().getBucketName(), S3_BUCKET_NAME);
+ assertEquals(putObjectRequestArgumentCaptor.getValue().getBucketName(), S3_BUCKET_NAME);
}
@Test
public void testSendLargeMessageWithDefaultConfigThenLegacyReservedAttributeNameIsUsed(){
- int messageLength = MORE_THAN_SQS_SIZE_LIMIT;
- String messageBody = generateStringWithLength(messageLength);
+ String messageBody = generateStringWithLength(MORE_THAN_SQS_SIZE_LIMIT);
SendMessageRequest messageRequest = new SendMessageRequest(SQS_QUEUE_URL, messageBody);
extendedSqsWithDefaultConfig.sendMessage(messageRequest);
@@ -225,15 +237,14 @@ public void testSendLargeMessageWithDefaultConfigThenLegacyReservedAttributeName
verify(mockSqsBackend).sendMessage(sendMessageRequestCaptor.capture());
Map attributes = sendMessageRequestCaptor.getValue().getMessageAttributes();
- Assert.assertTrue(attributes.keySet().contains(AmazonSQSExtendedClient.LEGACY_RESERVED_ATTRIBUTE_NAME));
- Assert.assertFalse(attributes.keySet().contains(SQSExtendedClientConstants.RESERVED_ATTRIBUTE_NAME));
+ assertTrue(attributes.containsKey(AmazonSQSExtendedClient.LEGACY_RESERVED_ATTRIBUTE_NAME));
+ assertFalse(attributes.containsKey(SQSExtendedClientConstants.RESERVED_ATTRIBUTE_NAME));
}
@Test
public void testSendLargeMessageWithGenericReservedAttributeNameConfigThenGenericReservedAttributeNameIsUsed(){
- int messageLength = MORE_THAN_SQS_SIZE_LIMIT;
- String messageBody = generateStringWithLength(messageLength);
+ String messageBody = generateStringWithLength(MORE_THAN_SQS_SIZE_LIMIT);
SendMessageRequest messageRequest = new SendMessageRequest(SQS_QUEUE_URL, messageBody);
extendedSqsWithGenericReservedAttributeName.sendMessage(messageRequest);
@@ -241,14 +252,13 @@ public void testSendLargeMessageWithGenericReservedAttributeNameConfigThenGeneri
verify(mockSqsBackend).sendMessage(sendMessageRequestCaptor.capture());
Map attributes = sendMessageRequestCaptor.getValue().getMessageAttributes();
- Assert.assertTrue(attributes.keySet().contains(SQSExtendedClientConstants.RESERVED_ATTRIBUTE_NAME));
- Assert.assertFalse(attributes.keySet().contains(AmazonSQSExtendedClient.LEGACY_RESERVED_ATTRIBUTE_NAME));
+ assertTrue(attributes.containsKey(SQSExtendedClientConstants.RESERVED_ATTRIBUTE_NAME));
+ assertFalse(attributes.containsKey(AmazonSQSExtendedClient.LEGACY_RESERVED_ATTRIBUTE_NAME));
}
@Test
public void testWhenSendSmallMessageThenS3IsNotUsed() {
- int messageLength = SQS_SIZE_LIMIT;
- String messageBody = generateStringWithLength(messageLength);
+ String messageBody = generateStringWithLength(SQS_SIZE_LIMIT);
SendMessageRequest messageRequest = new SendMessageRequest(SQS_QUEUE_URL, messageBody);
extendedSqsWithDefaultConfig.sendMessage(messageRequest);
@@ -258,8 +268,7 @@ public void testWhenSendSmallMessageThenS3IsNotUsed() {
@Test
public void testWhenSendMessageWithLargePayloadSupportDisabledThenS3IsNotUsedAndSqsBackendIsResponsibleToFailIt() {
- int messageLength = MORE_THAN_SQS_SIZE_LIMIT;
- String messageBody = generateStringWithLength(messageLength);
+ String messageBody = generateStringWithLength(MORE_THAN_SQS_SIZE_LIMIT);
ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration()
.withPayloadSupportDisabled();
AmazonSQS sqsExtended = spy(new AmazonSQSExtendedClient(mockSqsBackend, extendedClientConfiguration));
@@ -273,8 +282,7 @@ public void testWhenSendMessageWithLargePayloadSupportDisabledThenS3IsNotUsedAnd
@Test
public void testWhenSendMessageWithAlwaysThroughS3AndMessageIsSmallThenItIsStillStoredInS3() {
- int messageLength = LESS_THAN_SQS_SIZE_LIMIT;
- String messageBody = generateStringWithLength(messageLength);
+ String messageBody = generateStringWithLength(LESS_THAN_SQS_SIZE_LIMIT);
ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration()
.withPayloadSupportEnabled(mockS3, S3_BUCKET_NAME).withAlwaysThroughS3(true);
AmazonSQS sqsExtended = spy(new AmazonSQSExtendedClient(mock(AmazonSQSClient.class), extendedClientConfiguration));
@@ -309,10 +317,10 @@ public void testReceiveMessageMultipleTimesDoesNotAdditionallyAlterReceiveMessag
.withMessageAttributeNames(AmazonSQSExtendedClient.RESERVED_ATTRIBUTE_NAMES);
extendedSqsWithDefaultConfig.receiveMessage(messageRequest);
- Assert.assertEquals(expectedRequest, messageRequest);
+ assertEquals(expectedRequest, messageRequest);
extendedSqsWithDefaultConfig.receiveMessage(messageRequest);
- Assert.assertEquals(expectedRequest, messageRequest);
+ assertEquals(expectedRequest, messageRequest);
}
@Test
@@ -326,7 +334,7 @@ public void testReceiveMessage_when_MessageIsLarge_ReservedAttributeUsed() throw
}
@Test
- public void testReceiveMessage_when_MessageIsSmall() throws Exception {
+ public void testReceiveMessage_when_MessageIsSmall() {
String expectedMessageAttributeName = "AnyMessageAttribute";
String expectedMessage = "SmallMessage";
Message message = new Message().addMessageAttributesEntry(expectedMessageAttributeName, mock(MessageAttributeValue.class));
@@ -337,10 +345,10 @@ public void testReceiveMessage_when_MessageIsSmall() throws Exception {
ReceiveMessageResult actualReceiveMessageResult = extendedSqsWithDefaultConfig.receiveMessage(messageRequest);
Message actualMessage = actualReceiveMessageResult.getMessages().get(0);
- Assert.assertEquals(expectedMessage, actualMessage.getBody());
- Assert.assertTrue(actualMessage.getMessageAttributes().keySet().contains(expectedMessageAttributeName));
- Assert.assertFalse(actualMessage.getMessageAttributes().keySet().containsAll(AmazonSQSExtendedClient.RESERVED_ATTRIBUTE_NAMES));
- verifyZeroInteractions(mockS3);
+ assertEquals(expectedMessage, actualMessage.getBody());
+ assertTrue(actualMessage.getMessageAttributes().containsKey(expectedMessageAttributeName));
+ assertFalse(actualMessage.getMessageAttributes().keySet().containsAll(AmazonSQSExtendedClient.RESERVED_ATTRIBUTE_NAMES));
+ verifyNoInteractions(mockS3);
}
@Test
@@ -361,7 +369,7 @@ public void testWhenMessageBatchIsSentThenOnlyMessagesLargerThanThresholdAreStor
1000_000
};
- List batchEntries = new ArrayList();
+ List batchEntries = new ArrayList<>();
for (int i = 0; i < 10; i++) {
SendMessageBatchRequestEntry entry = new SendMessageBatchRequestEntry();
int messageLength = messageLengthForCounter[i];
@@ -380,8 +388,7 @@ public void testWhenMessageBatchIsSentThenOnlyMessagesLargerThanThresholdAreStor
@Test
public void testWhenSmallMessageIsSentThenNoAttributeIsAdded() {
- int messageLength = LESS_THAN_SQS_SIZE_LIMIT;
- String messageBody = generateStringWithLength(messageLength);
+ String messageBody = generateStringWithLength(LESS_THAN_SQS_SIZE_LIMIT);
SendMessageRequest messageRequest = new SendMessageRequest(SQS_QUEUE_URL, messageBody);
extendedSqsWithDefaultConfig.sendMessage(messageRequest);
@@ -390,7 +397,7 @@ public void testWhenSmallMessageIsSentThenNoAttributeIsAdded() {
verify(mockSqsBackend).sendMessage(sendMessageRequestCaptor.capture());
Map attributes = sendMessageRequestCaptor.getValue().getMessageAttributes();
- Assert.assertTrue(attributes.isEmpty());
+ assertTrue(attributes.isEmpty());
}
@Test
@@ -405,8 +412,8 @@ public void testWhenLargeMessageIsSentThenAttributeWithPayloadSizeIsAdded() {
verify(mockSqsBackend).sendMessage(sendMessageRequestCaptor.capture());
Map attributes = sendMessageRequestCaptor.getValue().getMessageAttributes();
- Assert.assertEquals("Number", attributes.get(AmazonSQSExtendedClient.LEGACY_RESERVED_ATTRIBUTE_NAME).getDataType());
- Assert.assertEquals(messageLength, (int) Integer.valueOf(attributes.get(AmazonSQSExtendedClient.LEGACY_RESERVED_ATTRIBUTE_NAME).getStringValue()));
+ assertEquals("Number", attributes.get(AmazonSQSExtendedClient.LEGACY_RESERVED_ATTRIBUTE_NAME).getDataType());
+ assertEquals(messageLength, Integer.parseInt(attributes.get(AmazonSQSExtendedClient.LEGACY_RESERVED_ATTRIBUTE_NAME).getStringValue()));
}
@Test
@@ -428,12 +435,12 @@ public void testWhenIgnorePayloadNotFoundIsSentThenNotFoundKeysInS3AreDeletedInS
AmazonSQS sqsExtended = spy(new AmazonSQSExtendedClient(mockSqsBackend, extendedClientConfiguration));
ReceiveMessageRequest messageRequest = new ReceiveMessageRequest().withQueueUrl(SQS_QUEUE_URL);
ReceiveMessageResult actualReceiveMessageResult = sqsExtended.receiveMessage(messageRequest);
- Assert.assertTrue(actualReceiveMessageResult.getMessages().isEmpty());
+ assertTrue(actualReceiveMessageResult.getMessages().isEmpty());
ArgumentCaptor deleteMessageRequestArgumentCaptor = ArgumentCaptor.forClass(DeleteMessageRequest.class);
verify(mockSqsBackend).deleteMessage(deleteMessageRequestArgumentCaptor.capture());
- Assert.assertEquals(SQS_QUEUE_URL, deleteMessageRequestArgumentCaptor.getValue().getQueueUrl());
- Assert.assertEquals("receipt-handle", deleteMessageRequestArgumentCaptor.getValue().getReceiptHandle());
+ assertEquals(SQS_QUEUE_URL, deleteMessageRequestArgumentCaptor.getValue().getQueueUrl());
+ assertEquals("receipt-handle", deleteMessageRequestArgumentCaptor.getValue().getReceiptHandle());
}
@Test
@@ -452,7 +459,7 @@ public void testWhenIgnorePayloadNotFoundIsNotSentThenNotFoundKeysInS3AreNotDele
try {
extendedSqsWithDefaultConfig.receiveMessage(messageRequest);
- Assert.fail("exception should have been thrown");
+ fail("exception should have been thrown");
} catch (AmazonServiceException e) {
verify(mockSqsBackend, never()).deleteMessage(any(DeleteMessageRequest.class));
}
@@ -470,8 +477,8 @@ public void testDefaultExtendedClientDeletesSmallMessage() {
// then
ArgumentCaptor deleteRequestCaptor = ArgumentCaptor.forClass(DeleteMessageRequest.class);
verify(mockSqsBackend).deleteMessage(deleteRequestCaptor.capture());
- Assert.assertEquals(receiptHandle, deleteRequestCaptor.getValue().getReceiptHandle());
- verifyZeroInteractions(mockS3);
+ assertEquals(receiptHandle, deleteRequestCaptor.getValue().getReceiptHandle());
+ verifyNoInteractions(mockS3);
}
@Test
@@ -488,7 +495,7 @@ public void testDefaultExtendedClientDeletesObjectS3UponMessageDelete() {
// then
ArgumentCaptor deleteRequestCaptor = ArgumentCaptor.forClass(DeleteMessageRequest.class);
verify(mockSqsBackend).deleteMessage(deleteRequestCaptor.capture());
- Assert.assertEquals(originalReceiptHandle, deleteRequestCaptor.getValue().getReceiptHandle());
+ assertEquals(originalReceiptHandle, deleteRequestCaptor.getValue().getReceiptHandle());
verify(mockS3).deleteObject(eq(S3_BUCKET_NAME), eq(randomS3Key));
}
@@ -511,8 +518,8 @@ public void testExtendedClientConfiguredDoesNotDeleteObjectFromS3UponDelete() {
// then
ArgumentCaptor deleteRequestCaptor = ArgumentCaptor.forClass(DeleteMessageRequest.class);
verify(mockSqsBackend).deleteMessage(deleteRequestCaptor.capture());
- Assert.assertEquals(originalReceiptHandle, deleteRequestCaptor.getValue().getReceiptHandle());
- verifyZeroInteractions(mockS3);
+ assertEquals(originalReceiptHandle, deleteRequestCaptor.getValue().getReceiptHandle());
+ verifyNoInteractions(mockS3);
}
@Test
@@ -529,7 +536,7 @@ public void testExtendedClientConfiguredDoesNotDeletesObjectsFromS3UponDeleteBat
// then
verify(mockSqsBackend, times(1)).deleteMessageBatch(any(DeleteMessageBatchRequest.class));
- verifyZeroInteractions(mockS3);
+ verifyNoInteractions(mockS3);
}
@Test
@@ -561,7 +568,7 @@ public void testWhenSendMessageWIthCannedAccessControlListDefined() {
verify(mockS3).putObject(captor.capture());
- Assert.assertEquals(expected, captor.getValue().getCannedAcl());
+ assertEquals(expected, captor.getValue().getCannedAcl());
}
private void testReceiveMessage_when_MessageIsLarge(String reservedAttributeName) throws Exception {
@@ -578,8 +585,8 @@ private void testReceiveMessage_when_MessageIsLarge(String reservedAttributeName
ReceiveMessageResult actualReceiveMessageResult = extendedSqsWithDefaultConfig.receiveMessage(messageRequest);
Message actualMessage = actualReceiveMessageResult.getMessages().get(0);
- Assert.assertEquals(expectedMessage, actualMessage.getBody());
- Assert.assertFalse(actualMessage.getMessageAttributes().keySet().containsAll(AmazonSQSExtendedClient.RESERVED_ATTRIBUTE_NAMES));
+ assertEquals(expectedMessage, actualMessage.getBody());
+ assertFalse(actualMessage.getMessageAttributes().keySet().containsAll(AmazonSQSExtendedClient.RESERVED_ATTRIBUTE_NAMES));
verify(mockS3, times(1)).getObject(isA(GetObjectRequest.class));
}
diff --git a/src/test/java/com/amazon/sqs/javamessaging/ExtendedClientConfigurationTest.java b/src/test/java/com/amazon/sqs/javamessaging/ExtendedClientConfigurationTest.java
index 1ff48be..b306319 100644
--- a/src/test/java/com/amazon/sqs/javamessaging/ExtendedClientConfigurationTest.java
+++ b/src/test/java/com/amazon/sqs/javamessaging/ExtendedClientConfigurationTest.java
@@ -18,19 +18,27 @@
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.model.PutObjectRequest;
import com.amazonaws.services.s3.model.SSEAwsKeyManagementParams;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import static org.mockito.Mockito.*;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
/**
* Tests the ExtendedClientConfiguration class.
*/
public class ExtendedClientConfigurationTest {
- private static String s3BucketName = "test-bucket-name";
- private static String s3ServerSideEncryptionKMSKeyId = "test-customer-managed-kms-key-id";
+ private static final String s3BucketName = "test-bucket-name";
+ private static final String s3ServerSideEncryptionKMSKeyId = "test-customer-managed-kms-key-id";
@Test
public void testCopyConstructor() {
@@ -48,15 +56,15 @@ public void testCopyConstructor() {
ExtendedClientConfiguration newExtendedClientConfig = new ExtendedClientConfiguration(extendedClientConfig);
- Assert.assertEquals(s3, newExtendedClientConfig.getAmazonS3Client());
- Assert.assertEquals(s3BucketName, newExtendedClientConfig.getS3BucketName());
- Assert.assertEquals(s3ServerSideEncryptionKMSKeyId, newExtendedClientConfig.getSSEAwsKeyManagementParams().getAwsKmsKeyId());
- Assert.assertTrue(newExtendedClientConfig.isPayloadSupportEnabled());
- Assert.assertEquals(doesCleanupS3Payload, newExtendedClientConfig.doesCleanupS3Payload());
- Assert.assertEquals(alwaysThroughS3, newExtendedClientConfig.isAlwaysThroughS3());
- Assert.assertEquals(messageSizeThreshold, newExtendedClientConfig.getPayloadSizeThreshold());
+ assertEquals(s3, newExtendedClientConfig.getAmazonS3Client());
+ assertEquals(s3BucketName, newExtendedClientConfig.getS3BucketName());
+ assertEquals(s3ServerSideEncryptionKMSKeyId, newExtendedClientConfig.getSSEAwsKeyManagementParams().getAwsKmsKeyId());
+ assertTrue(newExtendedClientConfig.isPayloadSupportEnabled());
+ assertEquals(doesCleanupS3Payload, newExtendedClientConfig.doesCleanupS3Payload());
+ assertEquals(alwaysThroughS3, newExtendedClientConfig.isAlwaysThroughS3());
+ assertEquals(messageSizeThreshold, newExtendedClientConfig.getPayloadSizeThreshold());
- Assert.assertNotSame(newExtendedClientConfig, extendedClientConfig);
+ assertNotSame(newExtendedClientConfig, extendedClientConfig);
}
@Test
@@ -65,10 +73,10 @@ public void testLargePayloadSupportEnabledWithDefaultDeleteFromS3Config() {
ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration();
extendedClientConfiguration.setPayloadSupportEnabled(s3, s3BucketName);
- Assert.assertTrue(extendedClientConfiguration.isPayloadSupportEnabled());
- Assert.assertTrue(extendedClientConfiguration.doesCleanupS3Payload());
- Assert.assertNotNull(extendedClientConfiguration.getAmazonS3Client());
- Assert.assertEquals(s3BucketName, extendedClientConfiguration.getS3BucketName());
+ assertTrue(extendedClientConfiguration.isPayloadSupportEnabled());
+ assertTrue(extendedClientConfiguration.doesCleanupS3Payload());
+ assertNotNull(extendedClientConfiguration.getAmazonS3Client());
+ assertEquals(s3BucketName, extendedClientConfiguration.getS3BucketName());
}
@@ -79,10 +87,10 @@ public void testLargePayloadSupportEnabledWithDeleteFromS3Enabled() {
ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration();
extendedClientConfiguration.setPayloadSupportEnabled(s3, s3BucketName, true);
- Assert.assertTrue(extendedClientConfiguration.isPayloadSupportEnabled());
- Assert.assertTrue(extendedClientConfiguration.doesCleanupS3Payload());
- Assert.assertNotNull(extendedClientConfiguration.getAmazonS3Client());
- Assert.assertEquals(s3BucketName, extendedClientConfiguration.getS3BucketName());
+ assertTrue(extendedClientConfiguration.isPayloadSupportEnabled());
+ assertTrue(extendedClientConfiguration.doesCleanupS3Payload());
+ assertNotNull(extendedClientConfiguration.getAmazonS3Client());
+ assertEquals(s3BucketName, extendedClientConfiguration.getS3BucketName());
}
@Test
@@ -91,10 +99,10 @@ public void testLargePayloadSupportEnabledWithDeleteFromS3Disabled() {
ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration();
extendedClientConfiguration.setPayloadSupportEnabled(s3, s3BucketName, false);
- Assert.assertTrue(extendedClientConfiguration.isPayloadSupportEnabled());
- Assert.assertFalse(extendedClientConfiguration.doesCleanupS3Payload());
- Assert.assertNotNull(extendedClientConfiguration.getAmazonS3Client());
- Assert.assertEquals(s3BucketName, extendedClientConfiguration.getS3BucketName());
+ assertTrue(extendedClientConfiguration.isPayloadSupportEnabled());
+ assertFalse(extendedClientConfiguration.doesCleanupS3Payload());
+ assertNotNull(extendedClientConfiguration.getAmazonS3Client());
+ assertEquals(s3BucketName, extendedClientConfiguration.getS3BucketName());
}
@Test
@@ -108,18 +116,18 @@ public void testCopyConstructorDeprecated() {
ExtendedClientConfiguration extendedClientConfig = new ExtendedClientConfiguration();
- extendedClientConfig.withLargePayloadSupportEnabled(s3, s3BucketName)
- .withAlwaysThroughS3(alwaysThroughS3).withMessageSizeThreshold(messageSizeThreshold);
+ extendedClientConfig.withPayloadSupportEnabled(s3, s3BucketName)
+ .withAlwaysThroughS3(alwaysThroughS3).withPayloadSizeThreshold(messageSizeThreshold);
ExtendedClientConfiguration newExtendedClientConfig = new ExtendedClientConfiguration(extendedClientConfig);
- Assert.assertEquals(s3, newExtendedClientConfig.getAmazonS3Client());
- Assert.assertEquals(s3BucketName, newExtendedClientConfig.getS3BucketName());
- Assert.assertTrue(newExtendedClientConfig.isLargePayloadSupportEnabled());
- Assert.assertEquals(alwaysThroughS3, newExtendedClientConfig.isAlwaysThroughS3());
- Assert.assertEquals(messageSizeThreshold, newExtendedClientConfig.getMessageSizeThreshold());
+ assertEquals(s3, newExtendedClientConfig.getAmazonS3Client());
+ assertEquals(s3BucketName, newExtendedClientConfig.getS3BucketName());
+ assertTrue(newExtendedClientConfig.isPayloadSupportEnabled());
+ assertEquals(alwaysThroughS3, newExtendedClientConfig.isAlwaysThroughS3());
+ assertEquals(messageSizeThreshold, newExtendedClientConfig.getPayloadSizeThreshold());
- Assert.assertNotSame(newExtendedClientConfig, extendedClientConfig);
+ assertNotSame(newExtendedClientConfig, extendedClientConfig);
}
@Test
@@ -129,11 +137,11 @@ public void testLargePayloadSupportEnabled() {
when(s3.putObject(isA(PutObjectRequest.class))).thenReturn(null);
ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration();
- extendedClientConfiguration.setLargePayloadSupportEnabled(s3, s3BucketName);
+ extendedClientConfiguration.setPayloadSupportEnabled(s3, s3BucketName);
- Assert.assertTrue(extendedClientConfiguration.isLargePayloadSupportEnabled());
- Assert.assertNotNull(extendedClientConfiguration.getAmazonS3Client());
- Assert.assertEquals(s3BucketName, extendedClientConfiguration.getS3BucketName());
+ assertTrue(extendedClientConfiguration.isPayloadSupportEnabled());
+ assertNotNull(extendedClientConfiguration.getAmazonS3Client());
+ assertEquals(s3BucketName, extendedClientConfiguration.getS3BucketName());
}
@@ -144,10 +152,10 @@ public void testDisableLargePayloadSupport() {
when(s3.putObject(isA(PutObjectRequest.class))).thenReturn(null);
ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration();
- extendedClientConfiguration.setLargePayloadSupportDisabled();
+ extendedClientConfiguration.setPayloadSupportDisabled();
- Assert.assertNull(extendedClientConfiguration.getAmazonS3Client());
- Assert.assertNull(extendedClientConfiguration.getS3BucketName());
+ assertNull(extendedClientConfiguration.getAmazonS3Client());
+ assertNull(extendedClientConfiguration.getS3BucketName());
verify(s3, never()).putObject(isA(PutObjectRequest.class));
}
@@ -157,12 +165,12 @@ public void testMessageSizeThreshold() {
ExtendedClientConfiguration extendedClientConfiguration = new ExtendedClientConfiguration();
- Assert.assertEquals(SQSExtendedClientConstants.DEFAULT_MESSAGE_SIZE_THRESHOLD,
- extendedClientConfiguration.getMessageSizeThreshold());
+ assertEquals(SQSExtendedClientConstants.DEFAULT_MESSAGE_SIZE_THRESHOLD,
+ extendedClientConfiguration.getPayloadSizeThreshold());
int messageLength = 1000;
- extendedClientConfiguration.setMessageSizeThreshold(messageLength);
- Assert.assertEquals(messageLength, extendedClientConfiguration.getMessageSizeThreshold());
+ extendedClientConfiguration.setPayloadSizeThreshold(messageLength);
+ assertEquals(messageLength, extendedClientConfiguration.getPayloadSizeThreshold());
}
}