You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by el...@apache.org on 2013/11/25 05:13:37 UTC

[1/2] git commit: ACCUMULO-1899 exit with non-zero exit code if there's an error parsing the arguments.

Updated Branches:
  refs/heads/1.6.0-SNAPSHOT 7d24ff5b5 -> de2168e0b


ACCUMULO-1899 exit with non-zero exit code if there's an error parsing the arguments.

Signed-off-by: Josh Elser <el...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/100e75be
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/100e75be
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/100e75be

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: 100e75bece15ad2d223070912854430d078e587a
Parents: e6e1df4
Author: Morgan Haskel <mo...@gmail.com>
Authored: Sun Nov 24 22:43:36 2013 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Sun Nov 24 23:01:15 2013 -0500

----------------------------------------------------------------------
 .../java/org/apache/accumulo/core/cli/Help.java | 14 ++++--
 .../org/apache/accumulo/core/cli/TestHelp.java  | 46 ++++++++++++++++++++
 2 files changed, 57 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/100e75be/core/src/main/java/org/apache/accumulo/core/cli/Help.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/cli/Help.java b/core/src/main/java/org/apache/accumulo/core/cli/Help.java
index dc4ead9..b5b16bc 100644
--- a/core/src/main/java/org/apache/accumulo/core/cli/Help.java
+++ b/core/src/main/java/org/apache/accumulo/core/cli/Help.java
@@ -34,12 +34,20 @@ public class Help {
       commander.parse(args);
     } catch (ParameterException ex) {
       commander.usage();
-      System.err.println(ex.getMessage());
-      System.exit(0);
+      exitWithError(ex.getMessage(), 1);
     }
     if (help) {
       commander.usage();
-      System.exit(0);
+      exit(0);
     }
   }
+  
+  public void exit(int status) {
+    System.exit(status);
+  }
+  
+  public void exitWithError(String message, int status) {
+    System.err.println(message);
+    exit(status);
+  }
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/100e75be/core/src/test/java/org/apache/accumulo/core/cli/TestHelp.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/accumulo/core/cli/TestHelp.java b/core/src/test/java/org/apache/accumulo/core/cli/TestHelp.java
new file mode 100644
index 0000000..7b29986
--- /dev/null
+++ b/core/src/test/java/org/apache/accumulo/core/cli/TestHelp.java
@@ -0,0 +1,46 @@
+package org.apache.accumulo.core.cli;
+/*
+ * 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.
+ */
+
+import static org.junit.Assert.assertEquals;
+import org.junit.Test;
+
+public class TestHelp {
+  protected class HelpStub extends Help {
+    @Override
+    public void parseArgs(String programName, String[] args, Object ... others) {
+      super.parseArgs(programName, args, others);
+    }
+
+    @Override
+    public void exit(int status) {
+      throw new RuntimeException(Integer.toString(status));
+    }
+  }
+  
+  @Test
+  public void testInvalidArgs() {
+    String[] args = {"foo"};
+    HelpStub help = new HelpStub();
+    try {
+      help.parseArgs("program", args);
+    } catch (RuntimeException e) {
+      assertEquals("1", e.getMessage());
+    }
+  }
+
+}


[2/2] git commit: Merge branch '1.5.1-SNAPSHOT' into 1.6.0-SNAPSHOT

Posted by el...@apache.org.
Merge branch '1.5.1-SNAPSHOT' into 1.6.0-SNAPSHOT


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/de2168e0
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/de2168e0
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/de2168e0

Branch: refs/heads/1.6.0-SNAPSHOT
Commit: de2168e0b8cbd2e5740eb28512ee29a8c0ace842
Parents: 7d24ff5 100e75b
Author: Josh Elser <el...@apache.org>
Authored: Sun Nov 24 23:09:21 2013 -0500
Committer: Josh Elser <el...@apache.org>
Committed: Sun Nov 24 23:09:21 2013 -0500

----------------------------------------------------------------------
 .../java/org/apache/accumulo/core/cli/Help.java | 14 ++++--
 .../org/apache/accumulo/core/cli/TestHelp.java  | 46 ++++++++++++++++++++
 2 files changed, 57 insertions(+), 3 deletions(-)
----------------------------------------------------------------------