zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From f..@apache.org
Subject svn commit: r1742003 [2/2] - in /zookeeper/branches/branch-3.5: ./ src/java/main/org/apache/zookeeper/ src/java/main/org/apache/zookeeper/client/ src/java/main/org/apache/zookeeper/common/ src/java/main/org/apache/zookeeper/server/ src/java/main/org/ap...
Date Mon, 02 May 2016 16:18:23 GMT
Modified: zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SSLAuthTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SSLAuthTest.java?rev=1742003&r1=1742002&r2=1742003&view=diff
==============================================================================
--- zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SSLAuthTest.java
(original)
+++ zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SSLAuthTest.java
Mon May  2 16:18:22 2016
@@ -22,8 +22,8 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.zookeeper.PortAssignment;
 import org.apache.zookeeper.TestableZooKeeper;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.common.X509Util;
+import org.apache.zookeeper.client.ZKClientConfig;
+import org.apache.zookeeper.common.ZKConfig;
 import org.apache.zookeeper.server.ServerCnxnFactory;
 import org.junit.After;
 import org.junit.Assert;
@@ -35,13 +35,13 @@ public class SSLAuthTest extends ClientB
     public void setUp() throws Exception {
         String testDataPath = System.getProperty("test.data.dir", "build/test/data");
         System.setProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY, "org.apache.zookeeper.server.NettyServerCnxnFactory");
-        System.setProperty(ZooKeeper.ZOOKEEPER_CLIENT_CNXN_SOCKET, "org.apache.zookeeper.ClientCnxnSocketNetty");
-        System.setProperty(ZooKeeper.SECURE_CLIENT, "true");
-        System.setProperty(X509Util.SSL_AUTHPROVIDER, "x509");
-        System.setProperty(X509Util.SSL_KEYSTORE_LOCATION, testDataPath + "/ssl/testKeyStore.jks");
-        System.setProperty(X509Util.SSL_KEYSTORE_PASSWD, "testpass");
-        System.setProperty(X509Util.SSL_TRUSTSTORE_LOCATION, testDataPath + "/ssl/testTrustStore.jks");
-        System.setProperty(X509Util.SSL_TRUSTSTORE_PASSWD, "testpass");
+        System.setProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET, "org.apache.zookeeper.ClientCnxnSocketNetty");
+        System.setProperty(ZKClientConfig.SECURE_CLIENT, "true");
+        System.setProperty(ZKConfig.SSL_AUTHPROVIDER, "x509");
+        System.setProperty(ZKConfig.SSL_KEYSTORE_LOCATION, testDataPath + "/ssl/testKeyStore.jks");
+        System.setProperty(ZKConfig.SSL_KEYSTORE_PASSWD, "testpass");
+        System.setProperty(ZKConfig.SSL_TRUSTSTORE_LOCATION, testDataPath + "/ssl/testTrustStore.jks");
+        System.setProperty(ZKConfig.SSL_TRUSTSTORE_PASSWD, "testpass");
         System.setProperty("javax.net.debug", "ssl");
 
         String host = "localhost";
@@ -57,13 +57,13 @@ public class SSLAuthTest extends ClientB
     @After
     public void teardown() throws Exception {
         System.clearProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY);
-        System.clearProperty(ZooKeeper.ZOOKEEPER_CLIENT_CNXN_SOCKET);
-        System.clearProperty(ZooKeeper.SECURE_CLIENT);
-        System.clearProperty(X509Util.SSL_AUTHPROVIDER);
-        System.clearProperty(X509Util.SSL_KEYSTORE_LOCATION);
-        System.clearProperty(X509Util.SSL_KEYSTORE_PASSWD);
-        System.clearProperty(X509Util.SSL_TRUSTSTORE_LOCATION);
-        System.clearProperty(X509Util.SSL_TRUSTSTORE_PASSWD);
+        System.clearProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET);
+        System.clearProperty(ZKClientConfig.SECURE_CLIENT);
+        System.clearProperty(ZKConfig.SSL_AUTHPROVIDER);
+        System.clearProperty(ZKConfig.SSL_KEYSTORE_LOCATION);
+        System.clearProperty(ZKConfig.SSL_KEYSTORE_PASSWD);
+        System.clearProperty(ZKConfig.SSL_TRUSTSTORE_LOCATION);
+        System.clearProperty(ZKConfig.SSL_TRUSTSTORE_PASSWD);
         System.clearProperty("javax.net.debug");
     }
 
