Use the resource plugin to copy the compatibility files instead of adding the source directory. This seems more compatible
Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/242b7011 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/242b7011 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/242b7011 Branch: refs/heads/CURATOR-425 Commit: 242b7011a7b8344f772c1a4497aadf6de16d73f5 Parents: 58bc969 Author: randgalt <[email protected]> Authored: Thu Jul 20 02:14:10 2017 -0500 Committer: randgalt <[email protected]> Committed: Thu Jul 20 02:14:10 2017 -0500 ---------------------------------------------------------------------- .../java/org/apache/curator/BasicTests.java | 2 +- .../curator/TestSessionFailRetryLoop.java | 2 +- .../framework/imps/TestCreateReturningStat.java | 4 +- .../imps/TestEnabledSessionExpiredState.java | 4 +- .../curator/framework/imps/TestFramework.java | 2 +- .../framework/imps/TestFrameworkEdges.java | 4 +- .../framework/imps/TestReconfiguration.java | 7 +- .../framework/imps/TestRemoveWatches.java | 4 +- .../curator/framework/imps/TestTtlNodes.java | 5 +- .../imps/TestWatcherRemovalManager.java | 5 +- .../recipes/cache/TestEventOrdering.java | 3 +- .../framework/recipes/cache/TestNodeCache.java | 2 +- .../recipes/cache/TestPathChildrenCache.java | 2 +- .../framework/recipes/cache/TestTreeCache.java | 2 +- .../recipes/leader/TestLeaderLatch.java | 2 +- .../recipes/leader/TestLeaderSelector.java | 4 +- .../recipes/locks/TestInterProcessMutex.java | 2 +- .../locks/TestInterProcessMutexBase.java | 4 +- .../nodes/TestPersistentEphemeralNode.java | 4 +- .../recipes/nodes/TestPersistentNode.java | 2 +- curator-test-zk34/pom.xml | 20 +- .../org/apache/curator/test/Compatibility.java | 6 +- curator-test/pom.xml | 19 -- .../apache/curator/test/CuratorTestBase.java | 27 -- .../org/apache/curator/test/KillSession2.java | 39 --- .../java/org/apache/curator/test/Timing2.java | 299 ------------------- .../curator/test/Zk35MethodInterceptor.java | 55 ---- .../org/apache/curator/test/Compatibility.java | 6 +- .../test/compatibility/CuratorTestBase.java | 28 ++ .../test/compatibility/KillSession2.java | 40 +++ .../curator/test/compatibility/Timing2.java | 299 +++++++++++++++++++ .../compatibility/Zk35MethodInterceptor.java | 56 ++++ .../x/async/CompletableBaseClassForTests.java | 3 +- .../discovery/details/TestServiceDiscovery.java | 2 +- pom.xml | 7 - 35 files changed, 474 insertions(+), 498 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-client/src/test/java/org/apache/curator/BasicTests.java ---------------------------------------------------------------------- diff --git a/curator-client/src/test/java/org/apache/curator/BasicTests.java b/curator-client/src/test/java/org/apache/curator/BasicTests.java index 94d418b..2875f49 100644 --- a/curator-client/src/test/java/org/apache/curator/BasicTests.java +++ b/curator-client/src/test/java/org/apache/curator/BasicTests.java @@ -21,7 +21,7 @@ package org.apache.curator; import org.apache.curator.ensemble.fixed.FixedEnsembleProvider; import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.test.KillSession2; +import org.apache.curator.test.compatibility.KillSession2; import org.apache.curator.test.Timing; import org.apache.curator.utils.ZookeeperFactory; import org.apache.zookeeper.CreateMode; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-client/src/test/java/org/apache/curator/TestSessionFailRetryLoop.java ---------------------------------------------------------------------- diff --git a/curator-client/src/test/java/org/apache/curator/TestSessionFailRetryLoop.java b/curator-client/src/test/java/org/apache/curator/TestSessionFailRetryLoop.java index e56f4d4..39b0e45 100644 --- a/curator-client/src/test/java/org/apache/curator/TestSessionFailRetryLoop.java +++ b/curator-client/src/test/java/org/apache/curator/TestSessionFailRetryLoop.java @@ -20,7 +20,7 @@ package org.apache.curator; import org.apache.curator.retry.ExponentialBackoffRetry; import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.test.KillSession2; +import org.apache.curator.test.compatibility.KillSession2; import org.apache.curator.utils.CloseableUtils; import org.apache.curator.test.Timing; import org.testng.Assert; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCreateReturningStat.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCreateReturningStat.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCreateReturningStat.java index bef143f..67a960f 100755 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCreateReturningStat.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestCreateReturningStat.java @@ -24,9 +24,9 @@ import org.apache.curator.framework.api.BackgroundCallback; import org.apache.curator.framework.api.CuratorEvent; import org.apache.curator.framework.api.CuratorEventType; import org.apache.curator.retry.RetryOneTime; -import org.apache.curator.test.CuratorTestBase; +import org.apache.curator.test.compatibility.CuratorTestBase; import org.apache.curator.test.Timing; -import org.apache.curator.test.Zk35MethodInterceptor; +import org.apache.curator.test.compatibility.Zk35MethodInterceptor; import org.apache.curator.utils.CloseableUtils; import org.apache.zookeeper.data.Stat; import org.testng.Assert; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-framework/src/test/java/org/apache/curator/framework/imps/TestEnabledSessionExpiredState.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestEnabledSessionExpiredState.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestEnabledSessionExpiredState.java index 63fd36e..f1bbc3b 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestEnabledSessionExpiredState.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestEnabledSessionExpiredState.java @@ -25,8 +25,8 @@ import org.apache.curator.framework.state.ConnectionState; import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.test.KillSession2; -import org.apache.curator.test.Timing2; +import org.apache.curator.test.compatibility.KillSession2; +import org.apache.curator.test.compatibility.Timing2; import org.apache.curator.utils.CloseableUtils; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.WatchedEvent; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java index 70ae2ea..a1d6f51 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFramework.java @@ -31,7 +31,7 @@ import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.BaseClassForTests; import org.apache.curator.test.Timing; -import org.apache.curator.test.Timing2; +import org.apache.curator.test.compatibility.Timing2; import org.apache.curator.utils.CloseableUtils; import org.apache.curator.utils.EnsurePath; import org.apache.curator.utils.ZKPaths; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java index 42e9afa..db5210d 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java @@ -33,9 +33,9 @@ import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.retry.RetryNTimes; import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.test.KillSession2; +import org.apache.curator.test.compatibility.KillSession2; import org.apache.curator.test.TestingServer; -import org.apache.curator.test.Timing2; +import org.apache.curator.test.compatibility.Timing2; import org.apache.curator.utils.CloseableUtils; import org.apache.curator.utils.ZKPaths; import org.apache.zookeeper.CreateMode; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java index 567d71d..acf9df3 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java @@ -27,13 +27,12 @@ import org.apache.curator.framework.api.BackgroundCallback; import org.apache.curator.framework.api.CuratorEvent; import org.apache.curator.framework.api.CuratorEventType; import org.apache.curator.retry.ExponentialBackoffRetry; -import org.apache.curator.test.CuratorTestBase; +import org.apache.curator.test.compatibility.CuratorTestBase; import org.apache.curator.test.InstanceSpec; import org.apache.curator.test.TestingCluster; import org.apache.curator.test.TestingZooKeeperServer; -import org.apache.curator.test.Timing; -import org.apache.curator.test.Timing2; -import org.apache.curator.test.Zk35MethodInterceptor; +import org.apache.curator.test.compatibility.Timing2; +import org.apache.curator.test.compatibility.Zk35MethodInterceptor; import org.apache.curator.utils.CloseableUtils; import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.Watcher; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-framework/src/test/java/org/apache/curator/framework/imps/TestRemoveWatches.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestRemoveWatches.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestRemoveWatches.java index 66f5703..f3b4f8d 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestRemoveWatches.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestRemoveWatches.java @@ -30,9 +30,9 @@ import org.apache.curator.framework.state.ConnectionState; import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.retry.ExponentialBackoffRetry; import org.apache.curator.retry.RetryOneTime; -import org.apache.curator.test.CuratorTestBase; +import org.apache.curator.test.compatibility.CuratorTestBase; import org.apache.curator.test.Timing; -import org.apache.curator.test.Zk35MethodInterceptor; +import org.apache.curator.test.compatibility.Zk35MethodInterceptor; import org.apache.curator.utils.CloseableUtils; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.WatchedEvent; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTtlNodes.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTtlNodes.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTtlNodes.java index 297399d..f253d96 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTtlNodes.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestTtlNodes.java @@ -23,10 +23,9 @@ import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.framework.api.BackgroundCallback; import org.apache.curator.framework.api.CuratorEvent; import org.apache.curator.retry.RetryOneTime; -import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.test.CuratorTestBase; +import org.apache.curator.test.compatibility.CuratorTestBase; import org.apache.curator.test.Timing; -import org.apache.curator.test.Zk35MethodInterceptor; +import org.apache.curator.test.compatibility.Zk35MethodInterceptor; import org.apache.zookeeper.CreateMode; import org.testng.Assert; import org.testng.annotations.AfterMethod; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java ---------------------------------------------------------------------- diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java index d3ad66f..74aac1d 100644 --- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java +++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestWatcherRemovalManager.java @@ -24,11 +24,10 @@ import org.apache.curator.framework.WatcherRemoveCuratorFramework; import org.apache.curator.framework.api.BackgroundCallback; import org.apache.curator.framework.api.CuratorEvent; import org.apache.curator.retry.RetryOneTime; -import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.test.CuratorTestBase; +import org.apache.curator.test.compatibility.CuratorTestBase; import org.apache.curator.test.Timing; import org.apache.curator.test.WatchersDebug; -import org.apache.curator.test.Zk35MethodInterceptor; +import org.apache.curator.test.compatibility.Zk35MethodInterceptor; import org.apache.zookeeper.KeeperException; import org.apache.zookeeper.WatchedEvent; import org.apache.zookeeper.Watcher; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java index c50474d..3d369e1 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestEventOrdering.java @@ -24,8 +24,7 @@ import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.test.Timing; -import org.apache.curator.test.Timing2; +import org.apache.curator.test.compatibility.Timing2; import org.apache.curator.utils.CloseableUtils; import org.apache.zookeeper.KeeperException; import org.testng.Assert; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java index 52c76ad..2e81034 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestNodeCache.java @@ -20,7 +20,7 @@ package org.apache.curator.framework.recipes.cache; import org.apache.curator.framework.imps.TestCleanState; import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.test.KillSession2; +import org.apache.curator.test.compatibility.KillSession2; import org.apache.curator.utils.CloseableUtils; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java index f24b846..14074f0 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestPathChildrenCache.java @@ -29,7 +29,7 @@ import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.BaseClassForTests; import org.apache.curator.test.ExecuteCalledWatchingExecutorService; -import org.apache.curator.test.KillSession2; +import org.apache.curator.test.compatibility.KillSession2; import org.apache.curator.test.TestingServer; import org.apache.curator.test.Timing; import org.apache.curator.utils.CloseableUtils; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java index 1e203b7..409cc48 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/cache/TestTreeCache.java @@ -23,7 +23,7 @@ import com.google.common.collect.ImmutableSet; import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.api.UnhandledErrorListener; import org.apache.curator.framework.recipes.cache.TreeCacheEvent.Type; -import org.apache.curator.test.KillSession2; +import org.apache.curator.test.compatibility.KillSession2; import org.apache.curator.utils.CloseableUtils; import org.apache.zookeeper.CreateMode; import org.testng.Assert; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatch.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatch.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatch.java index 93c955b..ef25ba6 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatch.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatch.java @@ -35,7 +35,7 @@ import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.BaseClassForTests; import org.apache.curator.test.TestingServer; import org.apache.curator.test.Timing; -import org.apache.curator.test.Timing2; +import org.apache.curator.test.compatibility.Timing2; import org.apache.curator.utils.CloseableUtils; import org.testng.Assert; import org.testng.annotations.Test; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelector.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelector.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelector.java index 79fcdb3..808ff8f 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelector.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderSelector.java @@ -30,10 +30,10 @@ import org.apache.curator.framework.state.SessionConnectionStateErrorPolicy; import org.apache.curator.framework.state.StandardConnectionStateErrorPolicy; import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.test.KillSession2; +import org.apache.curator.test.compatibility.KillSession2; import org.apache.curator.test.TestingServer; import org.apache.curator.test.Timing; -import org.apache.curator.test.Timing2; +import org.apache.curator.test.compatibility.Timing2; import org.apache.curator.utils.CloseableUtils; import org.testng.Assert; import org.testng.annotations.Test; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java index cf82c57..8ab2dc5 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutex.java @@ -26,7 +26,7 @@ import org.apache.curator.framework.imps.TestCleanState; import org.apache.curator.framework.schema.Schema; import org.apache.curator.framework.schema.SchemaSet; import org.apache.curator.retry.RetryOneTime; -import org.apache.curator.test.KillSession2; +import org.apache.curator.test.compatibility.KillSession2; import org.apache.curator.utils.CloseableUtils; import org.apache.zookeeper.CreateMode; import org.testng.Assert; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutexBase.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutexBase.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutexBase.java index 43ded2e..40c9144 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutexBase.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/locks/TestInterProcessMutexBase.java @@ -27,10 +27,10 @@ import org.apache.curator.framework.state.ConnectionState; import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.retry.ExponentialBackoffRetry; import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.test.KillSession2; +import org.apache.curator.test.compatibility.KillSession2; import org.apache.curator.test.TestingServer; import org.apache.curator.test.Timing; -import org.apache.curator.test.Timing2; +import org.apache.curator.test.compatibility.Timing2; import org.apache.curator.utils.CloseableUtils; import org.apache.curator.utils.ZKPaths; import org.testng.Assert; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java index 0ce61d5..03665c5 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentEphemeralNode.java @@ -31,8 +31,8 @@ import org.apache.curator.framework.state.ConnectionState; import org.apache.curator.framework.state.ConnectionStateListener; import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.test.KillSession2; -import org.apache.curator.test.Timing2; +import org.apache.curator.test.compatibility.KillSession2; +import org.apache.curator.test.compatibility.Timing2; import org.apache.curator.utils.CloseableUtils; import org.apache.curator.utils.ZKPaths; import org.apache.zookeeper.CreateMode; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentNode.java ---------------------------------------------------------------------- diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentNode.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentNode.java index b848fe4..0fdd7c8 100644 --- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentNode.java +++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/nodes/TestPersistentNode.java @@ -23,7 +23,7 @@ import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.BaseClassForTests; import org.apache.curator.test.Timing; -import org.apache.curator.test.Timing2; +import org.apache.curator.test.compatibility.Timing2; import org.apache.curator.utils.CloseableUtils; import org.apache.zookeeper.CreateMode; import org.testng.Assert; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-test-zk34/pom.xml ---------------------------------------------------------------------- diff --git a/curator-test-zk34/pom.xml b/curator-test-zk34/pom.xml index 8d2f073..d4101b0 100644 --- a/curator-test-zk34/pom.xml +++ b/curator-test-zk34/pom.xml @@ -149,19 +149,23 @@ </plugin> <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> <executions> <execution> - <id>add-compatibility</id> + <id>copy-curator-test-classes</id> + <phase>validate</phase> <goals> - <goal>add-test-source</goal> + <goal>copy-resources</goal> </goals> - <phase>generate-test-sources</phase> <configuration> - <sources> - <source>../curator-test/src/compatibility/java</source> - </sources> + <outputDirectory>${basedir}/target/generated-test-sources/test-annotations/org/apache/curator/test/compatibility</outputDirectory> + <resources> + <resource> + <directory>../curator-test/src/main/java/org/apache/curator/test/compatibility</directory> + <filtering>false</filtering> + </resource> + </resources> </configuration> </execution> </executions> http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-test-zk34/src/test/java/org/apache/curator/test/Compatibility.java ---------------------------------------------------------------------- diff --git a/curator-test-zk34/src/test/java/org/apache/curator/test/Compatibility.java b/curator-test-zk34/src/test/java/org/apache/curator/test/Compatibility.java index 77ddf2c..bebd7c9 100644 --- a/curator-test-zk34/src/test/java/org/apache/curator/test/Compatibility.java +++ b/curator-test-zk34/src/test/java/org/apache/curator/test/Compatibility.java @@ -21,14 +21,14 @@ package org.apache.curator.test; import org.apache.curator.utils.InjectSessionExpiration; import org.apache.zookeeper.ZooKeeper; -class Compatibility +public class Compatibility { - static boolean isZK34() + public static boolean isZK34() { return true; } - static void injectSessionExpiration(ZooKeeper zooKeeper) + public static void injectSessionExpiration(ZooKeeper zooKeeper) { InjectSessionExpiration.injectSessionExpiration(zooKeeper); } http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-test/pom.xml ---------------------------------------------------------------------- diff --git a/curator-test/pom.xml b/curator-test/pom.xml index 0ffe023..fb28d53 100644 --- a/curator-test/pom.xml +++ b/curator-test/pom.xml @@ -95,25 +95,6 @@ </execution> </executions> </plugin> - - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <executions> - <execution> - <id>add-compatibility</id> - <goals> - <goal>add-source</goal> - </goals> - <phase>generate-sources</phase> - <configuration> - <sources> - <source>src/compatibility/java</source> - </sources> - </configuration> - </execution> - </executions> - </plugin> </plugins> </build> </project> http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-test/src/compatibility/java/org/apache/curator/test/CuratorTestBase.java ---------------------------------------------------------------------- diff --git a/curator-test/src/compatibility/java/org/apache/curator/test/CuratorTestBase.java b/curator-test/src/compatibility/java/org/apache/curator/test/CuratorTestBase.java deleted file mode 100644 index efa94a3..0000000 --- a/curator-test/src/compatibility/java/org/apache/curator/test/CuratorTestBase.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.curator.test; - -import org.testng.annotations.Listeners; - -@Listeners(Zk35MethodInterceptor.class) -public class CuratorTestBase extends BaseClassForTests -{ - protected final Timing2 timing = new Timing2(); -} http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-test/src/compatibility/java/org/apache/curator/test/KillSession2.java ---------------------------------------------------------------------- diff --git a/curator-test/src/compatibility/java/org/apache/curator/test/KillSession2.java b/curator-test/src/compatibility/java/org/apache/curator/test/KillSession2.java deleted file mode 100644 index 52ab168..0000000 --- a/curator-test/src/compatibility/java/org/apache/curator/test/KillSession2.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.curator.test; - -import org.apache.zookeeper.ZooKeeper; - -/** - * <p> - * Utility to simulate a ZK session dying. - * </p> - */ -public class KillSession2 -{ - /** - * Kill the given ZK session - * - * @param client the client to kill - */ - public static void kill(ZooKeeper client) - { - Compatibility.injectSessionExpiration(client); - } -} http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-test/src/compatibility/java/org/apache/curator/test/Timing2.java ---------------------------------------------------------------------- diff --git a/curator-test/src/compatibility/java/org/apache/curator/test/Timing2.java b/curator-test/src/compatibility/java/org/apache/curator/test/Timing2.java deleted file mode 100644 index 02b71c4..0000000 --- a/curator-test/src/compatibility/java/org/apache/curator/test/Timing2.java +++ /dev/null @@ -1,299 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.apache.curator.test; - -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.Semaphore; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -/** - * Utility to get various testing times. - * - * Copied from the old Timing class which is now deprecated. Needed this to support ZK 3.4 compatibility - */ -public class Timing2 -{ - private final long value; - private final TimeUnit unit; - private final int waitingMultiple; - - private static final int DEFAULT_SECONDS = 10; - private static final int DEFAULT_WAITING_MULTIPLE = 5; - private static final double SESSION_MULTIPLE = 1.5; - private static final double SESSION_SLEEP_MULTIPLE = SESSION_MULTIPLE * 1.75; // has to be at least session + 2/3 of a session to account for missed heartbeat then session expiration - - /** - * Use the default base time - */ - public Timing2() - { - this(Integer.getInteger("timing-multiple", 1), getWaitingMultiple()); - } - - /** - * Use a multiple of the default base time - * - * @param multiple the multiple - */ - public Timing2(double multiple) - { - this((long)(DEFAULT_SECONDS * multiple), TimeUnit.SECONDS, getWaitingMultiple()); - } - - /** - * Use a multiple of the default base time - * - * @param multiple the multiple - * @param waitingMultiple multiple of main timing to use when waiting - */ - public Timing2(double multiple, int waitingMultiple) - { - this((long)(DEFAULT_SECONDS * multiple), TimeUnit.SECONDS, waitingMultiple); - } - - /** - * @param value base time - * @param unit base time unit - */ - public Timing2(long value, TimeUnit unit) - { - this(value, unit, getWaitingMultiple()); - } - - /** - * @param value base time - * @param unit base time unit - * @param waitingMultiple multiple of main timing to use when waiting - */ - public Timing2(long value, TimeUnit unit, int waitingMultiple) - { - this.value = value; - this.unit = unit; - this.waitingMultiple = waitingMultiple; - } - - /** - * Return the base time in milliseconds - * - * @return time ms - */ - public int milliseconds() - { - return (int)TimeUnit.MILLISECONDS.convert(value, unit); - } - - /** - * Return the base time in seconds - * - * @return time secs - */ - public int seconds() - { - return (int)value; - } - - /** - * Wait on the given latch - * - * @param latch latch to wait on - * @return result of {@link java.util.concurrent.CountDownLatch#await(long, java.util.concurrent.TimeUnit)} - */ - public boolean awaitLatch(CountDownLatch latch) - { - Timing2 m = forWaiting(); - try - { - return latch.await(m.value, m.unit); - } - catch ( InterruptedException e ) - { - Thread.currentThread().interrupt(); - } - return false; - } - - /** - * Try to take an item from the given queue - * - * @param queue queue - * @return item - * @throws Exception interrupted or timed out - */ - public <T> T takeFromQueue(BlockingQueue<T> queue) throws Exception - { - Timing2 m = forWaiting(); - try - { - T value = queue.poll(m.value, m.unit); - if ( value == null ) - { - throw new TimeoutException("Timed out trying to take from queue"); - } - return value; - } - catch ( InterruptedException e ) - { - Thread.currentThread().interrupt(); - throw e; - } - } - - /** - * Wait on the given semaphore - * - * @param semaphore the semaphore - * @return result of {@link java.util.concurrent.Semaphore#tryAcquire()} - */ - public boolean acquireSemaphore(Semaphore semaphore) - { - Timing2 m = forWaiting(); - try - { - return semaphore.tryAcquire(m.value, m.unit); - } - catch ( InterruptedException e ) - { - Thread.currentThread().interrupt(); - } - return false; - } - - /** - * Wait on the given semaphore - * - * @param semaphore the semaphore - * @param n number of permits to acquire - * @return result of {@link java.util.concurrent.Semaphore#tryAcquire(int, long, java.util.concurrent.TimeUnit)} - */ - public boolean acquireSemaphore(Semaphore semaphore, int n) - { - Timing2 m = forWaiting(); - try - { - return semaphore.tryAcquire(n, m.value, m.unit); - } - catch ( InterruptedException e ) - { - Thread.currentThread().interrupt(); - } - return false; - } - - /** - * Return a new timing that is a multiple of the this timing - * - * @param n the multiple - * @return this timing times the multiple - */ - public Timing2 multiple(double n) - { - return new Timing2((int)(value * n), unit); - } - - /** - * Return a new timing that is a multiple of the this timing - * - * @param n the multiple - * @param waitingMultiple new waitingMultiple - * @return this timing times the multiple - */ - public Timing2 multiple(double n, int waitingMultiple) - { - return new Timing2((int)(value * n), unit, waitingMultiple); - } - - /** - * Return a new timing with the standard multiple for waiting on latches, etc. - * - * @return this timing multiplied - */ - @SuppressWarnings("PointlessArithmeticExpression") - public Timing2 forWaiting() - { - return multiple(waitingMultiple); - } - - /** - * Return a new timing with a multiple that ensures a ZK session timeout - * - * @return this timing multiplied - */ - public Timing2 forSessionSleep() - { - return multiple(SESSION_SLEEP_MULTIPLE, 1); - } - - /** - * Return a new timing with a multiple for sleeping a smaller amount of time - * - * @return this timing multiplied - */ - public Timing2 forSleepingABit() - { - return multiple(.25); - } - - /** - * Sleep for a small amount of time - * - * @throws InterruptedException if interrupted - */ - public void sleepABit() throws InterruptedException - { - forSleepingABit().sleep(); - } - - /** - * Sleep for a the full amount of time - * - * @throws InterruptedException if interrupted - */ - public void sleep() throws InterruptedException - { - unit.sleep(value); - } - - /** - * Return the value to use for ZK session timeout - * - * @return session timeout - */ - public int session() - { - return multiple(SESSION_MULTIPLE).milliseconds(); - } - - /** - * Return the value to use for ZK connection timeout - * - * @return connection timeout - */ - public int connection() - { - return milliseconds(); - } - - private static Integer getWaitingMultiple() - { - return Integer.getInteger("timing-waiting-multiple", DEFAULT_WAITING_MULTIPLE); - } -} http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-test/src/compatibility/java/org/apache/curator/test/Zk35MethodInterceptor.java ---------------------------------------------------------------------- diff --git a/curator-test/src/compatibility/java/org/apache/curator/test/Zk35MethodInterceptor.java b/curator-test/src/compatibility/java/org/apache/curator/test/Zk35MethodInterceptor.java deleted file mode 100644 index 290910c..0000000 --- a/curator-test/src/compatibility/java/org/apache/curator/test/Zk35MethodInterceptor.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.curator.test; - -import org.testng.IMethodInstance; -import org.testng.IMethodInterceptor; -import org.testng.ITestContext; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class Zk35MethodInterceptor implements IMethodInterceptor -{ - public static final String zk35Group = "zk35"; - - @Override - public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) - { - if ( !Compatibility.isZK34() ) - { - return methods; - } - - List<IMethodInstance> filteredMethods = new ArrayList<>(); - for ( IMethodInstance method : methods ) - { - if ( !isInGroup(method.getMethod().getGroups()) ) - { - filteredMethods.add(method); - } - } - return filteredMethods; - } - - private boolean isInGroup(String[] groups) - { - return (groups != null) && Arrays.asList(groups).contains(zk35Group); - } -} http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-test/src/main/java/org/apache/curator/test/Compatibility.java ---------------------------------------------------------------------- diff --git a/curator-test/src/main/java/org/apache/curator/test/Compatibility.java b/curator-test/src/main/java/org/apache/curator/test/Compatibility.java index 87eb33e..4fc63df 100644 --- a/curator-test/src/main/java/org/apache/curator/test/Compatibility.java +++ b/curator-test/src/main/java/org/apache/curator/test/Compatibility.java @@ -20,14 +20,14 @@ package org.apache.curator.test; import org.apache.zookeeper.ZooKeeper; -class Compatibility +public class Compatibility { - static boolean isZK34() + public static boolean isZK34() { return false; } - static void injectSessionExpiration(ZooKeeper zooKeeper) + public static void injectSessionExpiration(ZooKeeper zooKeeper) { zooKeeper.getTestable().injectSessionExpiration(); } http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-test/src/main/java/org/apache/curator/test/compatibility/CuratorTestBase.java ---------------------------------------------------------------------- diff --git a/curator-test/src/main/java/org/apache/curator/test/compatibility/CuratorTestBase.java b/curator-test/src/main/java/org/apache/curator/test/compatibility/CuratorTestBase.java new file mode 100644 index 0000000..a3c2a29 --- /dev/null +++ b/curator-test/src/main/java/org/apache/curator/test/compatibility/CuratorTestBase.java @@ -0,0 +1,28 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.curator.test.compatibility; + +import org.apache.curator.test.BaseClassForTests; +import org.testng.annotations.Listeners; + +@Listeners(Zk35MethodInterceptor.class) +public class CuratorTestBase extends BaseClassForTests +{ + protected final Timing2 timing = new Timing2(); +} http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-test/src/main/java/org/apache/curator/test/compatibility/KillSession2.java ---------------------------------------------------------------------- diff --git a/curator-test/src/main/java/org/apache/curator/test/compatibility/KillSession2.java b/curator-test/src/main/java/org/apache/curator/test/compatibility/KillSession2.java new file mode 100644 index 0000000..d747d3d --- /dev/null +++ b/curator-test/src/main/java/org/apache/curator/test/compatibility/KillSession2.java @@ -0,0 +1,40 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.curator.test.compatibility; + +import org.apache.curator.test.Compatibility; +import org.apache.zookeeper.ZooKeeper; + +/** + * <p> + * Utility to simulate a ZK session dying. + * </p> + */ +public class KillSession2 +{ + /** + * Kill the given ZK session + * + * @param client the client to kill + */ + public static void kill(ZooKeeper client) + { + Compatibility.injectSessionExpiration(client); + } +} http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-test/src/main/java/org/apache/curator/test/compatibility/Timing2.java ---------------------------------------------------------------------- diff --git a/curator-test/src/main/java/org/apache/curator/test/compatibility/Timing2.java b/curator-test/src/main/java/org/apache/curator/test/compatibility/Timing2.java new file mode 100644 index 0000000..ad105eb --- /dev/null +++ b/curator-test/src/main/java/org/apache/curator/test/compatibility/Timing2.java @@ -0,0 +1,299 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.curator.test.compatibility; + +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +/** + * Utility to get various testing times. + * + * Copied from the old Timing class which is now deprecated. Needed this to support ZK 3.4 compatibility + */ +public class Timing2 +{ + private final long value; + private final TimeUnit unit; + private final int waitingMultiple; + + private static final int DEFAULT_SECONDS = 10; + private static final int DEFAULT_WAITING_MULTIPLE = 5; + private static final double SESSION_MULTIPLE = 1.5; + private static final double SESSION_SLEEP_MULTIPLE = SESSION_MULTIPLE * 1.75; // has to be at least session + 2/3 of a session to account for missed heartbeat then session expiration + + /** + * Use the default base time + */ + public Timing2() + { + this(Integer.getInteger("timing-multiple", 1), getWaitingMultiple()); + } + + /** + * Use a multiple of the default base time + * + * @param multiple the multiple + */ + public Timing2(double multiple) + { + this((long)(DEFAULT_SECONDS * multiple), TimeUnit.SECONDS, getWaitingMultiple()); + } + + /** + * Use a multiple of the default base time + * + * @param multiple the multiple + * @param waitingMultiple multiple of main timing to use when waiting + */ + public Timing2(double multiple, int waitingMultiple) + { + this((long)(DEFAULT_SECONDS * multiple), TimeUnit.SECONDS, waitingMultiple); + } + + /** + * @param value base time + * @param unit base time unit + */ + public Timing2(long value, TimeUnit unit) + { + this(value, unit, getWaitingMultiple()); + } + + /** + * @param value base time + * @param unit base time unit + * @param waitingMultiple multiple of main timing to use when waiting + */ + public Timing2(long value, TimeUnit unit, int waitingMultiple) + { + this.value = value; + this.unit = unit; + this.waitingMultiple = waitingMultiple; + } + + /** + * Return the base time in milliseconds + * + * @return time ms + */ + public int milliseconds() + { + return (int)TimeUnit.MILLISECONDS.convert(value, unit); + } + + /** + * Return the base time in seconds + * + * @return time secs + */ + public int seconds() + { + return (int)value; + } + + /** + * Wait on the given latch + * + * @param latch latch to wait on + * @return result of {@link java.util.concurrent.CountDownLatch#await(long, java.util.concurrent.TimeUnit)} + */ + public boolean awaitLatch(CountDownLatch latch) + { + Timing2 m = forWaiting(); + try + { + return latch.await(m.value, m.unit); + } + catch ( InterruptedException e ) + { + Thread.currentThread().interrupt(); + } + return false; + } + + /** + * Try to take an item from the given queue + * + * @param queue queue + * @return item + * @throws Exception interrupted or timed out + */ + public <T> T takeFromQueue(BlockingQueue<T> queue) throws Exception + { + Timing2 m = forWaiting(); + try + { + T value = queue.poll(m.value, m.unit); + if ( value == null ) + { + throw new TimeoutException("Timed out trying to take from queue"); + } + return value; + } + catch ( InterruptedException e ) + { + Thread.currentThread().interrupt(); + throw e; + } + } + + /** + * Wait on the given semaphore + * + * @param semaphore the semaphore + * @return result of {@link java.util.concurrent.Semaphore#tryAcquire()} + */ + public boolean acquireSemaphore(Semaphore semaphore) + { + Timing2 m = forWaiting(); + try + { + return semaphore.tryAcquire(m.value, m.unit); + } + catch ( InterruptedException e ) + { + Thread.currentThread().interrupt(); + } + return false; + } + + /** + * Wait on the given semaphore + * + * @param semaphore the semaphore + * @param n number of permits to acquire + * @return result of {@link java.util.concurrent.Semaphore#tryAcquire(int, long, java.util.concurrent.TimeUnit)} + */ + public boolean acquireSemaphore(Semaphore semaphore, int n) + { + Timing2 m = forWaiting(); + try + { + return semaphore.tryAcquire(n, m.value, m.unit); + } + catch ( InterruptedException e ) + { + Thread.currentThread().interrupt(); + } + return false; + } + + /** + * Return a new timing that is a multiple of the this timing + * + * @param n the multiple + * @return this timing times the multiple + */ + public Timing2 multiple(double n) + { + return new Timing2((int)(value * n), unit); + } + + /** + * Return a new timing that is a multiple of the this timing + * + * @param n the multiple + * @param waitingMultiple new waitingMultiple + * @return this timing times the multiple + */ + public Timing2 multiple(double n, int waitingMultiple) + { + return new Timing2((int)(value * n), unit, waitingMultiple); + } + + /** + * Return a new timing with the standard multiple for waiting on latches, etc. + * + * @return this timing multiplied + */ + @SuppressWarnings("PointlessArithmeticExpression") + public Timing2 forWaiting() + { + return multiple(waitingMultiple); + } + + /** + * Return a new timing with a multiple that ensures a ZK session timeout + * + * @return this timing multiplied + */ + public Timing2 forSessionSleep() + { + return multiple(SESSION_SLEEP_MULTIPLE, 1); + } + + /** + * Return a new timing with a multiple for sleeping a smaller amount of time + * + * @return this timing multiplied + */ + public Timing2 forSleepingABit() + { + return multiple(.25); + } + + /** + * Sleep for a small amount of time + * + * @throws InterruptedException if interrupted + */ + public void sleepABit() throws InterruptedException + { + forSleepingABit().sleep(); + } + + /** + * Sleep for a the full amount of time + * + * @throws InterruptedException if interrupted + */ + public void sleep() throws InterruptedException + { + unit.sleep(value); + } + + /** + * Return the value to use for ZK session timeout + * + * @return session timeout + */ + public int session() + { + return multiple(SESSION_MULTIPLE).milliseconds(); + } + + /** + * Return the value to use for ZK connection timeout + * + * @return connection timeout + */ + public int connection() + { + return milliseconds(); + } + + private static Integer getWaitingMultiple() + { + return Integer.getInteger("timing-waiting-multiple", DEFAULT_WAITING_MULTIPLE); + } +} http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-test/src/main/java/org/apache/curator/test/compatibility/Zk35MethodInterceptor.java ---------------------------------------------------------------------- diff --git a/curator-test/src/main/java/org/apache/curator/test/compatibility/Zk35MethodInterceptor.java b/curator-test/src/main/java/org/apache/curator/test/compatibility/Zk35MethodInterceptor.java new file mode 100644 index 0000000..8072b68 --- /dev/null +++ b/curator-test/src/main/java/org/apache/curator/test/compatibility/Zk35MethodInterceptor.java @@ -0,0 +1,56 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.curator.test.compatibility; + +import org.apache.curator.test.Compatibility; +import org.testng.IMethodInstance; +import org.testng.IMethodInterceptor; +import org.testng.ITestContext; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class Zk35MethodInterceptor implements IMethodInterceptor +{ + public static final String zk35Group = "zk35"; + + @Override + public List<IMethodInstance> intercept(List<IMethodInstance> methods, ITestContext context) + { + if ( !Compatibility.isZK34() ) + { + return methods; + } + + List<IMethodInstance> filteredMethods = new ArrayList<>(); + for ( IMethodInstance method : methods ) + { + if ( !isInGroup(method.getMethod().getGroups()) ) + { + filteredMethods.add(method); + } + } + return filteredMethods; + } + + private boolean isInGroup(String[] groups) + { + return (groups != null) && Arrays.asList(groups).contains(zk35Group); + } +} http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-x-async/src/test/java/org/apache/curator/x/async/CompletableBaseClassForTests.java ---------------------------------------------------------------------- diff --git a/curator-x-async/src/test/java/org/apache/curator/x/async/CompletableBaseClassForTests.java b/curator-x-async/src/test/java/org/apache/curator/x/async/CompletableBaseClassForTests.java index 28c9f11..ae0df3b 100644 --- a/curator-x-async/src/test/java/org/apache/curator/x/async/CompletableBaseClassForTests.java +++ b/curator-x-async/src/test/java/org/apache/curator/x/async/CompletableBaseClassForTests.java @@ -20,8 +20,7 @@ package org.apache.curator.x.async; import com.google.common.base.Throwables; import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.test.Timing; -import org.apache.curator.test.Timing2; +import org.apache.curator.test.compatibility.Timing2; import org.testng.Assert; import java.util.concurrent.CompletionStage; import java.util.concurrent.ExecutionException; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceDiscovery.java ---------------------------------------------------------------------- diff --git a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceDiscovery.java b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceDiscovery.java index a2cf157..b67bff9 100644 --- a/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceDiscovery.java +++ b/curator-x-discovery/src/test/java/org/apache/curator/x/discovery/details/TestServiceDiscovery.java @@ -25,7 +25,7 @@ import org.apache.curator.framework.CuratorFramework; import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.retry.RetryOneTime; import org.apache.curator.test.BaseClassForTests; -import org.apache.curator.test.KillSession2; +import org.apache.curator.test.compatibility.KillSession2; import org.apache.curator.test.Timing; import org.apache.curator.utils.CloseableUtils; import org.apache.curator.x.discovery.ServiceDiscovery; http://git-wip-us.apache.org/repos/asf/curator/blob/242b7011/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 5a8045e..b816d36 100644 --- a/pom.xml +++ b/pom.xml @@ -80,7 +80,6 @@ <maven-shade-plugin-version>2.4.3</maven-shade-plugin-version> <slf4j-version>1.7.6</slf4j-version> <clirr-maven-plugin-version>2.8</clirr-maven-plugin-version> - <build-helper-maven-plugin-version>3.0.0</build-helper-maven-plugin-version> <!-- OSGi Properties --> <osgi.export.package /> @@ -868,12 +867,6 @@ </execution> </executions> </plugin> - - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <version>${build-helper-maven-plugin-version}</version> - </plugin> </plugins> </build> </project>
