more work on repairing tests for new connection handling
authorrandgalt <randgalt@apache.org>
Sun, 23 Aug 2015 14:33:46 +0000 (09:33 -0500)
committerrandgalt <randgalt@apache.org>
Sun, 23 Aug 2015 14:33:46 +0000 (09:33 -0500)
curator-client/src/main/java/org/apache/curator/CuratorZookeeperClient.java
curator-client/src/main/java/org/apache/curator/RetryLoop.java
curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java
curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceDiscovery.java

index c8a9936..d6c2072 100644 (file)
@@ -19,7 +19,6 @@
 
 package org.apache.curator;
 
-import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 import org.apache.curator.connection.ClassicConnectionHandlingPolicy;
 import org.apache.curator.connection.ConnectionHandlingPolicy;
@@ -54,7 +53,6 @@ public class CuratorZookeeperClient implements Closeable
     private final AtomicBoolean started = new AtomicBoolean(false);
     private final AtomicReference<TracerDriver> tracer = new AtomicReference<TracerDriver>(new DefaultTracerDriver());
     private final ConnectionHandlingPolicy connectionHandlingPolicy;
-    private final AtomicReference<Exception> debugException = new AtomicReference<>();
 
     /**
      *
@@ -336,18 +334,6 @@ public class CuratorZookeeperClient implements Closeable
         return connectionHandlingPolicy;
     }
 
-    @VisibleForTesting
-    public void setDebugException(Exception e)
-    {
-        debugException.set(e);
-    }
-
-    @VisibleForTesting
-    Exception getDebugException()
-    {
-        return debugException.get();
-    }
-
     void addParentWatcher(Watcher watcher)
     {
         state.addParentWatcher(watcher);
index 4353c61..e58ce20 100644 (file)
@@ -96,12 +96,6 @@ public class RetryLoop
      */
     public static<T> T      callWithRetry(CuratorZookeeperClient client, Callable<T> proc) throws Exception
     {
-        Exception debugException = client.getDebugException();
-        if ( debugException != null )
-        {
-            throw debugException;
-        }
-
         return client.getConnectionHandlingPolicy().callWithRetry(client, proc);
     }
 
index 15781dc..ef77087 100644 (file)
@@ -423,7 +423,6 @@ public class TestFrameworkEdges extends BaseClassForTests
                         {
                             throw new Error(e);
                         }
-                        client.getZookeeperClient().setDebugException(null);
                     }
                     try
                     {
@@ -441,7 +440,6 @@ public class TestFrameworkEdges extends BaseClassForTests
             server.stop();
 
             // test foreground retry
-            client.getZookeeperClient().setDebugException(new KeeperException.ConnectionLossException());
             client.checkExists().forPath("/hey");
             Assert.assertTrue(semaphore.tryAcquire(MAX_RETRIES, timing.forWaiting().seconds(), TimeUnit.SECONDS), "Remaining leases: " + semaphore.availablePermits());
 
@@ -456,7 +454,6 @@ public class TestFrameworkEdges extends BaseClassForTests
             server.stop();
 
             // test background retry
-            client.getZookeeperClient().setDebugException(new KeeperException.ConnectionLossException());
             client.checkExists().inBackground().forPath("/hey");
             Assert.assertTrue(semaphore.tryAcquire(MAX_RETRIES, timing.forWaiting().seconds(), TimeUnit.SECONDS), "Remaining leases: " + semaphore.availablePermits());
         }
index 8b1e5fc..989edaf 100644 (file)
@@ -269,6 +269,7 @@ public class TestServiceDiscovery extends BaseClassForTests
     @Test
     public void testNoServerOnStart() throws Exception
     {
+        Timing timing = new Timing();
         server.stop();
         List<Closeable> closeables = Lists.newArrayList();
         try
@@ -283,6 +284,7 @@ public class TestServiceDiscovery extends BaseClassForTests
             discovery.start();
 
             server.restart();
+            timing.sleepABit();
             Assert.assertEquals(discovery.queryForNames(), Collections.singletonList("test"));
 
             List<ServiceInstance<String>> list = Lists.newArrayList();