Repository: softwaremill/elasticmq
Pull request #832 (2023-06-15 17:45:44)

Don't fail if datatype contains additional characters

katlasik: Closes #829

Patch:
diff --git a/build.sbt b/build.sbt
index 63edc216..b6a3b905 100644
--- a/build.sbt
+++ b/build.sbt
@@ -38,7 +38,7 @@ val jclOverSlf4j = "org.slf4j" % "jcl-over-slf4j" % "2.0.7" // needed form amazo
 val scalatest = "org.scalatest" %% "scalatest" % "3.2.16"
 val awaitility = "org.awaitility" % "awaitility-scala" % "4.2.0"
 
-val amazonJavaSdkSqs = "com.amazonaws" % "aws-java-sdk-sqs" % "1.11.1026" exclude ("commons-logging", "commons-logging")
+val amazonJavaSdkSqs = "com.amazonaws" % "aws-java-sdk-sqs" % "1.12.472" exclude ("commons-logging", "commons-logging")
 
 val akkaVersion = "2.6.20"
 val akkaHttpVersion = "10.2.10"
@@ -51,6 +51,12 @@ val sprayJson = "io.spray" %% "spray-json" % "1.3.6"
 val akkaHttpSprayJson = "com.typesafe.akka" %% "akka-http-spray-json" % akkaHttpVersion
 val akka2HttpTestkit = "com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion % "test"
 
+val awsSpringMessagingVersion = "2.2.6.RELEASE"
+val springVersion = "5.3.28"
+val awsSpringMessaging = "org.springframework.cloud" % "spring-cloud-aws-messaging" % awsSpringMessagingVersion
+val springWeb = "org.springframework" % "spring-web" % springVersion
+
+
 val scalaAsync = "org.scala-lang.modules" %% "scala-async" % "1.0.1"
 
 val scalikeJdbc = "org.scalikejdbc" %% "scalikejdbc" % "3.5.0"
@@ -186,7 +192,7 @@ lazy val restSqsTestingAmazonJavaSdk: Project =
     .settings(
       Seq(
         name := "elasticmq-rest-sqs-testing-amazon-java-sdk",
-        libraryDependencies ++= Seq(amazonJavaSdkSqs, jclOverSlf4j) ++ common,
+        libraryDependencies ++= Seq(amazonJavaSdkSqs, awsSpringMessaging, jclOverSlf4j, springWeb) ++ common,
         publish / skip := true
       )
     )
diff --git a/rest/rest-sqs/src/main/scala/org/elasticmq/rest/sqs/SendMessageDirectives.scala b/rest/rest-sqs/src/main/scala/org/elasticmq/rest/sqs/SendMessageDirectives.scala
index 56f4e943..3c2dd7b7 100644
--- a/rest/rest-sqs/src/main/scala/org/elasticmq/rest/sqs/SendMessageDirectives.scala
+++ b/rest/rest-sqs/src/main/scala/org/elasticmq/rest/sqs/SendMessageDirectives.scala
@@ -235,7 +235,7 @@ trait SendMessageDirectives {
       val availableDataTypes = Set("String", "Number", "Binary")
       if (value.getDataType().isEmpty)
         throw throw new SQSException(s"Attribute '$name' must contain a non-empty attribute type")
-      if (!availableDataTypes.contains(value.getDataType()))
+      if (!availableDataTypes.exists(value.getDataType().startsWith(_)))
         throw new Exception("Currently only handles String, Number and Binary typed attributes")
 
       value match {


Test patch:
diff --git a/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/SpringAWSTestSuite.scala b/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/SpringAWSTestSuite.scala
new file mode 100644
index 00000000..27f0a356
--- /dev/null
+++ b/rest/rest-sqs-testing-amazon-java-sdk/src/test/scala/org/elasticmq/rest/sqs/SpringAWSTestSuite.scala
@@ -0,0 +1,40 @@
+package org.elasticmq.rest.sqs
+
+import com.amazonaws.auth.{AWSCredentials, AWSCredentialsProvider}
+import com.amazonaws.client.builder.AwsClientBuilder
+import com.amazonaws.services.sqs.AmazonSQSAsyncClient
+import com.amazonaws.services.sqs.model.CreateQueueRequest
+import org.scalatest.matchers.should.Matchers
+import org.springframework.cloud.aws.messaging.core.QueueMessagingTemplate
+
+class SpringAWSTestSuite extends SqsClientServerCommunication with Matchers {
+
+  def withSpringClient(body: QueueMessagingTemplate => Unit) {
+    val sqs = AmazonSQSAsyncClient
+      .asyncBuilder()
+      .withCredentials(new AWSCredentialsProvider {
+        override def getCredentials: AWSCredentials = null
+        override def refresh(): Unit = ()
+      })
+      .withEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(ServiceEndpoint, "us-west-1"))
+      .build()
+
+    val template = new QueueMessagingTemplate(sqs)
+    try {
+      body(template)
+    } finally (sqs.shutdown())
+  }
+
+  test("should send message with spring aws") {
+
+    withSpringClient { template =>
+      // given
+      val queue = client.createQueue(new CreateQueueRequest("spring-test-queue"))
+
+      // when ~> then
+      template.convertAndSend(queue.getQueueUrl, "hello")
+
+    }
+  }
+
+}