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 2015/01/13 14:28:21 UTC
curator git commit: Final fix for backward compat ACL APIs and tests
Repository: curator
Updated Branches:
refs/heads/master 34bd3e8f3 -> 570352d54
Final fix for backward compat ACL APIs and tests
Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/570352d5
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/570352d5
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/570352d5
Branch: refs/heads/master
Commit: 570352d547ad32270109692abccc2ea30ea74294
Parents: 34bd3e8
Author: randgalt <ra...@apache.org>
Authored: Tue Jan 13 08:28:14 2015 -0500
Committer: randgalt <ra...@apache.org>
Committed: Tue Jan 13 08:28:14 2015 -0500
----------------------------------------------------------------------
.../framework/CuratorFrameworkFactory.java | 10 ++--
.../curator/framework/imps/TestFramework.java | 60 ++++++++++++--------
2 files changed, 43 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/curator/blob/570352d5/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
index fdcae48..11cee2d 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/CuratorFrameworkFactory.java
@@ -19,7 +19,6 @@
package org.apache.curator.framework;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import org.apache.curator.RetryPolicy;
import org.apache.curator.ensemble.EnsembleProvider;
@@ -382,7 +381,8 @@ public class CuratorFrameworkFactory
@Deprecated
public String getAuthScheme()
{
- switch ( authInfos.size() )
+ int qty = (authInfos != null) ? authInfos.size() : 0;
+ switch ( qty )
{
case 0:
{
@@ -404,7 +404,8 @@ public class CuratorFrameworkFactory
@Deprecated
public byte[] getAuthValue()
{
- switch ( authInfos.size() )
+ int qty = (authInfos != null) ? authInfos.size() : 0;
+ switch ( qty )
{
case 0:
{
@@ -413,7 +414,8 @@ public class CuratorFrameworkFactory
case 1:
{
- return authInfos.get(0).getAuth();
+ byte[] bytes = authInfos.get(0).getAuth();
+ return (bytes != null) ? Arrays.copyOf(bytes, bytes.length) : null;
}
default:
http://git-wip-us.apache.org/repos/asf/curator/blob/570352d5/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 6c71f2c..0d98f1d 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
@@ -227,7 +227,21 @@ public class TestFramework extends BaseClassForTests
}
@Test
- public void testCreateACLMultipleAuths() throws Exception
+ public void testACLDeprecatedApis() throws Exception
+ {
+ CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
+ .connectString(server.getConnectString())
+ .retryPolicy(new RetryOneTime(1));
+ Assert.assertNull(builder.getAuthScheme());
+ Assert.assertNull(builder.getAuthValue());
+
+ builder = builder.authorization("digest", "me1:pass1".getBytes());
+ Assert.assertEquals(builder.getAuthScheme(), "digest");
+ Assert.assertEquals(builder.getAuthValue(), "me1:pass1".getBytes());
+ }
+
+ @Test
+ public void testCreateACLMultipleAuths() throws Exception
{
// Add a few authInfos
List<AuthInfo> authInfos = new ArrayList<AuthInfo>();
@@ -483,20 +497,20 @@ public class TestFramework extends BaseClassForTests
try
{
client.getCuratorListenable().addListener
- (
- new CuratorListener()
- {
- @Override
- public void eventReceived(CuratorFramework client, CuratorEvent event) throws Exception
+ (
+ new CuratorListener()
{
- if ( event.getType() == CuratorEventType.SYNC )
+ @Override
+ public void eventReceived(CuratorFramework client, CuratorEvent event) throws Exception
{
- Assert.assertEquals(event.getPath(), "/head");
- ((CountDownLatch)event.getContext()).countDown();
+ if ( event.getType() == CuratorEventType.SYNC )
+ {
+ Assert.assertEquals(event.getPath(), "/head");
+ ((CountDownLatch)event.getContext()).countDown();
+ }
}
}
- }
- );
+ );
client.create().forPath("/head");
Assert.assertNotNull(client.checkExists().forPath("/head"));
@@ -587,20 +601,20 @@ public class TestFramework extends BaseClassForTests
try
{
client.getCuratorListenable().addListener
- (
- new CuratorListener()
+ (
+ new CuratorListener()
+ {
+ @Override
+ public void eventReceived(CuratorFramework client, CuratorEvent event) throws Exception
+ {
+ if ( event.getType() == CuratorEventType.DELETE )
{
- @Override
- public void eventReceived(CuratorFramework client, CuratorEvent event) throws Exception
- {
- if ( event.getType() == CuratorEventType.DELETE )
- {
- Assert.assertEquals(event.getPath(), "/one/two");
- ((CountDownLatch)event.getContext()).countDown();
- }
- }
+ Assert.assertEquals(event.getPath(), "/one/two");
+ ((CountDownLatch)event.getContext()).countDown();
}
- );
+ }
+ }
+ );
client.create().creatingParentsIfNeeded().forPath("/one/two/three/four");
Assert.assertNotNull(client.checkExists().forPath("/one/two/three/four"));