TisonKun commented on a change in pull request #1049: ZOOKEEPER-3475 Enable 
Checkstyle configuration on zookeeper-server
URL: https://github.com/apache/zookeeper/pull/1049#discussion_r314416189
 
 

 ##########
 File path: 
zookeeper-server/src/test/java/org/apache/zookeeper/test/ZooKeeperTestClient.java
 ##########
 @@ -18,450 +18,435 @@
 
 package org.apache.zookeeper.test;
 
-import java.io.File;
 import java.io.IOException;
 import java.util.List;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
-
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.KeeperException.Code;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
-import org.apache.zookeeper.ZKTestCase;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.KeeperException.Code;
 import org.apache.zookeeper.Watcher.Event.EventType;
+import org.apache.zookeeper.ZKTestCase;
 import org.apache.zookeeper.ZooDefs.Ids;
+import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.common.Time;
 import org.apache.zookeeper.data.Stat;
-import org.apache.zookeeper.server.ServerCnxnFactory;
-import org.apache.zookeeper.server.ZooKeeperServer;
 import org.junit.Assert;
 
 public class ZooKeeperTestClient extends ZKTestCase implements Watcher {
-  protected String hostPort = "127.0.0.1:22801";
 
-  protected static final String dirOnZK = "/test_dir";
+    protected String hostPort = "127.0.0.1:22801";
+
+    protected static final String dirOnZK = "/test_dir";
+
+    protected String testDirOnZK = dirOnZK + "/" + Time.currentElapsedTime();
 
-  protected String testDirOnZK = dirOnZK + "/" + Time.currentElapsedTime();
+    LinkedBlockingQueue<WatchedEvent> events = new 
LinkedBlockingQueue<WatchedEvent>();
 
-  LinkedBlockingQueue<WatchedEvent> events = new 
LinkedBlockingQueue<WatchedEvent>();
+    private WatchedEvent getEvent(int numTries) throws InterruptedException {
+        WatchedEvent event = null;
+        for (int i = 0; i < numTries; i++) {
+            System.out.println("i = " + i);
+            event = events.poll(10, TimeUnit.SECONDS);
+            if (event != null) {
+                break;
+            }
+            Thread.sleep(5000);
+        }
+        return event;
 
-  private WatchedEvent getEvent(int numTries) throws InterruptedException {
-    WatchedEvent event = null;
-    for (int i = 0; i < numTries; i++) {
-      System.out.println("i = " + i);
-      event = events.poll(10, TimeUnit.SECONDS);
-      if (event != null) {
-        break;
-      }
-      Thread.sleep(5000);
     }
-    return event;
 
-  }
+    private void deleteZKDir(ZooKeeper zk, String nodeName) throws 
IOException, InterruptedException, KeeperException {
 
-  private void deleteZKDir(ZooKeeper zk, String nodeName)
-          throws IOException, InterruptedException, KeeperException {
+        Stat stat = zk.exists(nodeName, false);
+        if (stat == null) {
+            return;
+        }
 
-    Stat stat = zk.exists(nodeName, false);
-    if (stat == null) {
-      return;
-    }
+        List<String> children1 = zk.getChildren(nodeName, false);
+        List<String> c2 = zk.getChildren(nodeName, false, stat);
 
-    List<String> children1 = zk.getChildren(nodeName, false);
-    List<String> c2 = zk.getChildren(nodeName, false, stat);
+        if (!children1.equals(c2)) {
+            Assert.fail("children lists from getChildren()/getChildren2() do 
not match");
+        }
 
-    if (!children1.equals(c2)) {
-        Assert.fail("children lists from getChildren()/getChildren2() do not 
match");
-    }
+        if (!stat.equals(stat)) {
+            Assert.fail("stats from exists()/getChildren2() do not match");
+        }
 
-    if (!stat.equals(stat)) {
-        Assert.fail("stats from exists()/getChildren2() do not match");
+        if (children1.size() == 0) {
+            zk.delete(nodeName, -1);
+            return;
+        }
+        for (String n : children1) {
+            deleteZKDir(zk, n);
+        }
     }
 
-    if (children1.size() == 0) {
-      zk.delete(nodeName, -1);
-      return;
-    }
-    for (String n : children1) {
-      deleteZKDir(zk, n);
-    }
-  }
-
-  private void checkRoot() throws IOException,
-      InterruptedException {
-    ZooKeeper zk = new ZooKeeper(hostPort, 10000, this);
-
-    try {
-      zk.create(dirOnZK, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-    } catch (KeeperException.NodeExistsException ke) {
-        // expected, sort of
-    } catch (KeeperException ke) {
-        Assert.fail("Unexpected exception code for create " + dirOnZK + ": "
-            + ke.getMessage());
-    }
+    private void checkRoot() throws IOException, InterruptedException {
+        ZooKeeper zk = new ZooKeeper(hostPort, 10000, this);
 
-    try {
-      zk.create(testDirOnZK, null, Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
-    } catch (KeeperException.NodeExistsException ke) {
-        // expected, sort of
-    } catch (KeeperException ke) {
-        Assert.fail("Unexpected exception code for create " + testDirOnZK + ": 
"
-            + ke.getMessage());
-    }
+        try {
+            zk.create(dirOnZK, null, Ids.OPEN_ACL_UNSAFE, 
CreateMode.PERSISTENT);
+        } catch (KeeperException.NodeExistsException ke) {
+            // expected, sort of
+        } catch (KeeperException ke) {
+            Assert.fail("Unexpected exception code for create " + dirOnZK + ": 
" + ke.getMessage());
+        }
 
-    zk.close();
-  }
-
-  private void enode_test_1() throws IOException,
-          InterruptedException, KeeperException {
-    checkRoot();
-    String parentName = testDirOnZK;
-    String nodeName = parentName + "/enode_abc";
-    ZooKeeper zk = new ZooKeeper(hostPort, 10000, this);
-
-    Stat stat = zk.exists(parentName, false);
-    if (stat == null) {
-      try {
-        zk.create(parentName, null, Ids.OPEN_ACL_UNSAFE, 
CreateMode.PERSISTENT);
-      } catch (KeeperException ke) {
-        Assert.fail("Creating node " + parentName + ke.getMessage());
-      }
-    }
+        try {
+            zk.create(testDirOnZK, null, Ids.OPEN_ACL_UNSAFE, 
CreateMode.PERSISTENT);
+        } catch (KeeperException.NodeExistsException ke) {
+            // expected, sort of
+        } catch (KeeperException ke) {
+            Assert.fail("Unexpected exception code for create " + testDirOnZK 
+ ": " + ke.getMessage());
 
 Review comment:
   the rule should be like 
   
   ```xml
       <module name="RegexpSingleline">
           <!-- Checks that do not use import org.junit.Assert. -->
           <property name="format" value="import org\.junit\.Assert;" />
           <property name="message" value="Always import static 
org.junit.Assert.[static-method]." />
           <property name="severity" value="error" />
       </module>
   ```
   
   but I would like do it in another pass since it would affect on other 
modules.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to