Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT

Conflicts:
        core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java


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

Branch: refs/heads/1.6.1-SNAPSHOT
Commit: 46931060631de41a55b4df7eec5ecdee8779ceb0
Parents: dda7a60 e6171e6
Author: Mike Drob <md...@cloudera.com>
Authored: Fri Jun 13 14:37:37 2014 -0400
Committer: Mike Drob <md...@cloudera.com>
Committed: Fri Jun 13 14:37:37 2014 -0400

----------------------------------------------------------------------
 .../accumulo/core/util/shell/ShellTest.java      | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/46931060/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
----------------------------------------------------------------------
diff --cc core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
index 3d9b89e,610caf1..87eea7a
--- a/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
@@@ -24,16 -25,12 +24,18 @@@ import java.io.InputStream
  import java.io.OutputStream;
  import java.io.OutputStreamWriter;
  import java.io.PrintWriter;
 +import java.text.DateFormat;
 +import java.text.SimpleDateFormat;
+ import java.util.Arrays;
 +import java.util.Date;
+ import java.util.List;
 +import java.util.TimeZone;
  
 -import jline.ConsoleReader;
 +import jline.console.ConsoleReader;
  
 +import org.apache.accumulo.core.util.format.DateStringFormatter;
  import org.apache.log4j.Level;
 +import org.junit.After;
  import org.junit.Before;
  import org.junit.Test;
  
@@@ -54,29 -51,23 +56,42 @@@ public class ShellTest 
        sb.setLength(0);
      }
    }
 -  
 +
 +  public static class StringInputStream extends InputStream {
 +    private String source = "";
 +    private int offset = 0;
 +
 +    @Override
 +    public int read() throws IOException {
 +      if (offset == source.length())
 +        return '\n';
 +      else
 +        return source.charAt(offset++);
 +    }
 +
 +    public void set(String other) {
 +      source = other;
 +      offset = 0;
 +    }
 +  }
 +
 +  private StringInputStream input;
    private TestOutputStream output;
    private Shell shell;
 -  
 +
+   void execExpectList(String cmd, boolean expecteGoodExit, List<String> 
expectedStrings) throws IOException {
+     exec(cmd);
+     if (expecteGoodExit) {
+       assertGoodExit("", true);
+     } else {
+       assertBadExit("", true);
+     }
+ 
+     for (String expectedString : expectedStrings) {
+       assertTrue(expectedString + " was not present in " + output.get(), 
output.get().contains(expectedString));
+     }
+   }
+ 
    void exec(String cmd) throws IOException {
      output.clear();
      shell.execCommand(cmd, true, true);
@@@ -182,16 -166,16 +197,16 @@@
      Shell.log.debug("Starting auths test --------------------------");
      exec("setauths x,y,z", false, "Missing required option");
      exec("setauths -s x,y,z -u notauser", false, "user does not exist");
 -    exec("setauths -s x,y,z", true);
 +    exec("setauths -s y,z,x", true);
      exec("getauths -u notauser", false, "user does not exist");
-     exec("getauths", true, "x,y,z");
+     execExpectList("getauths", true, Arrays.asList("x", "y", "z"));
      exec("addauths -u notauser", false, "Missing required option");
      exec("addauths -u notauser -s foo", false, "user does not exist");
      exec("addauths -s a", true);
-     exec("getauths", true, "a,x,y,z");
+     execExpectList("getauths", true, Arrays.asList("x", "y", "z", "a"));
      exec("setauths -c", true);
    }
 -  
 +
    @Test
    public void userTest() throws Exception {
      Shell.log.debug("Starting user test --------------------------");

Reply via email to