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:41 UTC
[3/8] accumulo git commit: ACCUMULO-4374: Changes to Shell to fix
ChangeSecret tool
ACCUMULO-4374: Changes to Shell to fix ChangeSecret tool
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/612ede69
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/612ede69
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/612ede69
Branch: refs/heads/master
Commit: 612ede6960503a8ffef0d30bd73503015c52274d
Parents: 9b7f60e
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:32:58 2016 -0400
----------------------------------------------------------------------
.../main/java/org/apache/accumulo/shell/Shell.java | 16 ++++++++++------
.../org/apache/accumulo/shell/mock/MockShell.java | 2 +-
.../org/apache/accumulo/shell/ShellConfigTest.java | 11 ++++++-----
3 files changed, 17 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/accumulo/blob/612ede69/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 0005c36..393fe26 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/Shell.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/Shell.java
@@ -230,10 +230,8 @@ public class Shell extends ShellOptions implements KeywordExecutable {
private PrintWriter writer = null;
private boolean masking = false;
- public Shell() throws IOException {
- this(new ConsoleReader(), new PrintWriter(new OutputStreamWriter(System.out, Charset.forName(System.getProperty("jline.WindowsTerminal.output.encoding",
- System.getProperty("file.encoding"))))));
- }
+ // no arg constructor should do minimal work since its used in Main ServiceLoader
+ public Shell() {}
public Shell(ConsoleReader reader, PrintWriter writer) {
super();
@@ -246,7 +244,12 @@ public class Shell extends ShellOptions implements KeywordExecutable {
*
* @return true if the shell was successfully configured, false otherwise.
*/
- public boolean config(String... args) {
+ public boolean config(String... args) throws IOException {
+ if (this.reader == null)
+ this.reader = new ConsoleReader();
+ if (this.writer == null)
+ this.writer = new PrintWriter(new OutputStreamWriter(System.out, Charset.forName(System.getProperty("jline.WindowsTerminal.output.encoding",
+ System.getProperty("file.encoding")))));
ShellOptionsJC options = new ShellOptionsJC();
JCommander jc = new JCommander();
@@ -583,7 +586,8 @@ public class Shell extends ShellOptions implements KeywordExecutable {
}
public static void main(String args[]) throws IOException {
- new Shell().execute(args);
+ new Shell(new ConsoleReader(), new PrintWriter(new OutputStreamWriter(System.out, Charset.forName(System.getProperty(
+ "jline.WindowsTerminal.output.encoding", System.getProperty("file.encoding")))))).execute(args);
}
public int start() throws IOException {
http://git-wip-us.apache.org/repos/asf/accumulo/blob/612ede69/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 609f23f..8e63eb8 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
@@ -50,7 +50,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/612ede69/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 64bad82..49f22a6 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.io.PrintWriter;
import java.nio.file.Files;
@@ -91,30 +92,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()));
}