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 2016/07/21 20:57:44 UTC

[6/8] accumulo git commit: ACCUMULO-4374: Changes to Shell to fix ChangeSecret tool

ACCUMULO-4374: Changes to Shell to fix ChangeSecret tool

Closes apache/accumulo#126, apache/accumulo#129

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/7a47b187
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/7a47b187
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/7a47b187

Branch: refs/heads/master
Commit: 7a47b187e0958f07425867f97012f7b2dc66a6f9
Parents: fa8177b
Author: milleruntime <mi...@gmail.com>
Authored: Fri Jul 15 15:42:00 2016 -0400
Committer: Josh Elser <el...@apache.org>
Committed: Thu Jul 21 16:33:49 2016 -0400

----------------------------------------------------------------------
 .../src/main/java/org/apache/accumulo/shell/Shell.java | 13 ++++++++-----
 .../java/org/apache/accumulo/shell/mock/MockShell.java |  2 +-
 .../org/apache/accumulo/shell/ShellConfigTest.java     | 11 ++++++-----
 3 files changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/7a47b187/shell/src/main/java/org/apache/accumulo/shell/Shell.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/Shell.java b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
index 053e998..7678ead 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/Shell.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
@@ -245,9 +245,8 @@ public class Shell extends ShellOptions implements KeywordExecutable {
     }
   }
 
-  public Shell() throws IOException {
-    this(new ConsoleReader());
-  }
+  // no arg constructor should do minimal work since its used in Main ServiceLoader
+  public Shell() {}
 
   public Shell(ConsoleReader reader) {
     super();
@@ -258,8 +257,12 @@ public class Shell extends ShellOptions implements KeywordExecutable {
    * Configures the shell using the provided options. Not for client use.
    *
    * @return true if the shell was successfully configured, false otherwise.
+   * @throws IOException
+   *           if problems occur creating the ConsoleReader
    */
-  public boolean config(String... args) {
+  public boolean config(String... args) throws IOException {
+    if (this.reader == null)
+      this.reader = new ConsoleReader();
     ShellOptionsJC options = new ShellOptionsJC();
     JCommander jc = new JCommander();
 
@@ -596,7 +599,7 @@ public class Shell extends ShellOptions implements KeywordExecutable {
   }
 
   public static void main(String args[]) throws IOException {
-    new Shell().execute(args);
+    new Shell(new ConsoleReader()).execute(args);
   }
 
   public int start() throws IOException {

http://git-wip-us.apache.org/repos/asf/accumulo/blob/7a47b187/shell/src/main/java/org/apache/accumulo/shell/mock/MockShell.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/accumulo/shell/mock/MockShell.java b/shell/src/main/java/org/apache/accumulo/shell/mock/MockShell.java
index f2bd075..ebc92f7 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/mock/MockShell.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/mock/MockShell.java
@@ -52,7 +52,7 @@ public class MockShell extends Shell {
   }
 
   @Override
-  public boolean config(String... args) {
+  public boolean config(String... args) throws IOException {
     // If configuring the shell failed, fail quickly
     if (!super.config(args)) {
       return false;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/7a47b187/shell/src/test/java/org/apache/accumulo/shell/ShellConfigTest.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/accumulo/shell/ShellConfigTest.java b/shell/src/test/java/org/apache/accumulo/shell/ShellConfigTest.java
index 9bfe992..8bef14d 100644
--- a/shell/src/test/java/org/apache/accumulo/shell/ShellConfigTest.java
+++ b/shell/src/test/java/org/apache/accumulo/shell/ShellConfigTest.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertTrue;
 import java.io.File;
 import java.io.FileDescriptor;
 import java.io.FileInputStream;
+import java.io.IOException;
 import java.io.PrintStream;
 import java.nio.file.Files;
 import java.util.HashMap;
@@ -90,30 +91,30 @@ public class ShellConfigTest {
   }
 
   @Test
-  public void testHelp() {
+  public void testHelp() throws IOException {
     assertFalse(shell.config(args("--help")));
     assertTrue("Did not print usage", output.get().startsWith("Usage"));
   }
 
   @Test
-  public void testBadArg() {
+  public void testBadArg() throws IOException {
     assertFalse(shell.config(args("--bogus")));
     assertTrue("Did not print usage", output.get().startsWith("Usage"));
   }
 
   @Test
-  public void testTokenWithoutOptions() {
+  public void testTokenWithoutOptions() throws IOException {
     assertFalse(shell.config(args("--fake", "-tc", PasswordToken.class.getName())));
     assertFalse(output.get().contains(ParameterException.class.getName()));
   }
 
   @Test
-  public void testTokenAndOption() {
+  public void testTokenAndOption() throws IOException {
     assertTrue(shell.config(args("--fake", "-tc", PasswordToken.class.getName(), "-u", "foo", "-l", "password=foo")));
   }
 
   @Test
-  public void testTokenAndOptionAndPassword() {
+  public void testTokenAndOptionAndPassword() throws IOException {
     assertFalse(shell.config(args("--fake", "-tc", PasswordToken.class.getName(), "-l", "password=foo", "-p", "bar")));
     assertTrue(output.get().contains(ParameterException.class.getName()));
   }