You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2017/02/28 22:33:20 UTC
[5/6] curator git commit: Remove mockito dependency from
curator-framework tests
Remove mockito dependency from curator-framework tests
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/952dd6b1
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/952dd6b1
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/952dd6b1
Branch: refs/heads/master
Commit: 952dd6b118ce3d2505a03abe1877b8d3db24d126
Parents: 4a95669
Author: Zoltan Szekeres <Zo...@morganstanley.com>
Authored: Tue Feb 7 11:05:47 2017 +0100
Committer: Zoltan Szekeres <Zo...@morganstanley.com>
Committed: Tue Feb 7 11:05:47 2017 +0100
----------------------------------------------------------------------
curator-framework/pom.xml | 6 ------
.../apache/curator/ConnectionStateAccessor.java | 18 +++++++++++++++---
2 files changed, 15 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/952dd6b1/curator-framework/pom.xml
----------------------------------------------------------------------
diff --git a/curator-framework/pom.xml b/curator-framework/pom.xml
index 251033f..f0ec6ba 100644
--- a/curator-framework/pom.xml
+++ b/curator-framework/pom.xml
@@ -67,12 +67,6 @@
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/curator/blob/952dd6b1/curator-framework/src/test/java/org/apache/curator/ConnectionStateAccessor.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/ConnectionStateAccessor.java b/curator-framework/src/test/java/org/apache/curator/ConnectionStateAccessor.java
old mode 100755
new mode 100644
index 5b01166..0efa989
--- a/curator-framework/src/test/java/org/apache/curator/ConnectionStateAccessor.java
+++ b/curator-framework/src/test/java/org/apache/curator/ConnectionStateAccessor.java
@@ -20,14 +20,26 @@
package org.apache.curator;
import org.apache.curator.framework.CuratorFramework;
-import org.mockito.internal.util.reflection.Whitebox;
+
+import java.lang.reflect.Field;
public final class ConnectionStateAccessor
{
- public static final void setDebugWaitOnExpiredForClient(CuratorFramework client)
+ public static void setDebugWaitOnExpiredForClient(CuratorFramework client)
{
CuratorZookeeperClient zookeeperClient = client.getZookeeperClient();
- ConnectionState state = (ConnectionState)Whitebox.getInternalState(zookeeperClient, "state");
+ ConnectionState state = (ConnectionState)getInternalState(zookeeperClient, "state");
state.debugWaitOnExpiredEvent = true;
}
+
+ private static Object getInternalState(Object target, String field) {
+ Class<?> c = target.getClass();
+ try {
+ Field f = c.getDeclaredField(field);
+ f.setAccessible(true);
+ return f.get(target);
+ } catch (Exception e) {
+ throw new RuntimeException("Unable to get internal state on a private field.", e);
+ }
+ }
}