Browse files

Removing the Typica testing module

  • Loading branch information...
1 parent e360b6b commit b0cec35a307bc415ab87c061cf4952380a1727c1 @adamw committed Jan 8, 2012
View
4 README.md
@@ -12,8 +12,8 @@ providing an SQS alternative e.g. for testing purposes.
The REST server is implemented using [Netty](http://www.jboss.org/netty), a high-performance,
asynchronous, event-driven server Java framework.
-The SQS interface has been tested using the [Typica](http://code.google.com/p/typica/) library;
-see the `rest-sqs-testing-typica` module for the testsuite.
+The SQS interface has been tested using the [Amazon Java SDK](http://aws.amazon.com/sdkforjava/) library;
+see the `rest-sqs-testing-amazon-java-sdk` module for the testsuite.
In the future... ElasticMQ may provide many more exciting features :).
View
9 project/Build.scala
@@ -42,7 +42,6 @@ object Dependencies {
val apacheHttp = "org.apache.httpcomponents" % "httpclient" % "4.1.1"
- val typica = "com.google.code.typica" % "typica" % "1.7-softwaremill-4"
val amazonJavaSdk = "com.amazonaws" % "aws-java-sdk" % "1.2.15"
val mysqlConnector = "mysql" % "mysql-connector-java" % "5.1.12"
@@ -80,7 +79,7 @@ object ElasticMQBuild extends Build {
"rest",
file("rest"),
settings = buildSettings
- ) aggregate(restCore, restSqs, restSqsTestingTypica, restSqsTestingAmazonJavaSdk)
+ ) aggregate(restCore, restSqs, restSqsTestingAmazonJavaSdk)
lazy val restCore: Project = Project(
"rest-core",
@@ -94,12 +93,6 @@ object ElasticMQBuild extends Build {
settings = buildSettings ++ Seq(libraryDependencies := Seq(mysqlConnector % "test") ++ common ++ testing ++ httpTesting)
) dependsOn(api, restCore, core % "test")
- lazy val restSqsTestingTypica: Project = Project(
- "rest-sqs-testing-typica",
- file("rest/rest-sqs-testing-typica"),
- settings = buildSettings ++ Seq(libraryDependencies := Seq(typica, apacheHttp) ++ common ++ testing)
- ) dependsOn(restSqs % "test->test")
-
lazy val restSqsTestingAmazonJavaSdk: Project = Project(
"rest-sqs-testing-amazon-java-sdk",
file("rest/rest-sqs-testing-amazon-java-sdk"),
View
289 rest/rest-sqs-testing-typica/src/test/scala/org/elasticmq/rest/sqs/TypicaTestSuite.scala
@@ -1,289 +0,0 @@
-package org.elasticmq.rest.sqs
-
-import org.scalatest.matchers.MustMatchers
-import org.scalatest.{BeforeAndAfter, FunSuite}
-import org.elasticmq.rest.RestServer
-import org.elasticmq.{Node, NodeBuilder}
-import org.apache.log4j.BasicConfigurator
-import org.jboss.netty.logging.{Log4JLoggerFactory, InternalLoggerFactory}
-import java.math.BigInteger
-import com.xerox.amazonws.sqs2.{Message, QueueAttribute, QueueService}
-
-class TypicaTestSuite extends FunSuite with MustMatchers with BeforeAndAfter {
- var node: Node = _
- var server: RestServer = _
-
- BasicConfigurator.configure();
- InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory())
-
- before {
- node = NodeBuilder.withInMemoryStorage().build()
- server = SQSRestServerFactory.start(node.nativeClient, 8888, "http://localhost:8888")
- }
-
- after {
- server.stop()
- node.shutdown()
- }
-
- test("should create a queue") {
- val queueService = newQueueService
- queueService.getOrCreateMessageQueue("testQueue1")
- }
-
- test("should create a queue with the specified visibilty timeout") {
- // Given
- val queueService = newQueueService
-
- // When
- queueService.getOrCreateMessageQueue("testQueue1", 14)
-
- // Then
- val queues = queueService.listMessageQueues(null)
- queues.size() must be (1)
- queues.get(0).getVisibilityTimeout must be (14)
- }
-
- test("should list created queues") {
- // Given
- val queueService = newQueueService
- queueService.getOrCreateMessageQueue("testQueue1")
- queueService.getOrCreateMessageQueue("testQueue2")
-
- // When
- val queues = queueService.listMessageQueues(null)
-
- // Then
- queues.size() must be (2)
- queues.get(0).getUrl.toString must include ("testQueue1")
- queues.get(1).getUrl.toString must include ("testQueue2")
- }
-
- test("should list queues with the specified prefix") {
- // Given
- val queueService = newQueueService
- queueService.getOrCreateMessageQueue("aaaQueue")
- queueService.getOrCreateMessageQueue("bbbQueue")
-
- // When
- val queues = queueService.listMessageQueues("aaa")
-
- // Then
- queues.size() must be (1)
- queues.get(0).getUrl.toString must include ("aaaQueue")
- }
-
- test("should create and delete a queue") {
- // Given
- val queueService = newQueueService
- val queue = queueService.getOrCreateMessageQueue("testQueue1")
-
- // When
- queue.deleteQueue()
-
- // Then
- newQueueService.listMessageQueues(null).size() must be (0)
- }
-
- test("should get queue visibility timeout") {
- // Given
- val queueService = newQueueService
- val queue = queueService.getOrCreateMessageQueue("testQueue1")
-
- // When
- val vt = queue.getVisibilityTimeout
-
- // Then
- vt must be (30)
- }
-
- test("should set queue visibility timeout") {
- // Given
- val queueService = newQueueService
- val queue = queueService.getOrCreateMessageQueue("testQueue1")
-
- // When
- queue.setVisibilityTimeout(10)
-
- // Then
- val vt = queue.getVisibilityTimeout
- vt must be (10)
- }
-
- test("should send and receive a message") {
- // Given
- val queueService = newQueueService
- val queue = queueService.getOrCreateMessageQueue("testQueue1")
-
- // When
- queue.sendMessage("Message 1")
- val message = queue.receiveMessage()
-
- // Then
- message.getMessageBody must be ("Message 1")
- }
-
- test("should block message for the visibility timeout duration") {
- // Given
- val queueService = newQueueService
- val queue = queueService.getOrCreateMessageQueue("testQueue1", 1)
-
- // When
- queue.sendMessage("Message 1")
- val m1 = queue.receiveMessage()
- val m2 = queue.receiveMessage()
- Thread.sleep(1100)
- val m3 = queue.receiveMessage()
-
- // Then
- m1.getMessageBody must be ("Message 1")
- m2 must be (null)
- m3.getMessageBody must be ("Message 1")
- }
-
- test("should block message for the specified non-default visibility timeout duration") {
- // Given
- val queueService = newQueueService
- val queue = queueService.getOrCreateMessageQueue("testQueue1", 1)
-
- // When
- queue.sendMessage("Message 1")
- val m1 = queue.receiveMessage(2)
- val m2 = queue.receiveMessage()
- Thread.sleep(1100)
- val m3 = queue.receiveMessage()
- Thread.sleep(1100)
- val m4 = queue.receiveMessage()
-
- // Then
- m1.getMessageBody must be ("Message 1")
- m2 must be (null)
- m3 must be (null)
- m4.getMessageBody must be ("Message 1")
- }
-
- test("should delete a message") {
- // Given
- val queueService = newQueueService
- val queue = queueService.getOrCreateMessageQueue("testQueue1", 1)
-
- // When
- queue.sendMessage("Message 1")
- val m1 = queue.receiveMessage()
- queue.deleteMessage(m1)
- Thread.sleep(1100)
- val m2 = queue.receiveMessage()
-
- // Then
- m1.getMessageBody must be ("Message 1")
- m2 must be (null)
- }
-
- test("should delete a message using the receipt handle") {
- // Given
- val queueService = newQueueService
- val queue = queueService.getOrCreateMessageQueue("testQueue1", 1)
-
- // When
- queue.sendMessage("Message 1")
- val m1 = queue.receiveMessage()
- queue.deleteMessage(m1.getReceiptHandle)
- Thread.sleep(1100)
- val m2 = queue.receiveMessage()
-
- // Then
- m1.getMessageBody must be ("Message 1")
- m2 must be (null)
- }
-
- test("should update message visibility timeout") {
- // Given
- val queueService = newQueueService
- val queue = queueService.getOrCreateMessageQueue("testQueue1", 1)
-
- // When
- val msgId = queue.sendMessage("Message 1")
- queue.setMessageVisibilityTimeout(msgId, 2)
-
- val m1 = queue.receiveMessage()
-
- Thread.sleep(1100) // Queue vis timeout - 1 second. The message shouldn't be received yet
- val m2 = queue.receiveMessage()
-
- Thread.sleep(1100)
- val m3 = queue.receiveMessage()
-
- // Then
- m1 must be (null)
- m2 must be (null)
- m3.getMessageBody must be ("Message 1")
- }
-
- test("should read all queue attributes") {
- // Given
- val queueService = newQueueService
- val queue = queueService.getOrCreateMessageQueue("testQueue1", 1)
- queue.sendMessage("Message 1")
- queue.sendMessage("Message 2")
- queue.sendMessage("Message 3")
- queue.receiveMessage() // two should remain visible, the received one - invisible
-
- // When
- val attributes = queue.getQueueAttributes(QueueAttribute.ALL)
-
- // Then
- attributes.get("ApproximateNumberOfMessages") must be ("2")
- attributes.get("ApproximateNumberOfMessagesNotVisible") must be ("1")
- attributes must contain key ("CreatedTimestamp")
- attributes must contain key ("LastModifiedTimestamp")
- }
-
- test("should read single queue attribute") {
- // Given
- val queueService = newQueueService
- val queue = queueService.getOrCreateMessageQueue("testQueue1", 1)
- queue.sendMessage("Message 1")
-
- // When
- val approximateNumberOfMessages = queue.getApproximateNumberOfMessages
-
- // Then
- approximateNumberOfMessages must be (1)
- }
-
- test("should receive message with statistics") {
- // Given
- val start = System.currentTimeMillis()
- val queueService = newQueueService
- val queue = queueService.getOrCreateMessageQueue("testQueue1", 1)
- queue.sendMessage("Message 1")
-
- def receiveMessages(): Array[Message] = {
- queue.receiveMessages(BigInteger.valueOf(1),
- null.asInstanceOf[BigInteger],
- java.util.Arrays.asList("SentTimestamp", "ApproximateReceiveCount", "ApproximateFirstReceiveTimestamp"))
- }
-
- // When
- val messageArray1 = receiveMessages()
- Thread.sleep(1100)
- val messageArray2 = receiveMessages()
-
- // Then
- messageArray1.length must be (1)
- val sent1 = messageArray1(0).getAttribute("SentTimestamp").toLong
- sent1 must be >= (start)
- messageArray1(0).getAttribute("ApproximateReceiveCount").toInt must be (0)
- messageArray1(0).getAttribute("ApproximateFirstReceiveTimestamp").toLong must be (0)
-
- messageArray2.length must be (1)
- val sent2 = messageArray2(0).getAttribute("SentTimestamp").toLong
- sent2 must be >= (start)
- messageArray2(0).getAttribute("ApproximateReceiveCount").toInt must be (1)
- messageArray2(0).getAttribute("ApproximateFirstReceiveTimestamp").toLong must be >= (start)
-
- sent1 must be (sent2)
- }
-
- def newQueueService = new QueueService("n/a", "n/a", false, "localhost", 8888)
-}

0 comments on commit b0cec35

Please sign in to comment.