zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f..@apache.org
Subject svn commit: r1519521 - in /zookeeper/branches/branch-3.4: CHANGES.txt src/java/main/org/apache/zookeeper/ZooKeeperMain.java src/java/test/org/apache/zookeeper/ZooKeeperTest.java
Date Mon, 02 Sep 2013 21:47:42 GMT
Author: fpj
Date: Mon Sep  2 21:47:42 2013
New Revision: 1519521

URL: http://svn.apache.org/r1519521
Log:
ZOOKEEPER-1379. 'printwatches, redo, history and connect '. client commands always print usage.
This is not necessary (edward via fpj)


Modified:
    zookeeper/branches/branch-3.4/CHANGES.txt
    zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
    zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/ZooKeeperTest.java

Modified: zookeeper/branches/branch-3.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/CHANGES.txt?rev=1519521&r1=1519520&r2=1519521&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.4/CHANGES.txt Mon Sep  2 21:47:42 2013
@@ -85,6 +85,8 @@ BUGFIXES:
   deadlock. (Dave Latham via camille)
 
   ZOOKEEPER-1713. wrong time calculation in zkfuse.cc (german via fpj)
+
+  ZOOKEEPER-1379. 'printwatches, redo, history and connect '. client commands always print
usage. This is not necessary (edward via fpj)
   
 IMPROVEMENTS:
 

Modified: zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ZooKeeperMain.java?rev=1519521&r1=1519520&r2=1519521&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ZooKeeperMain.java (original)
+++ zookeeper/branches/branch-3.4/src/java/main/org/apache/zookeeper/ZooKeeperMain.java Mon
Sep  2 21:47:42 2013
@@ -810,7 +810,7 @@ public class ZooKeeperMain {
                 b = args[2].getBytes();
 
             zk.addAuthInfo(args[1], b);
-        } else {
+        } else if (!commandMap.containsKey(cmd)) {
             usage();
         }
         return watch;

Modified: zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/ZooKeeperTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/ZooKeeperTest.java?rev=1519521&r1=1519520&r2=1519521&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/ZooKeeperTest.java (original)
+++ zookeeper/branches/branch-3.4/src/java/test/org/apache/zookeeper/ZooKeeperTest.java Mon
Sep  2 21:47:42 2013
@@ -19,7 +19,9 @@ package org.apache.zookeeper;
 
 import static org.junit.Assert.*;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.PrintStream;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -178,4 +180,25 @@ public class ZooKeeperTest extends Clien
             }
     }
 
+    @Test
+    public void testCliCommandsNotEchoingUsage() throws Exception {
+            // setup redirect out/err streams to get System.in/err, use this judiciously!
+           final PrintStream systemErr = System.err; // get current err
+           final ByteArrayOutputStream errContent = new ByteArrayOutputStream();
+           System.setErr(new PrintStream(errContent));
+           final ZooKeeper zk = createClient();
+           ZooKeeperMain zkMain = new ZooKeeperMain(zk);
+           String cmd1 = "printwatches";
+           zkMain.executeLine(cmd1);
+           String cmd2 = "history";
+           zkMain.executeLine(cmd2);
+           String cmd3 = "redo";
+           zkMain.executeLine(cmd3);
+           // revert redirect of out/err streams - important step!
+           System.setErr(systemErr);
+           if (errContent.toString().contains("ZooKeeper -server host:port cmd args")) {
+                fail("CLI commands (history, redo, connect, printwatches) display usage info!");
+            }
+    }
+
 }



Mime
View raw message