activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/4] activemq-artemis git commit: ARTEMIS-116 Fixed exception handling. Minor formatting clean up in the CLI.
Date Wed, 17 Jun 2015 02:49:41 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 4950c343e -> 9eb452124


ARTEMIS-116 Fixed exception handling.  Minor formatting clean up in the CLI.


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/1d0821ea
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/1d0821ea
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/1d0821ea

Branch: refs/heads/master
Commit: 1d0821ea4a62b9834589f348ad2411ac52c4815a
Parents: 4950c34
Author: John D. Ament <johndament@apache.org>
Authored: Tue Jun 16 20:28:32 2015 -0400
Committer: John D. Ament <johndament@apache.org>
Committed: Tue Jun 16 20:28:32 2015 -0400

----------------------------------------------------------------------
 .../apache/activemq/artemis/cli/Artemis.java    | 18 ++++-----
 .../activemq/artemis/test/ArtemisTest.java      | 41 ++++++++++++++++++++
 2 files changed, 50 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1d0821ea/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
index 060d543..c19b37d 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/Artemis.java
@@ -20,6 +20,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 
 import io.airlift.airline.Cli;
+import io.airlift.airline.ParseArgumentsMissingException;
 import io.airlift.airline.ParseArgumentsUnexpectedException;
 import org.apache.activemq.artemis.cli.commands.Action;
 import org.apache.activemq.artemis.cli.commands.ActionContext;
@@ -37,7 +38,7 @@ import org.apache.activemq.artemis.cli.commands.tools.XmlDataImporter;
 
 public class Artemis
 {
-
+   @SuppressWarnings("unchecked")
    public static void main(String[] args) throws Exception
    {
       String instance = System.getProperty("artemis.instance");
@@ -47,19 +48,18 @@ public class Artemis
          .withDefaultCommand(HelpAction.class);
 
 
-      builder.withGroup("data").withDescription("data tools group (print|exp|imp|exp|encode|decode)
(example ./artemis data print)").
-              withDefaultCommand(HelpData.class).withCommands(PrintData.class, XmlDataExporter.class,
XmlDataImporter.class,
-                                                               DecodeJournal.class, EncodeJournal.class);
+      builder.withGroup("data")
+              .withDescription("data tools group (print|exp|imp|exp|encode|decode) (example
./artemis data print)").
+              withDefaultCommand(HelpData.class).withCommands(PrintData.class, XmlDataExporter.class,
+              XmlDataImporter.class,DecodeJournal.class, EncodeJournal.class);
 
       if (instance != null)
       {
-         builder = builder
-            .withCommands(Run.class, Stop.class, Kill.class);
+         builder = builder.withCommands(Run.class, Stop.class, Kill.class);
       }
       else
       {
-         builder = builder
-            .withCommand(Create.class);
+         builder = builder.withCommand(Create.class);
       }
 
       Cli<Action> parser = builder.build();
@@ -67,7 +67,7 @@ public class Artemis
       {
          parser.parse(args).execute(ActionContext.system());
       }
-      catch (ParseArgumentsUnexpectedException e)
+      catch (ParseArgumentsUnexpectedException | ParseArgumentsMissingException e)
       {
          System.err.println(e.getMessage());
          System.out.println();

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/1d0821ea/artemis-cli/src/test/java/org/apache/activemq/artemis/test/ArtemisTest.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/test/java/org/apache/activemq/artemis/test/ArtemisTest.java b/artemis-cli/src/test/java/org/apache/activemq/artemis/test/ArtemisTest.java
new file mode 100644
index 0000000..5e02a63
--- /dev/null
+++ b/artemis-cli/src/test/java/org/apache/activemq/artemis/test/ArtemisTest.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.activemq.artemis.test;
+
+import org.apache.activemq.artemis.cli.Artemis;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test to validate that the CLI doesn't throw improper exceptions when invoked.
+ */
+public class ArtemisTest
+{
+   @Test
+   public void invalidCliDoesntThrowException()
+   {
+      try
+      {
+         Artemis.main(new String[]{"create"});
+      }
+      catch (Exception e)
+      {
+         e.printStackTrace();
+         Assert.fail("Exception caught " + e.getMessage());
+      }
+   }
+}


Mime
View raw message