zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f..@apache.org
Subject svn commit: r1519515 - in /zookeeper/trunk: CHANGES.txt src/java/main/org/apache/zookeeper/ZooKeeperMain.java src/java/test/org/apache/zookeeper/ZooKeeperTest.java
Date Mon, 02 Sep 2013 21:04:12 GMT
Author: fpj
Date: Mon Sep  2 21:04:12 2013
New Revision: 1519515

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


Modified:
    zookeeper/trunk/CHANGES.txt
    zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
    zookeeper/trunk/src/java/test/org/apache/zookeeper/ZooKeeperTest.java

Modified: zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1519515&r1=1519514&r2=1519515&view=diff
==============================================================================
--- zookeeper/trunk/CHANGES.txt (original)
+++ zookeeper/trunk/CHANGES.txt Mon Sep  2 21:04:12 2013
@@ -367,6 +367,8 @@ BUGFIXES:
   ZOOKEEPER-1629. testTransactionLogCorruption occasionally fails. (shralex 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/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java?rev=1519515&r1=1519514&r2=1519515&view=diff
==============================================================================
--- zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java (original)
+++ zookeeper/trunk/src/java/main/org/apache/zookeeper/ZooKeeperMain.java Mon Sep  2 21:04:12
2013
@@ -663,14 +663,15 @@ public class ZooKeeperMain {
         if(cliCmd != null) {
             cliCmd.setZk(zk);
             watch = cliCmd.parse(args).exec();
-            } else {
-                usage();
-            }
+        } else if (!commandMap.containsKey(cmd)) {
+             usage();
+        }
+
         } catch (ParseException ex) {
             System.err.println(ex.getMessage());
-                usage();
+            usage();
             return false;
-            }
+        }
         return watch;
     }
-        }
+}

Modified: zookeeper/trunk/src/java/test/org/apache/zookeeper/ZooKeeperTest.java
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/java/test/org/apache/zookeeper/ZooKeeperTest.java?rev=1519515&r1=1519514&r2=1519515&view=diff
==============================================================================
--- zookeeper/trunk/src/java/test/org/apache/zookeeper/ZooKeeperTest.java (original)
+++ zookeeper/trunk/src/java/test/org/apache/zookeeper/ZooKeeperTest.java Mon Sep  2 21:04:12
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;
 
@@ -344,4 +346,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