@@ -72,8 +72,8 @@ public class SSLAuthTest extends ClientB
         String testDataPath = System.getProperty("test.data.dir", "build/test/data");
 
         // Replace trusted keys with a valid key that is not trusted by the server
-        System.setProperty(X509Util.SSL_KEYSTORE_LOCATION, testDataPath + "/ssl/testUntrustedKeyStore.jks");
-        System.setProperty(X509Util.SSL_KEYSTORE_PASSWD, "testpass");
+        System.setProperty(ZKConfig.SSL_KEYSTORE_LOCATION, testDataPath + "/ssl/testUntrustedKeyStore.jks");
+        System.setProperty(ZKConfig.SSL_KEYSTORE_PASSWD, "testpass");
 
         CountdownWatcher watcher = new CountdownWatcher();
 
@@ -85,11 +85,11 @@ public class SSLAuthTest extends ClientB
 
     @Test
     public void testMisconfiguration() throws Exception {
-        System.clearProperty(X509Util.SSL_AUTHPROVIDER);
-        System.clearProperty(X509Util.SSL_KEYSTORE_LOCATION);
-        System.clearProperty(X509Util.SSL_KEYSTORE_PASSWD);
-        System.clearProperty(X509Util.SSL_TRUSTSTORE_LOCATION);
-        System.clearProperty(X509Util.SSL_TRUSTSTORE_PASSWD);
+        System.clearProperty(ZKConfig.SSL_AUTHPROVIDER);
+        System.clearProperty(ZKConfig.SSL_KEYSTORE_LOCATION);
+        System.clearProperty(ZKConfig.SSL_KEYSTORE_PASSWD);
+        System.clearProperty(ZKConfig.SSL_TRUSTSTORE_LOCATION);
+        System.clearProperty(ZKConfig.SSL_TRUSTSTORE_PASSWD);
 
         CountdownWatcher watcher = new CountdownWatcher();
         new TestableZooKeeper(hostPort, CONNECTION_TIMEOUT, watcher);

Modified: zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SSLTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SSLTest.java?rev=1742003&r1=1742002&r2=1742003&view=diff
==============================================================================
--- zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SSLTest.java (original)
+++ zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SSLTest.java Mon
May  2 16:18:22 2016
@@ -30,7 +30,8 @@ import org.apache.zookeeper.WatchedEvent
 import org.apache.zookeeper.Watcher;
 import org.apache.zookeeper.ZooDefs;
 import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.common.X509Util;
+import org.apache.zookeeper.client.ZKClientConfig;
+import org.apache.zookeeper.common.ZKConfig;
 import org.apache.zookeeper.server.ServerCnxnFactory;
 import org.apache.zookeeper.server.quorum.QuorumPeerTestBase;
 import org.junit.After;
@@ -44,23 +45,23 @@ public class SSLTest extends QuorumPeerT
     public void setup() {
         String testDataPath = System.getProperty("test.data.dir", "build/test/data");
         System.setProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY, "org.apache.zookeeper.server.NettyServerCnxnFactory");
-        System.setProperty(ZooKeeper.ZOOKEEPER_CLIENT_CNXN_SOCKET, "org.apache.zookeeper.ClientCnxnSocketNetty");
-        System.setProperty(ZooKeeper.SECURE_CLIENT, "true");
-        System.setProperty(X509Util.SSL_KEYSTORE_LOCATION, testDataPath + "/ssl/testKeyStore.jks");
-        System.setProperty(X509Util.SSL_KEYSTORE_PASSWD, "testpass");
-        System.setProperty(X509Util.SSL_TRUSTSTORE_LOCATION, testDataPath + "/ssl/testTrustStore.jks");
-        System.setProperty(X509Util.SSL_TRUSTSTORE_PASSWD, "testpass");
+        System.setProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET, "org.apache.zookeeper.ClientCnxnSocketNetty");
+        System.setProperty(ZKClientConfig.SECURE_CLIENT, "true");
+        System.setProperty(ZKConfig.SSL_KEYSTORE_LOCATION, testDataPath + "/ssl/testKeyStore.jks");
+        System.setProperty(ZKConfig.SSL_KEYSTORE_PASSWD, "testpass");
+        System.setProperty(ZKConfig.SSL_TRUSTSTORE_LOCATION, testDataPath + "/ssl/testTrustStore.jks");
+        System.setProperty(ZKConfig.SSL_TRUSTSTORE_PASSWD, "testpass");
     }
 
     @After
     public void teardown() throws Exception {
         System.clearProperty(ServerCnxnFactory.ZOOKEEPER_SERVER_CNXN_FACTORY);
-        System.clearProperty(ZooKeeper.ZOOKEEPER_CLIENT_CNXN_SOCKET);
-        System.clearProperty(ZooKeeper.SECURE_CLIENT);
-        System.clearProperty(X509Util.SSL_KEYSTORE_LOCATION);
-        System.clearProperty(X509Util.SSL_KEYSTORE_PASSWD);
-        System.clearProperty(X509Util.SSL_TRUSTSTORE_LOCATION);
-        System.clearProperty(X509Util.SSL_TRUSTSTORE_PASSWD);
+        System.clearProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET);
+        System.clearProperty(ZKClientConfig.SECURE_CLIENT);
+        System.clearProperty(ZKConfig.SSL_KEYSTORE_LOCATION);
+        System.clearProperty(ZKConfig.SSL_KEYSTORE_PASSWD);
+        System.clearProperty(ZKConfig.SSL_TRUSTSTORE_LOCATION);
+        System.clearProperty(ZKConfig.SSL_TRUSTSTORE_PASSWD);
     }
 
     /**

Modified: zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SaslAuthDesignatedClientTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SaslAuthDesignatedClientTest.java?rev=1742003&r1=1742002&r2=1742003&view=diff
==============================================================================
--- zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SaslAuthDesignatedClientTest.java
(original)
+++ zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SaslAuthDesignatedClientTest.java
Mon May  2 16:18:22 2016
@@ -29,6 +29,7 @@ import org.apache.zookeeper.KeeperExcept
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.ZooDefs.Perms;
+import org.apache.zookeeper.client.ZKClientConfig;
 import org.apache.zookeeper.client.ZooKeeperSaslClient;
 import org.apache.zookeeper.data.ACL;
 import org.apache.zookeeper.data.Id;
@@ -38,7 +39,8 @@ import org.junit.Test;
 public class SaslAuthDesignatedClientTest extends ClientBase {
     static {
         System.setProperty("zookeeper.authProvider.1","org.apache.zookeeper.server.auth.SASLAuthenticationProvider");
-        System.setProperty(ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY, "MyZookeeperClient");
+        System.setProperty(ZKClientConfig.LOGIN_CONTEXT_NAME_KEY,
+                "MyZookeeperClient");
 
         try {
             File tmpDir = createTmpDir();
@@ -144,7 +146,7 @@ public class SaslAuthDesignatedClientTes
       Thread.sleep(100);
       
       // disable Client Sasl
-      System.setProperty(ZooKeeperSaslClient.ENABLE_CLIENT_SASL_KEY, "false");
+        System.setProperty(ZKClientConfig.ENABLE_CLIENT_SASL_KEY, "false");
       
       try {
         zk = createClient();
@@ -157,7 +159,8 @@ public class SaslAuthDesignatedClientTes
         zk.close();
       } finally {
         // enable Client Sasl
-        System.setProperty(ZooKeeperSaslClient.ENABLE_CLIENT_SASL_KEY, "true");
+            System.setProperty(ZKClientConfig.ENABLE_CLIENT_SASL_KEY,
+                    "true");
       }
     }
 }

Modified: zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SaslAuthFailDesignatedClientTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SaslAuthFailDesignatedClientTest.java?rev=1742003&r1=1742002&r2=1742003&view=diff
==============================================================================
--- zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SaslAuthFailDesignatedClientTest.java
(original)
+++ zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SaslAuthFailDesignatedClientTest.java
Mon May  2 16:18:22 2016
@@ -22,23 +22,20 @@ import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.TestableZooKeeper;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.Watcher.Event.KeeperState;
 import org.apache.zookeeper.ZooDefs.Ids;
-import org.apache.zookeeper.client.ZooKeeperSaslClient;
+import org.apache.zookeeper.client.ZKClientConfig;
 import org.junit.Assert;
 import org.junit.Test;
 
 public class SaslAuthFailDesignatedClientTest extends ClientBase {
     static {
         System.setProperty("zookeeper.authProvider.1","org.apache.zookeeper.server.auth.SASLAuthenticationProvider");
-        System.setProperty(ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY, "MyZookeeperClient");
+        System.setProperty(ZKClientConfig.LOGIN_CONTEXT_NAME_KEY,
+                "MyZookeeperClient");
 
         try {
             File tmpDir = createTmpDir();
@@ -70,19 +67,6 @@ public class SaslAuthFailDesignatedClien
         }
     }
 
-    private AtomicInteger authFailed = new AtomicInteger(0);
-
-    private class MyWatcher extends CountdownWatcher {
-        @Override
-        public synchronized void process(WatchedEvent event) {
-            if (event.getState() == KeeperState.AuthFailed) {
-                authFailed.incrementAndGet();
-            }
-            else {
-                super.process(event);
-            }
-        }
-    }
 
     @Test
     public void testAuth() throws Exception {

Modified: zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SaslAuthMissingClientConfigTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SaslAuthMissingClientConfigTest.java?rev=1742003&r1=1742002&r2=1742003&view=diff
==============================================================================
--- zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SaslAuthMissingClientConfigTest.java
(original)
+++ zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SaslAuthMissingClientConfigTest.java
Mon May  2 16:18:22 2016
@@ -21,15 +21,12 @@ package org.apache.zookeeper.test;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.WatchedEvent;
-import org.apache.zookeeper.ZooKeeper;
-import org.apache.zookeeper.Watcher.Event.KeeperState;
 import org.apache.zookeeper.ZooDefs.Ids;
-import org.apache.zookeeper.client.ZooKeeperSaslClient;
+import org.apache.zookeeper.ZooKeeper;
+import org.apache.zookeeper.client.ZKClientConfig;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -38,7 +35,8 @@ public class SaslAuthMissingClientConfig
         System.setProperty("zookeeper.authProvider.1","org.apache.zookeeper.server.auth.SASLAuthenticationProvider");
         // This configuration section 'MyZookeeperClient', is missing from the JAAS configuration.
         // As a result, SASL authentication should fail, which is tested by this test (testAuth()).
-        System.setProperty(ZooKeeperSaslClient.LOGIN_CONTEXT_NAME_KEY, "MyZookeeperClient");
+        System.setProperty(ZKClientConfig.LOGIN_CONTEXT_NAME_KEY,
+                "MyZookeeperClient");
 
         try {
             File tmpDir = createTmpDir();
@@ -66,20 +64,6 @@ public class SaslAuthMissingClientConfig
         }
     }
 
-    private AtomicInteger authFailed = new AtomicInteger(0);
-
-    private class MyWatcher extends CountdownWatcher {
-        @Override
-        public synchronized void process(WatchedEvent event) {
-            if (event.getState() == KeeperState.AuthFailed) {
-                authFailed.incrementAndGet();
-            }
-            else {
-                super.process(event);
-            }
-        }
-    }
-
     @Test
     public void testAuth() throws Exception {
         ZooKeeper zk = createClient();

Modified: zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SaslClientTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SaslClientTest.java?rev=1742003&r1=1742002&r2=1742003&view=diff
==============================================================================
--- zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SaslClientTest.java
(original)
+++ zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/SaslClientTest.java
Mon May  2 16:18:22 2016
@@ -18,45 +18,52 @@
 
 package org.apache.zookeeper.test;
 
+
 import org.apache.zookeeper.ZKTestCase;
-import org.apache.zookeeper.client.ZooKeeperSaslClient;
+import org.apache.zookeeper.client.ZKClientConfig;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
 import java.util.Arrays;
-
 public class SaslClientTest extends ZKTestCase {
 
     private String existingPropertyValue = null;
 
     @Before
     public void setUp() {
-        existingPropertyValue = System.getProperty(ZooKeeperSaslClient.ENABLE_CLIENT_SASL_KEY);
+        existingPropertyValue = System
+                .getProperty(ZKClientConfig.ENABLE_CLIENT_SASL_KEY);
     }
 
     @After
     public void tearDown() {
         // Restore the System property if it was set previously
         if (existingPropertyValue != null) {
-            System.setProperty(ZooKeeperSaslClient.ENABLE_CLIENT_SASL_KEY, existingPropertyValue);
+            System.setProperty(ZKClientConfig.ENABLE_CLIENT_SASL_KEY,
+                    existingPropertyValue);
         }
     }
 
     @Test
     public void testSaslClientDisabled() {
-        System.clearProperty(ZooKeeperSaslClient.ENABLE_CLIENT_SASL_KEY);
-        Assert.assertTrue("SASL client disabled", ZooKeeperSaslClient.isEnabled());
+        System.clearProperty(ZKClientConfig.ENABLE_CLIENT_SASL_KEY);
+        Assert.assertTrue("SASL client disabled",
+                new ZKClientConfig().isSaslClientEnabled());
 
         for (String value : Arrays.asList("true", "TRUE")) {
-            System.setProperty(ZooKeeperSaslClient.ENABLE_CLIENT_SASL_KEY, value);
-            Assert.assertTrue("SASL client disabled", ZooKeeperSaslClient.isEnabled());
+            System.setProperty(ZKClientConfig.ENABLE_CLIENT_SASL_KEY,
+                    value);
+            Assert.assertTrue("SASL client disabled",
+                    new ZKClientConfig().isSaslClientEnabled());
         }
 
         for (String value : Arrays.asList("false", "FALSE")) {
-            System.setProperty(ZooKeeperSaslClient.ENABLE_CLIENT_SASL_KEY, value);
-            Assert.assertFalse("SASL client disabled", ZooKeeperSaslClient.isEnabled());
+            System.setProperty(ZKClientConfig.ENABLE_CLIENT_SASL_KEY,
+                    value);
+            Assert.assertFalse("SASL client disabled",
+                    new ZKClientConfig().isSaslClientEnabled());
         }
     }
 }

Modified: zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/WatcherTest.java
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/WatcherTest.java?rev=1742003&r1=1742002&r2=1742003&view=diff
==============================================================================
--- zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/WatcherTest.java
(original)
+++ zookeeper/branches/branch-3.5/src/java/test/org/apache/zookeeper/test/WatcherTest.java
Mon May  2 16:18:22 2016
@@ -25,7 +25,6 @@ import java.util.concurrent.TimeoutExcep
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.zookeeper.ClientCnxn;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.TestableZooKeeper;
@@ -36,6 +35,7 @@ import org.apache.zookeeper.AsyncCallbac
 import org.apache.zookeeper.Watcher.Event;
 import org.apache.zookeeper.Watcher.Event.EventType;
 import org.apache.zookeeper.ZooDefs.Ids;
+import org.apache.zookeeper.client.ZKClientConfig;
 import org.apache.zookeeper.data.Stat;
 import org.junit.Assert;
 import org.junit.Before;
@@ -73,7 +73,7 @@ public class WatcherTest extends ClientB
         super.setUp();
         // Reset to default value since some test cases set this to true.
         // Needed for JDK7 since unit test can run is random order
-        ClientCnxn.setDisableAutoResetWatch(false);
+        System.setProperty(ZKClientConfig.DISABLE_AUTO_WATCH_RESET, "false");
     }
 
     /**
@@ -243,13 +243,16 @@ public class WatcherTest extends ClientB
 
     @Test
     public void testWatcherAutoResetDisabledWithGlobal() throws Exception {
-        ClientCnxn.setDisableAutoResetWatch(true);
+        /**
+         * When ZooKeeper is created this property will get used.
+         */
+        System.setProperty(ZKClientConfig.DISABLE_AUTO_WATCH_RESET, "true");
         testWatcherAutoResetWithGlobal();
     }
 
     @Test
     public void testWatcherAutoResetDisabledWithLocal() throws Exception {
-        ClientCnxn.setDisableAutoResetWatch(true);
+        System.setProperty(ZKClientConfig.DISABLE_AUTO_WATCH_RESET, "true");
         testWatcherAutoResetWithLocal();
     }
 
