From 6da406bbaf1d6ffecc9f7af54e373c32b1761cfc Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 24 Jul 2023 10:07:13 +0100 Subject: [PATCH] Switch to ElasticMQ SQS container (#16) * Switch to ElasticMQ SQS container * Update TestSQS.scala --- .../pjfanning/pekkohttpspi/BaseAwsClientTest.scala | 12 ++++++++++++ .../github/pjfanning/pekkohttpspi/sqs/TestSQS.scala | 8 ++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/test/scala/com/github/pjfanning/pekkohttpspi/BaseAwsClientTest.scala b/src/test/scala/com/github/pjfanning/pekkohttpspi/BaseAwsClientTest.scala index b914bd0..2485645 100644 --- a/src/test/scala/com/github/pjfanning/pekkohttpspi/BaseAwsClientTest.scala +++ b/src/test/scala/com/github/pjfanning/pekkohttpspi/BaseAwsClientTest.scala @@ -60,3 +60,15 @@ trait LocalstackBaseAwsClientTest[C <: SdkClient] extends BaseAwsClientTest[C] { waitStrategy = Some(LocalStackReadyLogWaitStrategy) ) } + +trait ElasticMQSQSBaseAwsClientTest[C <: SdkClient] extends BaseAwsClientTest[C] { + def service: String + + lazy val exposedServicePort: Int = 9324 + + override lazy val container: GenericContainer = + new GenericContainer( + dockerImage = "softwaremill/elasticmq-native", + exposedPorts = Seq(exposedServicePort) + ) +} diff --git a/src/test/scala/com/github/pjfanning/pekkohttpspi/sqs/TestSQS.scala b/src/test/scala/com/github/pjfanning/pekkohttpspi/sqs/TestSQS.scala index 924ae94..53a26f9 100644 --- a/src/test/scala/com/github/pjfanning/pekkohttpspi/sqs/TestSQS.scala +++ b/src/test/scala/com/github/pjfanning/pekkohttpspi/sqs/TestSQS.scala @@ -16,15 +16,15 @@ package com.github.pjfanning.pekkohttpspi.sqs -import com.github.pjfanning.pekkohttpspi.{PekkoHttpAsyncHttpService, LocalstackBaseAwsClientTest} +import com.github.pjfanning.pekkohttpspi.{PekkoHttpAsyncHttpService, ElasticMQSQSBaseAwsClientTest} import software.amazon.awssdk.auth.credentials.{AwsBasicCredentials, StaticCredentialsProvider} import software.amazon.awssdk.services.sqs.SqsAsyncClient import software.amazon.awssdk.services.sqs.model._ -class TestSQS extends LocalstackBaseAwsClientTest[SqsAsyncClient] { +class TestSQS extends ElasticMQSQSBaseAwsClientTest[SqsAsyncClient] { "Async SQS client" should { - "publish a message to a queue" ignore withClient { implicit client => + "publish a message to a queue" in withClient { implicit client => client.createQueue(CreateQueueRequest.builder().queueName("foo").build()).join() client .sendMessage(SendMessageRequest.builder().queueUrl(s"$endpoint/queue/foo").messageBody("123").build()) @@ -35,7 +35,7 @@ class TestSQS extends LocalstackBaseAwsClientTest[SqsAsyncClient] { receivedMessage.messages().get(0).body() should be("123") } - "delete a message" ignore withClient { implicit client => + "delete a message" in withClient { implicit client => client.createQueue(CreateQueueRequest.builder().queueName("foo").build()).join() client .sendMessage(SendMessageRequest.builder().queueUrl(s"$endpoint/queue/foo").messageBody("123").build())