Skip to content

Commit

Permalink
Upgrade dependencies and minor refactoring (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
ziyanli-amazon committed Mar 24, 2023
1 parent f4ccdbd commit b5e97a2
Show file tree
Hide file tree
Showing 20 changed files with 302 additions and 323 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Temporary queues are also automatically deleted if the clients that created them
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>amazon-sqs-java-temporary-queues-client</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<type>jar</type>
</dependency>
```
Expand Down
44 changes: 24 additions & 20 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.amazonaws</groupId>
<artifactId>amazon-sqs-java-temporary-queues-client</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
<name>Amazon SQS Java Temporary Queues Client</name>
<description>An Amazon SQS client that supports creating lightweight, automatically-deleted temporary queues, for use in common messaging patterns such as Request/Response. See http:https://aws.amazon.com/sqs.</description>
<url>https://github.com/awslabs/amazon-sqs-java-temporary-queues-client</url>
Expand All @@ -27,7 +27,7 @@
</developer>
</developers>
<properties>
<aws-java-sdk.version>2.17.140</aws-java-sdk.version>
<aws-java-sdk.version>2.20.30</aws-java-sdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand All @@ -51,28 +51,22 @@
<version>1.2</version>
</dependency>

<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.7.0-M1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.7.0-M1</version>
<artifactId>junit-jupiter</artifactId>
<version>5.9.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.28.2</version>
<version>5.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.0.2</version>
<version>4.2.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -89,7 +83,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<version>3.11.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand All @@ -109,6 +103,11 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand All @@ -128,34 +127,39 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<version>3.5.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<!--
TODO-RS: Java 8 is more strict about some javadoc tags.
We'll need to update quite a few to remove this workaround.
-->
<additionalparam>-Xdoclint:none</additionalparam>
<source>8</source>
<doclint>none</doclint>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://aws.oss.sonatype.org</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
package com.amazonaws.services.sqs;

import java.util.Collections;
import java.util.HashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import com.amazonaws.services.sqs.util.Constants;
import com.amazonaws.services.sqs.util.SQSMessageConsumerBuilder;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import com.amazonaws.services.sqs.util.IntegrationTest;
import com.amazonaws.services.sqs.util.SQSMessageConsumer;
import com.amazonaws.services.sqs.util.SQSMessageConsumerBuilder;
import com.amazonaws.services.sqs.util.SQSQueueUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.services.sqs.model.CreateQueueRequest;
import software.amazon.awssdk.services.sqs.model.DeleteQueueRequest;
import software.amazon.awssdk.services.sqs.model.GetQueueUrlRequest;
Expand All @@ -24,6 +16,15 @@
import software.amazon.awssdk.services.sqs.model.QueueDoesNotExistException;
import software.amazon.awssdk.services.sqs.model.SendMessageRequest;

import java.util.Collections;
import java.util.HashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class AmazonSQSIdleQueueDeletingIT extends IntegrationTest {

Expand All @@ -32,15 +33,15 @@ public class AmazonSQSIdleQueueDeletingIT extends IntegrationTest {
private static AmazonSQSRequester requester;
private static AmazonSQSResponder responder;

@Before
@BeforeEach
public void setup() {
client = new AmazonSQSIdleQueueDeletingClient(sqs, queueNamePrefix);
requester = new AmazonSQSRequesterClient(sqs, queueNamePrefix,
Collections.emptyMap(), exceptionHandler);
responder = new AmazonSQSResponderClient(sqs);
}

@After
@AfterEach
public void teardown() {
if (client != null && queueUrl != null) {
try {
Expand Down Expand Up @@ -71,8 +72,8 @@ public void idleQueueIsDeleted() throws InterruptedException {
queueUrl = client.createQueue(createQueueRequest).queueUrl();

// May have to wait for up to a minute for the new queue to show up in ListQueues
Assert.assertTrue("Expected queue to be deleted: " + queueUrl,
SQSQueueUtils.awaitQueueDeleted(sqs, queueUrl, 70, TimeUnit.SECONDS));
assertTrue(SQSQueueUtils.awaitQueueDeleted(sqs, queueUrl, 70, TimeUnit.SECONDS),
"Expected queue to be deleted: " + queueUrl);
}

@Test
Expand All @@ -99,7 +100,7 @@ public void updatedHeartBeatTag() throws InterruptedException {

String updatedHeartbeat = getLastHeartbeatTimestamp();

Assert.assertNotEquals(initialHeartBeat, updatedHeartbeat);
assertNotEquals(initialHeartBeat, updatedHeartbeat);
}

private String getLastHeartbeatTimestamp() {
Expand Down Expand Up @@ -131,7 +132,7 @@ public void notUpdatedHeartBeatTag() throws InterruptedException {

String notUpdatedHeartbeat = getLastHeartbeatTimestamp();

Assert.assertEquals(initialHeartBeat, notUpdatedHeartbeat);
assertEquals(initialHeartBeat, notUpdatedHeartbeat);
}

@Test
Expand All @@ -153,14 +154,14 @@ public void recreatingQueues() throws InterruptedException {
sqs.deleteQueue(DeleteQueueRequest.builder().queueUrl(queueUrl).build());

// Sleeping is unfortunate here, but it's necessary to ensure the eventual consistency
// of the delete is resolved first. Otherwise it's easy to get a false positive below.
// of the delete is resolved first. Otherwise, it's easy to get a false positive below.
TimeUnit.MINUTES.sleep(1);

// Ensure the original queue is eventually recreated. This becoming true at least once
// indicates that CreateQueue was successfully called, even if it may flip back to false
// on subsequent calls.
Assert.assertTrue("Expected original queue to be recreated: " + queueUrl,
SQSQueueUtils.awaitQueueCreated(sqs, queueUrl, 70, TimeUnit.SECONDS));
assertTrue(SQSQueueUtils.awaitQueueCreated(sqs, queueUrl, 70, TimeUnit.SECONDS),
"Expected original queue to be recreated: " + queueUrl);

// Ensure the user doesn't experience any send or receive failures
user.finish();
Expand All @@ -180,10 +181,10 @@ public void recreatingQueues() throws InterruptedException {
}
});

Assert.assertTrue("Expected original queue to be deleted: " + failoverQueueUrl,
SQSQueueUtils.awaitQueueDeleted(sqs, queueUrl, 70, TimeUnit.SECONDS));
Assert.assertTrue("Expected failover queue to be deleted with the original: " + failoverQueueUrl,
SQSQueueUtils.awaitQueueDeleted(sqs, failoverQueueUrl, 70, TimeUnit.SECONDS));
assertTrue(SQSQueueUtils.awaitQueueDeleted(sqs, queueUrl, 70, TimeUnit.SECONDS),
"Expected original queue to be deleted: " + failoverQueueUrl);
assertTrue(SQSQueueUtils.awaitQueueDeleted(sqs, failoverQueueUrl, 70, TimeUnit.SECONDS),
"Expected failover queue to be deleted with the original: " + failoverQueueUrl);
}

private class QueueUser {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
package com.amazonaws.services.sqs;

import static org.hamcrest.core.IsInstanceOf.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

import java.util.Collections;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import com.amazonaws.services.sqs.util.Constants;
import org.junit.After;
import org.junit.Test;

import com.amazonaws.services.sqs.util.ExceptionAsserter;
import com.amazonaws.services.sqs.util.MockSQS;
import com.amazonaws.services.sqs.util.SQSQueueUtils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.services.sqs.SqsClient;
import software.amazon.awssdk.services.sqs.model.CreateQueueRequest;
import software.amazon.awssdk.services.sqs.model.Message;
import software.amazon.awssdk.services.sqs.model.ReceiveMessageRequest;
import software.amazon.awssdk.services.sqs.model.SendMessageRequest;

import java.util.Collections;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;

public class AmazonSQSRequesterClientTest {

private final ExceptionAsserter exceptionHandler = new ExceptionAsserter();
Expand All @@ -43,7 +41,7 @@ public AmazonSQSRequesterClientTest() {
this.responderClient = new AmazonSQSResponderClient(sqs);
}

@After
@AfterEach
public void tearDown() {
this.exceptionHandler.assertNothingThrown();
}
Expand Down Expand Up @@ -89,14 +87,9 @@ public void timeout() throws TimeoutException, InterruptedException, ExecutionEx
assertEquals(requestMessageBody, requestMessage.body());
String responseQueueUrl = requestMessage.messageAttributes().get(Constants.RESPONSE_QUEUE_URL_ATTRIBUTE_NAME).stringValue();
assertNotNull(responseQueueUrl);

// TODO-RS: Junit 5
try {
future.get();
fail();
} catch (ExecutionException e) {
assertThat(e.getCause(), instanceOf(TimeoutException.class));
}

Exception exception = assertThrows(ExecutionException.class, future::get);
assertInstanceOf(TimeoutException.class, exception.getCause());

// Make sure the response queue was deleted
SQSQueueUtils.awaitQueueDeleted(sqs, responseQueueUrl, 70, TimeUnit.SECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import com.amazonaws.services.sqs.util.IntegrationTest;
import com.amazonaws.services.sqs.util.SQSMessageConsumer;
import com.amazonaws.services.sqs.util.SQSMessageConsumerBuilder;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import software.amazon.awssdk.services.sqs.model.CreateQueueRequest;
import software.amazon.awssdk.services.sqs.model.DeleteQueueRequest;
import software.amazon.awssdk.services.sqs.model.Message;
Expand All @@ -16,7 +16,7 @@
import java.util.UUID;
import java.util.concurrent.TimeUnit;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class AmazonSQSResponsesClientCrossAccountIT extends IntegrationTest {
private static AmazonSQSRequester sqsRequester;
Expand All @@ -28,7 +28,7 @@ protected String testSuiteName() {
return "SQSXAccountResponsesClientIT";
}

@Before
@BeforeEach
public void setup() {
// Use the secondary role for the responder
sqsResponder = new AmazonSQSResponderClient(getBuddyPrincipalClient());
Expand All @@ -43,7 +43,7 @@ public void setup() {
requestQueueUrl = sqs.createQueue(createQueueRequest).queueUrl();
}

@After
@AfterEach
public void teardown() {
sqs.deleteQueue(DeleteQueueRequest.builder().queueUrl(requestQueueUrl).build());
sqsResponder.shutdown();
Expand Down
Loading

0 comments on commit b5e97a2

Please sign in to comment.