@@ -278,7 +281,8 @@ public class WatcherTest extends ClientB
         localWatcher.waitForDisconnected(500);
         startServer();
         globalWatcher.waitForConnected(3000);
-        if (!isGlobal && !ClientCnxn.getDisableAutoResetWatch()) {
+        boolean disableAutoWatchReset = zk.getClientConfig().getBoolean(ZKClientConfig.DISABLE_AUTO_WATCH_RESET);
+        if (!isGlobal && !disableAutoWatchReset) {
             localWatcher.waitForConnected(500);
         }
 
@@ -288,7 +292,7 @@ public class WatcherTest extends ClientB
                 CreateMode.PERSISTENT);
 
         WatchedEvent e;
-        if (!ClientCnxn.getDisableAutoResetWatch()) {
+        if (!disableAutoWatchReset) {
             e = localWatcher.events.poll(TIMEOUT, TimeUnit.MILLISECONDS);
             Assert.assertEquals(e.getPath(), EventType.NodeDataChanged, e.getType());
             Assert.assertEquals("/watchtest/child", e.getPath());
@@ -297,7 +301,7 @@ public class WatcherTest extends ClientB
             // why waste the time on poll
         }
 
-        if (!ClientCnxn.getDisableAutoResetWatch()) {
+        if (!disableAutoWatchReset) {
             e = localWatcher.events.poll(TIMEOUT, TimeUnit.MILLISECONDS);
             // The create will trigger the get children and the exist
             // watches
@@ -308,7 +312,7 @@ public class WatcherTest extends ClientB
             // why waste the time on poll
         }
 
-        if (!ClientCnxn.getDisableAutoResetWatch()) {
+        if (!disableAutoWatchReset) {
             e = localWatcher.events.poll(TIMEOUT, TimeUnit.MILLISECONDS);
             Assert.assertEquals(EventType.NodeChildrenChanged, e.getType());
             Assert.assertEquals("/watchtest", e.getPath());
@@ -323,11 +327,11 @@ public class WatcherTest extends ClientB
         try {
             try {
                 localWatcher.waitForDisconnected(500);
-                if (!isGlobal && !ClientCnxn.getDisableAutoResetWatch()) {
+                if (!isGlobal && !disableAutoWatchReset) {
                     Assert.fail("Got an event when I shouldn't have");
                 }
             } catch(TimeoutException toe) {
-                if (ClientCnxn.getDisableAutoResetWatch()) {
+                if (disableAutoWatchReset) {
                     Assert.fail("Didn't get an event when I should have");
                 }
                 // Else what we are expecting since there are no outstanding watches
@@ -368,14 +372,14 @@ public class WatcherTest extends ClientB
         localWatcher.waitForDisconnected(500);
         startServer();
         globalWatcher.waitForConnected(TIMEOUT);
-        if (!isGlobal && !ClientCnxn.getDisableAutoResetWatch()) {
+        if (!isGlobal && !disableAutoWatchReset) {
             localWatcher.waitForConnected(500);
         }
 
         zk.delete("/watchtest/child", -1);
         zk.delete("/watchtest", -1);
 
-        if (!ClientCnxn.getDisableAutoResetWatch()) {
+        if (!disableAutoWatchReset) {
             e = localWatcher.events.poll(TIMEOUT, TimeUnit.MILLISECONDS);
             Assert.assertEquals(EventType.NodeDeleted, e.getType());
             Assert.assertEquals("/watchtest/child", e.getPath());
@@ -387,7 +391,6 @@ public class WatcherTest extends ClientB
         // Make sure nothing is straggling!
         Thread.sleep(1000);
         Assert.assertTrue(localWatcher.events.isEmpty());
-
     }
 
 }



Mime
View raw message