From b42d8e065f6fb9b6b223d029c094feff75914b02 Mon Sep 17 00:00:00 2001 From: Anton Wierenga Date: Wed, 26 Feb 2020 22:05:13 +0100 Subject: [PATCH] v0.1.1 downgraded htmlunit for ActiveMQ 5.15.11 compatibility --- build.sbt | 6 +++--- src/main/scala/amazonmq/cli/AmazonMQCLI.scala | 3 +++ src/main/scala/amazonmq/cli/command/BrokerCommands.scala | 4 ++-- src/main/scala/amazonmq/cli/command/Commands.scala | 4 ++-- src/main/scala/amazonmq/cli/command/QueueCommands.scala | 1 + .../scala/amazonmq/cli/command/MessageCommandsTests.scala | 4 ++-- .../scala/amazonmq/cli/command/QueueCommandsTests.scala | 2 +- 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/build.sbt b/build.sbt index e758c6d..9d9174a 100644 --- a/build.sbt +++ b/build.sbt @@ -2,20 +2,20 @@ organization := "com.antonwierenga" name := "amazonmq-cli" -version := "0.1.0" +version := "0.1.1" scalaVersion := "2.11.6" licenses += ("Apache-2.0", url("http://opensource.org/licenses/apache2.0.php")) -libraryDependencies += "org.springframework.shell" % "spring-shell" % "1.1.0.RELEASE" +libraryDependencies += "org.springframework.shell" % "spring-shell" % "1.2.0.RELEASE" libraryDependencies += "org.apache.activemq" % "activemq-all" % "5.15.9" libraryDependencies += "com.typesafe" % "config" % "1.2.1" libraryDependencies += "org.scala-lang" % "jline" % "2.11.0-M3" libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % "1.0.3" libraryDependencies += "junit" % "junit" % "4.8" % "test" libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test->default" -libraryDependencies += "net.sourceforge.htmlunit" % "htmlunit" % "2.37.0" +libraryDependencies += "net.sourceforge.htmlunit" % "htmlunit" % "2.36.0" import scalariform.formatter.preferences._ diff --git a/src/main/scala/amazonmq/cli/AmazonMQCLI.scala b/src/main/scala/amazonmq/cli/AmazonMQCLI.scala index 6ecc463..f2606b5 100644 --- a/src/main/scala/amazonmq/cli/AmazonMQCLI.scala +++ b/src/main/scala/amazonmq/cli/AmazonMQCLI.scala @@ -37,6 +37,9 @@ class AmazonMQCLI extends CommandMarker { object AmazonMQCLI extends App { lazy val ReleaseNotes = Map( + "v0.1.1" → List( + "Updated dependencies for ActiveMQ 5.15.11 compatibility" + ), "v0.1.0" → List( "Updated shell command 'browse-messages': new option --regex", "Updated shell command 'copy-messages': new option --regex", diff --git a/src/main/scala/amazonmq/cli/command/BrokerCommands.scala b/src/main/scala/amazonmq/cli/command/BrokerCommands.scala index 6588a2d..293eaa9 100644 --- a/src/main/scala/amazonmq/cli/command/BrokerCommands.scala +++ b/src/main/scala/amazonmq/cli/command/BrokerCommands.scala @@ -88,8 +88,8 @@ class BrokerCommands extends Commands { withWebClient((webClient: WebClient) ⇒ { val page: HtmlPage = webClient.getPage(AmazonMQCLI.broker.get.webConsole) val tableRows = page.getByXPath("//td//table//tr").toArray.toList.asInstanceOf[List[HtmlTableRow]] - val headers = tableRows.map(tableRow ⇒ tableRow.getCell(0).getVisibleText) - val row = tableRows.map(tableRow ⇒ tableRow.getCell(1).getVisibleText) + val headers = tableRows.map(tableRow ⇒ tableRow.getCell(0).getTextContent) + val row = tableRows.map(tableRow ⇒ tableRow.getCell(1).getTextContent) renderTable(List(row), headers) }) } diff --git a/src/main/scala/amazonmq/cli/command/Commands.scala b/src/main/scala/amazonmq/cli/command/Commands.scala index 5af33c8..9d0c00a 100644 --- a/src/main/scala/amazonmq/cli/command/Commands.scala +++ b/src/main/scala/amazonmq/cli/command/Commands.scala @@ -23,7 +23,7 @@ import amazonmq.cli.AmazonMQCLI import amazonmq.cli.util.Console.{info, prompt, warn} import amazonmq.cli.util.Implicits._ import amazonmq.cli.util.PrintStackTraceExecutionProcessor -import com.gargoylesoftware.htmlunit.WebClient +import com.gargoylesoftware.htmlunit.{BrowserVersion, WebClient} import com.gargoylesoftware.htmlunit.xml.XmlPage import javax.jms.{Connection, Message, Session} import javax.xml.bind.DatatypeConverter._ @@ -129,7 +129,7 @@ abstract class Commands extends PrintStackTraceExecutionProcessor { } def withWebClient(callback: (WebClient) ⇒ String): String = { - val webClient = new WebClient(); + val webClient = new WebClient(BrowserVersion.BEST_SUPPORTED); webClient.addRequestHeader("Authorization", "Basic " + printBase64Binary(s"${AmazonMQCLI.broker.get.username}:${AmazonMQCLI.broker.get.password}".getBytes)) webClient.getOptions.setJavaScriptEnabled(false) try { diff --git a/src/main/scala/amazonmq/cli/command/QueueCommands.scala b/src/main/scala/amazonmq/cli/command/QueueCommands.scala index 326a82b..1a272af 100644 --- a/src/main/scala/amazonmq/cli/command/QueueCommands.scala +++ b/src/main/scala/amazonmq/cli/command/QueueCommands.scala @@ -64,6 +64,7 @@ class QueueCommands extends Commands { val page: HtmlPage = webClient.getPage(s"${AmazonMQCLI.broker.get.webConsole}/queues.jsp") val anchor = page.getAnchors().find(a ⇒ a.getHrefAttribute.startsWith("purgeDestination.action") && a.getHrefAttribute.contains(s"JMSDestination=$name&JMSDestinationType=queue")) + try { anchor.get.click() } catch { diff --git a/src/test/scala/amazonmq/cli/command/MessageCommandsTests.scala b/src/test/scala/amazonmq/cli/command/MessageCommandsTests.scala index a0fbb5a..04a3fe2 100644 --- a/src/test/scala/amazonmq/cli/command/MessageCommandsTests.scala +++ b/src/test/scala/amazonmq/cli/command/MessageCommandsTests.scala @@ -66,7 +66,7 @@ class MessageCommandsTests { @Test def testSendAndExportInlineMessageAllHeadersProvided = { - assertTrue(shell.executeCommand("send-message --queue testQueue --reply-to replyQueue --correlation-id testCorrelationId --delivery-mode NON_PERSISTENT --time-to-live 2000 --priority 1 --body testMessage").getResult.toString.contains("Messages sent to queue 'testQueue': 1")) + assertTrue(shell.executeCommand("send-message --queue testQueue --reply-to replyQueue --correlation-id testCorrelationId --delivery-mode NON_PERSISTENT --time-to-live 20000 --priority 1 --body testMessage").getResult.toString.contains("Messages sent to queue 'testQueue': 1")) assertEquals(info("\nMessages listed: 1"), shell.executeCommand("list-messages --queue testQueue").getResult) val messageFilePath = createTempFilePath("MessageCommandsTests_testSendAndExportMessage") @@ -101,7 +101,7 @@ class MessageCommandsTests { def testSendInlineMessageToTopic = { assertEquals(info("Topic 'VirtualTopic.testTopic' added"), shell.executeCommand("add-topic --name VirtualTopic.testTopic").getResult) assertEquals(info("Queue 'Consumer.testQueue.VirtualTopic.testTopic' added"), shell.executeCommand("add-queue --name Consumer.testQueue.VirtualTopic.testTopic").getResult) - assertEquals(info("Messages sent to topic 'VirtualTopic.testTopic': 1"), shell.executeCommand("send-message --topic VirtualTopic.testTopic --body testMessage").getResult) + assertTrue(shell.executeCommand("send-message --topic VirtualTopic.testTopic --body testMessage").getResult.toString.contains("Messages sent to topic 'VirtualTopic.testTopic': 1")) assertEquals(info("\nMessages listed: 1"), shell.executeCommand("list-messages --queue Consumer.testQueue.VirtualTopic.testTopic").getResult) } diff --git a/src/test/scala/amazonmq/cli/command/QueueCommandsTests.scala b/src/test/scala/amazonmq/cli/command/QueueCommandsTests.scala index f5a4d7a..a7dac9f 100644 --- a/src/test/scala/amazonmq/cli/command/QueueCommandsTests.scala +++ b/src/test/scala/amazonmq/cli/command/QueueCommandsTests.scala @@ -163,7 +163,7 @@ class QueueCommandsTests { @Test def testListQueuesFilters = { - assertEquals(info("Messages sent to queue 'testQueue': 1"), shell.executeCommand("send-message --queue testQueue --body testMessage1").getResult) + assertTrue(shell.executeCommand("send-message --queue testQueue --body testMessage1").getResult.toString.contains("Messages sent to queue 'testQueue': 1")) List( "list-queues --pending =1",