geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jinmeil...@apache.org
Subject [14/50] [abbrv] incubator-geode git commit: GEODE-1571: add utility method to simplify client cache creation
Date Fri, 08 Jul 2016 15:51:34 GMT
GEODE-1571: add utility method to simplify client cache creation


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/eb3ce44d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/eb3ce44d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/eb3ce44d

Branch: refs/heads/develop
Commit: eb3ce44da575601328c3ebe1ee4fbdf314379e3d
Parents: b43d026
Author: Jinmei Liao <jiliao@pivotal.io>
Authored: Mon Jun 27 14:53:46 2016 -0700
Committer: Jinmei Liao <jiliao@pivotal.io>
Committed: Mon Jun 27 14:53:46 2016 -0700

----------------------------------------------------------------------
 ...ractIntegratedClientAuthDistributedTest.java | 29 +++++++++++---------
 ...tegratedClientGetAllAuthDistributedTest.java | 22 +++++----------
 ...ntegratedClientQueryAuthDistributedTest.java | 18 ++++++------
 3 files changed, 32 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eb3ce44d/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java
index 5243bd5..a7ecb25 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/AbstractIntegratedClientAuthDistributedTest.java
@@ -17,23 +17,20 @@
 package com.gemstone.gemfire.security;
 
 import static com.gemstone.gemfire.distributed.ConfigurationProperties.*;
-import static com.gemstone.gemfire.test.dunit.Assert.fail;
-import static com.gemstone.gemfire.test.dunit.DistributedTestUtils.getDUnitLocatorPort;
-import static com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter;
-import static com.gemstone.gemfire.test.dunit.NetworkUtils.getIPLiteral;
 import static org.assertj.core.api.Assertions.*;
 import static org.junit.Assert.*;
 
 import java.util.Properties;
 
-import com.gemstone.gemfire.cache.AttributesFactory;
+import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
+import org.junit.Before;
+
 import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.cache.DataPolicy;
 import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.RegionAttributes;
 import com.gemstone.gemfire.cache.RegionShortcut;
-import com.gemstone.gemfire.cache.Scope;
+import com.gemstone.gemfire.cache.client.ClientCache;
+import com.gemstone.gemfire.cache.client.ClientCacheFactory;
+import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
 import com.gemstone.gemfire.cache.server.CacheServer;
 import com.gemstone.gemfire.management.internal.security.JSONAuthorization;
 import com.gemstone.gemfire.security.templates.UserPasswordAuthInit;
@@ -42,10 +39,6 @@ import com.gemstone.gemfire.test.dunit.Invoke;
 import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;
 
-import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
-import org.junit.After;
-import org.junit.Before;
-
 public class AbstractIntegratedClientAuthDistributedTest extends JUnit4CacheTestCase {
 
   protected static final String REGION_NAME = "AuthRegion";
@@ -111,4 +104,14 @@ public class AbstractIntegratedClientAuthDistributedTest extends JUnit4CacheTest
     return props;
   }
 
