ACCUMULO-2549 Fixes ShellTest Authorizations were coming back from getauths in an unexpected order. This patch changes the test to expect not a specific string a but a list of expected authorization entries.
Signed-off-by: Mike Drob <md...@cloudera.com> Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/e6171e6b Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/e6171e6b Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/e6171e6b Branch: refs/heads/1.6.1-SNAPSHOT Commit: e6171e6b2a293ac5561e20147e005df2d0e6c06a Parents: edfc56b Author: Michael Allen <mich...@sqrrl.com> Authored: Tue Mar 25 13:46:11 2014 -0400 Committer: Mike Drob <md...@cloudera.com> Committed: Fri Jun 13 12:53:11 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/e6171e6b/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java ---------------------------------------------------------------------- diff --git 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 index 8505370..610caf1 100644 --- 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 @@ -25,6 +25,8 @@ import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.util.Arrays; +import java.util.List; import jline.ConsoleReader; @@ -53,6 +55,19 @@ public class ShellTest { 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); @@ -153,11 +168,11 @@ public class ShellTest { exec("setauths -s x,y,z -u notauser", false, "user does not exist"); exec("setauths -s x,y,z", true); exec("getauths -u notauser", false, "user does not exist"); - exec("getauths", true, "y,z,x"); + 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, "y,z,a,x"); + execExpectList("getauths", true, Arrays.asList("x", "y", "z", "a")); exec("setauths -c", true); }