Skip to content

Commit 210b228

Browse files
Upgrade to JUNIT5 and refactoring (#89)
1 parent 8b7e3ff commit 210b228

21 files changed

+289
-349
lines changed

.github/dependabot.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "maven"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
- package-ecosystem: "github-actions"
8+
directory: "/"
9+
schedule:
10+
interval: "weekly"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Temporary queues are also automatically deleted if the clients that created them
2121
<dependency>
2222
<groupId>com.amazonaws</groupId>
2323
<artifactId>amazon-sqs-java-temporary-queues-client</artifactId>
24-
<version>1.2.4</version>
24+
<version>1.2.5</version>
2525
<type>jar</type>
2626
</dependency>
2727
```

pom.xml

+26-32
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>com.amazonaws</groupId>
44
<artifactId>amazon-sqs-java-temporary-queues-client</artifactId>
5-
<version>1.2.4</version>
5+
<version>1.2.5</version>
66
<name>Amazon SQS Java Temporary Queues Client</name>
77
<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://aws.amazon.com/sqs.</description>
88
<url>https://github.com/awslabs/amazon-sqs-java-temporary-queues-client</url>
@@ -27,55 +27,39 @@
2727
</developer>
2828
</developers>
2929
<properties>
30-
<aws-java-sdk.version>1.12.128</aws-java-sdk.version>
30+
<aws-java-sdk.version>1.12.438</aws-java-sdk.version>
3131
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3232
</properties>
3333

34-
<dependencyManagement>
35-
<dependencies>
36-
<dependency>
37-
<groupId>com.amazonaws</groupId>
38-
<artifactId>aws-java-sdk-bom</artifactId>
39-
<version>1.12.128</version>
40-
<type>pom</type>
41-
<scope>import</scope>
42-
</dependency>
43-
</dependencies>
44-
</dependencyManagement>
45-
4634
<dependencies>
4735
<dependency>
4836
<groupId>com.amazonaws</groupId>
4937
<artifactId>aws-java-sdk-sqs</artifactId>
38+
<version>${aws-java-sdk.version}</version>
5039
</dependency>
5140

52-
<dependency>
53-
<groupId>org.junit.vintage</groupId>
54-
<artifactId>junit-vintage-engine</artifactId>
55-
<version>5.7.0-M1</version>
56-
<scope>test</scope>
57-
</dependency>
5841
<dependency>
5942
<groupId>org.junit.jupiter</groupId>
60-
<artifactId>junit-jupiter-engine</artifactId>
61-
<version>5.7.0-M1</version>
43+
<artifactId>junit-jupiter</artifactId>
44+
<version>5.9.2</version>
6245
<scope>test</scope>
6346
</dependency>
6447
<dependency>
6548
<groupId>org.mockito</groupId>
6649
<artifactId>mockito-core</artifactId>
67-
<version>2.10.0</version>
50+
<version>5.2.0</version>
6851
<scope>test</scope>
6952
</dependency>
7053
<dependency>
7154
<groupId>org.awaitility</groupId>
7255
<artifactId>awaitility</artifactId>
73-
<version>4.0.2</version>
56+
<version>4.2.0</version>
7457
<scope>test</scope>
7558
</dependency>
7659
<dependency>
7760
<groupId>com.amazonaws</groupId>
7861
<artifactId>aws-java-sdk-sts</artifactId>
62+
<version>${aws-java-sdk.version}</version>
7963
<scope>test</scope>
8064
</dependency>
8165
</dependencies>
@@ -86,7 +70,7 @@
8670
<plugin>
8771
<groupId>org.apache.maven.plugins</groupId>
8872
<artifactId>maven-compiler-plugin</artifactId>
89-
<version>3.2</version>
73+
<version>3.11.0</version>
9074
<configuration>
9175
<source>1.8</source>
9276
<target>1.8</target>
@@ -109,6 +93,11 @@
10993
</plugins>
11094
</pluginManagement>
11195
<plugins>
96+
<plugin>
97+
<groupId>org.apache.maven.plugins</groupId>
98+
<artifactId>maven-surefire-plugin</artifactId>
99+
<version>3.0.0</version>
100+
</plugin>
112101
<plugin>
113102
<groupId>org.apache.maven.plugins</groupId>
114103
<artifactId>maven-source-plugin</artifactId>
@@ -125,34 +114,39 @@
125114
<plugin>
126115
<groupId>org.apache.maven.plugins</groupId>
127116
<artifactId>maven-javadoc-plugin</artifactId>
128-
<version>2.9.1</version>
117+
<version>3.5.0</version>
129118
<executions>
130119
<execution>
131120
<id>attach-javadocs</id>
132121
<goals>
133122
<goal>jar</goal>
134123
</goals>
135124
<configuration>
136-
<!--
137-
TODO-RS: Java 8 is more strict about some javadoc tags.
138-
We'll need to update quite a few to remove this workaround.
139-
-->
140-
<additionalparam>-Xdoclint:none</additionalparam>
125+
<source>8</source>
126+
<doclint>none</doclint>
141127
</configuration>
142128
</execution>
143129
</executions>
144130
</plugin>
145131
<plugin>
146132
<groupId>org.sonatype.plugins</groupId>
147133
<artifactId>nexus-staging-maven-plugin</artifactId>
148-
<version>1.6.7</version>
134+
<version>1.6.13</version>
149135
<extensions>true</extensions>
150136
<configuration>
151137
<serverId>ossrh</serverId>
152138
<nexusUrl>https://aws.oss.sonatype.org</nexusUrl>
153139
<autoReleaseAfterClose>true</autoReleaseAfterClose>
154140
</configuration>
155141
</plugin>
142+
<plugin>
143+
<groupId>org.apache.maven.plugins</groupId>
144+
<artifactId>maven-compiler-plugin</artifactId>
145+
<configuration>
146+
<source>9</source>
147+
<target>9</target>
148+
</configuration>
149+
</plugin>
156150
</plugins>
157151
</build>
158152

src/test/java/com/amazonaws/services/sqs/AmazonSQSIdleQueueDeletingIT.java

+27-25
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
package com.amazonaws.services.sqs;
22

3-
import java.util.Collections;
4-
import java.util.concurrent.Executors;
5-
import java.util.concurrent.ScheduledExecutorService;
6-
import java.util.concurrent.TimeUnit;
7-
8-
import com.amazonaws.services.sqs.model.SendMessageRequest;
9-
import com.amazonaws.services.sqs.util.Constants;
10-
import com.amazonaws.services.sqs.util.SQSMessageConsumerBuilder;
11-
import org.junit.After;
12-
import org.junit.Assert;
13-
import org.junit.Before;
14-
import org.junit.Test;
15-
163
import com.amazonaws.services.sqs.model.CreateQueueRequest;
174
import com.amazonaws.services.sqs.model.Message;
185
import com.amazonaws.services.sqs.model.QueueDoesNotExistException;
6+
import com.amazonaws.services.sqs.model.SendMessageRequest;
7+
import com.amazonaws.services.sqs.util.Constants;
198
import com.amazonaws.services.sqs.util.IntegrationTest;
209
import com.amazonaws.services.sqs.util.SQSMessageConsumer;
10+
import com.amazonaws.services.sqs.util.SQSMessageConsumerBuilder;
2111
import com.amazonaws.services.sqs.util.SQSQueueUtils;
12+
import org.junit.jupiter.api.AfterEach;
13+
import org.junit.jupiter.api.BeforeEach;
14+
import org.junit.jupiter.api.Test;
15+
16+
import java.util.Collections;
17+
import java.util.concurrent.Executors;
18+
import java.util.concurrent.ScheduledExecutorService;
19+
import java.util.concurrent.TimeUnit;
20+
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
22+
import static org.junit.jupiter.api.Assertions.assertNotEquals;
23+
import static org.junit.jupiter.api.Assertions.assertTrue;
2224

2325

2426
public class AmazonSQSIdleQueueDeletingIT extends IntegrationTest {
@@ -28,15 +30,15 @@ public class AmazonSQSIdleQueueDeletingIT extends IntegrationTest {
2830
private static AmazonSQSRequester requester;
2931
private static AmazonSQSResponder responder;
3032

31-
@Before
33+
@BeforeEach
3234
public void setup() {
3335
client = new AmazonSQSIdleQueueDeletingClient(sqs, queueNamePrefix);
3436
requester = new AmazonSQSRequesterClient(sqs, queueNamePrefix,
3537
Collections.emptyMap(), exceptionHandler);
3638
responder = new AmazonSQSResponderClient(sqs);
3739
}
3840

39-
@After
41+
@AfterEach
4042
public void teardown() {
4143
if (client != null && queueUrl != null) {
4244
try {
@@ -65,8 +67,8 @@ public void idleQueueIsDeleted() throws InterruptedException {
6567
queueUrl = client.createQueue(createQueueRequest).getQueueUrl();
6668

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

7274
@Test
@@ -91,7 +93,7 @@ public void updatedHeartBeatTag() throws InterruptedException {
9193

9294
String updatedHeartbeat = getLastHeartbeatTimestamp();
9395

94-
Assert.assertNotEquals(initialHeartBeat, updatedHeartbeat);
96+
assertNotEquals(initialHeartBeat, updatedHeartbeat);
9597
}
9698

9799
private String getLastHeartbeatTimestamp() {
@@ -121,7 +123,7 @@ public void notUpdatedHeartBeatTag() throws InterruptedException {
121123

122124
String notUpdatedHeartbeat = getLastHeartbeatTimestamp();
123125

124-
Assert.assertEquals(initialHeartBeat, notUpdatedHeartbeat);
126+
assertEquals(initialHeartBeat, notUpdatedHeartbeat);
125127
}
126128

127129
@Test
@@ -147,8 +149,8 @@ public void recreatingQueues() throws InterruptedException {
147149
// Ensure the original queue is eventually recreated. This becoming true at least once
148150
// indicates that CreateQueue was successfully called, even if it may flip back to false
149151
// on subsequent calls.
150-
Assert.assertTrue("Expected original queue to be recreated: " + queueUrl,
151-
SQSQueueUtils.awaitQueueCreated(sqs, queueUrl, 70, TimeUnit.SECONDS));
152+
assertTrue(SQSQueueUtils.awaitQueueCreated(sqs, queueUrl, 70, TimeUnit.SECONDS),
153+
"Expected original queue to be recreated: " + queueUrl);
152154

153155
// Ensure the user doesn't experience any send or receive failures
154156
user.finish();
@@ -168,10 +170,10 @@ public void recreatingQueues() throws InterruptedException {
168170
}
169171
});
170172

171-
Assert.assertTrue("Expected original queue to be deleted: " + failoverQueueUrl,
172-
SQSQueueUtils.awaitQueueDeleted(sqs, queueUrl, 70, TimeUnit.SECONDS));
173-
Assert.assertTrue("Expected failover queue to be deleted with the original: " + failoverQueueUrl,
174-
SQSQueueUtils.awaitQueueDeleted(sqs, failoverQueueUrl, 70, TimeUnit.SECONDS));
173+
assertTrue(SQSQueueUtils.awaitQueueDeleted(sqs, queueUrl, 70, TimeUnit.SECONDS),
174+
"Expected original queue to be deleted: " + failoverQueueUrl);
175+
assertTrue(SQSQueueUtils.awaitQueueDeleted(sqs, failoverQueueUrl, 70, TimeUnit.SECONDS),
176+
"Expected failover queue to be deleted with the original: " + failoverQueueUrl);
175177
}
176178

177179
private class QueueUser {

src/test/java/com/amazonaws/services/sqs/AmazonSQSRequesterClientTest.java

+17-24
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
package com.amazonaws.services.sqs;
22

3-
import static org.hamcrest.core.IsInstanceOf.instanceOf;
4-
import static org.junit.Assert.assertEquals;
5-
import static org.junit.Assert.assertNotNull;
6-
import static org.junit.Assert.assertThat;
7-
import static org.junit.Assert.fail;
3+
import com.amazonaws.services.sqs.model.Message;
4+
import com.amazonaws.services.sqs.model.SendMessageRequest;
5+
import com.amazonaws.services.sqs.util.Constants;
6+
import com.amazonaws.services.sqs.util.ExceptionAsserter;
7+
import com.amazonaws.services.sqs.util.MockSQS;
8+
import com.amazonaws.services.sqs.util.SQSQueueUtils;
9+
import org.junit.jupiter.api.AfterEach;
10+
import org.junit.jupiter.api.Test;
811

912
import java.util.Collections;
1013
import java.util.concurrent.ExecutionException;
1114
import java.util.concurrent.Future;
1215
import java.util.concurrent.TimeUnit;
1316
import java.util.concurrent.TimeoutException;
1417

15-
import com.amazonaws.services.sqs.util.Constants;
16-
import org.junit.After;
17-
import org.junit.Test;
18-
19-
import com.amazonaws.services.sqs.model.Message;
20-
import com.amazonaws.services.sqs.model.SendMessageRequest;
21-
import com.amazonaws.services.sqs.util.ExceptionAsserter;
22-
import com.amazonaws.services.sqs.util.MockSQS;
23-
import com.amazonaws.services.sqs.util.SQSQueueUtils;
18+
import static org.junit.jupiter.api.Assertions.assertEquals;
19+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
20+
import static org.junit.jupiter.api.Assertions.assertNotNull;
21+
import static org.junit.jupiter.api.Assertions.assertThrows;
2422

2523
public class AmazonSQSRequesterClientTest {
2624

@@ -32,15 +30,15 @@ public class AmazonSQSRequesterClientTest {
3230
private final AmazonSQSResponderClient responderClient;
3331

3432
public AmazonSQSRequesterClientTest() {
35-
this.accountPrefix = "http://queue.amazon.com/123456789012/";
33+
this.accountPrefix = "https://queue.amazon.com/123456789012/";
3634
this.sqs = new MockSQS(accountPrefix);
3735
this.requesterClient = new AmazonSQSRequesterClient(sqs, "RequesterClientQueues",
3836
Collections.emptyMap(),
3937
exceptionHandler);
4038
this.responderClient = new AmazonSQSResponderClient(sqs);
4139
}
4240

43-
@After
41+
@AfterEach
4442
public void tearDown() {
4543
this.exceptionHandler.assertNothingThrown();
4644
}
@@ -86,14 +84,9 @@ public void timeout() throws TimeoutException, InterruptedException, ExecutionEx
8684
assertEquals(requestMessageBody, requestMessage.getBody());
8785
String responseQueueUrl = requestMessage.getMessageAttributes().get(Constants.RESPONSE_QUEUE_URL_ATTRIBUTE_NAME).getStringValue();
8886
assertNotNull(responseQueueUrl);
89-
90-
// TODO-RS: Junit 5
91-
try {
92-
future.get();
93-
fail();
94-
} catch (ExecutionException e) {
95-
assertThat(e.getCause(), instanceOf(TimeoutException.class));
96-
}
87+
88+
Exception exception = assertThrows(ExecutionException.class, future::get);
89+
assertInstanceOf(TimeoutException.class, exception.getCause());
9790

9891
// Make sure the response queue was deleted
9992
SQSQueueUtils.awaitQueueDeleted(sqs, responseQueueUrl, 70, TimeUnit.SECONDS);

0 commit comments

Comments
 (0)