+  protected ClientCache createClientCache(String username, String password, int serverPort){
+    ClientCache cache = new ClientCacheFactory(createClientProperties(username, password))
+      .setPoolSubscriptionEnabled(true)
+      .addPoolServer("localhost", serverPort)
+      .create();
+
+    cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create(REGION_NAME);
+    return cache;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eb3ce44d/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetAllAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetAllAuthDistributedTest.java
b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetAllAuthDistributedTest.java
index f4b346d..792fa87 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetAllAuthDistributedTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/IntegratedClientGetAllAuthDistributedTest.java
@@ -17,7 +17,7 @@
 package com.gemstone.gemfire.security;
 
 import static com.gemstone.gemfire.internal.Assert.assertTrue;
-import static org.jgroups.util.Util.assertEquals;
+import static org.jgroups.util.Util.*;
 
 import java.util.Arrays;
 import java.util.Map;
@@ -27,8 +27,6 @@ import org.junit.experimental.categories.Category;
 
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.client.ClientCache;
-import com.gemstone.gemfire.cache.client.ClientCacheFactory;
-import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 
 @Category(DistributedTest.class)
@@ -36,24 +34,18 @@ public class IntegratedClientGetAllAuthDistributedTest extends AbstractIntegrate
 
   @Test
   public void testGetAll() {
-    client1.invoke("logging in super-user with correct password", () -> {
-      ClientCache cache = new ClientCacheFactory(createClientProperties("stranger", "1234567"))
-        .setPoolSubscriptionEnabled(true)
-        .addPoolServer("localhost", serverPort)
-        .create();
+    client1.invoke("logging in Stranger", () -> {
+      ClientCache cache = createClientCache("stranger", "1234567", serverPort);
 
-      Region region = cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create(REGION_NAME);
+      Region region = cache.getRegion(REGION_NAME);
       Map emptyMap = region.getAll(Arrays.asList("key1", "key2", "key3", "key4"));
       assertTrue(emptyMap.isEmpty());
     });
 
-    client2.invoke("logging in super-user with correct password", () -> {
-      ClientCache cache = new ClientCacheFactory(createClientProperties("authRegionReader",
"1234567"))
-        .setPoolSubscriptionEnabled(true)
-        .addPoolServer("localhost", serverPort)
-        .create();
+    client2.invoke("logging in authRegionReader", () -> {
+      ClientCache cache = createClientCache("authRegionReader", "1234567", serverPort);
 
-      Region region = cache.createClientRegionFactory(ClientRegionShortcut.PROXY).create(REGION_NAME);
+      Region region = cache.getRegion(REGION_NAME);
       Map filledMap = region.getAll(Arrays.asList("key1", "key2", "key3", "key4"));
       assertEquals("Map should contain 4 entries", 4, filledMap.size());
       assertTrue(filledMap.containsKey("key1"));

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/eb3ce44d/geode-cq/src/test/java/com/gemstone/gemfire/security/IntegratedClientQueryAuthDistributedTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/IntegratedClientQueryAuthDistributedTest.java
b/geode-cq/src/test/java/com/gemstone/gemfire/security/IntegratedClientQueryAuthDistributedTest.java
index a484160..ad219cf 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/IntegratedClientQueryAuthDistributedTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/IntegratedClientQueryAuthDistributedTest.java
@@ -19,8 +19,8 @@ package com.gemstone.gemfire.security;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
-import com.gemstone.gemfire.cache.Cache;
 import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.client.ClientCache;
 import com.gemstone.gemfire.cache.client.Pool;
 import com.gemstone.gemfire.cache.client.PoolManager;
 import com.gemstone.gemfire.cache.query.CqAttributes;
@@ -35,8 +35,8 @@ public class IntegratedClientQueryAuthDistributedTest extends AbstractIntegrated
   @Test
   public void testQuery(){
     client1.invoke(()-> {
-      Cache cache = SecurityTestUtils.createCacheClient("stranger", "1234567", serverPort,
SecurityTestUtils.NO_EXCEPTION);
-      final Region region = cache.getRegion(SecurityTestUtils.REGION_NAME);
+      ClientCache cache = createClientCache("stranger", "1234567", serverPort);
+      final Region region = cache.getRegion(REGION_NAME);
 
       String query = "select * from /AuthRegion";
       assertNotAuthorized(()->region.query(query), "DATA:READ:AuthRegion");
@@ -50,8 +50,8 @@ public class IntegratedClientQueryAuthDistributedTest extends AbstractIntegrated
   public void testCQ(){
     String query = "select * from /AuthRegion";
     client1.invoke(()-> {
-      Cache cache = SecurityTestUtils.createCacheClient("stranger", "1234567", serverPort,
SecurityTestUtils.NO_EXCEPTION);
-      Region region = cache.getRegion(SecurityTestUtils.REGION_NAME);
+      ClientCache cache =createClientCache("stranger", "1234567", serverPort);
+      Region region = cache.getRegion(REGION_NAME);
       Pool pool = PoolManager.find(region);
       QueryService qs = pool.getQueryService();
 
@@ -67,8 +67,8 @@ public class IntegratedClientQueryAuthDistributedTest extends AbstractIntegrated
     });
 
     client2.invoke(()-> {
-      Cache cache = SecurityTestUtils.createCacheClient("authRegionReader", "1234567", serverPort,
SecurityTestUtils.NO_EXCEPTION);
-      Region region = cache.getRegion(SecurityTestUtils.REGION_NAME);
+      ClientCache cache =createClientCache("authRegionReader", "1234567", serverPort);
+      Region region = cache.getRegion(REGION_NAME);
       Pool pool = PoolManager.find(region);
       QueryService qs = pool.getQueryService();
 
@@ -82,8 +82,8 @@ public class IntegratedClientQueryAuthDistributedTest extends AbstractIntegrated
     });
 
     client3.invoke(()-> {
-      Cache cache = SecurityTestUtils.createCacheClient("super-user", "1234567", serverPort,
SecurityTestUtils.NO_EXCEPTION);
-      Region region = cache.getRegion(SecurityTestUtils.REGION_NAME);
+      ClientCache cache =createClientCache("super-user", "1234567", serverPort);
+      Region region = cache.getRegion(REGION_NAME);
       Pool pool = PoolManager.find(region);
       QueryService qs = pool.getQueryService();
 


Mime
View raw message