diff --git a/build.sbt b/build.sbt index 3e442c2..499e6f2 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ organization := "com.antonwierenga" name := "activemq-cli" -version := "0.9.0" +version := "0.9.2" scalaVersion := "2.11.6" diff --git a/src/main/scala/activemq/cli/ActiveMQCLI.scala b/src/main/scala/activemq/cli/ActiveMQCLI.scala index 3f0ed23..a0f2441 100644 --- a/src/main/scala/activemq/cli/ActiveMQCLI.scala +++ b/src/main/scala/activemq/cli/ActiveMQCLI.scala @@ -38,7 +38,9 @@ class ActiveMQCLI extends CommandMarker { object ActiveMQCLI extends App { - lazy val ReleaseNotes = Map("v0.9.0" → List( + lazy val ReleaseNotes = Map("v0.9.2" → List( + "Fixed multiple shell commands not working for queue/topic names containing the colon or asterisk character" + ), "v0.9.0" → List( "Updated shell command 'list-queues': new option --exclude-filter", "Updated shell command 'purge-all-queues': new option --exclude-filter", "Updated shell command 'remove-all-queues': new option --exclude-filter" diff --git a/src/main/scala/activemq/cli/command/Commands.scala b/src/main/scala/activemq/cli/command/Commands.scala index 73d89fd..1386834 100644 --- a/src/main/scala/activemq/cli/command/Commands.scala +++ b/src/main/scala/activemq/cli/command/Commands.scala @@ -85,28 +85,28 @@ abstract class Commands extends PrintStackTraceExecutionProcessor { def validateTopicExists(brokerViewMBean: BrokerViewMBean, topic: String): ObjectName = { brokerViewMBean.getTopics.filter(objectName ⇒ - getDestinationKeyProperty(objectName).contains(topic)).headOption.getOrElse( + getDestinationKeyProperty(objectName).contains(replaceSpecialCharacters(topic))).headOption.getOrElse( throw new IllegalArgumentException(s"Topic '$topic' does not exist") ) } def validateTopicNotExists(brokerViewMBean: BrokerViewMBean, topic: String): Unit = { if (!brokerViewMBean.getTopics.filter(objectName ⇒ - getDestinationKeyProperty(objectName).equals(topic)).isEmpty) { + getDestinationKeyProperty(objectName).equals(replaceSpecialCharacters(topic))).isEmpty) { throw new IllegalArgumentException(s"Topic '$topic' already exists") } } def validateQueueExists(brokerViewMBean: BrokerViewMBean, queue: String): ObjectName = { brokerViewMBean.getQueues.filter(objectName ⇒ - getDestinationKeyProperty(objectName).equals(queue)).headOption.getOrElse( + getDestinationKeyProperty(objectName).equals(replaceSpecialCharacters(queue))).headOption.getOrElse( throw new IllegalArgumentException(s"Queue '$queue' does not exist") ) } def validateQueueNotExists(brokerViewMBean: BrokerViewMBean, queue: String): Unit = { if (!brokerViewMBean.getQueues.filter(objectName ⇒ - getDestinationKeyProperty(objectName).equals(queue)).isEmpty) { + getDestinationKeyProperty(objectName).equals(replaceSpecialCharacters(queue))).isEmpty) { throw new IllegalArgumentException(s"Queue '$queue' already exists") } } @@ -284,4 +284,8 @@ abstract class Commands extends PrintStackTraceExecutionProcessor { 0 } } + + def replaceSpecialCharacters(name: String): String = { + name.replace("*", "*").replace(":", "_") + } } diff --git a/src/test/scala/activemq/cli/command/QueueCommandsTests.scala b/src/test/scala/activemq/cli/command/QueueCommandsTests.scala index ef3dab0..ac80e31 100644 --- a/src/test/scala/activemq/cli/command/QueueCommandsTests.scala +++ b/src/test/scala/activemq/cli/command/QueueCommandsTests.scala @@ -70,6 +70,13 @@ class QueueCommandsTests { assertEquals(warn(s"No queues found"), shell.executeCommand("list-queues").getResult) } + @Test + def testRemoveQueueWithAsteriskAndColon = { + assertEquals(info("Queue 'test*:Queue' added"), shell.executeCommand("add-queue --name test*:Queue").getResult) + assertEquals(info("Queue 'test*:Queue' removed"), shell.executeCommand("remove-queue --name test*:Queue --force").getResult) + assertEquals(warn(s"No queues found"), shell.executeCommand("list-queues").getResult) + } + @Test def testPurgeQueue = { assertEquals(info("Messages sent to queue 'testQueue': 1"), shell.executeCommand("send-message --queue testQueue --body testMessage").getResult)