Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 22879113FA for ; Fri, 13 Jun 2014 18:50:38 +0000 (UTC) Received: (qmail 60842 invoked by uid 500); 13 Jun 2014 18:50:38 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 60810 invoked by uid 500); 13 Jun 2014 18:50:38 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 60800 invoked by uid 99); 13 Jun 2014 18:50:38 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Jun 2014 18:50:37 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B0B81933CF6; Fri, 13 Jun 2014 18:50:37 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: mdrob@apache.org To: commits@accumulo.apache.org Date: Fri, 13 Jun 2014 18:50:39 -0000 Message-Id: <9ba9c5e98af44649bc55c9760c2b8936@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [4/6] git commit: Merge branch '1.5.2-SNAPSHOT' into 1.6.1-SNAPSHOT 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/master Commit: 46931060631de41a55b4df7eec5ecdee8779ceb0 Parents: dda7a60 e6171e6 Author: Mike Drob Authored: Fri Jun 13 14:37:37 2014 -0400 Committer: Mike Drob 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 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 --------------------------");