You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/03/29 00:48:35 UTC

[1/8] incubator-geode git commit: Keep

Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-693 6924ad46e -> 4f6a5311f


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5a321ffd/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java
index 70af27a..3cf8cac 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java
@@ -16,7 +16,9 @@
  */
 package com.gemstone.gemfire.security;
 
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 
 import java.io.IOException;
 import java.util.Properties;
@@ -35,171 +37,78 @@ import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.cache.PoolManagerImpl;
 import com.gemstone.gemfire.security.generator.CredentialGenerator;
 import com.gemstone.gemfire.security.generator.DummyCredentialGenerator;
-import com.gemstone.gemfire.test.dunit.Assert;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
-import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 @Category(DistributedTest.class)
-public class MultiuserAPIDUnitTest extends ClientAuthorizationTestBase {
+public class MultiUserAPIDUnitTest extends ClientAuthorizationTestBase {
 
-  private VM server1 = null;
-
-  private VM server2 = null;
-
-  private VM client1 = null;
-
-  private VM client2 = null;
-
-  private static final String[] serverExpectedExceptions = {
+  private static final String[] serverIgnoredExceptions = {
       AuthenticationRequiredException.class.getName(),
       AuthenticationFailedException.class.getName(),
       GemFireSecurityException.class.getName(),
-      ClassNotFoundException.class.getName(), IOException.class.getName(),
-      SSLException.class.getName(), SSLHandshakeException.class.getName()};
+      ClassNotFoundException.class.getName(),
+      IOException.class.getName(),
+      SSLException.class.getName(),
+      SSLHandshakeException.class.getName()};
 
-  private static final String[] clientExpectedExceptions = {
+  private static final String[] clientIgnoredExceptions = {
       AuthenticationRequiredException.class.getName(),
       AuthenticationFailedException.class.getName(),
       SSLHandshakeException.class.getName()};
 
   @Override
-  public final void postSetUp() throws Exception {
-    final Host host = Host.getHost(0);
-    server1 = host.getVM(0);
-    server2 = host.getVM(1);
-    client1 = host.getVM(2);
-    client2 = host.getVM(3);
-
-    server1.invoke(() -> SecurityTestUtil.registerExpectedExceptions(serverExpectedExceptions));
-    server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions(serverExpectedExceptions));
-    client1.invoke(() -> SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions));
-    client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions));
-  }
-
-  public static Integer createCacheServer(Object dsPort, Object locatorString,
-      Object authenticator, Object extraProps, Object javaProps) {
-
-    Properties authProps;
-    if (extraProps == null) {
-      authProps = new Properties();
-    } else {
-      authProps = (Properties)extraProps;
-    }
-    if (authenticator != null) {
-      authProps.setProperty(
-          DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator
-              .toString());
-    }
-    return SecurityTestUtil.createCacheServer(authProps, javaProps,
-        (Integer)dsPort, (String)locatorString, null, new Integer(
-            SecurityTestUtil.NO_EXCEPTION));
-  }
-
-  private static void createCacheClient(Object authInit, Properties authProps,
-      Properties javaProps, Integer[] ports, Object numConnections,
-      Boolean multiUserMode, Integer expectedResult) {
-
-    String authInitStr = (authInit == null ? null : authInit.toString());
-    SecurityTestUtil.createCacheClient(authInitStr, authProps, javaProps,
-        ports, numConnections, multiUserMode.toString(), expectedResult);
-  }
-
-  public static void createCacheClient(Object authInit, Object authProps,
-      Object javaProps, Integer port1, Integer port2, Object numConnections,
-      Boolean multiUserMode, Integer expectedResult) {
-
-    createCacheClient(authInit, (Properties)authProps, (Properties)javaProps,
-        new Integer[] {port1, port2}, numConnections, multiUserMode,
-        expectedResult);
-  }
-
-  public static void registerAllInterest() {
-    Region region = SecurityTestUtil.getCache().getRegion(
-        SecurityTestUtil.regionName);
-    assertNotNull(region);
-    region.registerInterestRegex(".*");
-  }
-
-  private void setUpVMs(CredentialGenerator gen, Boolean multiUser) {
-    Properties extraProps = gen.getSystemProperties();
-    Properties javaProps = gen.getJavaProperties();
-    String authenticator = gen.getAuthenticator();
-    String authInit = gen.getAuthInit();
-
-    LogWriterUtils.getLogWriter().info(
-        "testValidCredentials: Using scheme: " + gen.classCode());
-    LogWriterUtils.getLogWriter().info(
-        "testValidCredentials: Using authenticator: " + authenticator);
-    LogWriterUtils.getLogWriter().info("testValidCredentials: Using authinit: " + authInit);
-
-    // Start the servers
-    Integer locPort1 = SecurityTestUtil.getLocatorPort();
-    Integer locPort2 = SecurityTestUtil.getLocatorPort();
-    String locString = SecurityTestUtil.getLocatorString();
-    Integer port1 = (Integer)server1.invoke(() -> MultiuserAPIDUnitTest.createCacheServer(locPort1, locString, authenticator,
-            extraProps, javaProps));
-    Integer port2 = (Integer)server2.invoke(() -> MultiuserAPIDUnitTest.createCacheServer(locPort2, locString, authenticator,
-            extraProps, javaProps));
-
-    // Start the clients with valid credentials
-    Properties credentials1 = gen.getValidCredentials(1);
-    Properties javaProps1 = gen.getJavaProperties();
-    LogWriterUtils.getLogWriter().info(
-        "testValidCredentials: For first client credentials: " + credentials1
-            + " : " + javaProps1);
-    Properties credentials2 = gen.getValidCredentials(2);
-    Properties javaProps2 = gen.getJavaProperties();
-    LogWriterUtils.getLogWriter().info(
-        "testValidCredentials: For second client credentials: " + credentials2
-            + " : " + javaProps2);
-    client1.invoke(() -> MultiuserAPIDUnitTest.createCacheClient(authInit, credentials1, javaProps1, port1, port2, null,
-            multiUser, new Integer(SecurityTestUtil.NO_EXCEPTION)));
+  public final void preTearDownClientAuthorizationTestBase() throws Exception {
+    // close the clients first
+    client1.invoke(() -> closeCache());
+    client2.invoke(() -> closeCache());
+    // then close the servers
+    server1.invoke(() -> closeCache());
+    server2.invoke(() -> closeCache());
   }
 
   @Test
   public void testSingleUserUnsupportedAPIs() {
-      // Start servers
-      // Start clients with multiuser-authentication set to false
-      setUpVMs(new DummyCredentialGenerator(), Boolean.FALSE);
-      client1.invoke(() -> MultiuserAPIDUnitTest.verifyDisallowedOps(Boolean.FALSE));
+    // Start servers
+    // Start clients with multiuser-authentication set to false
+    setUpVMs(new DummyCredentialGenerator(), Boolean.FALSE);
+    client1.invoke(() -> verifyDisallowedOps(Boolean.FALSE));
   }
 
   @Test
   public void testMultiUserUnsupportedAPIs() {
-      // Start servers.
-      // Start clients with multiuser-authentication set to true.
-      setUpVMs(new DummyCredentialGenerator(), Boolean.TRUE);
-      client1.invoke(() -> MultiuserAPIDUnitTest.verifyDisallowedOps(Boolean.TRUE));
+    // Start servers.
+    // Start clients with multiuser-authentication set to true.
+    setUpVMs(new DummyCredentialGenerator(), Boolean.TRUE);
+    client1.invoke(() -> verifyDisallowedOps(Boolean.TRUE));
   }
 
-  public static void verifyDisallowedOps(Boolean multiuserMode) {
+  private void verifyDisallowedOps(Boolean multiUserMode) throws Exception {
     String op = "unknown";
     boolean success = false;
-    if (!multiuserMode) {
+
+    if (!multiUserMode) {
       success = false;
+
       try {
         // Attempt cache.createAuthenticatedCacheView() and expect an exception, fail otherwise
         op = "Pool.createSecureUserCache()";
         GemFireCacheImpl.getInstance().createAuthenticatedView(new Properties(), "testPool");
       } catch (IllegalStateException uoe) {
-        LogWriterUtils.getLogWriter().info(op + ": Got expected exception: " + uoe);
+        getLogWriter().info(op + ": Got expected exception: " + uoe);
         success = true;
-      } catch (Exception e) {
-        Assert.fail("Got unexpected exception while doing " + op, e);
       }
+
       if (!success) {
         fail("Did not get exception while doing " + op);
       }
+
     } else { // multiuser mode
-      Region realRegion = GemFireCacheImpl.getInstance().getRegion(
-          SecurityTestUtil.regionName);
-      Region proxyRegion = SecurityTestUtil.proxyCaches[0]
-          .getRegion(SecurityTestUtil.regionName);
+      Region realRegion = GemFireCacheImpl.getInstance().getRegion(SecurityTestUtil.REGION_NAME);
+      Region proxyRegion = SecurityTestUtil.proxyCaches[0].getRegion(SecurityTestUtil.REGION_NAME);
       Pool pool = PoolManagerImpl.getPMI().find("testPool");
+
       for (int i = 0; i <= 27; i++) {
         success = false;
         try {
@@ -253,8 +162,7 @@ public class MultiuserAPIDUnitTest extends ClientAuthorizationTestBase {
             // and expect an exception, fail otherwise.
             case 9:
               op = "ProxyRegion.createSubregion()";
-              proxyRegion.createSubregion("subregion",
-                  null);
+              proxyRegion.createSubregion("subregion", null);
               break;
             case 10:
               op = "ProxyRegion.forceRolling()";
@@ -302,15 +210,12 @@ public class MultiuserAPIDUnitTest extends ClientAuthorizationTestBase {
             // QueryService.newQuery().execute()/newCq().execute/executeWithInitialResults()
             case 20:
               op = "QueryService.newQuery.execute()";
-              Query query = pool.getQueryService().newQuery(
-                  "SELECT * FROM /" + SecurityTestUtil.regionName);
+              Query query = pool.getQueryService().newQuery("SELECT * FROM /" + SecurityTestUtil.REGION_NAME);
               query.execute();
               break;
             case 21:
               op = "QueryService.newCq.execute()";
-              CqQuery cqQuery = pool.getQueryService().newCq(
-                  "SELECT * FROM /" + SecurityTestUtil.regionName,
-                  new CqAttributesFactory().create());
+              CqQuery cqQuery = pool.getQueryService().newCq("SELECT * FROM /" + SecurityTestUtil.REGION_NAME, new CqAttributesFactory().create());
               try {
                 cqQuery.execute();
               } catch (CqException ce) {
@@ -319,9 +224,7 @@ public class MultiuserAPIDUnitTest extends ClientAuthorizationTestBase {
               break;
             case 22:
               op = "QueryService.newCq.executeWithInitialResults()";
-              cqQuery = pool.getQueryService().newCq(
-                  "SELECT * FROM /" + SecurityTestUtil.regionName,
-                  new CqAttributesFactory().create());
+              cqQuery = pool.getQueryService().newCq("SELECT * FROM /" + SecurityTestUtil.REGION_NAME, new CqAttributesFactory().create());
               try {
                 cqQuery.executeWithInitialResults();
               } catch (CqException ce) {
@@ -332,13 +235,11 @@ public class MultiuserAPIDUnitTest extends ClientAuthorizationTestBase {
             // expect an exception, fail otherwise.
             case 23:
               op = "ProxyQueryService().getIndexes()";
-              SecurityTestUtil.proxyCaches[0].getQueryService()
-                  .getIndexes(null);
+              SecurityTestUtil.proxyCaches[0].getQueryService().getIndexes(null);
               break;
             case 24:
               op = "ProxyQueryService().createIndex()";
-              SecurityTestUtil.proxyCaches[0].getQueryService().createIndex(
-                  null, null, null );
+              SecurityTestUtil.proxyCaches[0].getQueryService().createIndex(null, null, null );
               break;
             case 25:
               op = "ProxyQueryService().removeIndexes()";
@@ -356,11 +257,10 @@ public class MultiuserAPIDUnitTest extends ClientAuthorizationTestBase {
               fail("Unknown op code: " + i);
               break;
           }
+
         } catch (UnsupportedOperationException uoe) {
-          LogWriterUtils.getLogWriter().info(op + ": Got expected exception: " + uoe);
+          getLogWriter().info(op + ": Got expected exception: " + uoe);
           success = true;
-        } catch (Exception e) {
-          Assert.fail("Got unexpected exception while doing " + op, e);
         }
         if (!success) {
           fail("Did not get exception while doing " + op);
@@ -369,13 +269,51 @@ public class MultiuserAPIDUnitTest extends ClientAuthorizationTestBase {
     }
   }
 
-  @Override
-  public final void preTearDown() throws Exception {
-    // close the clients first
-    client1.invoke(() -> SecurityTestUtil.closeCache());
-    client2.invoke(() -> SecurityTestUtil.closeCache());
-    // then close the servers
-    server1.invoke(() -> SecurityTestUtil.closeCache());
-    server2.invoke(() -> SecurityTestUtil.closeCache());
+  private void setUpVMs(CredentialGenerator gen, Boolean multiUser) {
+    Properties extraProps = gen.getSystemProperties();
+    Properties javaProps = gen.getJavaProperties();
+    String authenticator = gen.getAuthenticator();
+    String authInit = gen.getAuthInit();
+
+    getLogWriter().info("testValidCredentials: Using scheme: " + gen.classCode());
+    getLogWriter().info("testValidCredentials: Using authenticator: " + authenticator);
+    getLogWriter().info("testValidCredentials: Using authinit: " + authInit);
+
+    // Start the servers
+    Integer locPort1 = SecurityTestUtil.getLocatorPort();
+    Integer locPort2 = SecurityTestUtil.getLocatorPort();
+    String locString = SecurityTestUtil.getLocatorString();
+    Integer port1 = (Integer)server1.invoke(() -> createCacheServer(locPort1, locString, authenticator, extraProps, javaProps));
+    Integer port2 = (Integer)server2.invoke(() -> createCacheServer(locPort2, locString, authenticator, extraProps, javaProps));
+
+    // Start the clients with valid credentials
+    Properties credentials1 = gen.getValidCredentials(1);
+    Properties javaProps1 = gen.getJavaProperties();
+    getLogWriter().info("testValidCredentials: For first client credentials: " + credentials1 + " : " + javaProps1);
+    Properties credentials2 = gen.getValidCredentials(2);
+    Properties javaProps2 = gen.getJavaProperties();
+    getLogWriter().info("testValidCredentials: For second client credentials: " + credentials2 + " : " + javaProps2);
+    client1.invoke(() -> createCacheClient(authInit, credentials1, javaProps1, port1, port2, null, multiUser, new Integer(SecurityTestUtil.NO_EXCEPTION)));
+  }
+
+  private Integer createCacheServer(Object dsPort, Object locatorString, Object authenticator, Object extraProps, Object javaProps) {
+    Properties authProps = new Properties();
+    if (extraProps != null) {
+      authProps.putAll((Properties)extraProps);
+    }
+
+    if (authenticator != null) {
+      authProps.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator.toString());
+    }
+    return SecurityTestUtil.createCacheServer(authProps, javaProps, (Integer)dsPort, (String)locatorString, null, new Integer(SecurityTestUtil.NO_EXCEPTION));
+  }
+
+  private void createCacheClient(Object authInit, Object authProps, Object javaProps, Integer port1, Integer port2, Object numConnections, Boolean multiUserMode, Integer expectedResult) {
+    createCacheClient(authInit, (Properties)authProps, (Properties)javaProps, new Integer[] {port1, port2}, numConnections, multiUserMode, expectedResult);
+  }
+
+  private void createCacheClient(Object authInit, Properties authProps, Properties javaProps, Integer[] ports, Object numConnections, Boolean multiUserMode, Integer expectedResult) {
+    String authInitStr = (authInit == null ? null : authInit.toString());
+    SecurityTestUtil.createCacheClient(authInitStr, authProps, javaProps, ports, numConnections, multiUserMode.toString(), expectedResult);
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5a321ffd/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java
index 551400a..9c32a77 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java
@@ -16,7 +16,10 @@
  */
 package com.gemstone.gemfire.security;
 
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.Invoke.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -27,9 +30,12 @@ import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
 import com.gemstone.gemfire.cache.query.CqAttributes;
 import com.gemstone.gemfire.cache.query.CqAttributesFactory;
+import com.gemstone.gemfire.cache.query.CqException;
+import com.gemstone.gemfire.cache.query.CqExistsException;
 import com.gemstone.gemfire.cache.query.CqListener;
 import com.gemstone.gemfire.cache.query.CqQuery;
 import com.gemstone.gemfire.cache.query.QueryService;
+import com.gemstone.gemfire.cache.query.RegionNotFoundException;
 import com.gemstone.gemfire.cache.query.SelectResults;
 import com.gemstone.gemfire.cache.query.cq.dunit.CqQueryTestListener;
 import com.gemstone.gemfire.cache.query.internal.cq.ClientCQImpl;
@@ -39,46 +45,34 @@ import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
 import com.gemstone.gemfire.internal.logging.InternalLogWriter;
 import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
 import com.gemstone.gemfire.security.generator.CredentialGenerator;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.Invoke;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
 import com.gemstone.gemfire.test.dunit.SerializableRunnable;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 @Category(DistributedTest.class)
-public class MultiuserDurableCQAuthzDUnitTest extends
-    ClientAuthorizationTestBase {
+public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBase {
   
-  private Map<String, String> cqNameToQueryStrings = new HashMap<String, String>();
+  private final Map<String, String> cqNameToQueryStrings = new HashMap<String, String>();
 
   @Override
-  public final void postSetUp() throws Exception {
+  public final void preSetUpClientAuthorizationTestBase() throws Exception {
     getSystem();
-    Invoke.invokeInEveryVM(new SerializableRunnable("getSystem") {
+    invokeInEveryVM(new SerializableRunnable("getSystem") {
       public void run() {
         getSystem();
       }
     });
+  }
 
-    final Host host = Host.getHost(0);
-    server1 = host.getVM(0);
-    server2 = host.getVM(1);
-    client1 = host.getVM(2);
-    client2 = host.getVM(3);
-
-    server1.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions ));
-    SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions);
-
+  @Override
+  public final void postSetUpClientAuthorizationTestBase() throws Exception {
     cqNameToQueryStrings.put("CQ_0", "SELECT * FROM ");
     cqNameToQueryStrings.put("CQ_1", "SELECT * FROM ");
   }
 
   @Override
-  public final void postTearDown() throws Exception {
+  public final void postTearDownClientAuthorizationTestBase() throws Exception {
     cqNameToQueryStrings.clear();
   }
 
@@ -98,8 +92,7 @@ public class MultiuserDurableCQAuthzDUnitTest extends
     Integer numOfPuts = 5;
     Boolean[] postAuthzAllowed = new Boolean[] {Boolean.TRUE, Boolean.TRUE};
 
-    doTest(numOfUsers, numOfPuts, postAuthzAllowed,
-          getXmlAuthzGenerator(), null);
+    doTest(numOfUsers, numOfPuts, postAuthzAllowed, getXmlAuthzGenerator(), null);
   }
 
   @Test
@@ -118,8 +111,7 @@ public class MultiuserDurableCQAuthzDUnitTest extends
     Integer numOfPuts = 5;
     Boolean[] postAuthzAllowed = new Boolean[] {Boolean.TRUE, Boolean.TRUE};
 
-    doTest(numOfUsers, numOfPuts, postAuthzAllowed,
-          getXmlAuthzGenerator(), Boolean.TRUE);
+    doTest(numOfUsers, numOfPuts, postAuthzAllowed, getXmlAuthzGenerator(), Boolean.TRUE);
   }
 
   @Test
@@ -138,86 +130,78 @@ public class MultiuserDurableCQAuthzDUnitTest extends
     Integer numOfPuts = 5;
     Boolean[] postAuthzAllowed = new Boolean[] {Boolean.TRUE, Boolean.TRUE};
 
-    doTest(numOfUsers, numOfPuts, postAuthzAllowed,
-              getXmlAuthzGenerator(), Boolean.FALSE);
+    doTest(numOfUsers, numOfPuts, postAuthzAllowed, getXmlAuthzGenerator(), Boolean.FALSE);
   }
 
-  private void doTest(Integer numOfUsers, Integer numOfPuts,
-                      Boolean[] postAuthzAllowed, AuthzCredentialGenerator gen, Boolean keepAlive)
-      throws Exception {
-    CredentialGenerator cGen = gen.getCredentialGenerator();
-    Properties extraAuthProps = cGen.getSystemProperties();
-    Properties javaProps = cGen.getJavaProperties();
-    Properties extraAuthzProps = gen.getSystemProperties();
-    String authenticator = cGen.getAuthenticator();
-    String accessor = gen.getAuthorizationCallback();
-    String authInit = cGen.getAuthInit();
-    TestAuthzCredentialGenerator tgen = new TestAuthzCredentialGenerator(gen);
-
-    Properties serverProps = buildProperties(authenticator, accessor, true,
-        extraAuthProps, extraAuthzProps);
+  private void doTest(Integer numOfUsers, Integer numOfPuts, Boolean[] postAuthzAllowed, AuthzCredentialGenerator authzGenerator, Boolean keepAlive) throws Exception {
+    CredentialGenerator credentialGenerator = authzGenerator.getCredentialGenerator();
+    Properties extraAuthProps = credentialGenerator.getSystemProperties();
+    Properties javaProps = credentialGenerator.getJavaProperties();
+    Properties extraAuthzProps = authzGenerator.getSystemProperties();
+    String authenticator = credentialGenerator.getAuthenticator();
+    String accessor = authzGenerator.getAuthorizationCallback();
+    String authInit = credentialGenerator.getAuthInit();
+    TestAuthzCredentialGenerator tgen = new TestAuthzCredentialGenerator(authzGenerator);
+
+    Properties serverProps = buildProperties(authenticator, accessor, true, extraAuthProps, extraAuthzProps);
 
     Properties opCredentials;
-    cGen = tgen.getCredentialGenerator();
-    final Properties javaProps2;
-    if (cGen != null) {
-      javaProps2 = cGen.getJavaProperties();
-    } else {
-      javaProps2 = null;
-    }
+    credentialGenerator = tgen.getCredentialGenerator();
+    final Properties javaProps2 = credentialGenerator != null ? credentialGenerator.getJavaProperties() : null;
 
     int[] indices = new int[numOfPuts];
     for (int index = 0; index < numOfPuts; ++index) {
       indices[index] = index;
     }
 
-    Random rnd = new Random();
+    Random random = new Random();
     Properties[] authProps = new Properties[numOfUsers];
     String durableClientId = "multiuser_durable_client_1";
+
     Properties client2Credentials = null;
+
     for (int i = 0; i < numOfUsers; i++) {
-      int rand = rnd.nextInt(100) + 1;
+      int rand = random.nextInt(100) + 1;
       if (postAuthzAllowed[i]) {
-        opCredentials = tgen.getAllowedCredentials(new OperationCode[] {
-            OperationCode.EXECUTE_CQ, OperationCode.GET}, // For callback, GET should be allowed
-            new String[] {regionName}, indices, rand);
+        opCredentials = tgen.getAllowedCredentials(
+            new OperationCode[] {OperationCode.EXECUTE_CQ, OperationCode.GET}, // For callback, GET should be allowed
+            new String[] {regionName},
+            indices,
+            rand);
+
       } else {
-        opCredentials = tgen.getDisallowedCredentials(new OperationCode[] {
-            OperationCode.GET}, // For callback, GET should be disallowed
-            new String[] {regionName}, indices, rand);
+        opCredentials = tgen.getDisallowedCredentials(
+            new OperationCode[] {OperationCode.GET}, // For callback, GET should be disallowed
+            new String[] {regionName},
+            indices,
+            rand);
       }
-      authProps[i] = SecurityTestUtil.concatProperties(new Properties[] {
-          opCredentials, extraAuthProps, extraAuthzProps});
+
+      authProps[i] = SecurityTestUtil.concatProperties(new Properties[] {opCredentials, extraAuthProps, extraAuthzProps});
 
       if (client2Credentials == null) {
-        client2Credentials = tgen.getAllowedCredentials(new OperationCode[] {
-            OperationCode.PUT},
-            new String[] {regionName}, indices, rand);
+        client2Credentials = tgen.getAllowedCredentials(
+            new OperationCode[] {OperationCode.PUT},
+            new String[] {regionName},
+            indices,
+            rand);
       }
     }
 
     // Get ports for the servers
-    Integer port1 = new Integer(AvailablePort
-        .getRandomAvailablePort(AvailablePort.SOCKET));
-    Integer port2 = new Integer(AvailablePort
-        .getRandomAvailablePort(AvailablePort.SOCKET));
-    Integer locatorPort = new Integer(AvailablePort
-        .getRandomAvailablePort(AvailablePort.SOCKET));
+    Integer port1 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+    Integer port2 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+    Integer locatorPort = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+
     // Close down any running servers
     server1.invoke(() -> SecurityTestUtil.closeCache());
     server2.invoke(() -> SecurityTestUtil.closeCache());
 
     server1.invoke(() -> createServerCache(serverProps, javaProps, locatorPort, port1));
-    client1.invoke(() -> createClientCache(javaProps2, authInit, authProps,
-            new Integer[] {port1, port2}, numOfUsers, durableClientId, postAuthzAllowed));
-
-//    client2.invoke(SecurityTestUtil.class, "createCacheClient",
-//        new Object[] {authInit, client2Credentials, javaProps2,
-//            new Integer[] {port1, port2}, null, SecurityTestUtil.NO_EXCEPTION});
+    client1.invoke(() -> createClientCache(javaProps2, authInit, authProps, new Integer[] {port1, port2}, numOfUsers, durableClientId, postAuthzAllowed));
 
     client1.invoke(() -> createCQ(numOfUsers, Boolean.TRUE));
-    client1.invoke(() -> executeCQ(numOfUsers, new Boolean[] {false, false}, numOfPuts,
-            new String[numOfUsers]));
+    client1.invoke(() -> executeCQ(numOfUsers, new Boolean[] {false, false}, numOfPuts, new String[numOfUsers]));
     client1.invoke(() -> readyForEvents());
 
     if (keepAlive == null) {
@@ -228,180 +212,124 @@ public class MultiuserDurableCQAuthzDUnitTest extends
 
     server1.invoke(() -> doPuts(numOfPuts, Boolean.TRUE/* put last key */));
 
-    client1.invoke(() -> createClientCache(javaProps2, authInit, authProps,
-            new Integer[] {port1, port2}, numOfUsers, durableClientId, postAuthzAllowed));
+    client1.invoke(() -> createClientCache(javaProps2, authInit, authProps, new Integer[] {port1, port2}, numOfUsers, durableClientId, postAuthzAllowed));
     client1.invoke(() -> createCQ(numOfUsers, Boolean.TRUE));
-    client1.invoke(() ->executeCQ(numOfUsers, new Boolean[] {false, false}, numOfPuts,
-            new String[numOfUsers]));
+    client1.invoke(() ->executeCQ(numOfUsers, new Boolean[] {false, false}, numOfPuts, new String[numOfUsers]));
     client1.invoke(() -> readyForEvents());
 
     if (!postAuthzAllowed[0] || keepAlive == null || !keepAlive) {
       // Don't wait as no user is authorized to receive cq events.
-      Thread.sleep(1000);
+      Thread.sleep(1000); // TODO: use Awaitility
     } else {
       client1.invoke(() -> waitForLastKey(Integer.valueOf(0), Boolean.TRUE));
     }
-    Integer numOfCreates = (keepAlive == null) ? 0
-        : (keepAlive) ? (numOfPuts + 1/* last key */) : 0;
-    client1.invoke(() -> checkCQListeners(numOfUsers, postAuthzAllowed, numOfCreates, 0));
 
+    Integer numOfCreates = keepAlive == null ? 0 : (keepAlive ? numOfPuts + 1/* last key */ : 0);
+    client1.invoke(() -> checkCQListeners(numOfUsers, postAuthzAllowed, numOfCreates, 0));
     client1.invoke(() -> proxyCacheClose(new Integer[] {0, 1}, keepAlive));
-
-    client1.invoke(SecurityTestUtil.class, "createProxyCache",
-        new Object[] {new Integer[] {0, 1}, authProps});
-
+    client1.invoke(() -> SecurityTestUtil.createProxyCache(new Integer[] {0, 1}, authProps));
     client1.invoke(() -> createCQ(numOfUsers, Boolean.TRUE));
-    client1.invoke(() -> executeCQ(numOfUsers, new Boolean[] {false, false}, numOfPuts,
-            new String[numOfUsers]));
+    client1.invoke(() -> executeCQ(numOfUsers, new Boolean[] {false, false}, numOfPuts, new String[numOfUsers]));
 
     server1.invoke(() -> doPuts(numOfPuts, Boolean.TRUE/* put last key */));
 
     if (!postAuthzAllowed[0] || keepAlive == null || !keepAlive) {
       // Don't wait as no user is authorized to receive cq events.
-      Thread.sleep(1000);
+      Thread.sleep(1000); // TODO: use Awaitility
     } else {
       client1.invoke(() -> waitForLastKey(Integer.valueOf(0), Boolean.FALSE));
     }
+
     Integer numOfUpdates = numOfPuts + 1;
     client1.invoke(() -> checkCQListeners(numOfUsers, postAuthzAllowed, 0, numOfUpdates));
   }
 
-  private void createServerCache(Properties serverProps,
-      Properties javaProps, Integer locatorPort, Integer serverPort) {
-    SecurityTestUtil.createCacheServer((Properties)serverProps, javaProps,
-        locatorPort, null, serverPort, Boolean.TRUE, new Integer(
-            SecurityTestUtil.NO_EXCEPTION));
+  private void createServerCache(Properties serverProps, Properties javaProps, Integer locatorPort, Integer serverPort) {
+    SecurityTestUtil.createCacheServer((Properties)serverProps, javaProps, locatorPort, null, serverPort, Boolean.TRUE, new Integer(SecurityTestUtil.NO_EXCEPTION));
   }
 
-  private void createClientCache(Properties javaProps,
-      String authInit, Properties[] authProps, Integer ports[],
-      Integer numOfUsers, Boolean[] postAuthzAllowed) {
-    SecurityTestUtil.createCacheClientForMultiUserMode(numOfUsers, authInit,
-        authProps, javaProps, ports, null, Boolean.FALSE,
-        SecurityTestUtil.NO_EXCEPTION);
+  private void createClientCache(Properties javaProps, String authInit, Properties[] authProps, Integer ports[], Integer numOfUsers, Boolean[] postAuthzAllowed) {
+    SecurityTestUtil.createCacheClientForMultiUserMode(numOfUsers, authInit, authProps, javaProps, ports, null, Boolean.FALSE, SecurityTestUtil.NO_EXCEPTION);
   }
 
   private void readyForEvents() {
     GemFireCacheImpl.getInstance().readyForEvents();
   }
 
-  private void createClientCache(Properties javaProps,
-      String authInit, Properties[] authProps, Integer ports[],
-      Integer numOfUsers, String durableId, Boolean[] postAuthzAllowed) {
-    SecurityTestUtil.createCacheClientForMultiUserMode(numOfUsers, authInit,
-        authProps, javaProps, ports, null, Boolean.FALSE, durableId,
-        SecurityTestUtil.NO_EXCEPTION);
+  private void createClientCache(Properties javaProps, String authInit, Properties[] authProps, Integer ports[], Integer numOfUsers, String durableId, Boolean[] postAuthzAllowed) {
+    SecurityTestUtil.createCacheClientForMultiUserMode(numOfUsers, authInit, authProps, javaProps, ports, null, Boolean.FALSE, durableId, SecurityTestUtil.NO_EXCEPTION);
   }
 
-  private void createCQ(Integer num) {
+  private void createCQ(Integer num) throws CqException, CqExistsException {
     createCQ(num, false);
   }
 
-  private void createCQ(Integer num, Boolean isDurable) {
+  private void createCQ(Integer num, Boolean isDurable) throws CqException, CqExistsException {
     for (int i = 0; i < num; i++) {
       QueryService cqService = SecurityTestUtil.proxyCaches[i].getQueryService();
       String cqName = "CQ_" + i;
-      String queryStr = cqNameToQueryStrings.get(cqName)
-          + SecurityTestUtil.proxyCaches[i].getRegion(regionName).getFullPath();
+      String queryStr = cqNameToQueryStrings.get(cqName) + SecurityTestUtil.proxyCaches[i].getRegion(regionName).getFullPath();
+
       // Create CQ Attributes.
       CqAttributesFactory cqf = new CqAttributesFactory();
-      CqListener[] cqListeners = {new CqQueryTestListener(LogWriterUtils.getLogWriter())};
+      CqListener[] cqListeners = {new CqQueryTestListener(getLogWriter())};
       ((CqQueryTestListener)cqListeners[0]).cqName = cqName;
 
       cqf.initCqListeners(cqListeners);
       CqAttributes cqa = cqf.create();
 
       // Create CQ.
-      try {
-        CqQuery cq1 = cqService.newCq(cqName, queryStr, cqa, isDurable);
-        assertTrue("newCq() state mismatch", cq1.getState().isStopped());
-      } catch (Exception ex) {
-        AssertionError err = new AssertionError("Failed to create CQ " + cqName
-            + " . ");
-        err.initCause(ex);
-        LogWriterUtils.getLogWriter().info("CqService is :" + cqService, err);
-        throw err;
-      }
+      CqQuery cq1 = cqService.newCq(cqName, queryStr, cqa, isDurable);
+      assertTrue("newCq() state mismatch", cq1.getState().isStopped());
     }
   }
 
-  private void executeCQ(Integer num, Boolean[] initialResults,
-      Integer expectedResultsSize, String[] expectedErr) {
+  private void executeCQ(Integer num, Boolean[] initialResults, Integer expectedResultsSize, String[] expectedErr) throws CqException, RegionNotFoundException {
     InternalLogWriter logWriter = InternalDistributedSystem.getStaticInternalLogWriter();
+
     for (int i = 0; i < num; i++) {
       try {
         if (expectedErr[i] != null) {
-          logWriter.info(
-              "<ExpectedException action=add>" + expectedErr[i]
-                  + "</ExpectedException>");
+          logWriter.info("<ExpectedException action=add>" + expectedErr[i]+ "</ExpectedException>");
         }
+
         CqQuery cq1 = null;
         String cqName = "CQ_" + i;
-        String queryStr = cqNameToQueryStrings.get(cqName)
-            + SecurityTestUtil.proxyCaches[i].getRegion(regionName)
-                .getFullPath();
-        QueryService cqService = SecurityTestUtil.proxyCaches[i]
-            .getQueryService();
+        String queryStr = cqNameToQueryStrings.get(cqName) + SecurityTestUtil.proxyCaches[i].getRegion(regionName).getFullPath();
+        QueryService cqService = SecurityTestUtil.proxyCaches[i].getQueryService();
 
         // Get CqQuery object.
-        try {
-          cq1 = cqService.getCq(cqName);
-          if (cq1 == null) {
-            LogWriterUtils.getLogWriter().info(
-                "Failed to get CqQuery object for CQ name: " + cqName);
-            fail("Failed to get CQ " + cqName);
-          } else {
-            LogWriterUtils.getLogWriter().info("Obtained CQ, CQ name: " + cq1.getName());
-            assertTrue("newCq() state mismatch", cq1.getState().isStopped());
-          }
-        } catch (Exception ex) {
-          LogWriterUtils.getLogWriter().info("CqService is :" + cqService);
-          LogWriterUtils.getLogWriter().error(ex);
-          AssertionError err = new AssertionError("Failed to execute CQ "
-              + cqName);
-          err.initCause(ex);
-          throw err;
+        cq1 = cqService.getCq(cqName);
+        if (cq1 == null) {
+          getLogWriter().info("Failed to get CqQuery object for CQ name: " + cqName);
+          fail("Failed to get CQ " + cqName);
+
+        } else {
+          getLogWriter().info("Obtained CQ, CQ name: " + cq1.getName());
+          assertTrue("newCq() state mismatch", cq1.getState().isStopped());
         }
 
         if (initialResults[i]) {
           SelectResults cqResults = null;
 
-          try {
-            cqResults = cq1.executeWithInitialResults();
-          } catch (Exception ex) {
-            LogWriterUtils.getLogWriter().info("CqService is: " + cqService);
-            ex.printStackTrace();
-            AssertionError err = new AssertionError("Failed to execute CQ "
-                + cqName);
-            err.initCause(ex);
-            throw err;
-          }
-          LogWriterUtils.getLogWriter().info("initial result size = " + cqResults.size());
+          cqResults = cq1.executeWithInitialResults();
+
+          getLogWriter().info("initial result size = " + cqResults.size());
           assertTrue("executeWithInitialResults() state mismatch", cq1
               .getState().isRunning());
           if (expectedResultsSize >= 0) {
             assertEquals("unexpected results size", expectedResultsSize
                 .intValue(), cqResults.size());
           }
+
         } else {
-          try {
-            cq1.execute();
-          } catch (Exception ex) {
-            AssertionError err = new AssertionError("Failed to execute CQ "
-                + cqName);
-            err.initCause(ex);
-            if (expectedErr == null) {
-              LogWriterUtils.getLogWriter().info("CqService is: " + cqService, err);
-            }
-            throw err;
-          }
+          cq1.execute();
           assertTrue("execute() state mismatch", cq1.getState().isRunning());
         }
+
       } finally {
         if (expectedErr[i] != null) {
-          logWriter.info(
-              "<ExpectedException action=remove>" + expectedErr[i]
-                  + "</ExpectedException>");
+          logWriter.info("<ExpectedException action=remove>" + expectedErr[i]+ "</ExpectedException>");
         }
       }
     }
@@ -427,28 +355,24 @@ public class MultiuserDurableCQAuthzDUnitTest extends
     QueryService qService = SecurityTestUtil.proxyCaches[cqIndex].getQueryService();
     ClientCQImpl cqQuery = (ClientCQImpl)qService.getCq(cqName);
     if (isCreate) {
-      ((CqQueryTestListener)cqQuery.getCqListeners()[cqIndex])
-          .waitForCreated("LAST_KEY");
+      ((CqQueryTestListener)cqQuery.getCqListeners()[cqIndex]).waitForCreated("LAST_KEY");
     } else {
-      ((CqQueryTestListener)cqQuery.getCqListeners()[cqIndex])
-          .waitForUpdated("LAST_KEY");
+      ((CqQueryTestListener)cqQuery.getCqListeners()[cqIndex]).waitForUpdated("LAST_KEY");
     }
   }
 
-  private void checkCQListeners(Integer numOfUsers,
-      Boolean[] expectedListenerInvocation, Integer createEventsSize,
-      Integer updateEventsSize) {
+  private void checkCQListeners(Integer numOfUsers,Boolean[] expectedListenerInvocation, Integer createEventsSize, Integer updateEventsSize) {
     for (int i = 0; i < numOfUsers; i++) {
       String cqName = "CQ_" + i;
       QueryService qService = SecurityTestUtil.proxyCaches[i].getQueryService();
       ClientCQImpl cqQuery = (ClientCQImpl)qService.getCq(cqName);
+
       if (expectedListenerInvocation[i]) {
         for (CqListener listener : cqQuery.getCqListeners()) {
-          assertEquals(createEventsSize.intValue(),
-              ((CqQueryTestListener)listener).getCreateEventCount());
-          assertEquals(updateEventsSize.intValue(),
-              ((CqQueryTestListener)listener).getUpdateEventCount());
+          assertEquals(createEventsSize.intValue(), ((CqQueryTestListener)listener).getCreateEventCount());
+          assertEquals(updateEventsSize.intValue(), ((CqQueryTestListener)listener).getUpdateEventCount());
         }
+
       } else {
         for (CqListener listener : cqQuery.getCqListeners()) {
           assertEquals(0, ((CqQueryTestListener)listener).getTotalEventCount());
@@ -466,11 +390,11 @@ public class MultiuserDurableCQAuthzDUnitTest extends
       for (int i : userIndices) {
         SecurityTestUtil.proxyCaches[i].close(keepAliveFlags);
       }
+
     } else {
       for (int i : userIndices) {
         SecurityTestUtil.proxyCaches[i].close();
       }
     }
   }
-
 }



[2/8] incubator-geode git commit: Keep

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5a321ffd/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
index 8b47cdf..8ef10c1 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
@@ -60,64 +60,10 @@ import org.junit.experimental.categories.Category;
 public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase {
 
   private static final String preAccessor = FilterPreAuthorization.class.getName() + ".create";
-
   private static final String postAccessor = FilterPostAuthorization.class.getName() + ".create";
 
-  private static class TestPostCredentialGenerator implements
-      TestCredentialGenerator {
-
-    public TestPostCredentialGenerator() {
-    }
-
-    public Properties getAllowedCredentials(OperationCode[] opCodes,
-        String[] regionNames, int[] keyIndices, int num) {
-
-      int userIndex = 1;
-      byte role = DummyAuthzCredentialGenerator.getRequiredRole(opCodes);
-      if (role == DummyAuthzCredentialGenerator.READER_ROLE) {
-        userIndex = keyIndices[0] + 1;
-      }
-      Properties props = new Properties();
-      props.setProperty(UserPasswordAuthInit.USER_NAME, "user" + userIndex);
-      props.setProperty(UserPasswordAuthInit.PASSWORD, "user" + userIndex);
-      return props;
-    }
-
-    public Properties getDisallowedCredentials(OperationCode[] opCodes,
-        String[] regionNames, int[] keyIndices, int num) {
-
-      int userIndex = 0;
-      for (int index = 0; index < keyIndices.length; ++index) {
-        if (keyIndices[index] != index) {
-          userIndex = index + 1;
-          break;
-        }
-      }
-      Properties props = new Properties();
-      props.setProperty(UserPasswordAuthInit.USER_NAME, "gemfire" + userIndex);
-      props.setProperty(UserPasswordAuthInit.PASSWORD, "gemfire" + userIndex);
-      return props;
-    }
-
-    public CredentialGenerator getCredentialGenerator() {
-
-      return null;
-    }
-  }
-
   @Override
-  public final void postSetUp() throws Exception {
-    final Host host = Host.getHost(0);
-    server1 = host.getVM(0);
-    server2 = host.getVM(1);
-    client1 = host.getVM(2);
-    client2 = host.getVM(3);
-
-    server1.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions ));
-    SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions);
-
+  protected final void postSetUpClientAuthorizationTestBase() throws Exception {
     //required by FilterPreAuthorization and FilterPostAuthorization. Normally,
     //this would be automatically registered in the static initializer, but with dunit
     //a previous test may have already loaded these classes. We clear the instantiators
@@ -131,268 +77,207 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase {
     server2.invoke(registerInstantiator);
   }
   
-  // Region: Utility and static functions invoked by the tests
+  @Test
+  public void testAllOpsObjectModWithFailover() {
+    OperationWithAction[] allOps = allOps();
 
-  private static Properties buildProperties(String authenticator,
-      Properties extraProps, String preAccessor, String postAccessor) {
+    TestPostCredentialGenerator tgen = new TestPostCredentialGenerator();
 
-    Properties authProps = new Properties();
-    if (authenticator != null) {
-      authProps.setProperty(
-          DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator);
-    }
-    if (preAccessor != null) {
-      authProps.setProperty(DistributionConfig.SECURITY_CLIENT_ACCESSOR_NAME,
-          preAccessor);
-    }
-    if (postAccessor != null) {
-      authProps.setProperty(
-          DistributionConfig.SECURITY_CLIENT_ACCESSOR_PP_NAME, postAccessor);
-    }
-    if (extraProps != null) {
-      authProps.putAll(extraProps);
-    }
-    return authProps;
-  }
+    CredentialGenerator credentialGenerator = new DummyCredentialGenerator();
+    credentialGenerator.init();
+    Properties extraProps = credentialGenerator.getSystemProperties();
+    Properties javaProps = credentialGenerator.getJavaProperties();
+    String authInit = credentialGenerator.getAuthInit();
+    String authenticator = credentialGenerator.getAuthenticator();
 
-  public static Integer createCacheServer(Integer mcastPort,
-      Properties authProps) {
+    LogWriterUtils.getLogWriter().info("testPutsGetsObjectModWithFailover: Using authinit: " + authInit);
+    LogWriterUtils.getLogWriter().info("testPutsGetsObjectModWithFailover: Using authenticator: " + authenticator);
+    LogWriterUtils.getLogWriter().info("testPutsGetsObjectModWithFailover: Using pre-operation accessor: " + preAccessor);
+    LogWriterUtils.getLogWriter().info("testPutsGetsObjectModWithFailover: Using post-operation accessor: " + postAccessor);
 
-    if (mcastPort == null) {
-      mcastPort = new Integer(AvailablePort
-          .getRandomAvailablePort(AvailablePort.SOCKET));
-    }
-    return SecurityTestUtil.createCacheServer(authProps, null, mcastPort, null,
-        null, Boolean.FALSE, new Integer(SecurityTestUtil.NO_EXCEPTION));
-  }
+    // Start servers with all required properties
+    Properties serverProps = buildProperties(authenticator, extraProps, preAccessor, postAccessor);
+    // Get ports for the servers
+    Integer port1 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+    Integer port2 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+
+    // Perform all the ops on the clients
+    List opBlock = new ArrayList();
+    Random rnd = new Random();
 
-  public static void createCacheServer(Integer loctorPort, Integer serverPort,
-      Properties authProps) {
+    for (int opNum = 0; opNum < allOps.length; ++opNum) {
+      // Start client with valid credentials as specified in OperationWithAction
+      OperationWithAction currentOp = allOps[opNum];
+      if (currentOp.equals(OperationWithAction.OPBLOCK_END) || currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
+        // End of current operation block; execute all the operations on the servers with failover
+        if (opBlock.size() > 0) {
+          // Start the first server and execute the operation block
+          server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port1, serverProps, javaProps ));
+          server2.invoke(() -> SecurityTestUtil.closeCache());
+          executeOpBlock(opBlock, port1, port2, authInit, extraProps, null, tgen, rnd);
+          if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
+            // Failover to the second server and run the block again
+            server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port2, serverProps, javaProps ));
+            server1.invoke(() -> SecurityTestUtil.closeCache());
+            executeOpBlock(opBlock, port1, port2, authInit, extraProps, null, tgen, rnd);
+          }
+          opBlock.clear();
+        }
 
-    if (loctorPort == null) {
-      loctorPort = new Integer(AvailablePort
-          .getRandomAvailablePort(AvailablePort.SOCKET));
+      } else {
+        currentOp.setOpNum(opNum);
+        opBlock.add(currentOp);
+      }
     }
-    SecurityTestUtil.createCacheServer(authProps, null, loctorPort, null,
-        serverPort, Boolean.FALSE, new Integer(SecurityTestUtil.NO_EXCEPTION));
   }
 
-  @Test
-  public void testAllOpsObjectModWithFailover() {
-
-    OperationWithAction[] allOps = {
+  private OperationWithAction[] allOps() {
+    return new OperationWithAction[] {
         // Perform CREATE and verify with GET
         new OperationWithAction(OperationCode.PUT, 1, OpFlags.NONE, 8),
-        // For second client connect with valid credentials for key2, key4,
-        // key6, key8 and check that other keys are not accessible
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.CHECK_NOKEY,
-            new int[] { 1, 3, 5, 7 }),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.CHECK_NOKEY
-            | OpFlags.USE_OLDCONN | OpFlags.CHECK_NOTAUTHZ, new int[] { 0, 2,
-            4, 6 }),
-        // For third client check that key3, key6 are accessible but others are
-        // not
-        new OperationWithAction(OperationCode.GET, 3, OpFlags.CHECK_NOKEY,
-            new int[] { 2, 5 }),
-        new OperationWithAction(OperationCode.GET, 3, OpFlags.CHECK_NOKEY
-            | OpFlags.USE_OLDCONN | OpFlags.CHECK_NOTAUTHZ, new int[] { 0, 1,
-            3, 4, 6, 7 }),
-
-        // OPBLOCK_END indicates end of an operation block that needs to
-        // be executed on each server when doing failover
+        // For second client connect with valid credentials for key2, key4, key6, key8 and check that other KEYS are not accessible
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.CHECK_NOKEY, new int[]{1, 3, 5, 7}),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.CHECK_NOKEY | OpFlags.USE_OLDCONN | OpFlags.CHECK_NOTAUTHZ, new int[]{0, 2, 4, 6}),
+        // For third client check that key3, key6 are accessible but others are not
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.CHECK_NOKEY, new int[]{2, 5}),
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.CHECK_NOKEY | OpFlags.USE_OLDCONN | OpFlags.CHECK_NOTAUTHZ, new int[]{0, 1, 3, 4, 6, 7}),
+
+        // OPBLOCK_END indicates end of an operation block that needs to be executed on each server when doing failover
         OperationWithAction.OPBLOCK_END,
 
         // Perform UPDATE and verify with GET
-        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, 8),
-        // For second client check that key2, key4, key6, key8 are accessible
-        // but others are not
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, new int[] { 1, 3, 5, 7 }),
-        new OperationWithAction(OperationCode.GET, 2,
-            OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL | OpFlags.CHECK_NOKEY
-                | OpFlags.CHECK_NOTAUTHZ, new int[] { 0, 2, 4, 6 }),
-        // For third client check that key3, key6 are accessible but others are
-        // not
-        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, new int[] { 2, 5 }),
-        new OperationWithAction(OperationCode.GET, 3,
-            OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL | OpFlags.CHECK_NOKEY
-                | OpFlags.CHECK_NOTAUTHZ, new int[] { 0, 1, 3, 4, 6, 7 }),
+        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, 8),
+        // For second client check that key2, key4, key6, key8 are accessible but others are not
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, new int[]{1, 3, 5, 7}),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL | OpFlags.CHECK_NOKEY | OpFlags.CHECK_NOTAUTHZ, new int[]{0, 2, 4, 6}),
+        // For third client check that key3, key6 are accessible but others are not
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, new int[]{2, 5}),
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL | OpFlags.CHECK_NOKEY | OpFlags.CHECK_NOTAUTHZ, new int[]{0, 1, 3, 4, 6, 7}),
 
         OperationWithAction.OPBLOCK_END,
 
         // Perform UPDATE and verify with GET_ALL
-        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, 8),
-        // For second client check that key2, key4, key6, key8 are accessible
-        // but others are not; getAll test in doOp uses a combination of local
-        // entries and remote fetches
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL | OpFlags.USE_ALL_KEYS,
-            new int[] { 1, 3, 5, 7 }),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL | OpFlags.USE_ALL_KEYS | OpFlags.CHECK_NOKEY
-            | OpFlags.CHECK_FAIL, new int[] { 0, 2, 4, 6 }),
-        // For third client check that key3, key6 are accessible but others are
-        // not
-        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL | OpFlags.USE_ALL_KEYS, new int[] { 2, 5 }),
-        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL | OpFlags.USE_ALL_KEYS | OpFlags.CHECK_NOKEY
-            | OpFlags.CHECK_FAIL, new int[] { 0, 1, 3, 4, 6, 7 }),
-
-        // locally destroy the keys to also test create after failover
-        new OperationWithAction(OperationCode.DESTROY, 1, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP, 8),
+        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, 8),
+        // For second client check that key2, key4, key6, key8 are accessible but others are not; getAll test in doOp uses a combination of local entries and remote fetches
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL | OpFlags.USE_ALL_KEYS, new int[]{1, 3, 5, 7}),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL | OpFlags.USE_ALL_KEYS | OpFlags.CHECK_NOKEY | OpFlags.CHECK_FAIL, new int[]{0, 2, 4, 6}),
+        // For third client check that key3, key6 are accessible but others are not
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL | OpFlags.USE_ALL_KEYS, new int[]{2, 5}),
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL | OpFlags.USE_ALL_KEYS | OpFlags.CHECK_NOKEY | OpFlags.CHECK_FAIL, new int[]{0, 1, 3, 4, 6, 7}),
+
+        // locally destroy the KEYS to also test create after failover
+        new OperationWithAction(OperationCode.DESTROY, 1, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 8),
 
         OperationWithAction.OPBLOCK_END,
 
         // Perform PUTALL and verify with GET
-        new OperationWithAction(OperationCode.PUTALL, 1, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, 8),
-        // For second client check that key2, key4, key6, key8 are accessible
-        // but others are not
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, new int[] { 1, 3, 5, 7 }),
-        new OperationWithAction(OperationCode.GET, 2,
-            OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL | OpFlags.CHECK_NOKEY
-                | OpFlags.CHECK_NOTAUTHZ, new int[] { 0, 2, 4, 6 }),
-        // For third client check that key3, key6 are accessible but others are
-        // not
-        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, new int[] { 2, 5 }),
-        new OperationWithAction(OperationCode.GET, 3,
-            OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL | OpFlags.CHECK_NOKEY
-                | OpFlags.CHECK_NOTAUTHZ, new int[] { 0, 1, 3, 4, 6, 7 }),
+        new OperationWithAction(OperationCode.PUTALL, 1, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, 8),
+        // For second client check that key2, key4, key6, key8 are accessible but others are not
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, new int[]{1, 3, 5, 7}),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL | OpFlags.CHECK_NOKEY | OpFlags.CHECK_NOTAUTHZ, new int[]{0, 2, 4, 6}),
+        // For third client check that key3, key6 are accessible but others are not
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, new int[]{2, 5}),
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL | OpFlags.CHECK_NOKEY | OpFlags.CHECK_NOTAUTHZ, new int[]{0, 1, 3, 4, 6, 7}),
 
         OperationWithAction.OPBLOCK_END,
-        
+
         // Test UPDATE and verify with a QUERY
         new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN, 8),
-        // For second client check that key2, key4, key6, key8 are accessible
-        // but others are not
-        new OperationWithAction(OperationCode.QUERY, 2, OpFlags.USE_OLDCONN,
-            new int[] { 1, 3, 5, 7 }),
-        new OperationWithAction(OperationCode.QUERY, 2, OpFlags.USE_OLDCONN
-            | OpFlags.CHECK_FAIL, new int[] { 0, 2, 4, 6 }),
-        // For third client check that key3, key6 are accessible but others are
-        // not
-        new OperationWithAction(OperationCode.QUERY, 3, OpFlags.USE_OLDCONN,
-            new int[] { 2, 5 }),
-        new OperationWithAction(OperationCode.QUERY, 3, OpFlags.USE_OLDCONN
-            | OpFlags.CHECK_FAIL, new int[] { 0, 1, 3, 4, 6, 7 }),
+        // For second client check that key2, key4, key6, key8 are accessible but others are not
+        new OperationWithAction(OperationCode.QUERY, 2, OpFlags.USE_OLDCONN, new int[]{1, 3, 5, 7}),
+        new OperationWithAction(OperationCode.QUERY, 2, OpFlags.USE_OLDCONN | OpFlags.CHECK_FAIL, new int[]{0, 2, 4, 6}),
+        // For third client check that key3, key6 are accessible but others are not
+        new OperationWithAction(OperationCode.QUERY, 3, OpFlags.USE_OLDCONN, new int[]{2, 5}),
+        new OperationWithAction(OperationCode.QUERY, 3, OpFlags.USE_OLDCONN | OpFlags.CHECK_FAIL, new int[]{0, 1, 3, 4, 6, 7}),
 
         OperationWithAction.OPBLOCK_END,
 
         // Test UPDATE and verify with a EXECUTE_CQ initial results
-        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, 8),
-        // For second client check that key2, key4, key6, key8 are accessible
-        // but others are not
-        new OperationWithAction(OperationCode.EXECUTE_CQ, 2,
-            OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, new int[] { 1, 3, 5, 7 }),
-        new OperationWithAction(OperationCode.CLOSE_CQ, 2, OpFlags.USE_OLDCONN,
-            1),
-        new OperationWithAction(OperationCode.EXECUTE_CQ, 2,
-            OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL | OpFlags.CHECK_FAIL,
-            new int[] { 0, 2, 4, 6 }),
-        new OperationWithAction(OperationCode.CLOSE_CQ, 2, OpFlags.USE_OLDCONN,
-            1),
-        // For third client check that key3, key6 are accessible but others are
-        // not
-        new OperationWithAction(OperationCode.EXECUTE_CQ, 3,
-            OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, new int[] { 2, 5 }),
-        new OperationWithAction(OperationCode.CLOSE_CQ, 3, OpFlags.USE_OLDCONN,
-            1),
-        new OperationWithAction(OperationCode.EXECUTE_CQ, 3,
-            OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL | OpFlags.CHECK_FAIL,
-            new int[] { 0, 1, 3, 4, 6, 7 }),
-        new OperationWithAction(OperationCode.CLOSE_CQ, 3, OpFlags.USE_OLDCONN,
-            1),
-
-        OperationWithAction.OPBLOCK_END };
-
-    TestPostCredentialGenerator tgen = new TestPostCredentialGenerator();
+        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, 8),
+        // For second client check that key2, key4, key6, key8 are accessible but others are not
+        new OperationWithAction(OperationCode.EXECUTE_CQ, 2, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, new int[]{1, 3, 5, 7}),
+        new OperationWithAction(OperationCode.CLOSE_CQ, 2, OpFlags.USE_OLDCONN, 1),
+        new OperationWithAction(OperationCode.EXECUTE_CQ, 2, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL | OpFlags.CHECK_FAIL, new int[]{0, 2, 4, 6}),
+        new OperationWithAction(OperationCode.CLOSE_CQ, 2, OpFlags.USE_OLDCONN, 1),
+        // For third client check that key3, key6 are accessible but others are not
+        new OperationWithAction(OperationCode.EXECUTE_CQ, 3, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, new int[]{2, 5}),
+        new OperationWithAction(OperationCode.CLOSE_CQ, 3, OpFlags.USE_OLDCONN, 1),
+        new OperationWithAction(OperationCode.EXECUTE_CQ, 3, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL | OpFlags.CHECK_FAIL, new int[]{0, 1, 3, 4, 6, 7}),
+        new OperationWithAction(OperationCode.CLOSE_CQ, 3, OpFlags.USE_OLDCONN, 1),
+
+        OperationWithAction.OPBLOCK_END};
+  }
 
-    CredentialGenerator gen = new DummyCredentialGenerator();
-    gen.init();
-    Properties extraProps = gen.getSystemProperties();
-    Properties javaProps = gen.getJavaProperties();
-    String authInit = gen.getAuthInit();
-    String authenticator = gen.getAuthenticator();
-
-    LogWriterUtils.getLogWriter().info(
-        "testPutsGetsObjectModWithFailover: Using authinit: " + authInit);
-    LogWriterUtils.getLogWriter().info(
-        "testPutsGetsObjectModWithFailover: Using authenticator: "
-            + authenticator);
-    LogWriterUtils.getLogWriter().info(
-        "testPutsGetsObjectModWithFailover: Using pre-operation accessor: "
-            + preAccessor);
-    LogWriterUtils.getLogWriter().info(
-        "testPutsGetsObjectModWithFailover: Using post-operation accessor: "
-            + postAccessor);
 
-    // Start servers with all required properties
-    Properties serverProps = buildProperties(authenticator, extraProps,
-        preAccessor, postAccessor);
-    // Get ports for the servers
-    Integer port1 = new Integer(AvailablePort
-        .getRandomAvailablePort(AvailablePort.SOCKET));
-    Integer port2 = new Integer(AvailablePort
-        .getRandomAvailablePort(AvailablePort.SOCKET));
-
-    // Perform all the ops on the clients
-    List opBlock = new ArrayList();
-    Random rnd = new Random();
-    for (int opNum = 0; opNum < allOps.length; ++opNum) {
-      // Start client with valid credentials as specified in
-      // OperationWithAction
-      OperationWithAction currentOp = allOps[opNum];
-      if (currentOp.equals(OperationWithAction.OPBLOCK_END)
-          || currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
-        // End of current operation block; execute all the operations
-        // on the servers with failover
-        if (opBlock.size() > 0) {
-          // Start the first server and execute the operation block
-          server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
-                  SecurityTestUtil.getLocatorPort(), port1, serverProps,
-                  javaProps ));
-          server2.invoke(() -> SecurityTestUtil.closeCache());
-          executeOpBlock(opBlock, port1, port2, authInit, extraProps, null,
-              tgen, rnd);
-          if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
-            // Failover to the second server and run the block again
-            server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
-                    SecurityTestUtil.getLocatorPort(), port2, serverProps,
-                    javaProps ));
-            server1.invoke(() -> SecurityTestUtil.closeCache());
-            executeOpBlock(opBlock, port1, port2, authInit, extraProps, null,
-                tgen, rnd);
-          }
-          opBlock.clear();
-        }
-      }
-      else {
-        currentOp.setOpNum(opNum);
-        opBlock.add(currentOp);
-      }
+  private Properties buildProperties(String authenticator, Properties extraProps, String preAccessor, String postAccessor) {
+    Properties authProps = new Properties();
+    if (authenticator != null) {
+      authProps.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator);
     }
+    if (preAccessor != null) {
+      authProps.setProperty(DistributionConfig.SECURITY_CLIENT_ACCESSOR_NAME, preAccessor);
+    }
+    if (postAccessor != null) {
+      authProps.setProperty(DistributionConfig.SECURITY_CLIENT_ACCESSOR_PP_NAME, postAccessor);
+    }
+    if (extraProps != null) {
+      authProps.putAll(extraProps);
+    }
+    return authProps;
   }
 
   private static class MyInstantiator extends Instantiator {
 
-    public MyInstantiator(Class clazz, int classId) {
-      super(clazz, classId);
-    }
     public MyInstantiator() {
       this(ObjectWithAuthz.class, ObjectWithAuthz.CLASSID);
     }
 
+    public MyInstantiator(Class clazz, int classId) {
+      super(clazz, classId);
+    }
+
+    @Override
     public DataSerializable newInstance() {
       return new ObjectWithAuthz();
     }
   }
 
+  private static class TestPostCredentialGenerator implements TestCredentialGenerator {
+
+    public TestPostCredentialGenerator() {
+    }
+
+    @Override
+    public Properties getAllowedCredentials(OperationCode[] opCodes, String[] regionNames, int[] keyIndices, int num) {
+      int userIndex = 1;
+      byte role = DummyAuthzCredentialGenerator.getRequiredRole(opCodes);
+      if (role == DummyAuthzCredentialGenerator.READER_ROLE) {
+        userIndex = keyIndices[0] + 1;
+      }
+      Properties props = new Properties();
+      props.setProperty(UserPasswordAuthInit.USER_NAME, "user" + userIndex);
+      props.setProperty(UserPasswordAuthInit.PASSWORD, "user" + userIndex);
+      return props;
+    }
+
+    @Override
+    public Properties getDisallowedCredentials(OperationCode[] opCodes, String[] regionNames, int[] keyIndices, int num) {
+      int userIndex = 0;
+      for (int index = 0; index < keyIndices.length; ++index) {
+        if (keyIndices[index] != index) {
+          userIndex = index + 1;
+          break;
+        }
+      }
+      Properties props = new Properties();
+      props.setProperty(UserPasswordAuthInit.USER_NAME, "gemfire" + userIndex);
+      props.setProperty(UserPasswordAuthInit.PASSWORD, "gemfire" + userIndex);
+      return props;
+    }
+
+    @Override
+    public CredentialGenerator getCredentialGenerator() {
+      return null;
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5a321ffd/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
index fa032ed..6bca85f 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
@@ -29,9 +29,11 @@ import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
 import com.gemstone.gemfire.cache.query.CqAttributes;
 import com.gemstone.gemfire.cache.query.CqAttributesFactory;
 import com.gemstone.gemfire.cache.query.CqException;
+import com.gemstone.gemfire.cache.query.CqExistsException;
 import com.gemstone.gemfire.cache.query.CqListener;
 import com.gemstone.gemfire.cache.query.CqQuery;
 import com.gemstone.gemfire.cache.query.QueryService;
+import com.gemstone.gemfire.cache.query.RegionNotFoundException;
 import com.gemstone.gemfire.cache.query.SelectResults;
 import com.gemstone.gemfire.cache.query.cq.dunit.CqQueryTestListener;
 import com.gemstone.gemfire.cache.query.internal.cq.ClientCQImpl;
@@ -57,37 +59,28 @@ import org.junit.experimental.categories.Category;
  * This is for multiuser-authentication
  */
 @Category(DistributedTest.class)
-public class ClientCQPostAuthorizationDUnitTest extends
-    ClientAuthorizationTestBase {
+public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestBase {
 
   private Map<String, String> cqNameToQueryStrings = new HashMap<String, String>();
 
   @Override
-  public final void postSetUp() throws Exception {
+  protected final void preSetUpClientAuthorizationTestBase() throws Exception {
     getSystem();
     Invoke.invokeInEveryVM(new SerializableRunnable("getSystem") {
       public void run() {
         getSystem();
       }
     });
+  }
 
-    final Host host = Host.getHost(0);
-    server1 = host.getVM(0);
-    server2 = host.getVM(1);
-    client1 = host.getVM(2);
-    client2 = host.getVM(3);
-
-    server1.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions ));
-    SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions);
-
+  @Override
+  protected final void postSetUpClientAuthorizationTestBase() throws Exception {
     this.cqNameToQueryStrings.put("CQ_0", "SELECT * FROM ");
     this.cqNameToQueryStrings.put("CQ_1", "SELECT * FROM ");
   }
 
   @Override
-  public final void preTearDown() throws Exception {
+  public final void preTearDownClientAuthorizationTestBase() throws Exception {
     client1.invoke(() -> SecurityTestUtil.closeCache());
     client2.invoke(() -> SecurityTestUtil.closeCache());
     server1.invoke(() -> SecurityTestUtil.closeCache());
@@ -104,8 +97,7 @@ public class ClientCQPostAuthorizationDUnitTest extends
      * Client2 does some operations on the region which satisfies both the CQs
      * Validate that listeners for both the CQs are invoked.
      */
-    doStartUp(Integer.valueOf(2), Integer.valueOf(5), new Boolean[] {true,
-      true});
+    doStartUp(Integer.valueOf(2), Integer.valueOf(5), new Boolean[] {true, true});
   }
 
   @Test
@@ -117,8 +109,7 @@ public class ClientCQPostAuthorizationDUnitTest extends
      * Client2 does some operations on the region which satisfies both the CQs
      * Validate that listeners for none of the CQs are invoked.
      */
-    doStartUp(Integer.valueOf(2), Integer.valueOf(5), new Boolean[] {false,
-      false});
+    doStartUp(Integer.valueOf(2), Integer.valueOf(5), new Boolean[] {false, false});
   }
 
   @Test
@@ -131,8 +122,7 @@ public class ClientCQPostAuthorizationDUnitTest extends
      * Client2 does some operations on the region which satisfies both the CQs
      * Validate that listener for User1's CQ is invoked but that for User2's CQ is not invoked.
      */
-    doStartUp(Integer.valueOf(2), Integer.valueOf(5), new Boolean[] {true,
-        false});
+    doStartUp(Integer.valueOf(2), Integer.valueOf(5), new Boolean[] {true, false});
   }
 
   @Test
@@ -147,145 +137,108 @@ public class ClientCQPostAuthorizationDUnitTest extends
      * Client2 does some operations on the region which satisfies both the CQs
      * Validate that listeners for both the CQs are get updates.
      */
-    doStartUp(Integer.valueOf(2), Integer.valueOf(5), new Boolean[] {true,
-      true}, Boolean.TRUE);
+    doStartUp(Integer.valueOf(2), Integer.valueOf(5), new Boolean[] {true, true}, Boolean.TRUE);
   }
 
-  private void doStartUp(Integer numOfUsers, Integer numOfPuts,
-      Boolean[] postAuthzAllowed) throws Exception {
+  private void doStartUp(Integer numOfUsers, Integer numOfPuts, Boolean[] postAuthzAllowed) throws Exception {
     doStartUp(numOfUsers, numOfPuts, postAuthzAllowed, Boolean.FALSE /* failover */);
   }
 
-  private void doStartUp(Integer numOfUsers, Integer numOfPuts,
-      Boolean[] postAuthzAllowed, Boolean failover) throws Exception {
-      AuthzCredentialGenerator gen = this.getXmlAuthzGenerator();
-      CredentialGenerator cGen = gen.getCredentialGenerator();
-      Properties extraAuthProps = cGen.getSystemProperties();
-      Properties javaProps = cGen.getJavaProperties();
-      Properties extraAuthzProps = gen.getSystemProperties();
-      String authenticator = cGen.getAuthenticator();
-      String accessor = gen.getAuthorizationCallback();
-      String authInit = cGen.getAuthInit();
-      TestAuthzCredentialGenerator tgen = new TestAuthzCredentialGenerator(gen);
-
-      Properties serverProps = buildProperties(authenticator, accessor, true,
-          extraAuthProps, extraAuthzProps);
-
-      Properties opCredentials;
-      cGen = tgen.getCredentialGenerator();
-      final Properties javaProps2;
-      if (cGen != null) {
-        javaProps2 = cGen.getJavaProperties();
+  private void doStartUp(Integer numOfUsers, Integer numOfPuts, Boolean[] postAuthzAllowed, Boolean failover) throws Exception {
+    AuthzCredentialGenerator authzGenerator = getXmlAuthzGenerator();
+    CredentialGenerator credentialGenerator = authzGenerator.getCredentialGenerator();
+    Properties extraAuthProps = credentialGenerator.getSystemProperties();
+    Properties javaProps = credentialGenerator.getJavaProperties();
+    Properties extraAuthzProps = authzGenerator.getSystemProperties();
+    String authenticator = credentialGenerator.getAuthenticator();
+    String accessor = authzGenerator.getAuthorizationCallback();
+    String authInit = credentialGenerator.getAuthInit();
+    TestAuthzCredentialGenerator tgen = new TestAuthzCredentialGenerator(authzGenerator);
+
+    Properties serverProps = buildProperties(authenticator, accessor, true, extraAuthProps, extraAuthzProps);
+
+    Properties opCredentials;
+    credentialGenerator = tgen.getCredentialGenerator();
+    final Properties javaProps2 = credentialGenerator == null ? null : credentialGenerator.getJavaProperties();
+
+    int[] indices = new int[numOfPuts];
+    for (int index = 0; index < numOfPuts; ++index) {
+      indices[index] = index;
+    }
+
+    Random rnd = new Random();
+    Properties[] authProps = new Properties[numOfUsers];
+    for (int i = 0; i < numOfUsers; i++) {
+      int rand = rnd.nextInt(100) + 1;
+      if (postAuthzAllowed[i]) {
+        opCredentials = tgen.getAllowedCredentials(new OperationCode[] {OperationCode.EXECUTE_CQ, OperationCode.GET}, /* For callback, GET should be allowed */ new String[] {regionName}, indices, rand);
       } else {
-        javaProps2 = null;
+        opCredentials = tgen.getDisallowedCredentials(new OperationCode[] { OperationCode.GET}, /* For callback, GET should be disallowed */ new String[] {regionName}, indices, rand);
       }
+      authProps[i] = SecurityTestUtil.concatProperties(new Properties[] {opCredentials, extraAuthProps, extraAuthzProps});
+    }
 
-      int[] indices = new int[numOfPuts];
-      for (int index = 0; index < numOfPuts; ++index) {
-        indices[index] = index;
-      }
+    // Get ports for the servers
+    Integer port1 = Integer.valueOf(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+    Integer port2 = Integer.valueOf(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+    Integer locatorPort = Integer.valueOf(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
 
-      Random rnd = new Random();
-      Properties[] authProps = new Properties[numOfUsers];
-      for (int i = 0; i < numOfUsers; i++) {
-        int rand = rnd.nextInt(100) + 1;
-        if (postAuthzAllowed[i]) {
-          opCredentials = tgen.getAllowedCredentials(new OperationCode[] {
-              OperationCode.EXECUTE_CQ, OperationCode.GET}, // For callback, GET should be allowed
-              new String[] {regionName}, indices, rand);
-//          authProps[i] = gen.getAllowedCredentials(
-//              new OperationCode[] {OperationCode.EXECUTE_CQ},
-//              new String[] {regionName}, rnd.nextInt(100) + 1);
-        } else {
-          opCredentials = tgen.getDisallowedCredentials(new OperationCode[] {
-              OperationCode.GET}, // For callback, GET should be disallowed
-              new String[] {regionName}, indices, rand);
-//          authProps[i] = gen.getDisallowedCredentials(
-//              new OperationCode[] {OperationCode.EXECUTE_CQ},
-//              new String[] {regionName}, rnd.nextInt(100) + 1);
-        }
-        authProps[i] = SecurityTestUtil.concatProperties(new Properties[] {
-            opCredentials, extraAuthProps, extraAuthzProps});
+    // Close down any running servers
+    server1.invoke(() -> SecurityTestUtil.closeCache());
+    server2.invoke(() -> SecurityTestUtil.closeCache());
+
+    server1.invoke(() -> createServerCache(serverProps, javaProps, locatorPort, port1));
+    client1.invoke(() -> createClientCache(javaProps2, authInit, authProps, new Integer[] {port1, port2}, numOfUsers, postAuthzAllowed));
+    client2.invoke(() -> createClientCache(javaProps2, authInit, authProps, new Integer[] {port1, port2}, numOfUsers, postAuthzAllowed));
+
+    client1.invoke(() -> createCQ(numOfUsers));
+    client1.invoke(() -> executeCQ(numOfUsers, new Boolean[] {false, false}, numOfPuts, new String[numOfUsers], postAuthzAllowed));
+
+    client2.invoke(() -> doPuts(numOfPuts, Boolean.TRUE/* put last key */));
+
+    if (!postAuthzAllowed[0]) {
+      // There is no point waiting as no user is authorized to receive cq events.
+      try {Thread.sleep(1000);} catch (InterruptedException ie) {} // TODO: replace with Awaitility
+    } else {
+      client1.invoke(() -> waitForLastKey(Integer.valueOf(0)));
+      if (postAuthzAllowed[1]) {
+        client1.invoke(() -> waitForLastKey(Integer.valueOf(1)));
       }
+    }
 
-      // Get ports for the servers
-      Integer port1 = Integer.valueOf(AvailablePort
-          .getRandomAvailablePort(AvailablePort.SOCKET));
-      Integer port2 = Integer.valueOf(AvailablePort
-          .getRandomAvailablePort(AvailablePort.SOCKET));
-      Integer locatorPort = Integer.valueOf(AvailablePort
-          .getRandomAvailablePort(AvailablePort.SOCKET));
-      // Close down any running servers
+    client1.invoke(() -> checkCQListeners(numOfUsers, postAuthzAllowed, numOfPuts + 1/* last key */, 0, !failover));
+    if (failover) {
+      server2.invoke(() -> createServerCache(serverProps, javaProps, locatorPort, port2));
       server1.invoke(() -> SecurityTestUtil.closeCache());
-      server2.invoke(() -> SecurityTestUtil.closeCache());
 
-      server1.invoke(() -> createServerCache(serverProps, javaProps, locatorPort, port1));
-      client1.invoke(() -> createClientCache(javaProps2, authInit, authProps,
-              new Integer[] {port1, port2}, numOfUsers, postAuthzAllowed));
-      client2.invoke(() -> createClientCache(javaProps2, authInit, authProps,
-              new Integer[] {port1, port2}, numOfUsers, postAuthzAllowed));
-
-      client1.invoke(() -> createCQ(numOfUsers));
-      client1.invoke(() -> executeCQ(numOfUsers, new Boolean[] {false, false}, numOfPuts,
-              new String[numOfUsers], postAuthzAllowed));
+      // Allow time for client1 to register its CQs on server2
+      server2.invoke(() -> allowCQsToRegister(Integer.valueOf(2)));
 
       client2.invoke(() -> doPuts(numOfPuts, Boolean.TRUE/* put last key */));
-      if (!postAuthzAllowed[0]) {
-        // There is no point waiting as no user is authorized to receive cq events.
-        try {Thread.sleep(1000);} catch (InterruptedException ie) {}
-      } else {
-        client1.invoke(() -> waitForLastKey(Integer.valueOf(0)));
-        if (postAuthzAllowed[1]) {
-          client1.invoke(() -> waitForLastKey(Integer.valueOf(1)));
-        }
-      }
-      client1.invoke(() -> checkCQListeners(numOfUsers, postAuthzAllowed,
-              numOfPuts + 1/* last key */, 0, !failover));
-      if (failover) {
-        server2.invoke(() -> createServerCache(serverProps, javaProps, locatorPort, port2));
-        server1.invoke(() -> SecurityTestUtil.closeCache());
-
-        // Allow time for client1 to register its CQs on server2
-        server2.invoke(() -> allowCQsToRegister(Integer.valueOf(2)));
-
-        client2.invoke(() -> doPuts(numOfPuts, Boolean.TRUE/* put last key */));
-        client1.invoke(() -> waitForLastKeyUpdate(Integer.valueOf(0)));
-        client1.invoke(() -> checkCQListeners(numOfUsers, postAuthzAllowed,
-                numOfPuts + 1/* last key */, numOfPuts + 1/* last key */,
-                Boolean.TRUE));
-      }
+      client1.invoke(() -> waitForLastKeyUpdate(Integer.valueOf(0)));
+      client1.invoke(() -> checkCQListeners(numOfUsers, postAuthzAllowed, numOfPuts + 1/* last key */, numOfPuts + 1/* last key */, Boolean.TRUE));
+    }
   }
 
-  private void createServerCache(Properties serverProps,
-      Properties javaProps, Integer serverPort) {
-    Integer locatorPort = Integer.valueOf(AvailablePort
-        .getRandomAvailablePort(AvailablePort.SOCKET));
-    SecurityTestUtil.createCacheServer((Properties)serverProps, javaProps,
-        locatorPort, null, serverPort, Boolean.TRUE, Integer.valueOf(
-            SecurityTestUtil.NO_EXCEPTION));
+  private void createServerCache(Properties serverProps, Properties javaProps, Integer serverPort) {
+    Integer locatorPort = Integer.valueOf(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+    SecurityTestUtil.createCacheServer((Properties)serverProps, javaProps, locatorPort, null, serverPort, Boolean.TRUE, Integer.valueOf(SecurityTestUtil.NO_EXCEPTION));
   }
 
-  private void createServerCache(Properties serverProps,
-        Properties javaProps, Integer locatorPort, Integer serverPort) {
-    SecurityTestUtil.createCacheServer((Properties)serverProps, javaProps,
-        locatorPort, null, serverPort, Boolean.TRUE, Integer.valueOf(
-            SecurityTestUtil.NO_EXCEPTION));
+  private void createServerCache(Properties serverProps, Properties javaProps, Integer locatorPort, Integer serverPort) {
+    SecurityTestUtil.createCacheServer((Properties)serverProps, javaProps, locatorPort, null, serverPort, Boolean.TRUE, Integer.valueOf(SecurityTestUtil.NO_EXCEPTION));
   }
 
-  private void createClientCache(Properties javaProps, String authInit,
-      Properties[] authProps, Integer ports[], Integer numOfUsers,
-      Boolean[] postAuthzAllowed) {
-    SecurityTestUtil.createCacheClientForMultiUserMode(numOfUsers, authInit,
-        authProps, javaProps, ports, null, Boolean.FALSE,
-        SecurityTestUtil.NO_EXCEPTION);
+  private void createClientCache(Properties javaProps, String authInit, Properties[] authProps, Integer ports[], Integer numOfUsers, Boolean[] postAuthzAllowed) {
+    SecurityTestUtil.createCacheClientForMultiUserMode(numOfUsers, authInit, authProps, javaProps, ports, null, Boolean.FALSE, SecurityTestUtil.NO_EXCEPTION);
   }
 
-  private void createCQ(Integer num) {
+  private void createCQ(Integer num) throws CqException, CqExistsException {
     for (int i = 0; i < num; i++) {
       QueryService cqService = SecurityTestUtil.proxyCaches[i].getQueryService();
       String cqName = "CQ_" + i;
-      String queryStr = cqNameToQueryStrings.get(cqName)
-          + SecurityTestUtil.proxyCaches[i].getRegion(regionName).getFullPath();
+      String queryStr = cqNameToQueryStrings.get(cqName) + SecurityTestUtil.proxyCaches[i].getRegion(regionName).getFullPath();
+
       // Create CQ Attributes.
       CqAttributesFactory cqf = new CqAttributesFactory();
       CqListener[] cqListeners = {new CqQueryTestListener(LogWriterUtils.getLogWriter())};
@@ -295,55 +248,33 @@ public class ClientCQPostAuthorizationDUnitTest extends
       CqAttributes cqa = cqf.create();
 
       // Create CQ.
-      try {
-        CqQuery cq1 = cqService.newCq(cqName, queryStr, cqa);
-        assertTrue("newCq() state mismatch", cq1.getState().isStopped());
-      } catch (Exception ex) {
-        AssertionError err = new AssertionError("Failed to create CQ " + cqName
-            + " . ");
-        err.initCause(ex);
-        LogWriterUtils.getLogWriter().info("CqService is :" + cqService, err);
-        throw err;
-      }
+      CqQuery cq1 = cqService.newCq(cqName, queryStr, cqa);
+      assertTrue("newCq() state mismatch", cq1.getState().isStopped());
     }
   }
 
-  private void executeCQ(Integer num, Boolean[] initialResults,
-      Integer expectedResultsSize, String[] expectedErr, Boolean[] postAuthzAllowed) {
+  private void executeCQ(Integer num, Boolean[] initialResults, Integer expectedResultsSize, String[] expectedErr, Boolean[] postAuthzAllowed) throws RegionNotFoundException {
     InternalLogWriter logWriter = InternalDistributedSystem.getStaticInternalLogWriter();
+
     for (int i = 0; i < num; i++) {
       try {
         if (expectedErr[i] != null) {
-          logWriter.info(
-              "<ExpectedException action=add>" + expectedErr[i]
-                  + "</ExpectedException>");
+          logWriter.info("<ExpectedException action=add>" + expectedErr[i] + "</ExpectedException>");
         }
         CqQuery cq1 = null;
         String cqName = "CQ_" + i;
-        String queryStr = cqNameToQueryStrings.get(cqName)
-            + SecurityTestUtil.proxyCaches[i].getRegion(regionName)
-                .getFullPath();
-        QueryService cqService = SecurityTestUtil.proxyCaches[i]
-            .getQueryService();
+        String queryStr = cqNameToQueryStrings.get(cqName) + SecurityTestUtil.proxyCaches[i].getRegion(regionName).getFullPath();
+        QueryService cqService = SecurityTestUtil.proxyCaches[i].getQueryService();
 
         // Get CqQuery object.
-        try {
-          cq1 = cqService.getCq(cqName);
-          if (cq1 == null) {
-            LogWriterUtils.getLogWriter().info(
-                "Failed to get CqQuery object for CQ name: " + cqName);
-            fail("Failed to get CQ " + cqName);
-          } else {
-            LogWriterUtils.getLogWriter().info("Obtained CQ, CQ name: " + cq1.getName());
-            assertTrue("newCq() state mismatch", cq1.getState().isStopped());
-          }
-        } catch (Exception ex) {
-          LogWriterUtils.getLogWriter().info("CqService is :" + cqService);
-          LogWriterUtils.getLogWriter().error(ex);
-          AssertionError err = new AssertionError("Failed to execute CQ "
-              + cqName);
-          err.initCause(ex);
-          throw err;
+        cq1 = cqService.getCq(cqName);
+        if (cq1 == null) {
+          LogWriterUtils.getLogWriter().info(
+              "Failed to get CqQuery object for CQ name: " + cqName);
+          fail("Failed to get CQ " + cqName);
+        } else {
+          LogWriterUtils.getLogWriter().info("Obtained CQ, CQ name: " + cq1.getName());
+          assertTrue("newCq() state mismatch", cq1.getState().isStopped());
         }
 
         if (initialResults[i]) {
@@ -356,28 +287,17 @@ public class ClientCQPostAuthorizationDUnitTest extends
               LogWriterUtils.getLogWriter().info("Got expected exception for CQ " + cqName);
             } else {
               LogWriterUtils.getLogWriter().info("CqService is: " + cqService);
-              ce.printStackTrace();
-              AssertionError err = new AssertionError("Failed to execute CQ "
-                  + cqName);
-              err.initCause(ce);
-              throw err;
+              throw new AssertionError("Failed to execute CQ " + cqName, ce);
             }
-          } catch (Exception ex) {
-            LogWriterUtils.getLogWriter().info("CqService is: " + cqService);
-            ex.printStackTrace();
-            AssertionError err = new AssertionError("Failed to execute CQ "
-                + cqName);
-            err.initCause(ex);
-            throw err;
           }
           LogWriterUtils.getLogWriter().info("initial result size = " + cqResults.size());
-          assertTrue("executeWithInitialResults() state mismatch", cq1
-              .getState().isRunning());
+          assertTrue("executeWithInitialResults() state mismatch", cq1.getState().isRunning());
           if (expectedResultsSize >= 0) {
-            assertEquals("unexpected results size", expectedResultsSize
-                .intValue(), cqResults.size());
+            assertEquals("unexpected results size", expectedResultsSize.intValue(), cqResults.size());
           }
+
         } else {
+
           try {
             cq1.execute();
           } catch (CqException ce) {
@@ -386,11 +306,9 @@ public class ClientCQPostAuthorizationDUnitTest extends
             } else {
               LogWriterUtils.getLogWriter().info("CqService is: " + cqService);
               ce.printStackTrace();
-              AssertionError err = new AssertionError("Failed to execute CQ "
-                  + cqName);
-              err.initCause(ce);
-              throw err;
+              throw new AssertionError("Failed to execute CQ " + cqName, ce);
             }
+
           } catch (Exception ex) {
             AssertionError err = new AssertionError("Failed to execute CQ "
                 + cqName);
@@ -404,16 +322,13 @@ public class ClientCQPostAuthorizationDUnitTest extends
         }
       } finally {
         if (expectedErr[i] != null) {
-          logWriter.info(
-              "<ExpectedException action=remove>" + expectedErr[i]
-                  + "</ExpectedException>");
+          logWriter.info("<ExpectedException action=remove>" + expectedErr[i] + "</ExpectedException>");
         }
       }
     }
   }
 
   private void doPuts(Integer num, Boolean putLastKey) {
-//    Region region = GemFireCache.getInstance().getRegion(regionName);
     Region region = SecurityTestUtil.proxyCaches[0].getRegion(regionName);
     for (int i = 0; i < num; i++) {
       region.put("CQ_key"+i, "CQ_value"+i);
@@ -432,32 +347,14 @@ public class ClientCQPostAuthorizationDUnitTest extends
     String cqName = "CQ_" + cqIndex;
     QueryService qService = SecurityTestUtil.proxyCaches[cqIndex].getQueryService();
     ClientCQImpl cqQuery = (ClientCQImpl)qService.getCq(cqName);
-    ((CqQueryTestListener)cqQuery.getCqListeners()[0])
-        .waitForCreated("LAST_KEY");
-//    WaitCriterion wc = new WaitCriterion() {
-//      public boolean done() {
-//        Region region = GemFireCache.getInstance().getRegion(regionName);
-//        Region.Entry entry = region.getEntry("LAST_KEY");
-//        if (entry != null && entry.getValue() != null) {
-//          return false;
-//        } else if (entry.getValue() != null) {
-//          return true;
-//        }
-//        return false;
-//      }
-//      public String description() {
-//        return "Last key not received.";
-//      }
-//    };
-//    DistributedTestCase.waitForCriterion(wc, 60 * 1000, 100, false);
+    ((CqQueryTestListener)cqQuery.getCqListeners()[0]).waitForCreated("LAST_KEY");
   }
 
   private void waitForLastKeyUpdate(Integer cqIndex) {
     String cqName = "CQ_" + cqIndex;
     QueryService qService = SecurityTestUtil.proxyCaches[cqIndex].getQueryService();
     ClientCQImpl cqQuery = (ClientCQImpl)qService.getCq(cqName);
-    ((CqQueryTestListener)cqQuery.getCqListeners()[0])
-        .waitForUpdated("LAST_KEY");
+    ((CqQueryTestListener)cqQuery.getCqListeners()[0]).waitForUpdated("LAST_KEY");
   }
 
   private void allowCQsToRegister(Integer number) {
@@ -475,26 +372,22 @@ public class ClientCQPostAuthorizationDUnitTest extends
       }
 
       public String description() {
-        return num + "Waited for " + num
-            + " CQs to be registered on this server.";
+        return num + "Waited for " + num + " CQs to be registered on this server.";
       }
     };
     Wait.waitForCriterion(wc, 60 * 1000, 100, false);
   }
 
-  private void checkCQListeners(Integer numOfUsers,
-      Boolean[] expectedListenerInvocation, Integer createEventsSize,
-      Integer updateEventsSize, Boolean closeCache) {
+  private void checkCQListeners(Integer numOfUsers, Boolean[] expectedListenerInvocation, Integer createEventsSize, Integer updateEventsSize, Boolean closeCache) {
     for (int i = 0; i < numOfUsers; i++) {
       String cqName = "CQ_" + i;
       QueryService qService = SecurityTestUtil.proxyCaches[i].getQueryService();
       ClientCQImpl cqQuery = (ClientCQImpl)qService.getCq(cqName);
+
       if (expectedListenerInvocation[i]) {
         for (CqListener listener : cqQuery.getCqListeners()) {
-          assertEquals(createEventsSize.intValue(),
-              ((CqQueryTestListener)listener).getCreateEventCount());
-          assertEquals(updateEventsSize.intValue(),
-              ((CqQueryTestListener)listener).getUpdateEventCount());
+          assertEquals(createEventsSize.intValue(), ((CqQueryTestListener)listener).getCreateEventCount());
+          assertEquals(updateEventsSize.intValue(), ((CqQueryTestListener)listener).getUpdateEventCount());
         }
       } else {
         for (CqListener listener : cqQuery.getCqListeners()) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5a321ffd/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
index 519b76f..931a53e 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
@@ -50,72 +50,23 @@ public class ClientPostAuthorizationDUnitTest extends
   public RetryRule retryRule = new RetryRule();
 
   @Override
-  public final void postSetUp() throws Exception {
-    final Host host = Host.getHost(0);
-    server1 = host.getVM(0);
-    server2 = host.getVM(1);
-    client1 = host.getVM(2);
-    client2 = host.getVM(3);
-
-    server1.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions ));
-    SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions);
+  public final void preTearDownClientAuthorizationTestBase() throws Exception {
+    // close the clients first
+    client1.invoke(() -> SecurityTestUtil.closeCache());
+    client2.invoke(() -> SecurityTestUtil.closeCache());
+    SecurityTestUtil.closeCache();
+    // then close the servers
+    server1.invoke(() -> SecurityTestUtil.closeCache());
+    server2.invoke(() -> SecurityTestUtil.closeCache());
   }
 
   @Test
   @Retry(2)
   public void testAllPostOps() {
+    OperationWithAction[] allOps = allOpsForTestAllPostOps();
 
-    OperationWithAction[] allOps = {
-        // Test CREATE and verify with a GET
-        new OperationWithAction(OperationCode.PUT),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.CHECK_NOKEY, 4),
-        new OperationWithAction(OperationCode.GET, 3, OpFlags.CHECK_NOKEY
-            | OpFlags.CHECK_NOTAUTHZ, 4),
-
-        // OPBLOCK_END indicates end of an operation block that needs to
-        // be executed on each server when doing failover
-        OperationWithAction.OPBLOCK_END,
-
-        // Test UPDATE and verify with a GET
-        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, 4),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, 4),
-        new OperationWithAction(OperationCode.GET, 3,
-            OpFlags.USE_OLDCONN | OpFlags.CHECK_NOKEY | OpFlags.USE_NEWVAL
-                | OpFlags.CHECK_NOTAUTHZ, 4),
-
-        OperationWithAction.OPBLOCK_END,
-
-        // Test UPDATE and verify with a KEY_SET
-        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN, 6),
-        new OperationWithAction(OperationCode.KEY_SET, 2, OpFlags.NONE, 6),
-        new OperationWithAction(OperationCode.KEY_SET, 3,
-            OpFlags.CHECK_NOTAUTHZ, 6),
-
-        OperationWithAction.OPBLOCK_END,
-
-        // Test UPDATE and verify with a QUERY
-        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, 7),
-        new OperationWithAction(OperationCode.QUERY, 2, OpFlags.USE_NEWVAL, 7),
-        new OperationWithAction(OperationCode.QUERY, 3, OpFlags.USE_NEWVAL
-            | OpFlags.CHECK_NOTAUTHZ, 7),
-
-        OperationWithAction.OPBLOCK_END,
+    for (Iterator iter = getDummyGeneratorCombos().iterator(); iter.hasNext();) {
 
-        // Test UPDATE and verify with a EXECUTE_CQ initial results
-        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN, 8),
-        new OperationWithAction(OperationCode.EXECUTE_CQ, 2, OpFlags.NONE, 8),
-        new OperationWithAction(OperationCode.EXECUTE_CQ, 3,
-            OpFlags.CHECK_NOTAUTHZ, 8),
-
-        OperationWithAction.OPBLOCK_END };
-
-    Iterator iter = getDummyGeneratorCombos().iterator();
-    while (iter.hasNext()) {
       AuthzCredentialGenerator gen = (AuthzCredentialGenerator)iter.next();
       CredentialGenerator cGen = gen.getCredentialGenerator();
       Properties extraAuthProps = cGen.getSystemProperties();
@@ -127,18 +78,15 @@ public class ClientPostAuthorizationDUnitTest extends
       TestAuthzCredentialGenerator tgen = new TestAuthzCredentialGenerator(gen);
 
       LogWriterUtils.getLogWriter().info("testAllPostOps: Using authinit: " + authInit);
-      LogWriterUtils.getLogWriter().info(
-          "testAllPostOps: Using authenticator: " + authenticator);
+      LogWriterUtils.getLogWriter().info("testAllPostOps: Using authenticator: " + authenticator);
       LogWriterUtils.getLogWriter().info("testAllPostOps: Using accessor: " + accessor);
 
       // Start servers with all required properties
-      Properties serverProps = buildProperties(authenticator, accessor, true,
-          extraAuthProps, extraAuthzProps);
+      Properties serverProps = buildProperties(authenticator, accessor, true, extraAuthProps, extraAuthzProps);
+
       // Get ports for the servers
-      Integer port1 = new Integer(AvailablePort
-          .getRandomAvailablePort(AvailablePort.SOCKET));
-      Integer port2 = new Integer(AvailablePort
-          .getRandomAvailablePort(AvailablePort.SOCKET));
+      Integer port1 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+      Integer port2 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
 
       // Close down any running servers
       server1.invoke(() -> SecurityTestUtil.closeCache());
@@ -147,35 +95,29 @@ public class ClientPostAuthorizationDUnitTest extends
       // Perform all the ops on the clients
       List opBlock = new ArrayList();
       Random rnd = new Random();
+
       for (int opNum = 0; opNum < allOps.length; ++opNum) {
         // Start client with valid credentials as specified in
         // OperationWithAction
         OperationWithAction currentOp = allOps[opNum];
-        if (currentOp.equals(OperationWithAction.OPBLOCK_END)
-            || currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
+        if (currentOp.equals(OperationWithAction.OPBLOCK_END) || currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
           // End of current operation block; execute all the operations
           // on the servers with failover
           if (opBlock.size() > 0) {
             // Start the first server and execute the operation block
-            server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
-                    SecurityTestUtil.getLocatorPort(), port1, serverProps,
-                    javaProps ));
+            server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port1, serverProps, javaProps ));
             server2.invoke(() -> SecurityTestUtil.closeCache());
-            executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps,
-                extraAuthzProps, tgen, rnd);
+            executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
             if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
               // Failover to the second server and run the block again
-              server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
-                      SecurityTestUtil.getLocatorPort(), port2, serverProps,
-                      javaProps ));
+              server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port2, serverProps, javaProps ));
               server1.invoke(() -> SecurityTestUtil.closeCache());
-              executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps,
-                  extraAuthzProps, tgen, rnd);
+              executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
             }
             opBlock.clear();
           }
-        }
-        else {
+
+        } else {
           currentOp.setOpNum(opNum);
           opBlock.add(currentOp);
         }
@@ -185,20 +127,115 @@ public class ClientPostAuthorizationDUnitTest extends
 
   @Test
   public void testAllOpsNotifications() {
+    OperationWithAction[] allOps = allOpsForTestAllOpsNotifications();
+
+    AuthzCredentialGenerator authzGenerator = getXmlAuthzGenerator();
+    LogWriterUtils.getLogWriter().info("Executing opblocks with credential generator " + authzGenerator);
+    CredentialGenerator credentialGenerator = authzGenerator.getCredentialGenerator();
+    Properties extraAuthProps = credentialGenerator.getSystemProperties();
+    Properties javaProps = credentialGenerator.getJavaProperties();
+    Properties extraAuthzProps = authzGenerator.getSystemProperties();
+    String authenticator = credentialGenerator.getAuthenticator();
+    String authInit = credentialGenerator.getAuthInit();
+    String accessor = authzGenerator.getAuthorizationCallback();
+    TestAuthzCredentialGenerator tgen = new TestAuthzCredentialGenerator(authzGenerator);
+
+    LogWriterUtils.getLogWriter().info("testAllOpsNotifications: Using authinit: " + authInit);
+    LogWriterUtils.getLogWriter().info("testAllOpsNotifications: Using authenticator: " + authenticator);
+    LogWriterUtils.getLogWriter().info("testAllOpsNotifications: Using accessor: " + accessor);
+
+    // Start servers with all required properties
+    Properties serverProps = buildProperties(authenticator, accessor, true, extraAuthProps, extraAuthzProps);
+    // Get ports for the servers
+    Integer port1 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+    Integer port2 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+
+    // Perform all the ops on the clients
+    List opBlock = new ArrayList();
+    Random rnd = new Random();
+
+    for (int opNum = 0; opNum < allOps.length; ++opNum) {
+      // Start client with valid credentials as specified in
+      // OperationWithAction
+      OperationWithAction currentOp = allOps[opNum];
+      if (currentOp.equals(OperationWithAction.OPBLOCK_END) || currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
+        // End of current operation block; execute all the operations
+        // on the servers with failover
+        if (opBlock.size() > 0) {
+          // Start the first server and execute the operation block
+          server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port1, serverProps, javaProps ));
+          server2.invoke(() -> SecurityTestUtil.closeCache());
+          executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
+          if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
+            // Failover to the second server and run the block again
+            server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port2, serverProps, javaProps ));
+            server1.invoke(() -> SecurityTestUtil.closeCache());
+            executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
+          }
+          opBlock.clear();
+        }
+
+      } else {
+        currentOp.setOpNum(opNum);
+        opBlock.add(currentOp);
+      }
+    }
+  }
+
+  private OperationWithAction[] allOpsForTestAllPostOps() {
+    return new OperationWithAction[] {
+        // Test CREATE and verify with a GET
+        new OperationWithAction(OperationCode.PUT),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.CHECK_NOKEY, 4),
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.CHECK_NOKEY | OpFlags.CHECK_NOTAUTHZ, 4),
+
+        // OPBLOCK_END indicates end of an operation block that needs to
+        // be executed on each server when doing failover
+        OperationWithAction.OPBLOCK_END,
+
+        // Test UPDATE and verify with a GET
+        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, 4),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, 4),
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.CHECK_NOKEY | OpFlags.USE_NEWVAL | OpFlags.CHECK_NOTAUTHZ, 4),
+
+        OperationWithAction.OPBLOCK_END,
+
+        // Test UPDATE and verify with a KEY_SET
+        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN, 6),
+        new OperationWithAction(OperationCode.KEY_SET, 2, OpFlags.NONE, 6),
+        new OperationWithAction(OperationCode.KEY_SET, 3, OpFlags.CHECK_NOTAUTHZ, 6),
+
+        OperationWithAction.OPBLOCK_END,
+
+        // Test UPDATE and verify with a QUERY
+        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, 7),
+        new OperationWithAction(OperationCode.QUERY, 2, OpFlags.USE_NEWVAL, 7),
+        new OperationWithAction(OperationCode.QUERY, 3, OpFlags.USE_NEWVAL | OpFlags.CHECK_NOTAUTHZ, 7),
+
+        OperationWithAction.OPBLOCK_END,
 
-    OperationWithAction[] allOps = {
+        // Test UPDATE and verify with a EXECUTE_CQ initial results
+        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN, 8),
+        new OperationWithAction(OperationCode.EXECUTE_CQ, 2, OpFlags.NONE, 8),
+        new OperationWithAction(OperationCode.EXECUTE_CQ, 3, OpFlags.CHECK_NOTAUTHZ, 8),
+
+        OperationWithAction.OPBLOCK_END };
+  }
+
+  private OperationWithAction[] allOpsForTestAllOpsNotifications() {
+    return new OperationWithAction[]{
         // Test CREATE and verify with a GET
         new OperationWithAction(OperationCode.REGISTER_INTEREST,
-            OperationCode.GET, 2, OpFlags.USE_REGEX
+                OperationCode.GET, 2, OpFlags.USE_REGEX
                 | OpFlags.REGISTER_POLICY_NONE, 8),
         new OperationWithAction(OperationCode.REGISTER_INTEREST,
-            OperationCode.GET, 3, OpFlags.USE_REGEX
+                OperationCode.GET, 3, OpFlags.USE_REGEX
                 | OpFlags.REGISTER_POLICY_NONE | OpFlags.USE_NOTAUTHZ, 8),
         new OperationWithAction(OperationCode.PUT),
         new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP, 4),
+                | OpFlags.LOCAL_OP, 4),
         new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 4),
+                | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 4),
 
         // OPBLOCK_END indicates end of an operation block that needs to
         // be executed on each server when doing failover
@@ -206,35 +243,35 @@ public class ClientPostAuthorizationDUnitTest extends
 
         // Test UPDATE and verify with a GET
         new OperationWithAction(OperationCode.REGISTER_INTEREST,
-            OperationCode.GET, 2, OpFlags.USE_REGEX
+                OperationCode.GET, 2, OpFlags.USE_REGEX
                 | OpFlags.REGISTER_POLICY_NONE, 8),
         new OperationWithAction(OperationCode.REGISTER_INTEREST,
-            OperationCode.GET, 3, OpFlags.USE_REGEX
+                OperationCode.GET, 3, OpFlags.USE_REGEX
                 | OpFlags.REGISTER_POLICY_NONE | OpFlags.USE_NOTAUTHZ, 8),
         new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, 4),
+                | OpFlags.USE_NEWVAL, 4),
         new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP | OpFlags.USE_NEWVAL, 4),
+                | OpFlags.LOCAL_OP | OpFlags.USE_NEWVAL, 4),
         new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP | OpFlags.USE_NEWVAL | OpFlags.CHECK_FAIL, 4),
+                | OpFlags.LOCAL_OP | OpFlags.USE_NEWVAL | OpFlags.CHECK_FAIL, 4),
 
         OperationWithAction.OPBLOCK_END,
 
-        // Test DESTROY and verify with GET that keys should not exist
+        // Test DESTROY and verify with GET that KEYS should not exist
         new OperationWithAction(OperationCode.PUT, 3, OpFlags.NONE, 8),
         new OperationWithAction(OperationCode.REGISTER_INTEREST,
-            OperationCode.GET, 2, OpFlags.USE_REGEX, 8),
+                OperationCode.GET, 2, OpFlags.USE_REGEX, 8),
         new OperationWithAction(OperationCode.REGISTER_INTEREST, 3,
-            OpFlags.USE_REGEX | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 8),
-        // registerInterest now clears the keys, so a dummy put to add
-        // those keys back for the case when updates should not come
+                OpFlags.USE_REGEX | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 8),
+        // registerInterest now clears the KEYS, so a dummy put to add
+        // those KEYS back for the case when updates should not come
         new OperationWithAction(OperationCode.PUT, 3, OpFlags.USE_OLDCONN, 8),
         new OperationWithAction(OperationCode.DESTROY, 1, OpFlags.USE_OLDCONN,
-            4),
+                4),
         new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 4),
+                | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 4),
         new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP, 4),
+                | OpFlags.LOCAL_OP, 4),
         // Repopulate the region
         new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN, 8),
 
@@ -243,18 +280,18 @@ public class ClientPostAuthorizationDUnitTest extends
         // Do REGION_CLEAR and check with GET
         new OperationWithAction(OperationCode.PUT, 3, OpFlags.NONE, 8),
         new OperationWithAction(OperationCode.REGISTER_INTEREST,
-            OperationCode.GET, 2, OpFlags.USE_ALL_KEYS, 1),
+                OperationCode.GET, 2, OpFlags.USE_ALL_KEYS, 1),
         new OperationWithAction(OperationCode.REGISTER_INTEREST, 3,
-            OpFlags.USE_ALL_KEYS | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 1),
-        // registerInterest now clears the keys, so a dummy put to add
-        // those keys back for the case when updates should not come
+                OpFlags.USE_ALL_KEYS | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 1),
+        // registerInterest now clears the KEYS, so a dummy put to add
+        // those KEYS back for the case when updates should not come
         new OperationWithAction(OperationCode.PUT, 3, OpFlags.USE_OLDCONN, 8),
         new OperationWithAction(OperationCode.REGION_CLEAR, 1,
-            OpFlags.USE_OLDCONN, 1),
+                OpFlags.USE_OLDCONN, 1),
         new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 8),
+                | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 8),
         new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP, 8),
+                | OpFlags.LOCAL_OP, 8),
         // Repopulate the region
         new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN, 8),
 
@@ -262,132 +299,55 @@ public class ClientPostAuthorizationDUnitTest extends
 
         // Do REGION_CREATE and check with CREATE/GET
         new OperationWithAction(OperationCode.REGISTER_INTEREST,
-            OperationCode.GET, 2, OpFlags.USE_ALL_KEYS | OpFlags.ENABLE_DRF, 1),
+                OperationCode.GET, 2, OpFlags.USE_ALL_KEYS | OpFlags.ENABLE_DRF, 1),
         new OperationWithAction(OperationCode.REGISTER_INTEREST,
-            OperationCode.GET, 3, OpFlags.USE_ALL_KEYS | OpFlags.ENABLE_DRF
+                OperationCode.GET, 3, OpFlags.USE_ALL_KEYS | OpFlags.ENABLE_DRF
                 | OpFlags.USE_NOTAUTHZ | OpFlags.REGISTER_POLICY_NONE, 1),
         new OperationWithAction(OperationCode.REGION_CREATE, 1,
-            OpFlags.ENABLE_DRF, 1),
+                OpFlags.ENABLE_DRF, 1),
         new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN
-            | OpFlags.USE_SUBREGION, 4),
+                | OpFlags.USE_SUBREGION, 4),
         new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION
-            | OpFlags.NO_CREATE_SUBREGION, 4),
+                | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION
+                | OpFlags.NO_CREATE_SUBREGION, 4),
         new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION
-            | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
+                | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION
+                | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
 
         // Do REGION_DESTROY of the sub-region and check with GET
         new OperationWithAction(OperationCode.REGION_DESTROY, 1,
-            OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION, 1),
+                OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION, 1),
         new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION
-            | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
+                | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION
+                | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
         new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.USE_SUBREGION | OpFlags.CHECK_NOKEY
-            | OpFlags.CHECK_EXCEPTION, 4),
+                | OpFlags.USE_SUBREGION | OpFlags.CHECK_NOKEY
+                | OpFlags.CHECK_EXCEPTION, 4),
         new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION
-            | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
+                | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION
+                | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
         new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-            | OpFlags.USE_SUBREGION | OpFlags.CHECK_NOKEY
-            | OpFlags.CHECK_EXCEPTION, 4),
+                | OpFlags.USE_SUBREGION | OpFlags.CHECK_NOKEY
+                | OpFlags.CHECK_EXCEPTION, 4),
 
         OperationWithAction.OPBLOCK_END,
 
         // Do REGION_DESTROY of the region and check with GET
         new OperationWithAction(OperationCode.PUT, 3, OpFlags.NONE, 8),
         new OperationWithAction(OperationCode.REGISTER_INTEREST,
-            OperationCode.GET, 2, OpFlags.USE_ALL_KEYS, 1),
+                OperationCode.GET, 2, OpFlags.USE_ALL_KEYS, 1),
         new OperationWithAction(OperationCode.REGISTER_INTEREST, 3,
-            OpFlags.USE_ALL_KEYS | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 1),
-        // registerInterest now clears the keys, so a dummy put to add
-        // those keys back for the case when updates should not come
+                OpFlags.USE_ALL_KEYS | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 1),
+        // registerInterest now clears the KEYS, so a dummy put to add
+        // those KEYS back for the case when updates should not come
         new OperationWithAction(OperationCode.PUT, 3, OpFlags.USE_OLDCONN, 8),
         new OperationWithAction(OperationCode.REGION_DESTROY, 1, OpFlags.NONE,
-            1),
+                1),
         new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP | OpFlags.CHECK_NOREGION, 4),
+                | OpFlags.LOCAL_OP | OpFlags.CHECK_NOREGION, 4),
         new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP, 4),
-
-        OperationWithAction.OPBLOCK_NO_FAILOVER };
+                | OpFlags.LOCAL_OP, 4),
 
-      AuthzCredentialGenerator gen = getXmlAuthzGenerator();
-      LogWriterUtils.getLogWriter().info("Executing opblocks with credential generator " + gen);
-      CredentialGenerator cGen = gen.getCredentialGenerator();
-      Properties extraAuthProps = cGen.getSystemProperties();
-      Properties javaProps = cGen.getJavaProperties();
-      Properties extraAuthzProps = gen.getSystemProperties();
-      String authenticator = cGen.getAuthenticator();
-      String authInit = cGen.getAuthInit();
-      String accessor = gen.getAuthorizationCallback();
-      TestAuthzCredentialGenerator tgen = new TestAuthzCredentialGenerator(gen);
-
-      LogWriterUtils.getLogWriter().info(
-          "testAllOpsNotifications: Using authinit: " + authInit);
-      LogWriterUtils.getLogWriter().info(
-          "testAllOpsNotifications: Using authenticator: " + authenticator);
-      LogWriterUtils.getLogWriter().info(
-          "testAllOpsNotifications: Using accessor: " + accessor);
-
-      // Start servers with all required properties
-      Properties serverProps = buildProperties(authenticator, accessor, true,
-          extraAuthProps, extraAuthzProps);
-      // Get ports for the servers
-      Integer port1 = new Integer(AvailablePort
-          .getRandomAvailablePort(AvailablePort.SOCKET));
-      Integer port2 = new Integer(AvailablePort
-          .getRandomAvailablePort(AvailablePort.SOCKET));
-
-      // Perform all the ops on the clients
-      List opBlock = new ArrayList();
-      Random rnd = new Random();
-      for (int opNum = 0; opNum < allOps.length; ++opNum) {
-        // Start client with valid credentials as specified in
-        // OperationWithAction
-        OperationWithAction currentOp = allOps[opNum];
-        if (currentOp.equals(OperationWithAction.OPBLOCK_END)
-            || currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
-          // End of current operation block; execute all the operations
-          // on the servers with failover
-          if (opBlock.size() > 0) {
-            // Start the first server and execute the operation block
-            server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
-                    SecurityTestUtil.getLocatorPort(), port1, serverProps,
-                    javaProps ));
-            server2.invoke(() -> SecurityTestUtil.closeCache());
-            executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps,
-                extraAuthzProps, tgen, rnd);
-            if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
-              // Failover to the second server and run the block again
-              server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
-                      SecurityTestUtil.getLocatorPort(), port2, serverProps,
-                      javaProps ));
-              server1.invoke(() -> SecurityTestUtil.closeCache());
-              executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps,
-                  extraAuthzProps, tgen, rnd);
-            }
-            opBlock.clear();
-          }
-        }
-        else {
-          currentOp.setOpNum(opNum);
-          opBlock.add(currentOp);
-        }
-      }
-  }
-
-  // End Region: Tests
-
-  @Override
-  public final void preTearDown() throws Exception {
-    // close the clients first
-    client1.invoke(() -> SecurityTestUtil.closeCache());
-    client2.invoke(() -> SecurityTestUtil.closeCache());
-    SecurityTestUtil.closeCache();
-    // then close the servers
-    server1.invoke(() -> SecurityTestUtil.closeCache());
-    server2.invoke(() -> SecurityTestUtil.closeCache());
+        OperationWithAction.OPBLOCK_NO_FAILOVER};
   }
 }


[7/8] incubator-geode git commit: Tests are passing

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
index b39fe34..7a738f1 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
@@ -18,6 +18,7 @@
  */
 package com.gemstone.gemfire.security;
 
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
 
 import java.util.ArrayList;
@@ -32,7 +33,6 @@ import com.gemstone.gemfire.security.generator.CredentialGenerator;
 import com.gemstone.gemfire.security.generator.DummyCredentialGenerator;
 import com.gemstone.gemfire.security.generator.XmlAuthzCredentialGenerator;
 import com.gemstone.gemfire.security.templates.UserPasswordAuthInit;
-import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.IgnoredException;
 import com.gemstone.gemfire.test.dunit.LogWriterUtils;
 import com.gemstone.gemfire.test.dunit.VM;
@@ -72,7 +72,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
 
   private void executeRIOpBlock(List opBlock, Integer port1, Integer port2,
       String authInit, Properties extraAuthProps, Properties extraAuthzProps,
-      Properties javaProps) {
+      Properties javaProps) throws InterruptedException {
 
     Iterator opIter = opBlock.iterator();
     while (opIter.hasNext()) {
@@ -150,16 +150,10 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
             "executeRIOpBlock: For client" + clientNum + credentialsTypeStr
                 + " credentials: " + opCredentials);
         if (useThisVM) {
-          createCacheClient(authInit, clientProps, javaProps, new Integer[] {
-              port1, port2 }, null, Boolean.valueOf(false), new Integer(
-              SecurityTestUtil.NO_EXCEPTION));
+          SecurityTestUtil.createCacheClientWithDynamicRegion(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, false, NO_EXCEPTION);
         }
         else {
-          clientVM.invoke(ClientAuthorizationTestBase.class,
-              "createCacheClient", new Object[] { authInit, clientProps,
-                  javaProps, new Integer[] { port1, port2 }, null,
-                  Boolean.valueOf(false),
-                  new Integer(SecurityTestUtil.NO_EXCEPTION) });
+          clientVM.invoke(() -> createCacheClient(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, false, SecurityTestUtil.NO_EXCEPTION));
         }
       }
       int expectedResult;
@@ -274,14 +268,14 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
   
   protected void createClient2NoException(Properties javaProps, String authInit,
       Integer port1, Integer port2, Properties getCredentials) {
-    client2.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, getCredentials, javaProps, port1, port2,
-            null, new Integer(SecurityTestUtil.NO_EXCEPTION) ));
+    client2.invoke(() -> ClientAuthenticationUtils.createCacheClient(authInit, getCredentials, javaProps, port1, port2,
+            0, SecurityTestUtil.NO_EXCEPTION));
   }
 
   protected void createClient1NoException(Properties javaProps, String authInit,
       Integer port1, Integer port2, Properties createCredentials) {
-    client1.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, createCredentials, javaProps, port1, port2,
-            null, new Integer(SecurityTestUtil.NO_EXCEPTION) ));
+    client1.invoke(() -> ClientAuthenticationUtils.createCacheClient(authInit, createCredentials, javaProps, port1, port2,
+            0, SecurityTestUtil.NO_EXCEPTION));
   }
 
   protected Integer createServer2(Properties javaProps,
@@ -410,13 +404,13 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
       LogWriterUtils.getLogWriter().info(
           "testInvalidAccessor: For second client GET credentials: "
               + getCredentials);
-      client1.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, createCredentials, createJavaProps, port1,
-              port2, null, Boolean.FALSE, Boolean.FALSE,
+      client1.invoke(() -> ClientAuthenticationUtils.createCacheClient( authInit, createCredentials, createJavaProps, port1,
+              port2, 0, Boolean.FALSE, Boolean.FALSE,
               Integer.valueOf(SecurityTestUtil.NO_EXCEPTION) ));
       client1.invoke(() -> SecurityTestUtil.doPuts(
           new Integer(1), new Integer(SecurityTestUtil.AUTHFAIL_EXCEPTION) ));
-      client2.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, getCredentials, getJavaProps, port1, port2,
-              null, Boolean.FALSE, Boolean.FALSE,
+      client2.invoke(() -> ClientAuthenticationUtils.createCacheClient( authInit, getCredentials, getJavaProps, port1, port2,
+              0, Boolean.FALSE, Boolean.FALSE,
               Integer.valueOf(SecurityTestUtil.NO_EXCEPTION) ));
       client2.invoke(() -> SecurityTestUtil.doPuts(
           new Integer(1), new Integer(SecurityTestUtil.AUTHFAIL_EXCEPTION) ));
@@ -559,7 +553,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
   }
 
   @Test
-  public void testUnregisterInterestWithFailover() {
+  public void testUnregisterInterestWithFailover() throws InterruptedException {
 
     OperationWithAction[] unregisterOps = {
         // Register interest in all KEYS using one key at a time
@@ -690,7 +684,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
   }
 
   @Test
-  public void testAllOpsWithFailover() {
+  public void testAllOpsWithFailover() throws InterruptedException {
     IgnoredException.addIgnoredException("Read timed out");
 
     OperationWithAction[] allOps = {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
index 5689993..c67a823 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
@@ -18,10 +18,13 @@
  */
 package com.gemstone.gemfire.security;
 
-//import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.Host.*;
+import static com.gemstone.gemfire.test.dunit.Wait.*;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -60,9 +63,7 @@ import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator.ClassCod
 import com.gemstone.gemfire.security.generator.CredentialGenerator;
 import com.gemstone.gemfire.security.generator.DummyCredentialGenerator;
 import com.gemstone.gemfire.security.generator.XmlAuthzCredentialGenerator;
-import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.Wait;
 import com.gemstone.gemfire.test.dunit.WaitCriterion;
 import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
 
@@ -74,12 +75,14 @@ import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
  */
 public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
 
+  private static final int PAUSE = 5 * 1000;
+
   protected static VM server1 = null;
   protected static VM server2 = null;
   protected static VM client1 = null;
   protected static VM client2 = null;
 
-  protected static final String regionName = SecurityTestUtil.REGION_NAME;
+  protected static final String regionName = REGION_NAME;
   protected static final String subregionName = "AuthSubregion";
 
   private static final String[] serverIgnoredExceptions = {
@@ -89,12 +92,14 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
       NotAuthorizedException.class.getName(),
       GemFireSecurityException.class.getName(),
       RegionDestroyedException.class.getName(),
-      ClassNotFoundException.class.getName() };
+      ClassNotFoundException.class.getName()
+  };
 
   private static final String[] clientIgnoredExceptions = {
       AuthenticationFailedException.class.getName(),
       NotAuthorizedException.class.getName(),
-      RegionDestroyedException.class.getName() };
+      RegionDestroyedException.class.getName()
+  };
 
   @Override
   public final void preSetUp() throws Exception {
@@ -108,16 +113,41 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
   }
 
   private final void setUpClientAuthorizationTestBase() throws Exception {
-    final Host host = Host.getHost(0);
-    server1 = host.getVM(0);
-    server2 = host.getVM(1);
-    client1 = host.getVM(2);
-    client2 = host.getVM(3);
-
-    server1.invoke(() -> SecurityTestUtil.registerExpectedExceptions(serverIgnoredExceptions));
-    server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions(serverIgnoredExceptions));
-    client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions(clientIgnoredExceptions));
-    SecurityTestUtil.registerExpectedExceptions(clientIgnoredExceptions);
+    server1 = getHost(0).getVM(0);
+    server2 = getHost(0).getVM(1);
+    client1 = getHost(0).getVM(2);
+    client2 = getHost(0).getVM(3);
+    setUpIgnoredExceptions();
+  }
+
+  private final void setUpIgnoredExceptions() {
+    Set<String> serverExceptions = new HashSet<>();
+    serverExceptions.addAll(Arrays.asList(serverIgnoredExceptions()));
+    if (serverExceptions.isEmpty()) {
+      serverExceptions.addAll(Arrays.asList(serverIgnoredExceptions));
+    }
+
+    String[] serverExceptionsArray = serverExceptions.toArray(new String[serverExceptions.size()]);
+    server1.invoke(() -> registerExpectedExceptions(serverExceptionsArray));
+    server2.invoke(() -> registerExpectedExceptions(serverExceptionsArray));
+
+    Set<String> clientExceptions = new HashSet<>();
+    clientExceptions.addAll(Arrays.asList(clientIgnoredExceptions()));
+    if (clientExceptions.isEmpty()) {
+      clientExceptions.addAll(Arrays.asList(clientIgnoredExceptions));
+    }
+
+    String[] clientExceptionsArray = serverExceptions.toArray(new String[clientExceptions.size()]);
+    client2.invoke(() -> registerExpectedExceptions(clientExceptionsArray));
+    registerExpectedExceptions(clientExceptionsArray);
+  }
+
+  protected String[] serverIgnoredExceptions() {
+    return new String[]{};
+  }
+
+  protected String[] clientIgnoredExceptions() {
+    return new String[]{};
   }
 
   protected void preSetUpClientAuthorizationTestBase() throws Exception {
@@ -129,6 +159,7 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
   @Override
   public final void preTearDown() throws Exception {
     preTearDownClientAuthorizationTestBase();
+    tearDownClientAuthorizationTestBase();
     postTearDownClientAuthorizationTestBase();
   }
 
@@ -136,82 +167,59 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
   public final void postTearDown() throws Exception {
   }
 
+  private final void tearDownClientAuthorizationTestBase() throws Exception {
+    // close the clients first
+    client1.invoke(() -> closeCache());
+    client2.invoke(() -> closeCache());
+    // then close the servers
+    server1.invoke(() -> closeCache());
+    server2.invoke(() -> closeCache());
+  }
+
   protected void preTearDownClientAuthorizationTestBase() throws Exception {
   }
 
   protected void postTearDownClientAuthorizationTestBase() throws Exception {
   }
 
-  protected static Properties buildProperties(String authenticator,
-      String accessor, boolean isAccessorPP, Properties extraAuthProps,
-      Properties extraAuthzProps) {
-
+  protected static Properties buildProperties(String authenticator, String accessor, boolean isAccessorPP, Properties extraAuthProps, Properties extraAuthzProps) {
     Properties authProps = new Properties();
     if (authenticator != null) {
-      authProps.setProperty(
-          DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator);
+      authProps.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator);
     }
     if (accessor != null) {
       if (isAccessorPP) {
-        authProps.setProperty(
-            DistributionConfig.SECURITY_CLIENT_ACCESSOR_PP_NAME, accessor);
-      }
-      else {
-        authProps.setProperty(DistributionConfig.SECURITY_CLIENT_ACCESSOR_NAME,
-            accessor);
+        authProps.setProperty(DistributionConfig.SECURITY_CLIENT_ACCESSOR_PP_NAME, accessor);
+      } else {
+        authProps.setProperty(DistributionConfig.SECURITY_CLIENT_ACCESSOR_NAME, accessor);
       }
     }
-    return SecurityTestUtil.concatProperties(new Properties[] { authProps,
-        extraAuthProps, extraAuthzProps });
-  }
-
-  public static Integer createCacheServer(Integer locatorPort, Object authProps,
-      Object javaProps) {
-
-    if (locatorPort == null) {
-      locatorPort = new Integer(AvailablePort
-          .getRandomAvailablePort(AvailablePort.SOCKET));
-    }
-    return SecurityTestUtil.createCacheServer((Properties)authProps, javaProps,
-        locatorPort, null, null, Boolean.TRUE, new Integer(
-            SecurityTestUtil.NO_EXCEPTION));
+    return concatProperties(new Properties[] { authProps, extraAuthProps, extraAuthzProps });
   }
 
-  public static Integer createCacheServer(Integer locatorPort, Integer serverPort,
-      Object authProps, Object javaProps) {
-    if (locatorPort == null) {
-      locatorPort = new Integer(AvailablePort
-          .getRandomAvailablePort(AvailablePort.SOCKET));
+  protected static Integer createCacheServer(int locatorPort, Properties authProps, Properties javaProps) {
+    if (locatorPort == 0) {
+      locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     }
-    return SecurityTestUtil.createCacheServer((Properties)authProps, javaProps,
-        locatorPort, null, serverPort, Boolean.TRUE, new Integer(
-            SecurityTestUtil.NO_EXCEPTION));
+    return SecurityTestUtil.createCacheServer(authProps, javaProps, locatorPort, null, 0, true, NO_EXCEPTION);
   }
 
-  public static void createCacheClient(Object authInit, Object authProps,
-      Object javaProps, Integer[] ports, Integer numConnections,
-      Boolean setupDynamicRegionFactory, Integer expectedResult) {
-
-    String authInitStr = (authInit == null ? null : authInit.toString());
-    if (authProps == null) {
-      authProps = new Properties();
+  protected static int createCacheServer(int locatorPort, int serverPort, Properties authProps, Properties javaProps) {
+    if (locatorPort == 0) {
+      locatorPort = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
     }
-    SecurityTestUtil.createCacheClient(authInitStr, (Properties)authProps,
-        (Properties)javaProps, ports, numConnections,
-        setupDynamicRegionFactory, expectedResult);
+    return SecurityTestUtil.createCacheServer(authProps, javaProps, locatorPort, null, serverPort, true, NO_EXCEPTION);
   }
 
   protected static Region getRegion() {
-    return SecurityTestUtil.getCache().getRegion(regionName);
+    return getCache().getRegion(regionName);
   }
 
   protected static Region getSubregion() {
-    return SecurityTestUtil.getCache().getRegion(
-        regionName + '/' + subregionName);
+    return getCache().getRegion(regionName + '/' + subregionName);
   }
 
   private static Region createSubregion(Region region) {
-
     Region subregion = getSubregion();
     if (subregion == null) {
       subregion = region.createSubregion(subregionName, region.getAttributes());
@@ -220,7 +228,6 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
   }
 
   protected static String indicesToString(int[] indices) {
-
     String str = "";
     if (indices != null && indices.length > 0) {
       str += indices[0];
@@ -232,22 +239,20 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
     return str;
   }
 
-  private static final int PAUSE = 5 * 1000;
-  
-  public static void doOp(Byte opCode, int[] indices, Integer flagsI,
-      Integer expectedResult) {
-
+  protected static void doOp(Byte opCode, int[] indices, Integer flagsI, Integer expectedResult) throws InterruptedException {
     OperationCode op = OperationCode.fromOrdinal(opCode.byteValue());
     boolean operationOmitted = false;
     final int flags = flagsI.intValue();
     Region region = getRegion();
+
     if ((flags & OpFlags.USE_SUBREGION) > 0) {
       assertNotNull(region);
       Region subregion = null;
+
       if ((flags & OpFlags.NO_CREATE_SUBREGION) > 0) {
         if ((flags & OpFlags.CHECK_NOREGION) > 0) {
           // Wait for some time for DRF update to come
-          SecurityTestUtil.waitForCondition(new Callable() {
+          waitForCondition(new Callable() {
             public Object call() throws Exception {
               return Boolean.valueOf(getSubregion() == null);
             }
@@ -255,10 +260,10 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
           subregion = getSubregion();
           assertNull(subregion);
           return;
-        }
-        else {
+
+        } else {
           // Wait for some time for DRF update to come
-          SecurityTestUtil.waitForCondition(new Callable() {
+          waitForCondition(new Callable() {
             public Object call() throws Exception {
               return Boolean.valueOf(getSubregion() != null);
             }
@@ -266,16 +271,17 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
           subregion = getSubregion();
           assertNotNull(subregion);
         }
-      }
-      else {
+
+      } else {
         subregion = createSubregion(region);
       }
+
       assertNotNull(subregion);
       region = subregion;
-    }
-    else if ((flags & OpFlags.CHECK_NOREGION) > 0) {
+
+    } else if ((flags & OpFlags.CHECK_NOREGION) > 0) {
       // Wait for some time for region destroy update to come
-      SecurityTestUtil.waitForCondition(new Callable() {
+      waitForCondition(new Callable() {
         public Object call() throws Exception {
           return Boolean.valueOf(getRegion() == null);
         }
@@ -283,48 +289,44 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
       region = getRegion();
       assertNull(region);
       return;
-    }
-    else {
+
+    } else {
       assertNotNull(region);
     }
-    final String[] keys = SecurityTestUtil.KEYS;
+
+    final String[] keys = KEYS;
     final String[] vals;
     if ((flags & OpFlags.USE_NEWVAL) > 0) {
-      vals = SecurityTestUtil.nvalues;
+      vals = NVALUES;
     }
     else {
-      vals = SecurityTestUtil.values;
+      vals = VALUES;
     }
+
     InterestResultPolicy policy = InterestResultPolicy.KEYS_VALUES;
     if ((flags & OpFlags.REGISTER_POLICY_NONE) > 0) {
       policy = InterestResultPolicy.NONE;
     }
+
     final int numOps = indices.length;
-    System.out.println(
-        "Got doOp for op: " + op.toString() + ", numOps: " + numOps
-            + ", indices: " + indicesToString(indices) + ", expect: " + expectedResult);
+    System.out.println("Got doOp for op: " + op.toString() + ", numOps: " + numOps + ", indices: " + indicesToString(indices) + ", expect: " + expectedResult);
     boolean exceptionOccured = false;
     boolean breakLoop = false;
-    if (op.isGet() || 
-        op.isContainsKey() || 
-        op.isKeySet() || 
-        op.isQuery() || 
-        op.isExecuteCQ()) {
-      try {
-        Thread.sleep(PAUSE);
-      }
-      catch (InterruptedException e) {
-        fail("interrupted");
-      }
+
+    if (op.isGet() || op.isContainsKey() || op.isKeySet() || op.isQuery() || op.isExecuteCQ()) {
+      Thread.sleep(PAUSE);
     }
+
     for (int indexIndex = 0; indexIndex < numOps; ++indexIndex) {
       if (breakLoop) {
         break;
       }
       int index = indices[indexIndex];
+
       try {
         final Object key = keys[index];
         final Object expectedVal = vals[index];
+
         if (op.isGet()) {
           Object value = null;
           // this is the case for testing GET_ALL
@@ -332,48 +334,50 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
             breakLoop = true;
             List keyList = new ArrayList(numOps);
             Object searchKey;
+
             for (int keyNumIndex = 0; keyNumIndex < numOps; ++keyNumIndex) {
               int keyNum = indices[keyNumIndex];
               searchKey = keys[keyNum];
               keyList.add(searchKey);
-              // local invalidate some KEYS to force fetch of those KEYS from
-              // server
+
+              // local invalidate some KEYS to force fetch of those KEYS from server
               if ((flags & OpFlags.CHECK_NOKEY) > 0) {
                 AbstractRegionEntry entry = (AbstractRegionEntry)((LocalRegion)region).getRegionEntry(searchKey);
                 System.out.println(""+keyNum+": key is " + searchKey + " and entry is " + entry);
                 assertFalse(region.containsKey(searchKey));
-              }
-              else {
+              } else {
                 if (keyNumIndex % 2 == 1) {
                   assertTrue(region.containsKey(searchKey));
                   region.localInvalidate(searchKey);
                 }
               }
             }
+
             Map entries = region.getAll(keyList);
+
             for (int keyNumIndex = 0; keyNumIndex < numOps; ++keyNumIndex) {
               int keyNum = indices[keyNumIndex];
               searchKey = keys[keyNum];
               if ((flags & OpFlags.CHECK_FAIL) > 0) {
                 assertFalse(entries.containsKey(searchKey));
-              }
-              else {
+              } else {
                 assertTrue(entries.containsKey(searchKey));
                 value = entries.get(searchKey);
                 assertEquals(vals[keyNum], value);
               }
             }
+
             break;
           }
+
           if ((flags & OpFlags.LOCAL_OP) > 0) {
             Callable cond = new Callable() {
               private Region region;
 
+              @Override
               public Object call() throws Exception {
-                Object value = SecurityTestUtil.getLocalValue(region, key);
-                return Boolean
-                    .valueOf((flags & OpFlags.CHECK_FAIL) > 0 ? !expectedVal
-                        .equals(value) : expectedVal.equals(value));
+                Object value = getLocalValue(region, key);
+                return Boolean.valueOf((flags & OpFlags.CHECK_FAIL) > 0 ? !expectedVal.equals(value) : expectedVal.equals(value));
               }
 
               public Callable init(Region region) {
@@ -381,50 +385,50 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
                 return this;
               }
             }.init(region);
-            SecurityTestUtil.waitForCondition(cond);
-            value = SecurityTestUtil.getLocalValue(region, key);
-          }
-          else if ((flags & OpFlags.USE_GET_ENTRY_IN_TX) > 0) {
-            SecurityTestUtil.getCache().getCacheTransactionManager().begin();
+
+            waitForCondition(cond);
+            value = getLocalValue(region, key);
+
+          } else if ((flags & OpFlags.USE_GET_ENTRY_IN_TX) > 0) {
+            getCache().getCacheTransactionManager().begin();
             Entry e = region.getEntry(key);
             // Also, check getAll()
             ArrayList a = new ArrayList();
             a.addAll(a);
             region.getAll(a);
 
-            SecurityTestUtil.getCache().getCacheTransactionManager().commit();
+            getCache().getCacheTransactionManager().commit();
             value = e.getValue();
-          }
-          else {
+
+          } else {
             if ((flags & OpFlags.CHECK_NOKEY) > 0) {
               assertFalse(region.containsKey(key));
-            }
-            else {
+            } else {
               assertTrue(region.containsKey(key) || ((LocalRegion)region).getRegionEntry(key).isTombstone());
               region.localInvalidate(key);
             }
             value = region.get(key);
           }
+
           if ((flags & OpFlags.CHECK_FAIL) > 0) {
             assertFalse(expectedVal.equals(value));
-          }
-          else {
+          } else {
             assertNotNull(value);
             assertEquals(expectedVal, value);
           }
-        }
-        else if (op.isPut()) {
+
+        } else if (op.isPut()) {
           region.put(key, expectedVal);
-        }
-        else if (op.isPutAll()) {
+
+        } else if (op.isPutAll()) {
           HashMap map = new HashMap();
           for (int i=0; i<indices.length; i++) {
             map.put(keys[indices[i]], vals[indices[i]]);
           }
           region.putAll(map);
           breakLoop = true;
-        }
-        else if (op.isDestroy()) {
+
+        } else if (op.isDestroy()) {
           // if (!region.containsKey(key)) {
           // // Since DESTROY will fail unless the value is present
           // // in the local cache, this is a workaround for two cases:
@@ -455,33 +459,30 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
           else {
             region.destroy(key);
           }
-        }
-        else if (op.isInvalidate()) {
+
+        } else if (op.isInvalidate()) {
           if (region.containsKey(key)) {
             if ((flags & OpFlags.LOCAL_OP) > 0) {
               region.localInvalidate(key);
-            }
-            else {
+            } else {
               region.invalidate(key);
             }
           }
-        }
-        else if (op.isContainsKey()) {
+
+        } else if (op.isContainsKey()) {
           boolean result;
           if ((flags & OpFlags.LOCAL_OP) > 0) {
             result = region.containsKey(key);
-          }
-          else {
+          } else {
             result = region.containsKeyOnServer(key);
           }
           if ((flags & OpFlags.CHECK_FAIL) > 0) {
             assertFalse(result);
-          }
-          else {
+          } else {
             assertTrue(result);
           }
-        }
-        else if (op.isRegisterInterest()) {
+
+        } else if (op.isRegisterInterest()) {
           if ((flags & OpFlags.USE_LIST) > 0) {
             breakLoop = true;
             // Register interest list in this case
@@ -491,20 +492,20 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
               keyList.add(keys[keyNum]);
             }
             region.registerInterest(keyList, policy);
-          }
-          else if ((flags & OpFlags.USE_REGEX) > 0) {
+
+          } else if ((flags & OpFlags.USE_REGEX) > 0) {
             breakLoop = true;
             region.registerInterestRegex("key[1-" + numOps + ']', policy);
-          }
-          else if ((flags & OpFlags.USE_ALL_KEYS) > 0) {
+
+          } else if ((flags & OpFlags.USE_ALL_KEYS) > 0) {
             breakLoop = true;
             region.registerInterest("ALL_KEYS", policy);
-          }
-          else {
+
+          } else {
             region.registerInterest(key, policy);
           }
-        }
-        else if (op.isUnregisterInterest()) {
+
+        } else if (op.isUnregisterInterest()) {
           if ((flags & OpFlags.USE_LIST) > 0) {
             breakLoop = true;
             // Register interest list in this case
@@ -514,28 +515,28 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
               keyList.add(keys[keyNum]);
             }
             region.unregisterInterest(keyList);
-          }
-          else if ((flags & OpFlags.USE_REGEX) > 0) {
+
+          } else if ((flags & OpFlags.USE_REGEX) > 0) {
             breakLoop = true;
             region.unregisterInterestRegex("key[1-" + numOps + ']');
-          }
-          else if ((flags & OpFlags.USE_ALL_KEYS) > 0) {
+
+          } else if ((flags & OpFlags.USE_ALL_KEYS) > 0) {
             breakLoop = true;
             region.unregisterInterest("ALL_KEYS");
-          }
-          else {
+
+          } else {
             region.unregisterInterest(key);
           }
-        }
-        else if (op.isKeySet()) {
+
+        } else if (op.isKeySet()) {
           breakLoop = true;
           Set keySet;
           if ((flags & OpFlags.LOCAL_OP) > 0) {
             keySet = region.keySet();
-          }
-          else {
+          } else {
             keySet = region.keySetOnServer();
           }
+
           assertNotNull(keySet);
           if ((flags & OpFlags.CHECK_FAIL) == 0) {
             assertEquals(numOps, keySet.size());
@@ -544,16 +545,14 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
             int keyNum = indices[keyNumIndex];
             if ((flags & OpFlags.CHECK_FAIL) > 0) {
               assertFalse(keySet.contains(keys[keyNum]));
-            }
-            else {
+            } else {
               assertTrue(keySet.contains(keys[keyNum]));
             }
           }
-        }
-        else if (op.isQuery()) {
+
+        } else if (op.isQuery()) {
           breakLoop = true;
-          SelectResults queryResults = region.query("SELECT DISTINCT * FROM "
-              + region.getFullPath());
+          SelectResults queryResults = region.query("SELECT DISTINCT * FROM " + region.getFullPath());
           assertNotNull(queryResults);
           Set queryResultSet = queryResults.asSet();
           if ((flags & OpFlags.CHECK_FAIL) == 0) {
@@ -563,55 +562,54 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
             int keyNum = indices[keyNumIndex];
             if ((flags & OpFlags.CHECK_FAIL) > 0) {
               assertFalse(queryResultSet.contains(vals[keyNum]));
-            }
-            else {
+            } else {
               assertTrue(queryResultSet.contains(vals[keyNum]));
             }
           }
-        }
-        else if (op.isExecuteCQ()) {
+
+        } else if (op.isExecuteCQ()) {
           breakLoop = true;
-          QueryService queryService = SecurityTestUtil.getCache()
-              .getQueryService();
+          QueryService queryService = getCache().getQueryService();
           CqQuery cqQuery;
           if ((cqQuery = queryService.getCq("cq1")) == null) {
             CqAttributesFactory cqFact = new CqAttributesFactory();
             cqFact.addCqListener(new AuthzCqListener());
             CqAttributes cqAttrs = cqFact.create();
-            cqQuery = queryService.newCq("cq1", "SELECT * FROM "
-                + region.getFullPath(), cqAttrs);
+            cqQuery = queryService.newCq("cq1", "SELECT * FROM " + region.getFullPath(), cqAttrs);
           }
+
           if ((flags & OpFlags.LOCAL_OP) > 0) {
             // Interpret this as testing results using CqListener
-            final AuthzCqListener listener = (AuthzCqListener)cqQuery
-                .getCqAttributes().getCqListener();
+            final AuthzCqListener listener = (AuthzCqListener)cqQuery.getCqAttributes().getCqListener();
             WaitCriterion ev = new WaitCriterion() {
+              @Override
               public boolean done() {
                 if ((flags & OpFlags.CHECK_FAIL) > 0) {
                   return 0 == listener.getNumUpdates();
-                }
-                else {
+                } else {
                   return numOps == listener.getNumUpdates();
                 }
               }
+              @Override
               public String description() {
                 return null;
               }
             };
-            Wait.waitForCriterion(ev, 3 * 1000, 200, true);
+            waitForCriterion(ev, 3 * 1000, 200, true);
+
             if ((flags & OpFlags.CHECK_FAIL) > 0) {
               assertEquals(0, listener.getNumUpdates());
-            }
-            else {
+            } else {
               assertEquals(numOps, listener.getNumUpdates());
               listener.checkPuts(vals, indices);
             }
+
             assertEquals(0, listener.getNumCreates());
             assertEquals(0, listener.getNumDestroys());
             assertEquals(0, listener.getNumOtherOps());
             assertEquals(0, listener.getNumErrors());
-          }
-          else {
+
+          } else {
             SelectResults cqResults = cqQuery.executeWithInitialResults();
             assertNotNull(cqResults);
             Set cqResultValues = new HashSet();
@@ -619,45 +617,43 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
               Struct s = (Struct)o;
               cqResultValues.add(s.get("value"));
             }
+
             Set cqResultSet = cqResults.asSet();
             if ((flags & OpFlags.CHECK_FAIL) == 0) {
               assertEquals(numOps, cqResultSet.size());
             }
+
             for (int keyNumIndex = 0; keyNumIndex < numOps; ++keyNumIndex) {
               int keyNum = indices[keyNumIndex];
               if ((flags & OpFlags.CHECK_FAIL) > 0) {
                 assertFalse(cqResultValues.contains(vals[keyNum]));
-              }
-              else {
+              } else {
                 assertTrue(cqResultValues.contains(vals[keyNum]));
               }
             }
           }
-        }
-        else if (op.isStopCQ()) {
+
+        } else if (op.isStopCQ()) {
           breakLoop = true;
-          CqQuery cqQuery = SecurityTestUtil.getCache().getQueryService()
-              .getCq("cq1");
+          CqQuery cqQuery = getCache().getQueryService().getCq("cq1");
           ((AuthzCqListener)cqQuery.getCqAttributes().getCqListener()).reset();
           cqQuery.stop();
-        }
-        else if (op.isCloseCQ()) {
+
+        } else if (op.isCloseCQ()) {
           breakLoop = true;
-          CqQuery cqQuery = SecurityTestUtil.getCache().getQueryService()
-              .getCq("cq1");
+          CqQuery cqQuery = getCache().getQueryService().getCq("cq1");
           ((AuthzCqListener)cqQuery.getCqAttributes().getCqListener()).reset();
           cqQuery.close();
-        }
-        else if (op.isRegionClear()) {
+
+        } else if (op.isRegionClear()) {
           breakLoop = true;
           if ((flags & OpFlags.LOCAL_OP) > 0) {
             region.localClear();
-          }
-          else {
+          } else {
             region.clear();
           }
-        }
-        else if (op.isRegionCreate()) {
+
+        } else if (op.isRegionCreate()) {
           breakLoop = true;
           // Region subregion = createSubregion(region);
           // subregion.createRegionOnServer();
@@ -665,88 +661,66 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
           // Assume it has been already initialized
           DynamicRegionFactory drf = DynamicRegionFactory.get();
           Region subregion = drf.createDynamicRegion(regionName, subregionName);
-          assertEquals('/' + regionName + '/' + subregionName, subregion
-              .getFullPath());
-        }
-        else if (op.isRegionDestroy()) {
+          assertEquals('/' + regionName + '/' + subregionName, subregion.getFullPath());
+
+        } else if (op.isRegionDestroy()) {
           breakLoop = true;
           if ((flags & OpFlags.LOCAL_OP) > 0) {
             region.localDestroyRegion();
-          }
-          else {
+
+          } else {
             if ((flags & OpFlags.USE_SUBREGION) > 0) {
               try {
-                DynamicRegionFactory.get().destroyDynamicRegion(
-                    region.getFullPath());
-              }
-              catch (RegionDestroyedException ex) {
+                DynamicRegionFactory.get().destroyDynamicRegion(region.getFullPath());
+              } catch (RegionDestroyedException ex) {
                 // harmless to ignore this
-                System.out.println(
-                    "doOp: sub-region " + region.getFullPath()
-                        + " already destroyed");
+                System.out.println("doOp: sub-region " + region.getFullPath() + " already destroyed");
                 operationOmitted = true;
               }
-            }
-            else {
+            } else {
               region.destroyRegion();
             }
           }
-        }
-        else {
+
+        } else {
           fail("doOp: Unhandled operation " + op);
         }
-        if (expectedResult.intValue() != SecurityTestUtil.NO_EXCEPTION) {
+
+        if (expectedResult.intValue() != NO_EXCEPTION) {
           if (!operationOmitted && !op.isUnregisterInterest()) {
-            fail("Expected an exception while performing operation op =" + op +
-                "flags = " + OpFlags.description(flags));
+            fail("Expected an exception while performing operation op =" + op + "flags = " + OpFlags.description(flags));
           }
         }
-      }
-      catch (Exception ex) {
+
+      } catch (Exception ex) {
         exceptionOccured = true;
-        if ((ex instanceof ServerConnectivityException
-            || ex instanceof QueryInvocationTargetException || ex instanceof CqException)
-            && (expectedResult.intValue() == SecurityTestUtil.NOTAUTHZ_EXCEPTION)
-            && (ex.getCause() instanceof NotAuthorizedException)) {
-          System.out.println(
-              "doOp: Got expected NotAuthorizedException when doing operation ["
-                  + op + "] with flags " + OpFlags.description(flags) 
-                  + ": " + ex.getCause());
+        if ((ex instanceof ServerConnectivityException || ex instanceof QueryInvocationTargetException || ex instanceof CqException)
+            && (expectedResult.intValue() == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
+          System.out.println("doOp: Got expected NotAuthorizedException when doing operation [" + op + "] with flags " + OpFlags.description(flags) + ": " + ex.getCause());
           continue;
-        }
-        else if (expectedResult.intValue() == SecurityTestUtil.OTHER_EXCEPTION) {
-          System.out.println(
-              "doOp: Got expected exception when doing operation: "
-                  + ex.toString());
+        } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+          System.out.println("doOp: Got expected exception when doing operation: " + ex.toString());
           continue;
-        }
-        else {
-          fail("doOp: Got unexpected exception when doing operation. Policy = "
-              + policy + " flags = " + OpFlags.description(flags), ex);
+        } else {
+          fail("doOp: Got unexpected exception when doing operation. Policy = " + policy + " flags = " + OpFlags.description(flags), ex);
         }
       }
     }
-    if (!exceptionOccured && !operationOmitted
-        && expectedResult.intValue() != SecurityTestUtil.NO_EXCEPTION) {
-      fail("Expected an exception while performing operation: " + op + 
-          " flags = " + OpFlags.description(flags));
+    if (!exceptionOccured && !operationOmitted && expectedResult.intValue() != NO_EXCEPTION) {
+      fail("Expected an exception while performing operation: " + op + " flags = " + OpFlags.description(flags));
     }
   }
 
-  protected void executeOpBlock(List opBlock, Integer port1, Integer port2,
-      String authInit, Properties extraAuthProps, Properties extraAuthzProps,
-      TestCredentialGenerator gen, Random rnd) {
-
-    Iterator opIter = opBlock.iterator();
-    while (opIter.hasNext()) {
-      // Start client with valid credentials as specified in
-      // OperationWithAction
+  protected void executeOpBlock(List opBlock, Integer port1, Integer port2, String authInit, Properties extraAuthProps, Properties extraAuthzProps, TestCredentialGenerator gen, Random rnd) throws InterruptedException {
+    for (Iterator opIter = opBlock.iterator(); opIter.hasNext();) {
+      // Start client with valid credentials as specified in OperationWithAction
       OperationWithAction currentOp = (OperationWithAction)opIter.next();
       OperationCode opCode = currentOp.getOperationCode();
       int opFlags = currentOp.getFlags();
       int clientNum = currentOp.getClientNum();
       VM clientVM = null;
       boolean useThisVM = false;
+
       switch (clientNum) {
         case 1:
           clientVM = client1;
@@ -761,9 +735,8 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
           fail("executeOpBlock: Unknown client number " + clientNum);
           break;
       }
-      System.out.println(
-          "executeOpBlock: performing operation number ["
-              + currentOp.getOpNum() + "]: " + currentOp);
+
+      System.out.println("executeOpBlock: performing operation number [" + currentOp.getOpNum() + "]: " + currentOp);
       if ((opFlags & OpFlags.USE_OLDCONN) == 0) {
         Properties opCredentials;
         int newRnd = rnd.nextInt(100) + 1;
@@ -771,71 +744,49 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
         if ((opFlags & OpFlags.USE_SUBREGION) > 0) {
           currentRegionName += ('/' + subregionName);
         }
+
         String credentialsTypeStr;
         OperationCode authOpCode = currentOp.getAuthzOperationCode();
         int[] indices = currentOp.getIndices();
         CredentialGenerator cGen = gen.getCredentialGenerator();
-        Properties javaProps = null;
-        if ((opFlags & OpFlags.CHECK_NOTAUTHZ) > 0
-            || (opFlags & OpFlags.USE_NOTAUTHZ) > 0) {
-          opCredentials = gen.getDisallowedCredentials(
-              new OperationCode[] { authOpCode },
-              new String[] { currentRegionName }, indices, newRnd);
+        final Properties javaProps = cGen == null ? null : cGen.getJavaProperties();
+
+        if ((opFlags & OpFlags.CHECK_NOTAUTHZ) > 0 || (opFlags & OpFlags.USE_NOTAUTHZ) > 0) {
+          opCredentials = gen.getDisallowedCredentials(new OperationCode[] { authOpCode }, new String[] { currentRegionName }, indices, newRnd);
           credentialsTypeStr = " unauthorized " + authOpCode;
-        }
-        else {
-          opCredentials = gen.getAllowedCredentials(new OperationCode[] {
-              opCode, authOpCode }, new String[] { currentRegionName },
-              indices, newRnd);
+        } else {
+          opCredentials = gen.getAllowedCredentials(new OperationCode[] { opCode, authOpCode }, new String[] { currentRegionName }, indices, newRnd);
           credentialsTypeStr = " authorized " + authOpCode;
         }
-        if (cGen != null) {
-          javaProps = cGen.getJavaProperties();
-        }
-        Properties clientProps = SecurityTestUtil
-            .concatProperties(new Properties[] { opCredentials, extraAuthProps,
-                extraAuthzProps });
-        // Start the client with valid credentials but allowed or disallowed to
-        // perform an operation
-        System.out.println(
-            "executeOpBlock: For client" + clientNum + credentialsTypeStr
-                + " credentials: " + opCredentials);
+
+        Properties clientProps = concatProperties(new Properties[] { opCredentials, extraAuthProps, extraAuthzProps });
+        // Start the client with valid credentials but allowed or disallowed to perform an operation
+        System.out.println("executeOpBlock: For client" + clientNum + credentialsTypeStr + " credentials: " + opCredentials);
         boolean setupDynamicRegionFactory = (opFlags & OpFlags.ENABLE_DRF) > 0;
+
         if (useThisVM) {
-          createCacheClient(authInit, clientProps, javaProps, new Integer[] {
-              port1, port2 }, null, Boolean.valueOf(setupDynamicRegionFactory),
-              new Integer(SecurityTestUtil.NO_EXCEPTION));
-        }
-        else {
-          clientVM.invoke(ClientAuthorizationTestBase.class,
-              "createCacheClient", new Object[] { authInit, clientProps,
-                  javaProps, new Integer[] { port1, port2 }, null,
-                  Boolean.valueOf(setupDynamicRegionFactory),
-                  new Integer(SecurityTestUtil.NO_EXCEPTION) });
+          SecurityTestUtil.createCacheClientWithDynamicRegion(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, setupDynamicRegionFactory, NO_EXCEPTION);
+        } else {
+          clientVM.invoke(() -> SecurityTestUtil.createCacheClientWithDynamicRegion(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, setupDynamicRegionFactory, NO_EXCEPTION));
         }
       }
+
       int expectedResult;
       if ((opFlags & OpFlags.CHECK_NOTAUTHZ) > 0) {
-        expectedResult = SecurityTestUtil.NOTAUTHZ_EXCEPTION;
-      }
-      else if ((opFlags & OpFlags.CHECK_EXCEPTION) > 0) {
-        expectedResult = SecurityTestUtil.OTHER_EXCEPTION;
-      }
-      else {
-        expectedResult = SecurityTestUtil.NO_EXCEPTION;
+        expectedResult = NOTAUTHZ_EXCEPTION;
+      } else if ((opFlags & OpFlags.CHECK_EXCEPTION) > 0) {
+        expectedResult = OTHER_EXCEPTION;
+      } else {
+        expectedResult = NO_EXCEPTION;
       }
 
       // Perform the operation from selected client
       if (useThisVM) {
-        doOp(new Byte(opCode.toOrdinal()), currentOp.getIndices(), new Integer(
-            opFlags), new Integer(expectedResult));
-      }
-      else {
+        doOp(new Byte(opCode.toOrdinal()), currentOp.getIndices(), new Integer(opFlags), new Integer(expectedResult));
+      } else {
         byte ordinal = opCode.toOrdinal();
         int[] indices = currentOp.getIndices();
-        clientVM.invoke(() -> ClientAuthorizationTestBase.doOp( new Byte(ordinal),
-                indices, new Integer(opFlags),
-                new Integer(expectedResult) ));
+        clientVM.invoke(() -> ClientAuthorizationTestBase.doOp( new Byte(ordinal), indices, new Integer(opFlags), new Integer(expectedResult) ));
       }
     }
   }
@@ -850,12 +801,12 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
 
   protected List getDummyGeneratorCombos() {
     List generators = new ArrayList();
-    Iterator authzCodeIter = AuthzCredentialGenerator.ClassCode.getAll()
-            .iterator();
+    Iterator authzCodeIter = AuthzCredentialGenerator.ClassCode.getAll().iterator();
+
     while (authzCodeIter.hasNext()) {
       ClassCode authzClassCode = (ClassCode) authzCodeIter.next();
-      AuthzCredentialGenerator authzGen = AuthzCredentialGenerator
-              .create(authzClassCode);
+      AuthzCredentialGenerator authzGen = AuthzCredentialGenerator.create(authzClassCode);
+
       if (authzGen != null) {
         CredentialGenerator cGen = new DummyCredentialGenerator();
         cGen.init();
@@ -869,76 +820,67 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
     return generators;
   }
 
-
-  protected void runOpsWithFailover(OperationWithAction[] opCodes,
-      String testName) {
-      AuthzCredentialGenerator gen = getXmlAuthzGenerator();
-      CredentialGenerator cGen = gen.getCredentialGenerator();
-      Properties extraAuthProps = cGen.getSystemProperties();
-      Properties javaProps = cGen.getJavaProperties();
-      Properties extraAuthzProps = gen.getSystemProperties();
-      String authenticator = cGen.getAuthenticator();
-      String authInit = cGen.getAuthInit();
-      String accessor = gen.getAuthorizationCallback();
-      TestAuthzCredentialGenerator tgen = new TestAuthzCredentialGenerator(gen);
-
-      System.out.println(testName + ": Using authinit: " + authInit);
-      System.out.println(testName + ": Using authenticator: " + authenticator);
-      System.out.println(testName + ": Using accessor: " + accessor);
-
-      // Start servers with all required properties
-      Properties serverProps = buildProperties(authenticator, accessor, false,
-          extraAuthProps, extraAuthzProps);
-      // Get ports for the servers
-      Keeper locator1PortKeeper = AvailablePort.getRandomAvailablePortKeeper(AvailablePort.SOCKET);
-      Keeper locator2PortKeeper = AvailablePort.getRandomAvailablePortKeeper(AvailablePort.SOCKET);
-      Keeper port1Keeper = AvailablePort.getRandomAvailablePortKeeper(AvailablePort.SOCKET);
-      Keeper port2Keeper = AvailablePort.getRandomAvailablePortKeeper(AvailablePort.SOCKET);
-      int locator1Port = locator1PortKeeper.getPort();
-      int locator2Port = locator2PortKeeper.getPort();
-      int port1 = port1Keeper.getPort();
-      int port2 = port2Keeper.getPort();
-
-      // Perform all the ops on the clients
-      List opBlock = new ArrayList();
-      Random rnd = new Random();
-      for (int opNum = 0; opNum < opCodes.length; ++opNum) {
-        // Start client with valid credentials as specified in
-        // OperationWithAction
-        OperationWithAction currentOp = opCodes[opNum];
-        if (currentOp.equals(OperationWithAction.OPBLOCK_END)
-            || currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
-          // End of current operation block; execute all the operations
-          // on the servers with/without failover
-          if (opBlock.size() > 0) {
-            locator1PortKeeper.release();
-            port1Keeper.release();
-            // Start the first server and execute the operation block
-            server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
-                    locator1Port, port1, serverProps,
-                    javaProps ));
-            server2.invoke(() -> SecurityTestUtil.closeCache());
-            executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps,
-                extraAuthzProps, tgen, rnd);
-            if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
-              // Failover to the second server and run the block again
-              locator2PortKeeper.release();
-              port2Keeper.release();
-              server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
-                      locator2Port, port2, serverProps,
-                      javaProps ));
-              server1.invoke(() -> SecurityTestUtil.closeCache());
-              executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps,
-                  extraAuthzProps, tgen, rnd);
-            }
-            opBlock.clear();
+  protected void runOpsWithFailover(OperationWithAction[] opCodes, String testName) throws InterruptedException {
+    AuthzCredentialGenerator gen = getXmlAuthzGenerator();
+    CredentialGenerator cGen = gen.getCredentialGenerator();
+    Properties extraAuthProps = cGen.getSystemProperties();
+    Properties javaProps = cGen.getJavaProperties();
+    Properties extraAuthzProps = gen.getSystemProperties();
+    String authenticator = cGen.getAuthenticator();
+    String authInit = cGen.getAuthInit();
+    String accessor = gen.getAuthorizationCallback();
+    TestAuthzCredentialGenerator tgen = new TestAuthzCredentialGenerator(gen);
+
+    System.out.println(testName + ": Using authinit: " + authInit);
+    System.out.println(testName + ": Using authenticator: " + authenticator);
+    System.out.println(testName + ": Using accessor: " + accessor);
+
+    // Start servers with all required properties
+    Properties serverProps = buildProperties(authenticator, accessor, false, extraAuthProps, extraAuthzProps);
+
+    // Get ports for the servers
+    Keeper locator1PortKeeper = AvailablePort.getRandomAvailablePortKeeper(AvailablePort.SOCKET);
+    Keeper locator2PortKeeper = AvailablePort.getRandomAvailablePortKeeper(AvailablePort.SOCKET);
+    Keeper port1Keeper = AvailablePort.getRandomAvailablePortKeeper(AvailablePort.SOCKET);
+    Keeper port2Keeper = AvailablePort.getRandomAvailablePortKeeper(AvailablePort.SOCKET);
+    int locator1Port = locator1PortKeeper.getPort();
+    int locator2Port = locator2PortKeeper.getPort();
+    int port1 = port1Keeper.getPort();
+    int port2 = port2Keeper.getPort();
+
+    // Perform all the ops on the clients
+    List opBlock = new ArrayList();
+    Random rnd = new Random();
+
+    for (int opNum = 0; opNum < opCodes.length; ++opNum) {
+      // Start client with valid credentials as specified in OperationWithAction
+      OperationWithAction currentOp = opCodes[opNum];
+
+      if (currentOp.equals(OperationWithAction.OPBLOCK_END) || currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
+        // End of current operation block; execute all the operations on the servers with/without failover
+        if (opBlock.size() > 0) {
+          locator1PortKeeper.release();
+          port1Keeper.release();
+          // Start the first server and execute the operation block
+          server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(locator1Port, port1, serverProps, javaProps ));
+          server2.invoke(() -> closeCache());
+          executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
+          if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
+            // Failover to the second server and run the block again
+            locator2PortKeeper.release();
+            port2Keeper.release();
+            server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(locator2Port, port2, serverProps, javaProps ));
+            server1.invoke(() -> closeCache());
+            executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
           }
+          opBlock.clear();
         }
-        else {
-          currentOp.setOpNum(opNum);
-          opBlock.add(currentOp);
-        }
+
+      } else {
+        currentOp.setOpNum(opNum);
+        opBlock.add(currentOp);
       }
+    }
   }
 
   /**
@@ -946,21 +888,15 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
    * different operations and also queues up the received updates to precise
    * checking of each update.
    * 
-   * @author sumedh
    * @since 5.5
    */
-  public static class AuthzCqListener implements CqListener {
+  private static class AuthzCqListener implements CqListener {
 
     private List eventList;
-
     private int numCreates;
-
     private int numUpdates;
-
     private int numDestroys;
-
     private int numOtherOps;
-
     private int numErrors;
 
     public AuthzCqListener() {
@@ -979,14 +915,11 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
       Operation op = aCqEvent.getBaseOperation();
       if (op.isCreate()) {
         ++this.numCreates;
-      }
-      else if (op.isUpdate()) {
+      } else if (op.isUpdate()) {
         ++this.numUpdates;
-      }
-      else if (op.isDestroy()) {
+      } else if (op.isDestroy()) {
         ++this.numDestroys;
-      }
-      else {
+      } else {
         ++this.numOtherOps;
       }
       eventList.add(aCqEvent);
@@ -1025,14 +958,16 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
         int index = indices[indexIndex];
         Iterator eventIter = this.eventList.iterator();
         boolean foundKey = false;
+
         while (eventIter.hasNext()) {
           CqEvent event = (CqEvent)eventIter.next();
-          if (SecurityTestUtil.KEYS[index].equals(event.getKey())) {
+          if (KEYS[index].equals(event.getKey())) {
             assertEquals(vals[index], event.getNewValue());
             foundKey = true;
             break;
           }
         }
+
         assertTrue(foundKey);
       }
     }
@@ -1042,10 +977,9 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
    * This class specifies flags that can be used to alter the behaviour of
    * operations being performed by the <code>doOp</code> function.
    * 
-   * @author sumedh
    * @since 5.5
    */
-  public static class OpFlags {
+  protected static class OpFlags {
 
     /**
      * Default behaviour.
@@ -1139,8 +1073,8 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
      * Use the {@link LocalRegion#getEntry} under transaction.
      */
     public static final int USE_GET_ENTRY_IN_TX = 0x10000;
-    
-    static public String description(int f) {
+
+    public static String description(int f) {
       StringBuffer sb = new StringBuffer();
       sb.append("[");
       if ((f & CHECK_FAIL) != 0) {
@@ -1200,10 +1134,9 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
    * This class encapsulates an {@link OperationCode} with associated flags, the
    * client to perform the operation, and the number of operations to perform.
    * 
-   * @author sumedh
    * @since 5.5
    */
-  public static class OperationWithAction {
+  protected static class OperationWithAction {
 
     /**
      * The operation to be performed.
@@ -1241,18 +1174,15 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
      * Indicates end of an operation block which can be used for testing with
      * failover
      */
-    public static final OperationWithAction OPBLOCK_END = new OperationWithAction(
-        null, 4);
+    public static final OperationWithAction OPBLOCK_END = new OperationWithAction(null, 4);
 
     /**
      * Indicates end of an operation block which should not be used for testing
      * with failover
      */
-    public static final OperationWithAction OPBLOCK_NO_FAILOVER = new OperationWithAction(
-        null, 5);
+    public static final OperationWithAction OPBLOCK_NO_FAILOVER = new OperationWithAction(null, 5);
 
     private void setIndices(int numOps) {
-
       this.indices = new int[numOps];
       for (int index = 0; index < numOps; ++index) {
         this.indices[index] = index;
@@ -1260,7 +1190,6 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
     }
 
     public OperationWithAction(OperationCode opCode) {
-
       this.opCode = opCode;
       this.authzOpCode = opCode;
       this.clientNum = 1;
@@ -1270,7 +1199,6 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
     }
 
     public OperationWithAction(OperationCode opCode, int clientNum) {
-
       this.opCode = opCode;
       this.authzOpCode = opCode;
       this.clientNum = clientNum;
@@ -1279,9 +1207,7 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
       this.opNum = 0;
     }
 
-    public OperationWithAction(OperationCode opCode, int clientNum, int flags,
-        int numOps) {
-
+    public OperationWithAction(OperationCode opCode, int clientNum, int flags, int numOps) {
       this.opCode = opCode;
       this.authzOpCode = opCode;
       this.clientNum = clientNum;
@@ -1290,9 +1216,7 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
       this.opNum = 0;
     }
 
-    public OperationWithAction(OperationCode opCode,
-        OperationCode deniedOpCode, int clientNum, int flags, int numOps) {
-
+    public OperationWithAction(OperationCode opCode, OperationCode deniedOpCode, int clientNum, int flags, int numOps) {
       this.opCode = opCode;
       this.authzOpCode = deniedOpCode;
       this.clientNum = clientNum;
@@ -1301,9 +1225,7 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
       this.opNum = 0;
     }
 
-    public OperationWithAction(OperationCode opCode, int clientNum, int flags,
-        int[] indices) {
-
+    public OperationWithAction(OperationCode opCode, int clientNum, int flags, int[] indices) {
       this.opCode = opCode;
       this.authzOpCode = opCode;
       this.clientNum = clientNum;
@@ -1312,9 +1234,7 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
       this.opNum = 0;
     }
 
-    public OperationWithAction(OperationCode opCode,
-        OperationCode deniedOpCode, int clientNum, int flags, int[] indices) {
-
+    public OperationWithAction(OperationCode opCode, OperationCode deniedOpCode, int clientNum, int flags, int[] indices) {
       this.opCode = opCode;
       this.authzOpCode = deniedOpCode;
       this.clientNum = clientNum;
@@ -1351,11 +1271,9 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
       this.opNum = opNum;
     }
 
+    @Override
     public String toString() {
-      return "opCode:" + this.opCode + ",authOpCode:" + this.authzOpCode
-          + ",clientNum:" + this.clientNum + ",flags:" + this.flags
-          + ",numOps:" + this.indices.length + ",indices:"
-          + indicesToString(this.indices);
+      return "opCode:" + this.opCode + ",authOpCode:" + this.authzOpCode + ",clientNum:" + this.clientNum + ",flags:" + this.flags + ",numOps:" + this.indices.length + ",indices:" + indicesToString(this.indices);
     }
   }
 
@@ -1364,24 +1282,21 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
    * indices also. This is utilized by the post-operation authorization tests
    * where authorization is based on key indices.
    * 
-   * @author sumedh
    * @since 5.5
    */
-  public interface TestCredentialGenerator {
+  protected interface TestCredentialGenerator {
 
     /**
      * Get allowed credentials for the given set of operations in the given
      * regions and indices of KEYS in the <code>KEYS</code> array
      */
-    public Properties getAllowedCredentials(OperationCode[] opCodes,
-        String[] regionNames, int[] keyIndices, int num);
+    public Properties getAllowedCredentials(OperationCode[] opCodes, String[] regionNames, int[] keyIndices, int num);
 
     /**
      * Get disallowed credentials for the given set of operations in the given
      * regions and indices of KEYS in the <code>KEYS</code> array
      */
-    public Properties getDisallowedCredentials(OperationCode[] opCodes,
-        String[] regionNames, int[] keyIndices, int num);
+    public Properties getDisallowedCredentials(OperationCode[] opCodes, String[] regionNames, int[] keyIndices, int num);
 
     /**
      * Get the {@link CredentialGenerator} if any.
@@ -1393,11 +1308,9 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
    * Contains a {@link AuthzCredentialGenerator} and implements the
    * {@link TestCredentialGenerator} interface.
    * 
-   * @author sumedh
    * @since 5.5
    */
-  protected static class TestAuthzCredentialGenerator implements
-      TestCredentialGenerator {
+  protected static class TestAuthzCredentialGenerator implements TestCredentialGenerator {
 
     private AuthzCredentialGenerator authzGen;
 
@@ -1405,22 +1318,16 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
       this.authzGen = authzGen;
     }
 
-    public Properties getAllowedCredentials(OperationCode[] opCodes,
-        String[] regionNames, int[] keyIndices, int num) {
-
+    public Properties getAllowedCredentials(OperationCode[] opCodes, String[] regionNames, int[] keyIndices, int num) {
       return this.authzGen.getAllowedCredentials(opCodes, regionNames, num);
     }
 
-    public Properties getDisallowedCredentials(OperationCode[] opCodes,
-        String[] regionNames, int[] keyIndices, int num) {
-
+    public Properties getDisallowedCredentials(OperationCode[] opCodes, String[] regionNames, int[] keyIndices, int num) {
       return this.authzGen.getDisallowedCredentials(opCodes, regionNames, num);
     }
 
     public CredentialGenerator getCredentialGenerator() {
-
       return authzGen.getCredentialGenerator();
     }
   }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
index 7a5b49d..50c1811 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
@@ -152,10 +152,8 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
     LogWriterUtils.getLogWriter().info(
         "testOps1: For first client credentials: " + client1Credentials[0]
             + "\n" + client1Credentials[1]);
-    client1.invoke(SecurityTestUtil.class, "createCacheClientForMultiUserMode",
-        new Object[] {Integer.valueOf(2), authInit, client1Credentials,
-            javaProps, new Integer[] {port1, port2}, null, Boolean.FALSE,
-            SecurityTestUtil.NO_EXCEPTION});
+    final Properties finalJavaProps = javaProps;
+    client1.invoke(() -> SecurityTestUtil.createCacheClientForMultiUserMode(2, authInit, client1Credentials, finalJavaProps, new int[] {port1, port2}, -1, false, SecurityTestUtil.NO_EXCEPTION));
 
     // Start client2 with valid/invalid client2OpCodes credentials
     Properties[] client2Credentials = new Properties[] {
@@ -182,17 +180,12 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
         "testOps1: For second client credentials: " + client2Credentials[0]
             + "\n" + client2Credentials[1]);
     if (bothClientsInMultiuserMode) {
-      client2.invoke(SecurityTestUtil.class,
-          "createCacheClientForMultiUserMode", new Object[] {
-              Integer.valueOf(2), authInit, client2Credentials, javaProps,
-              new Integer[] {port1, port2}, null, Boolean.FALSE,
-              SecurityTestUtil.NO_EXCEPTION});
+      final Properties finalJavaProps2 = javaProps;
+      client2.invoke(() -> SecurityTestUtil.createCacheClientForMultiUserMode(2, authInit, client2Credentials, finalJavaProps2, new int[] {port1, port2}, -1, false, SecurityTestUtil.NO_EXCEPTION));
     } else {
       int credentialsIndex = allowOp ? 0 : 1;
-      client2.invoke(SecurityTestUtil.class, "createCacheClient", new Object[] {
-          authInit, client2Credentials[credentialsIndex], javaProps,
-          new Integer[] {port1, port2}, null, Boolean.FALSE, "false",
-          SecurityTestUtil.NO_EXCEPTION});
+      final Properties finalJavaProps2 = javaProps;
+      client2.invoke(() -> SecurityTestUtil.createCacheClient(authInit, client2Credentials[credentialsIndex], finalJavaProps2, new int[] {port1, port2}, -1, false, false, SecurityTestUtil.NO_EXCEPTION));
     }
     return true;
   }
@@ -204,25 +197,15 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
   private void verifyPutsGets(Boolean isMultiuser, Boolean opAllowed)
       throws Exception {
     // Perform some put operations from client1
-    client1.invoke(SecurityTestUtil.class, "doMultiUserPuts", new Object[] {
-        Integer.valueOf(2),
-        Integer.valueOf(2),
-        new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-            SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
+    client1.invoke(() -> SecurityTestUtil.doMultiUserPuts(2, 2, new Integer[] { SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}));
 
     // Verify that the gets succeed/fail
     if (isMultiuser) {
-      client2.invoke(SecurityTestUtil.class, "doMultiUserGets", new Object[] {
-          Integer.valueOf(2),
-          Integer.valueOf(2),
-          new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-              SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
+      client2.invoke(() -> SecurityTestUtil.doMultiUserGets(2, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}));
     } else {
       int expectedResult = (opAllowed) ? SecurityTestUtil.NO_EXCEPTION
           : SecurityTestUtil.NOTAUTHZ_EXCEPTION;
-      client2.invoke(SecurityTestUtil.class, "doMultiUserGets", new Object[] {
-          Integer.valueOf(1), Integer.valueOf(1),
-          new Integer[] {expectedResult}});
+      client2.invoke(() -> SecurityTestUtil.doMultiUserGets(1, 1, new Integer[] {expectedResult}));
     }
   }
 
@@ -233,33 +216,16 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
   private void verifyContainsKeyDestroys(Boolean isMultiuser, Boolean opAllowed)
       throws Exception {
     // Do puts before verifying containsKey
-    client1.invoke(SecurityTestUtil.class, "doMultiUserPuts", new Object[] {
-        Integer.valueOf(2),
-        Integer.valueOf(2),
-        new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-            SecurityTestUtil.NO_EXCEPTION}});
-    client1.invoke(SecurityTestUtil.class, "doMultiUserContainsKeys",
-        new Object[] {
-            Integer.valueOf(1),
-            Integer.valueOf(2),
-            new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-                SecurityTestUtil.NOTAUTHZ_EXCEPTION},
-            new Boolean[] {Boolean.TRUE, Boolean.FALSE}});
+    client1.invoke(() -> SecurityTestUtil.doMultiUserPuts(2, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NO_EXCEPTION}));
+    client1.invoke(() -> SecurityTestUtil.doMultiUserContainsKeys(1, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, new Boolean[] {Boolean.TRUE, Boolean.FALSE}));
 
     // Verify that the destroys succeed/fail
     if (isMultiuser) {
-      client2.invoke(SecurityTestUtil.class, "doMultiUserDestroys",
-          new Object[] {
-              Integer.valueOf(2),
-              Integer.valueOf(2),
-              new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-                  SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
+      client2.invoke(() -> SecurityTestUtil.doMultiUserDestroys(2, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}));
     } else {
       int expectedResult = (opAllowed) ? SecurityTestUtil.NO_EXCEPTION
           : SecurityTestUtil.NOTAUTHZ_EXCEPTION;
-      client2.invoke(SecurityTestUtil.class, "doMultiUserDestroys",
-          new Object[] {Integer.valueOf(1), Integer.valueOf(1),
-              new Integer[] {expectedResult}});
+      client2.invoke(() -> SecurityTestUtil.doMultiUserDestroys(1, 1, new Integer[] {expectedResult}));
     }
   }
 
@@ -270,57 +236,30 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
   private void verifyContainsKeyInvalidates(Boolean isMultiuser, Boolean opAllowed)
       throws Exception {
     // Do puts before verifying containsKey
-    client1.invoke(SecurityTestUtil.class, "doMultiUserPuts", new Object[] {
-        Integer.valueOf(2),
-        Integer.valueOf(2),
-        new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-            SecurityTestUtil.NO_EXCEPTION}});
-    client1.invoke(SecurityTestUtil.class, "doMultiUserContainsKeys",
-        new Object[] {
-            Integer.valueOf(1),
-            Integer.valueOf(2),
-            new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-                SecurityTestUtil.NOTAUTHZ_EXCEPTION},
-            new Boolean[] {Boolean.TRUE, Boolean.FALSE}});
+    client1.invoke(() -> SecurityTestUtil.doMultiUserPuts(2, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NO_EXCEPTION}));
+    client1.invoke(() -> SecurityTestUtil.doMultiUserContainsKeys(1, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, new Boolean[] {Boolean.TRUE, Boolean.FALSE}));
 
     // Verify that the invalidates succeed/fail
     if (isMultiuser) {
-      client2.invoke(SecurityTestUtil.class, "doMultiUserInvalidates",
-          new Object[] {
-              Integer.valueOf(2),
-              Integer.valueOf(2),
-              new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-                  SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
+      client2.invoke(() -> SecurityTestUtil.doMultiUserInvalidates(2, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}));
     } else {
       int expectedResult = (opAllowed) ? SecurityTestUtil.NO_EXCEPTION
           : SecurityTestUtil.NOTAUTHZ_EXCEPTION;
-      client2.invoke(SecurityTestUtil.class, "doMultiUserInvalidates",
-          new Object[] {Integer.valueOf(1), Integer.valueOf(1),
-              new Integer[] {expectedResult}});
+      client2.invoke(() -> SecurityTestUtil.doMultiUserInvalidates(1, 1, new Integer[] {expectedResult}));
     }
   }
 
   private void verifyGetAllInTX() {
     server1.invoke(() -> ClientMultiUserAuthzDUnitTest.doPuts());
-    client1.invoke(SecurityTestUtil.class, "doMultiUserGetAll", new Object[] {
-        Integer.valueOf(2),
-        new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-            SecurityTestUtil.NOTAUTHZ_EXCEPTION}, Boolean.TRUE/*use TX*/});
+    client1.invoke(() -> SecurityTestUtil.doMultiUserGetAll(2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, Boolean.TRUE/*use TX*/));
   }
 
   private void verifyGetAllRegionDestroys() {
     server1.invoke(() -> ClientMultiUserAuthzDUnitTest.doPuts());
-    client1.invoke(SecurityTestUtil.class, "doMultiUserGetAll", new Object[] {
-        Integer.valueOf(2),
-        new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-            SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
+    client1.invoke(() -> SecurityTestUtil.doMultiUserGetAll(2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}));
 
     // Verify that the region destroys succeed/fail
-    client2.invoke(SecurityTestUtil.class, "doMultiUserRegionDestroys",
-        new Object[] {
-            Integer.valueOf(2),
-            new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-                SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
+    client2.invoke(() -> SecurityTestUtil.doMultiUserRegionDestroys(2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}));
   }
 
   public static void doPuts() {
@@ -369,11 +308,8 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
     LogWriterUtils.getLogWriter().info(
         "testOps2: For first client credentials: " + client1Credentials[0]
             + "\n" + client1Credentials[1]);
-    client1.invoke(SecurityTestUtil.class,
-        "createCacheClientForMultiUserMode", new Object[] {
-            Integer.valueOf(2), authInit, client1Credentials, javaProps,
-            new Integer[] {port1, port2}, null, Boolean.FALSE,
-            SecurityTestUtil.NO_EXCEPTION});
+    final Properties finalJavaProps = javaProps;
+    client1.invoke(() -> SecurityTestUtil.createCacheClientForMultiUserMode(2, authInit, client1Credentials, finalJavaProps, new int[] {port1, port2}, -1, false, SecurityTestUtil.NO_EXCEPTION));
 
     // Start client2 with valid/invalid EXECUTE_FUNCTION credentials
     Properties[] client2Credentials = new Properties[] {
@@ -386,79 +322,37 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
     LogWriterUtils.getLogWriter().info(
         "testOps2: For second client credentials: " + client2Credentials[0]
             + "\n" + client2Credentials[1]);
-    client2.invoke(SecurityTestUtil.class,
-        "createCacheClientForMultiUserMode", new Object[] {
-            Integer.valueOf(2), authInit, client2Credentials, javaProps,
-            new Integer[] {port1, port2}, null, Boolean.FALSE,
-            SecurityTestUtil.NO_EXCEPTION});
+    final Properties finalJavaProps2 = javaProps;
+    client2.invoke(() -> SecurityTestUtil.createCacheClientForMultiUserMode(2, authInit, client2Credentials, finalJavaProps2, new int[] {port1, port2}, -1, false, SecurityTestUtil.NO_EXCEPTION));
+
     Function function = new TestFunction(true,TestFunction.TEST_FUNCTION1);
-    server1.invoke(PRClientServerTestBase.class,
-        "registerFunction", new Object []{function});
+    server1.invoke(() -> PRClientServerTestBase.registerFunction(function));
 
-    server2.invoke(PRClientServerTestBase.class,
-        "registerFunction", new Object []{function});
+    server2.invoke(() -> PRClientServerTestBase.registerFunction(function));
 
     // Perform some put operations before verifying queries
-    client1.invoke(SecurityTestUtil.class, "doMultiUserPuts", new Object[] {
-        Integer.valueOf(4),
-        Integer.valueOf(2),
-        new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-            SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
-    client1.invoke(SecurityTestUtil.class, "doMultiUserQueries",
-        new Object[] {
-            Integer.valueOf(2),
-            new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-                SecurityTestUtil.NOTAUTHZ_EXCEPTION}, Integer.valueOf(4)});
-    client1.invoke(SecurityTestUtil.class, "doMultiUserQueryExecute",
-        new Object[] {
-            Integer.valueOf(2),
-            new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-                SecurityTestUtil.NOTAUTHZ_EXCEPTION}, Integer.valueOf(4)});
+    client1.invoke(() -> SecurityTestUtil.doMultiUserPuts(4, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}));
+    client1.invoke(() -> SecurityTestUtil.doMultiUserQueries(2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, 4));
+    client1.invoke(() -> SecurityTestUtil.doMultiUserQueryExecute(2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, 4));
 
     // Verify that the FE succeeds/fails
-    client2.invoke(SecurityTestUtil.class, "doMultiUserFE", new Object[] {
-        Integer.valueOf(2),
-        function,
-        new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-            SecurityTestUtil.NOTAUTHZ_EXCEPTION}, new Object[] {null, null},
-        Boolean.FALSE});
+    client2.invoke(() ->SecurityTestUtil.doMultiUserFE(2, function, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, new Object[] {null, null}, false));
 
     // Failover
     server1.invoke(() -> SecurityTestUtil.closeCache());
     Thread.sleep(2000);
 
-    client1.invoke(SecurityTestUtil.class, "doMultiUserPuts", new Object[] {
-        Integer.valueOf(4),
-        Integer.valueOf(2),
-        new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-            SecurityTestUtil.NOTAUTHZ_EXCEPTION}});
-
-    client1.invoke(SecurityTestUtil.class, "doMultiUserQueries",
-        new Object[] {
-            Integer.valueOf(2),
-            new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-                SecurityTestUtil.NOTAUTHZ_EXCEPTION}, Integer.valueOf(4)});
-    client1.invoke(SecurityTestUtil.class, "doMultiUserQueryExecute",
-        new Object[] {
-            Integer.valueOf(2),
-            new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-                SecurityTestUtil.NOTAUTHZ_EXCEPTION}, Integer.valueOf(4)});
-
-    // Verify that the FE succeeds/fails
-    client2.invoke(SecurityTestUtil.class, "doMultiUserFE", new Object[] {
-        Integer.valueOf(2),
-        function,
-        new Integer[] {SecurityTestUtil.NO_EXCEPTION,
-            SecurityTestUtil.NOTAUTHZ_EXCEPTION}, new Object[] {null, null},
-        Boolean.TRUE});
+    client1.invoke(() -> SecurityTestUtil.doMultiUserPuts(4, 2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}));
 
+    client1.invoke(() -> SecurityTestUtil.doMultiUserQueries(2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, 4));
+    client1.invoke(() -> SecurityTestUtil.doMultiUserQueryExecute(2, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, 4));
 
+    // Verify that the FE succeeds/fails
+    client2.invoke(() -> SecurityTestUtil.doMultiUserFE(2, function, new Integer[] {SecurityTestUtil.NO_EXCEPTION, SecurityTestUtil.NOTAUTHZ_EXCEPTION}, new Object[] {null, null}, true));
   }
 
-
   protected Integer createCacheServerOnVM(VM server, Properties javaProps, Properties serverProps) {
-    return (Integer)server.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), serverProps,
-        javaProps));
+    return server.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), serverProps, javaProps));
 
   }
 


[8/8] incubator-geode git commit: Tests are passing

Posted by kl...@apache.org.
Tests are passing


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

Branch: refs/heads/feature/GEODE-693
Commit: 4f6a5311f17b6014532fd9743d59e45ce0c0c7af
Parents: 5a321ff
Author: Kirk Lund <kl...@apache.org>
Authored: Mon Mar 28 15:48:20 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Mon Mar 28 15:48:20 2016 -0700

----------------------------------------------------------------------
 .../controllers/RestAPIsWithSSLDUnitTest.java   |    1 +
 .../security/ClientAuthenticationDUnitTest.java |  888 +-------
 .../ClientAuthenticationPart2DUnitTest.java     |   96 +-
 .../security/ClientAuthenticationTestCase.java  |  574 +++++
 .../security/ClientAuthenticationUtils.java     |   94 +
 .../security/ClientAuthorizationDUnitTest.java  |   34 +-
 .../security/ClientAuthorizationTestBase.java   |  759 +++----
 .../security/ClientMultiUserAuthzDUnitTest.java |  180 +-
 .../DeltaClientAuthorizationDUnitTest.java      |  295 +--
 .../DeltaClientPostAuthorizationDUnitTest.java  |  625 ++----
 .../security/P2PAuthenticationDUnitTest.java    |  657 +++---
 .../gemfire/security/SecurityTestUtil.java      | 2011 +++++++++---------
 .../ClientAuthorizationTwoDUnitTest.java        |   25 +-
 .../security/ClientAuthzObjectModDUnitTest.java |   38 +-
 .../ClientCQPostAuthorizationDUnitTest.java     |  183 +-
 .../ClientPostAuthorizationDUnitTest.java       |  218 +-
 .../gemfire/security/MultiuserAPIDUnitTest.java |   38 +-
 .../MultiuserDurableCQAuthzDUnitTest.java       |   77 +-
 18 files changed, 2875 insertions(+), 3918 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java
index 852591f..2217ecc 100644
--- a/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java
+++ b/geode-assembly/src/test/java/com/gemstone/gemfire/rest/internal/web/controllers/RestAPIsWithSSLDUnitTest.java
@@ -92,6 +92,7 @@ public class RestAPIsWithSSLDUnitTest extends LocatorTestBase {
   @Override
   public final void preSetUp() throws Exception {
     disconnectAllFromDS();
+    // add ignoredexception
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationDUnitTest.java
index 456a6ed..1744c15 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationDUnitTest.java
@@ -18,885 +18,77 @@
  */
 package com.gemstone.gemfire.security;
 
-import java.io.IOException;
-import java.util.Properties;
-
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLHandshakeException;
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.test.dunit.Assert.*;
 
-import com.gemstone.gemfire.security.generator.CredentialGenerator;
-import com.gemstone.gemfire.security.generator.CredentialGenerator.ClassCode;
+import java.util.Properties;
 
 import com.gemstone.gemfire.cache.Region;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.AvailablePort;
-import com.gemstone.gemfire.security.generator.DummyCredentialGenerator;
-import com.gemstone.gemfire.test.dunit.DistributedTestCase;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.IgnoredException;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
-import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 /**
  * Test for authentication from client to server. This tests for both valid and
  * invalid credentials/modules. It also checks for authentication
  * success/failure in case of failover and for the notification channel.
  * 
- * @author sumedh
  * @since 5.5
  */
-public class ClientAuthenticationDUnitTest extends DistributedTestCase {
-
-  /** constructor */
-  public ClientAuthenticationDUnitTest(String name) {
-    super(name);
-  }
-
-  private VM server1 = null;
-
-  private VM server2 = null;
-
-  private VM client1 = null;
-
-  private VM client2 = null;
-
-  private static final String[] serverExpectedExceptions = {
-      AuthenticationRequiredException.class.getName(),
-      AuthenticationFailedException.class.getName(),
-      GemFireSecurityException.class.getName(),
-      ClassNotFoundException.class.getName(), IOException.class.getName(),
-      SSLException.class.getName(), SSLHandshakeException.class.getName() };
-
-  private static final String[] clientExpectedExceptions = {
-      AuthenticationRequiredException.class.getName(),
-      AuthenticationFailedException.class.getName(),
-      SSLHandshakeException.class.getName() };
-
-  @Override
-  public final void postSetUp() throws Exception {
-    final Host host = Host.getHost(0);
-    server1 = host.getVM(0);
-    server2 = host.getVM(1);
-    client1 = host.getVM(2);
-    client2 = host.getVM(3);
-    
-    IgnoredException.addIgnoredException("Connection refused: connect");
-
-    server1.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    client1.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions ));
-    client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions ));
-  }
-
-  // Region: Utility and static functions invoked by the tests
-
-  public static Integer createCacheServer(Object dsPort, Object locatorString,
-      Object authenticator, Object extraProps, Object javaProps) {
-
-    Properties authProps;
-    if (extraProps == null) {
-      authProps = new Properties();
-    }
-    else {
-      authProps = (Properties)extraProps;
-    }
-    if (authenticator != null) {
-      authProps.setProperty(
-          DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator
-              .toString());
-    }
-    return SecurityTestUtil.createCacheServer(authProps, javaProps,
-        (Integer)dsPort, (String)locatorString, null, new Integer(
-            SecurityTestUtil.NO_EXCEPTION));
-  }
-
-  public static void createCacheServer(Object dsPort, Object locatorString,
-      Integer serverPort, Object authenticator, Object extraProps,
-      Object javaProps) {
-
-    Properties authProps;
-    if (extraProps == null) {
-      authProps = new Properties();
-    }
-    else {
-      authProps = (Properties)extraProps;
-    }
-    if (authenticator != null) {
-      authProps.setProperty(
-          DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator
-              .toString());
-    }
-    SecurityTestUtil.createCacheServer(authProps, javaProps, (Integer)dsPort,
-        (String)locatorString, serverPort, new Integer(
-            SecurityTestUtil.NO_EXCEPTION));
-  }
-
-  private static void createCacheClient(Object authInit, Properties authProps,
-      Properties javaProps, Integer[] ports, Object numConnections,
-      Boolean multiUserMode, Boolean subscriptionEnabled, Integer expectedResult) {
-
-    String authInitStr = (authInit == null ? null : authInit.toString());
-    SecurityTestUtil.createCacheClient(authInitStr, authProps, javaProps,
-        ports, (Integer)numConnections, Boolean.FALSE,
-        multiUserMode.toString(), subscriptionEnabled, expectedResult);
-  }
-
-  public static void createCacheClient(Object authInit, Object authProps,
-      Object javaProps, Integer[] ports, Object numConnections,
-      Boolean multiUserMode, Integer expectedResult) {
-
-    createCacheClient(authInit, (Properties)authProps, (Properties)javaProps,
-        ports, numConnections, multiUserMode, Boolean.TRUE, expectedResult);
-  }
-
-  public static void createCacheClient(Object authInit, Object authProps,
-      Object javaProps, Integer port1, Object numConnections,
-      Integer expectedResult) {
-
-    createCacheClient(authInit, (Properties)authProps, (Properties)javaProps,
-        new Integer[] { port1 }, numConnections, Boolean.FALSE, Boolean.TRUE,
-        expectedResult);
-  }
-
-  public static void createCacheClient(Object authInit, Object authProps,
-      Object javaProps, Integer port1, Integer port2, Object numConnections,
-      Integer expectedResult) {
-    createCacheClient(authInit, authProps, javaProps, port1, port2,
-        numConnections, Boolean.FALSE, expectedResult);
-  }
-
-  public static void createCacheClient(Object authInit, Object authProps,
-      Object javaProps, Integer port1, Integer port2, Object numConnections,
-      Boolean multiUserMode, Integer expectedResult) {
-
-    createCacheClient(authInit, authProps, javaProps,
-        port1, port2, numConnections, multiUserMode, Boolean.TRUE,
-        expectedResult);
-  }
-
-  public static void createCacheClient(Object authInit, Object authProps,
-      Object javaProps, Integer port1, Integer port2, Object numConnections,
-      Boolean multiUserMode, Boolean subscriptionEnabled,
-      Integer expectedResult) {
-
-    createCacheClient(authInit, (Properties)authProps, (Properties)javaProps,
-        new Integer[] { port1, port2 }, numConnections, multiUserMode,
-        subscriptionEnabled, expectedResult);
-  }
-
-  public static void registerAllInterest() {
-
-    Region region = SecurityTestUtil.getCache().getRegion(
-        SecurityTestUtil.regionName);
-    assertNotNull(region);
-    region.registerInterestRegex(".*");
-  }
-
-  // End Region: Utility and static functions invoked by the tests
-
-  // Region: Tests
-
-  public void testValidCredentials() {
-    itestValidCredentials(Boolean.FALSE);
-  }
-
-  public void itestValidCredentials(Boolean multiUser) {
-      CredentialGenerator gen = new DummyCredentialGenerator();
-      Properties extraProps = gen.getSystemProperties();
-      Properties javaProps = gen.getJavaProperties();
-      String authenticator = gen.getAuthenticator();
-      String authInit = gen.getAuthInit();
-
-      LogWriterUtils.getLogWriter().info(
-          "testValidCredentials: Using scheme: " + gen.classCode());
-      LogWriterUtils.getLogWriter().info(
-          "testValidCredentials: Using authenticator: " + authenticator);
-      LogWriterUtils.getLogWriter().info("testValidCredentials: Using authinit: " + authInit);
-
-      // Start the servers
-      Integer locPort1 = SecurityTestUtil.getLocatorPort();
-      Integer locPort2 = SecurityTestUtil.getLocatorPort();
-      String locString = SecurityTestUtil.getLocatorString();
-      Integer port1 = (Integer)server1.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort1, locString, authenticator, extraProps,
-              javaProps ));
-      Integer port2 = (Integer)server2.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort2, locString, authenticator, extraProps,
-              javaProps ));
-
-      // Start the clients with valid credentials
-      Properties credentials1 = gen.getValidCredentials(1);
-      Properties javaProps1 = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testValidCredentials: For first client credentials: " + credentials1
-              + " : " + javaProps1);
-      Properties credentials2 = gen.getValidCredentials(2);
-      Properties javaProps2 = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testValidCredentials: For second client credentials: "
-              + credentials2 + " : " + javaProps2);
-      createClientsNoException(multiUser, authInit, port1, port2, credentials1,
-          javaProps1, credentials2, javaProps2);
-
-      // Perform some put operations from client1
-      client1.invoke(() -> SecurityTestUtil.doPuts( new Integer(2) ));
-
-      // Verify that the puts succeeded
-      client2.invoke(() -> SecurityTestUtil.doGets( new Integer(2) ));
-      
-      if (multiUser) {
-        client1.invoke(() -> SecurityTestUtil.doProxyCacheClose());
-        client2.invoke(() -> SecurityTestUtil.doProxyCacheClose());
-        client1.invoke(() -> SecurityTestUtil.doSimplePut("CacheClosedException"));
-        client2.invoke(() -> SecurityTestUtil.doSimpleGet("CacheClosedException"));
-      }
-  }
-
-  public void testNoCredentials() {
-    itestNoCredentials(Boolean.FALSE);
-  }
-
-  public void itestNoCredentials(Boolean multiUser) {
-      CredentialGenerator gen = new DummyCredentialGenerator();
-      Properties extraProps = gen.getSystemProperties();
-      Properties javaProps = gen.getJavaProperties();
-      String authenticator = gen.getAuthenticator();
-      String authInit = gen.getAuthInit();
-
-      LogWriterUtils.getLogWriter()
-          .info("testNoCredentials: Using scheme: " + gen.classCode());
-      LogWriterUtils.getLogWriter().info(
-          "testNoCredentials: Using authenticator: " + authenticator);
-      LogWriterUtils.getLogWriter().info("testNoCredentials: Using authinit: " + authInit);
-
-      // Start the servers
-      Integer locPort1 = SecurityTestUtil.getLocatorPort();
-      Integer locPort2 = SecurityTestUtil.getLocatorPort();
-      String locString = SecurityTestUtil.getLocatorString();
-      Integer port1 = createServer1(extraProps, javaProps, authenticator,
-          locPort1, locString);
-      Integer port2 = ((Integer)server2.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort2, locString, authenticator, extraProps,
-              javaProps )));
-
-      // Start first client with valid credentials
-      Properties credentials1 = gen.getValidCredentials(1);
-      Properties javaProps1 = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testNoCredentials: For first client credentials: " + credentials1
-              + " : " + javaProps1);
-      createClient1NoException(multiUser, authInit, port1, port2, credentials1,
-          javaProps1);
-
-      // Perform some put operations from client1
-      client1.invoke(() -> SecurityTestUtil.doPuts( new Integer(2) ));
-
-      // Trying to create the region on client2 
-      if (gen.classCode().equals(ClassCode.SSL)) {
-        // For SSL the exception may not come since the server can close socket
-        // before handshake message is sent from client. However exception
-        // should come in any region operations.
-        client2
-            .invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( null, null, null, port1, port2, null, multiUser,
-                    new Integer(SecurityTestUtil.NO_EXCEPTION) ));
-        client2.invoke(() -> SecurityTestUtil.doPuts(
-            new Integer(2), new Integer(SecurityTestUtil.OTHER_EXCEPTION) ));
-      }
-      else {
-        client2.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( null, null, null, port1, port2,
-                null, multiUser, new Integer(SecurityTestUtil.AUTHREQ_EXCEPTION) ));
-      }
-  }
-
-  public void testInvalidCredentials() {
-    itestInvalidCredentials(Boolean.FALSE);
-  }
-
-  public void itestInvalidCredentials(Boolean multiUser) {
-
-
-      CredentialGenerator gen = new DummyCredentialGenerator();
-      Properties extraProps = gen.getSystemProperties();
-      Properties javaProps = gen.getJavaProperties();
-      String authenticator = gen.getAuthenticator();
-      String authInit = gen.getAuthInit();
-
-      LogWriterUtils.getLogWriter().info(
-          "testInvalidCredentials: Using scheme: " + gen.classCode());
-      LogWriterUtils.getLogWriter().info(
-          "testInvalidCredentials: Using authenticator: " + authenticator);
-      LogWriterUtils.getLogWriter()
-          .info("testInvalidCredentials: Using authinit: " + authInit);
-
-      // Start the servers
-      Integer locPort1 = SecurityTestUtil.getLocatorPort();
-      Integer locPort2 = SecurityTestUtil.getLocatorPort();
-      String locString = SecurityTestUtil.getLocatorString();
-      Integer port1 = createServer1(extraProps, javaProps, authenticator,
-          locPort1, locString);
-      Integer port2 = ((Integer)server2.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort2, locString, authenticator, extraProps,
-              javaProps )));
-
-      // Start first client with valid credentials
-      Properties credentials1 = gen.getValidCredentials(1);
-      Properties javaProps1 = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testInvalidCredentials: For first client credentials: "
-              + credentials1 + " : " + javaProps1);
-      createClient1NoException(multiUser, authInit, port1, port2, credentials1,
-          javaProps1);
-
-      // Perform some put operations from client1
-      client1.invoke(() -> SecurityTestUtil.doPuts( new Integer(2) ));
-
-      // Start second client with invalid credentials
-      // Trying to create the region on client2 should throw a security
-      // exception
-      Properties credentials2 = gen.getInvalidCredentials(1);
-      Properties javaProps2 = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testInvalidCredentials: For second client credentials: "
-              + credentials2 + " : " + javaProps2);
-      client2.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, credentials2, javaProps2, port1, port2,
-              null, multiUser, new Integer(SecurityTestUtil.AUTHFAIL_EXCEPTION) ));
-  }
-
-  public void testInvalidAuthInit() {
-    itestInvalidAuthInit(Boolean.FALSE);
-  }
+@Category(DistributedTest.class)
+public class ClientAuthenticationDUnitTest extends ClientAuthenticationTestCase {
 
-  public void itestInvalidAuthInit(Boolean multiUser) {
-
-      CredentialGenerator gen = new DummyCredentialGenerator();
-      Properties extraProps = gen.getSystemProperties();
-      Properties javaProps = gen.getJavaProperties();
-      String authenticator = gen.getAuthenticator();
-
-      LogWriterUtils.getLogWriter().info(
-          "testInvalidAuthInit: Using scheme: " + gen.classCode());
-      LogWriterUtils.getLogWriter().info(
-          "testInvalidAuthInit: Using authenticator: " + authenticator);
-
-      // Start the server
-      Integer locPort1 = SecurityTestUtil.getLocatorPort();
-      String locString = SecurityTestUtil.getLocatorString();
-      Integer port1 = createServer1(extraProps, javaProps, authenticator,
-          locPort1, locString);
-
-      Properties credentials = gen.getValidCredentials(1);
-      javaProps = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testInvalidAuthInit: For first client credentials: " + credentials
-              + " : " + javaProps);
-      client1.invoke(ClientAuthenticationDUnitTest.class, "createCacheClient",
-          new Object[] { "com.gemstone.none", credentials, javaProps,
-            new Integer[] { port1 }, null, multiUser,
-            Integer.valueOf(SecurityTestUtil.AUTHREQ_EXCEPTION) });
-  }
-
-  protected Integer createServer1(Properties extraProps, Properties javaProps,
-      String authenticator, Integer locPort1, String locString) {
-    Integer port1 = ((Integer)server1.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort1, locString, authenticator, extraProps,
-            javaProps )));
-    return port1;
-  }
-
-  public void testNoAuthInitWithCredentials() {
-    itestNoAuthInitWithCredentials(Boolean.FALSE);
-  }
-
-  public void itestNoAuthInitWithCredentials(Boolean multiUser) {
-
-      CredentialGenerator gen = new DummyCredentialGenerator();
-      Properties extraProps = gen.getSystemProperties();
-      Properties javaProps = gen.getJavaProperties();
-      String authenticator = gen.getAuthenticator();
-
-
-      LogWriterUtils.getLogWriter().info(
-          "testNoAuthInitWithCredentials: Using scheme: " + gen.classCode());
-      LogWriterUtils.getLogWriter().info(
-          "testNoAuthInitWithCredentials: Using authenticator: "
-              + authenticator);
-
-      // Start the servers
-      Integer locPort1 = SecurityTestUtil.getLocatorPort();
-      Integer locPort2 = SecurityTestUtil.getLocatorPort();
-      String locString = SecurityTestUtil.getLocatorString();
-      Integer port1 = createServer1(extraProps, javaProps, authenticator,
-          locPort1, locString);
-      Integer port2 = ((Integer)server2.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort2, locString, authenticator, extraProps,
-              javaProps )));
-
-      // Start the clients with valid credentials
-      Properties credentials1 = gen.getValidCredentials(1);
-      Properties javaProps1 = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testNoAuthInitWithCredentials: For first client credentials: "
-              + credentials1 + " : " + javaProps1);
-      Properties credentials2 = gen.getValidCredentials(2);
-      Properties javaProps2 = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testNoAuthInitWithCredentials: For second client credentials: "
-              + credentials2 + " : " + javaProps2);
-      client1.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( null, credentials1, javaProps1, port1, port2, null,
-          multiUser, new Integer(SecurityTestUtil.AUTHREQ_EXCEPTION) ));
-      client2.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( null, credentials2, javaProps2, port1, port2, null,
-          multiUser, new Integer(SecurityTestUtil.AUTHREQ_EXCEPTION) ));
-      client2.invoke(() -> SecurityTestUtil.closeCache());
-      
-
-      // Now also try with invalid credentials
-      Properties credentials3 = gen.getInvalidCredentials(5);
-      Properties javaProps3 = gen.getJavaProperties();
-      client2.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( null, credentials3, javaProps3, port1, port2, null,
-          multiUser, new Integer(SecurityTestUtil.AUTHREQ_EXCEPTION) ));
-  }
-
-  public void testInvalidAuthenticator() {
-    itestInvalidAuthenticator(Boolean.FALSE);
-  }
-
-  public void itestInvalidAuthenticator(Boolean multiUser) {
-
-      CredentialGenerator gen = new DummyCredentialGenerator();
-      Properties extraProps = gen.getSystemProperties();
-      Properties javaProps = gen.getJavaProperties();
-      String authInit = gen.getAuthInit();
-
-      LogWriterUtils.getLogWriter().info(
-          "testInvalidAuthenticator: Using scheme: " + gen.classCode());
-      LogWriterUtils.getLogWriter().info(
-          "testInvalidAuthenticator: Using authinit: " + authInit);
-
-      // Start the server with invalid authenticator
-      Integer locPort1 = SecurityTestUtil.getLocatorPort();
-      String locString = SecurityTestUtil.getLocatorString();
-      Integer port1 = (Integer)server1.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort1, locString, "com.gemstone.gemfire.none",
-              extraProps, javaProps ));
-
-      // Trying to create the region on client should throw a security exception
-      Properties credentials2 = gen.getValidCredentials(1);
-      Properties javaProps2 = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testInvalidAuthenticator: For first client credentials: "
-              + credentials2 + " : " + javaProps2);
-      client1.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, credentials2, javaProps2, port1, null,
-              new Integer(SecurityTestUtil.AUTHFAIL_EXCEPTION) ));
-      client1.invoke(() -> SecurityTestUtil.closeCache());
-      
-
-      // Also test with invalid credentials
-      Properties credentials3 = gen.getInvalidCredentials(1);
-      Properties javaProps3 = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testInvalidAuthenticator: For first client credentials: "
-              + credentials3 + " : " + javaProps3);
-      client1.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, credentials3, javaProps3, port1, null,
-              new Integer(SecurityTestUtil.AUTHFAIL_EXCEPTION) ));
-  }
-
-  public void testNoAuthenticatorWithCredentials() {
-    itestNoAuthenticatorWithCredentials(Boolean.FALSE);
-  }
-
-  public void itestNoAuthenticatorWithCredentials(Boolean multiUser) {
-
-      CredentialGenerator gen = new DummyCredentialGenerator();
-      Properties extraProps = gen.getSystemProperties();
-      Properties javaProps = gen.getJavaProperties();
-      String authenticator = gen.getAuthenticator();
-      String authInit = gen.getAuthInit();
-
-      LogWriterUtils.getLogWriter().info(
-          "testNoAuthenticatorWithCredentials: Using scheme: "
-              + gen.classCode());
-      LogWriterUtils.getLogWriter().info(
-          "testNoAuthenticatorWithCredentials: Using authinit: " + authInit);
-
-      // Start the servers with no authenticator
-      Integer locPort1 = SecurityTestUtil.getLocatorPort();
-      Integer locPort2 = SecurityTestUtil.getLocatorPort();
-      String locString = SecurityTestUtil.getLocatorString();
-      Integer port1 = (Integer)server1.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort1, locString, null, extraProps, javaProps ));
-      Integer port2 = (Integer)server2.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort2, locString, null, extraProps, javaProps ));
-
-      // Clients should connect successfully and work properly with
-      // valid/invalid credentials when none are required on the server side
-      Properties credentials1 = gen.getValidCredentials(3);
-      Properties javaProps1 = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testNoAuthenticatorWithCredentials: For first client credentials: "
-              + credentials1 + " : " + javaProps1);
-      Properties credentials2 = gen.getInvalidCredentials(5);
-      Properties javaProps2 = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testNoAuthenticatorWithCredentials: For second client credentials: "
-              + credentials2 + " : " + javaProps2);
-      createClientsNoException(multiUser, authInit, port1, port2, credentials1,
-          javaProps1, credentials2, javaProps2);
-
-      // Perform some put operations from client1
-      client1.invoke(() -> SecurityTestUtil.doPuts( new Integer(2) ));
-
-      // Verify that the puts succeeded
-      client2.invoke(() -> SecurityTestUtil.doGets( new Integer(2) ));
-  }
-
-  public void testCredentialsWithFailover() {
-    itestCredentialsWithFailover(Boolean.FALSE);
+  @Test
+  public void testValidCredentials() throws Exception {
+    doTestValidCredentials(Boolean.FALSE);
   }
 
-  public void itestCredentialsWithFailover(Boolean multiUser) {
-      CredentialGenerator gen = new DummyCredentialGenerator();
-      Properties extraProps = gen.getSystemProperties();
-      Properties javaProps = gen.getJavaProperties();
-      String authenticator = gen.getAuthenticator();
-      String authInit = gen.getAuthInit();
-
-      LogWriterUtils.getLogWriter().info(
-          "testCredentialsWithFailover: Using scheme: " + gen.classCode());
-      LogWriterUtils.getLogWriter().info(
-          "testCredentialsWithFailover: Using authenticator: " + authenticator);
-      LogWriterUtils.getLogWriter().info(
-          "testCredentialsWithFailover: Using authinit: " + authInit);
-
-      // Start the first server
-      Integer locPort1 = SecurityTestUtil.getLocatorPort();
-      Integer locPort2 = SecurityTestUtil.getLocatorPort();
-      String locString = SecurityTestUtil.getLocatorString();
-      Integer port1 = (Integer)server1.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort1, locString, authenticator, extraProps,
-              javaProps ));
-      // Get a port for second server but do not start it
-      // This forces the clients to connect to the first server
-      Integer port2 = new Integer(AvailablePort
-          .getRandomAvailablePort(AvailablePort.SOCKET));
-
-      // Start the clients with valid credentials
-      Properties credentials1 = gen.getValidCredentials(5);
-      Properties javaProps1 = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testCredentialsWithFailover: For first client credentials: "
-              + credentials1 + " : " + javaProps1);
-      Properties credentials2 = gen.getValidCredentials(6);
-      Properties javaProps2 = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testCredentialsWithFailover: For second client credentials: "
-              + credentials2 + " : " + javaProps2);
-      createClientsNoException(multiUser, authInit, port1, port2, credentials1,
-          javaProps1, credentials2, javaProps2);
-
-      // Perform some put operations from client1
-      client1.invoke(() -> SecurityTestUtil.doPuts( new Integer(2) ));
-      // Verify that the puts succeeded
-      client2.invoke(() -> SecurityTestUtil.doGets( new Integer(2) ));
-
-      // start the second one and stop the first server to force a failover
-      server2.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort2, locString, port2, authenticator, extraProps,
-              javaProps ));
-      server1.invoke(() -> SecurityTestUtil.closeCache());
-
-      // Perform some create/update operations from client1
-      client1.invoke(() -> SecurityTestUtil.doNPuts( new Integer(4) ));
-      // Verify that the creates/updates succeeded
-      client2.invoke(() -> SecurityTestUtil.doNGets( new Integer(4) ));
-
-      // Try to connect client2 with no credentials
-      // Verify that the creation of region throws security exception
-      if (gen.classCode().equals(ClassCode.SSL)) {
-        // For SSL the exception may not come since the server can close socket
-        // before handshake message is sent from client. However exception
-        // should come in any region operations.
-        client2
-            .invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( null, null, null, port1, port2, null, multiUser,
-                    new Integer(SecurityTestUtil.NOFORCE_AUTHREQ_EXCEPTION) ));
-        client2.invoke(() -> SecurityTestUtil.doPuts(
-            new Integer(2), new Integer(SecurityTestUtil.OTHER_EXCEPTION) ));
-      }
-      else {
-        client2.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( null, null, null, port1, port2,
-                null, multiUser, new Integer(SecurityTestUtil.AUTHREQ_EXCEPTION) ));
-      }
-
-      // Now try to connect client1 with invalid credentials
-      // Verify that the creation of region throws security exception
-      Properties credentials3 = gen.getInvalidCredentials(7);
-      Properties javaProps3 = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testCredentialsWithFailover: For first client invalid credentials: "
-              + credentials3 + " : " + javaProps3);
-      client1.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, credentials3, javaProps3, port1, port2,
-              null, multiUser, new Integer(SecurityTestUtil.AUTHFAIL_EXCEPTION) ));
-
-      if (multiUser) {
-        client1.invoke(() -> SecurityTestUtil.doProxyCacheClose());
-        client2.invoke(() -> SecurityTestUtil.doProxyCacheClose());
-        client1.invoke(() -> SecurityTestUtil.doSimplePut("CacheClosedException"));
-        client2.invoke(() -> SecurityTestUtil.doSimpleGet("CacheClosedException"));
-      }
+  @Test
+  public void testNoCredentials() throws Exception {
+    doTestNoCredentials(Boolean.FALSE);
   }
 
-  protected void createClientsNoException(Boolean multiUser, String authInit,
-      Integer port1, Integer port2, Properties credentials1,
-      Properties javaProps1, Properties credentials2, Properties javaProps2) {
-    createClient1NoException(multiUser, authInit, port1, port2, credentials1,
-        javaProps1);
-    client2.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, credentials2, javaProps2, port1, port2,
-            null, multiUser, new Integer(SecurityTestUtil.NO_EXCEPTION) ));
+  @Test
+  public void testInvalidCredentials() throws Exception {
+    doTestInvalidCredentials(Boolean.FALSE);
   }
 
-  public void testCredentialsForNotifications() {
-    itestCredentialsForNotifications(Boolean.FALSE);
+  @Test
+  public void testInvalidAuthInit() throws Exception {
+    doTestInvalidAuthInit(Boolean.FALSE);
   }
 
-  public void itestCredentialsForNotifications(Boolean multiUser) {
-      CredentialGenerator gen = new DummyCredentialGenerator();
-      Properties extraProps = gen.getSystemProperties();
-      Properties javaProps = gen.getJavaProperties();
-      String authenticator = gen.getAuthenticator();
-      String authInit = gen.getAuthInit();
-
-      LogWriterUtils.getLogWriter().info(
-          "testCredentialsForNotifications: Using scheme: " + gen.classCode());
-      LogWriterUtils.getLogWriter().info(
-          "testCredentialsForNotifications: Using authenticator: "
-              + authenticator);
-      LogWriterUtils.getLogWriter().info(
-          "testCredentialsForNotifications: Using authinit: " + authInit);
-
-      // Start the first server
-      Integer locPort1 = SecurityTestUtil.getLocatorPort();
-      Integer locPort2 = SecurityTestUtil.getLocatorPort();
-      String locString = SecurityTestUtil.getLocatorString();
-      Integer port1 = (Integer)server1.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort1, locString, authenticator, extraProps,
-              javaProps ));
-      // Get a port for second server but do not start it
-      // This forces the clients to connect to the first server
-      Integer port2 = new Integer(AvailablePort
-          .getRandomAvailablePort(AvailablePort.SOCKET));
-
-      // Start the clients with valid credentials
-      Properties credentials1 = gen.getValidCredentials(3);
-      Properties javaProps1 = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testCredentialsForNotifications: For first client credentials: "
-              + credentials1 + " : " + javaProps1);
-      Properties credentials2 = gen.getValidCredentials(4);
-      Properties javaProps2 = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testCredentialsForNotifications: For second client credentials: "
-              + credentials2 + " : " + javaProps2);
-      createClient1NoException(multiUser, authInit, port1, port2, credentials1,
-          javaProps1);
-      // Set up zero forward connections to check notification handshake only
-      Object zeroConns = new Integer(0);
-      createClient2NoException(multiUser, authInit, port1, port2, credentials2,
-          javaProps2, zeroConns);
-
-      // Register interest on all keys on second client
-      client2
-          .invoke(() -> ClientAuthenticationDUnitTest.registerAllInterest());
-
-      // Perform some put operations from client1
-      client1.invoke(() -> SecurityTestUtil.doPuts( new Integer(2) ));
-
-      // Verify that the puts succeeded
-      client2.invoke(() -> SecurityTestUtil.doLocalGets( new Integer(2) ));
-
-      // start the second one and stop the first server to force a failover
-      server2.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort2, locString, port2, authenticator, extraProps,
-              javaProps ));
-      server1.invoke(() -> SecurityTestUtil.closeCache());
-
-      // Wait for failover to complete
-      Wait.pause(500);
-
-      // Perform some create/update operations from client1
-      client1.invoke(() -> SecurityTestUtil.doNPuts( new Integer(4) ));
-      // Verify that the creates/updates succeeded
-      client2.invoke(() -> SecurityTestUtil.doNLocalGets( new Integer(4) ));
-
-      // Try to connect client1 with no credentials
-      // Verify that the creation of region throws security exception
-      server1.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort1, locString, port1, authenticator, extraProps,
-              javaProps ));
-      if (gen.classCode().equals(ClassCode.SSL)) {
-        // For SSL the exception may not come since the server can close socket
-        // before handshake message is sent from client. However exception
-        // should come in any region operations.
-        client1.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( null, null, null, port1, port2,
-                zeroConns, multiUser,
-                new Integer(SecurityTestUtil.NOFORCE_AUTHREQ_EXCEPTION) ));
-        client1.invoke(() -> SecurityTestUtil.doPuts(
-            new Integer(2), new Integer(SecurityTestUtil.OTHER_EXCEPTION) ));
-      }
-      else {
-        client1.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( null, null, null, port1, port2,
-                zeroConns, multiUser, new Integer(SecurityTestUtil.AUTHREQ_EXCEPTION) ));
-      }
-
-      // Now try to connect client2 with invalid credentials
-      // Verify that the creation of region throws security exception
-      credentials2 = gen.getInvalidCredentials(3);
-      javaProps2 = gen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testCredentialsForNotifications: For second client invalid credentials: "
-              + credentials2 + " : " + javaProps2);
-      createClient2WithException(multiUser, authInit, port1, port2,
-          credentials2, javaProps2, zeroConns);
-
-      // Now try to connect client2 with invalid auth-init method
-      // Trying to create the region on client with valid credentials should
-      // throw a security exception
-      client2
-          .invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( "com.gemstone.none", credentials1, javaProps1,
-                  port1, port2, zeroConns, multiUser, 
-                  new Integer(SecurityTestUtil.AUTHREQ_EXCEPTION) ));
-
-      // Now start the servers with invalid authenticator method.
-      // Skip this test for a scheme which does not have an authInit in the
-      // first place (e.g. SSL) since that will fail with AuthReqEx before
-      // authenticator is even invoked.
-      if (authInit != null && authInit.length() > 0) {
-        server1.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort1, locString, port1,
-                "com.gemstone.gemfire.none", extraProps, javaProps ));
-        server2.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort2, locString, port2,
-                "com.gemstone.gemfire.none", extraProps, javaProps ));
-
-        createClient2WithException(multiUser, authInit, port1, port2,
-            credentials1, javaProps1, zeroConns);
-        createClient1WithException(multiUser, authInit, port1, port2,
-            credentials2, javaProps2, zeroConns);
-      }
-      else {
-        LogWriterUtils.getLogWriter().info(
-            "testCredentialsForNotifications: Skipping invalid authenticator for scheme ["
-                + gen.classCode() + "] which has no authInit");
-      }
-
-      // Try connection with null auth-init on clients.
-      // Skip this test for a scheme which does not have an authInit in the
-      // first place (e.g. SSL).
-      if (authInit != null && authInit.length() > 0) {
-        server1.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort1, locString, port1,
-                authenticator, extraProps, javaProps ));
-        server2.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort2, locString, port2,
-                authenticator, extraProps, javaProps ));
-        client1.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( null, credentials1, javaProps1,
-                port1, port2, null, multiUser,
-                new Integer(SecurityTestUtil.AUTHREQ_EXCEPTION) ));
-        createClient2AuthReqException(multiUser, port1, port2, credentials2,
-            javaProps2, zeroConns);
-
-        createClient2AuthReqException(multiUser, port1, port2, credentials2,
-            javaProps2, zeroConns);
-      }
-      else {
-        LogWriterUtils.getLogWriter().info(
-            "testCredentialsForNotifications: Skipping null authInit for scheme ["
-                + gen.classCode() + "] which has no authInit");
-      }
-
-      // Try connection with null authenticator on server and sending
-      // valid/invalid credentials.
-      // If the scheme does not have an authenticator in the first place (e.g.
-      // SSL) then skip it since this test is useless.
-      if (authenticator != null && authenticator.length() > 0) {
-        server1.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort1, locString, port1,
-                null, extraProps, javaProps ));
-        server2.invoke(() -> ClientAuthenticationDUnitTest.createCacheServer( locPort2, locString, port2,
-                null, extraProps, javaProps ));
-        createClient1NoException(multiUser, authInit, port1, port2,
-            credentials1, javaProps1);
-        createClient2NoException(multiUser, authInit, port1, port2,
-            credentials2, javaProps2, zeroConns);
-
-        // Register interest on all keys on second client
-        client2.invoke(() -> ClientAuthenticationDUnitTest.registerAllInterest());
-
-        // Perform some put operations from client1
-        client1.invoke(() -> SecurityTestUtil.doPuts( new Integer(4) ));
-
-        // Verify that the puts succeeded
-        client2.invoke(() -> SecurityTestUtil.doLocalGets( new Integer(4) ));
-
-        // Now also try with valid credentials on client2
-        createClient1NoException(multiUser, authInit, port1, port2,
-            credentials2, javaProps2);
-        createClient2NoException(multiUser, authInit, port1, port2,
-            credentials1, javaProps1, zeroConns);
-
-        // Register interest on all keys on second client
-        client2.invoke(() -> ClientAuthenticationDUnitTest.registerAllInterest());
-
-        // Perform some put operations from client1
-        client1.invoke(() -> SecurityTestUtil.doNPuts( new Integer(4) ));
-
-        // Verify that the puts succeeded
-        client2.invoke(() -> SecurityTestUtil.doNLocalGets( new Integer(4) ));
-      }
-      else {
-        LogWriterUtils.getLogWriter().info(
-            "testCredentialsForNotifications: Skipping scheme ["
-                + gen.classCode() + "] which has no authenticator");
-      }
+  @Test
+  public void testNoAuthInitWithCredentials() throws Exception {
+    doTestNoAuthInitWithCredentials(Boolean.FALSE);
   }
 
-  protected void createClient1NoException(Boolean multiUser, String authInit,
-      Integer port1, Integer port2, Properties credentials2,
-      Properties javaProps2) {
-    client1.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, credentials2,
-            javaProps2, port1, port2, null, multiUser,
-            new Integer(SecurityTestUtil.NO_EXCEPTION) ));
+  @Test
+  public void testInvalidAuthenticator() throws Exception {
+    doTestInvalidAuthenticator(Boolean.FALSE);
   }
 
-  protected void createClient2AuthReqException(Boolean multiUser, Integer port1,
-      Integer port2, Properties credentials2, Properties javaProps2,
-      Object zeroConns) {
-    client2.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( null, credentials2, javaProps2,
-            port1, port2, zeroConns, multiUser,
-            new Integer(SecurityTestUtil.AUTHREQ_EXCEPTION) ));
+  @Test
+  public void testNoAuthenticatorWithCredentials() throws Exception {
+    doTestNoAuthenticatorWithCredentials(Boolean.FALSE);
   }
 
-  protected void createClient1WithException(Boolean multiUser, String authInit,
-      Integer port1, Integer port2, Properties credentials2,
-      Properties javaProps2, Object zeroConns) {
-    client1.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, credentials2,
-            javaProps2, port1, port2, zeroConns, multiUser,
-            new Integer(SecurityTestUtil.AUTHFAIL_EXCEPTION) ));
+  @Test
+  public void testCredentialsWithFailover() throws Exception {
+    doTestCredentialsWithFailover(Boolean.FALSE);
   }
 
-  protected void createClient2WithException(Boolean multiUser, String authInit,
-      Integer port1, Integer port2, Properties credentials2,
-      Properties javaProps2, Object zeroConns) {
-    client2.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, credentials2, javaProps2, port1, port2,
-            zeroConns, multiUser, new Integer(SecurityTestUtil.AUTHFAIL_EXCEPTION) ));
+  @Test
+  public void testCredentialsForNotifications() throws Exception {
+    doTestCredentialsForNotifications(Boolean.FALSE);
   }
 
-  protected void createClient2NoException(Boolean multiUser, String authInit,
-      Integer port1, Integer port2, Properties credentials2,
-      Properties javaProps2, Object zeroConns) {
-    client2.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, credentials2, javaProps2, port1, port2,
-            zeroConns, multiUser, new Integer(SecurityTestUtil.NO_EXCEPTION) ));
+  @Ignore("Disabled for unknown reason")
+  @Test
+  public void testValidCredentialsForMultipleUsers() throws Exception {
+    doTestValidCredentials(Boolean.TRUE);
   }
 
-  //////////////////////////////////////////////////////////////////////////////
-  // Tests for MULTI_USER_MODE start here
-  //////////////////////////////////////////////////////////////////////////////
-
-  public void xtestValidCredentialsForMultipleUsers() {
-    itestValidCredentials(Boolean.TRUE);
-  }
-
-  //////////////////////////////////////////////////////////////////////////////
-  // Tests for MULTI_USER_MODE end here
-  //////////////////////////////////////////////////////////////////////////////
-  
-  @Override
-  public final void preTearDown() throws Exception {
-    // close the clients first
-    client1.invoke(() -> SecurityTestUtil.closeCache());
-    client2.invoke(() -> SecurityTestUtil.closeCache());
-    // then close the servers
-    server1.invoke(() -> SecurityTestUtil.closeCache());
-    server2.invoke(() -> SecurityTestUtil.closeCache());
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationPart2DUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationPart2DUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationPart2DUnitTest.java
index 138114a..540632a 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationPart2DUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationPart2DUnitTest.java
@@ -1,6 +1,3 @@
-
-package com.gemstone.gemfire.security;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -9,9 +6,9 @@ package com.gemstone.gemfire.security;
  * 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
@@ -19,70 +16,59 @@ package com.gemstone.gemfire.security;
  * specific language governing permissions and limitations
  * under the License.
  */
+package com.gemstone.gemfire.security;
 
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 /**
  * this class contains test methods that used to be in its superclass but
  * that test started taking too long and caused dunit runs to hang
  */
-public class ClientAuthenticationPart2DUnitTest extends
-    ClientAuthenticationDUnitTest {
+@Category(DistributedTest.class)
+public class ClientAuthenticationPart2DUnitTest extends ClientAuthenticationTestCase {
 
-  /** constructor */
-  public ClientAuthenticationPart2DUnitTest(String name) {
-    super(name);
+  @Test
+  public void testNoCredentialsForMultipleUsers() throws Exception {
+    doTestNoCredentials(Boolean.TRUE);
   }
 
-  // override inherited tests so they aren't executed again
-  
-  @Override
-  public void testValidCredentials() {  }
-  @Override
-  public void testNoCredentials() {  }
-  @Override
-  public void testInvalidCredentials() {  }
-  @Override
-  public void testInvalidAuthInit() {  }
-  @Override
-  public void testNoAuthInitWithCredentials() {  }
-  @Override
-  public void testInvalidAuthenticator() {  }
-  @Override
-  public void testNoAuthenticatorWithCredentials() {  }
-  @Override
-  public void testCredentialsWithFailover() {  }
-  @Override
-  public void testCredentialsForNotifications() {  }
-  //@Override
-  public void testValidCredentialsForMultipleUsers() {  }
-
-
-  
-  
-  
-  public void testNoCredentialsForMultipleUsers() {
-    itestNoCredentials(Boolean.TRUE);
-  }
-  public void testInvalidCredentialsForMultipleUsers() {
-    itestInvalidCredentials(Boolean.TRUE);
+  @Test
+  public void testInvalidCredentialsForMultipleUsers() throws Exception {
+    doTestInvalidCredentials(Boolean.TRUE);
   }
-  public void testInvalidAuthInitForMultipleUsers() {
-    itestInvalidAuthInit(Boolean.TRUE);
-  }
-  public void testNoAuthInitWithCredentialsForMultipleUsers() {
-    itestNoAuthInitWithCredentials(Boolean.TRUE);
+
+  @Test
+  public void testInvalidAuthInitForMultipleUsers() throws Exception {
+    doTestInvalidAuthInit(Boolean.TRUE);
   }
-  public void testInvalidAuthenitcatorForMultipleUsers() {
-    itestInvalidAuthenticator(Boolean.TRUE);
+
+  @Test
+  public void testNoAuthInitWithCredentialsForMultipleUsers() throws Exception {
+    doTestNoAuthInitWithCredentials(Boolean.TRUE);
   }
-  public void testNoAuthenticatorWithCredentialsForMultipleUsers() {
-    itestNoAuthenticatorWithCredentials(Boolean.TRUE);
+
+  @Test
+  public void testInvalidAuthenitcatorForMultipleUsers() throws Exception {
+    doTestInvalidAuthenticator(Boolean.TRUE);
   }
-  public void disabled_testCredentialsWithFailoverForMultipleUsers() {
-    itestCredentialsWithFailover(Boolean.TRUE);
+
+  @Test
+  public void testNoAuthenticatorWithCredentialsForMultipleUsers() throws Exception {
+    doTestNoAuthenticatorWithCredentials(Boolean.TRUE);
   }
-  public void __testCredentialsForNotificationsForMultipleUsers() {
-    itestCredentialsForNotifications(Boolean.TRUE);
+
+  @Ignore("Disabled for unknown reason")
+  @Test
+  public void testCredentialsWithFailoverForMultipleUsers() throws Exception {
+    doTestCredentialsWithFailover(Boolean.TRUE);
   }
 
+  @Ignore("Disabled for unknown reason")
+  @Test
+  public void testCredentialsForNotificationsForMultipleUsers() throws Exception {
+    doTestCredentialsForNotifications(Boolean.TRUE);
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestCase.java
new file mode 100644
index 0000000..d308769
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestCase.java
@@ -0,0 +1,574 @@
+/*
+ * 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 com.gemstone.gemfire.security;
+
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.test.dunit.IgnoredException.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
+import static com.gemstone.gemfire.test.dunit.Wait.*;
+
+import java.io.IOException;
+import java.util.Properties;
+import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLHandshakeException;
+
+import com.gemstone.gemfire.internal.AvailablePort;
+import com.gemstone.gemfire.security.generator.CredentialGenerator;
+import com.gemstone.gemfire.security.generator.DummyCredentialGenerator;
+import com.gemstone.gemfire.test.dunit.Host;
+import com.gemstone.gemfire.test.dunit.VM;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+
+public abstract class ClientAuthenticationTestCase extends JUnit4DistributedTestCase {
+
+  private VM server1 = null;
+  private VM server2 = null;
+  private VM client1 = null;
+  private VM client2 = null;
+
+  private static final String[] serverIgnoredExceptions = {
+      AuthenticationRequiredException.class.getName(),
+      AuthenticationFailedException.class.getName(),
+      GemFireSecurityException.class.getName(),
+      ClassNotFoundException.class.getName(),
+      IOException.class.getName(),
+      SSLException.class.getName(),
+      SSLHandshakeException.class.getName()
+  };
+
+  private static final String[] clientIgnoredExceptions = {
+      AuthenticationRequiredException.class.getName(),
+      AuthenticationFailedException.class.getName(),
+      SSLHandshakeException.class.getName()
+  };
+
+  @Override
+  public final void postSetUp() throws Exception {
+    final Host host = Host.getHost(0);
+    server1 = host.getVM(0);
+    server2 = host.getVM(1);
+    client1 = host.getVM(2);
+    client2 = host.getVM(3);
+
+    addIgnoredException("Connection refused: connect");
+
+    server1.invoke(() -> registerExpectedExceptions(serverIgnoredExceptions));
+    server2.invoke(() -> registerExpectedExceptions(serverIgnoredExceptions));
+    client1.invoke(() -> registerExpectedExceptions(clientIgnoredExceptions));
+    client2.invoke(() -> registerExpectedExceptions(clientIgnoredExceptions));
+  }
+
+  protected void doTestValidCredentials(boolean multiUser) throws Exception {
+    CredentialGenerator gen = new DummyCredentialGenerator();
+    Properties extraProps = gen.getSystemProperties();
+    Properties javaProps = gen.getJavaProperties();
+    String authenticator = gen.getAuthenticator();
+    String authInit = gen.getAuthInit();
+
+    getLogWriter().info("testValidCredentials: Using scheme: " + gen.classCode());
+    getLogWriter().info("testValidCredentials: Using authenticator: " + authenticator);
+    getLogWriter().info("testValidCredentials: Using authinit: " + authInit);
+
+    // Start the servers
+    Integer locPort1 = getLocatorPort();
+    Integer locPort2 = getLocatorPort();
+    String locString = getLocatorString();
+    Integer port1 = server1.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort1, locString, authenticator, extraProps, javaProps));
+    Integer port2 = server2.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort2, locString, authenticator, extraProps, javaProps));
+
+    // Start the clients with valid credentials
+    Properties credentials1 = gen.getValidCredentials(1);
+    Properties javaProps1 = gen.getJavaProperties();
+
+    getLogWriter().info("testValidCredentials: For first client credentials: " + credentials1 + " : " + javaProps1);
+
+    Properties credentials2 = gen.getValidCredentials(2);
+    Properties javaProps2 = gen.getJavaProperties();
+
+    getLogWriter().info("testValidCredentials: For second client credentials: " + credentials2 + " : " + javaProps2);
+
+    createClientsNoException(multiUser, authInit, port1, port2, credentials1, javaProps1, credentials2, javaProps2);
+
+    // Perform some put operations from client1
+    client1.invoke(() -> doPuts(2));
+
+    // Verify that the puts succeeded
+    client2.invoke(() -> doGets(2));
+
+    if (multiUser) {
+      client1.invoke(() -> doProxyCacheClose());
+      client2.invoke(() -> doProxyCacheClose());
+      client1.invoke(() -> doSimplePut("CacheClosedException"));
+      client2.invoke(() -> doSimpleGet("CacheClosedException"));
+    }
+  }
+
+  protected void doTestNoCredentials(boolean multiUser) throws Exception {
+    CredentialGenerator gen = new DummyCredentialGenerator();
+    Properties extraProps = gen.getSystemProperties();
+    Properties javaProps = gen.getJavaProperties();
+    String authenticator = gen.getAuthenticator();
+    String authInit = gen.getAuthInit();
+
+    getLogWriter().info("testNoCredentials: Using scheme: " + gen.classCode());
+    getLogWriter().info("testNoCredentials: Using authenticator: " + authenticator);
+    getLogWriter().info("testNoCredentials: Using authinit: " + authInit);
+
+    // Start the servers
+    Integer locPort1 = getLocatorPort();
+    Integer locPort2 = getLocatorPort();
+    String locString = getLocatorString();
+    Integer port1 = createServer1(extraProps, javaProps, authenticator, locPort1, locString);
+    Integer port2 = server2.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort2, locString, authenticator, extraProps, javaProps));
+
+    // Start first client with valid credentials
+    Properties credentials1 = gen.getValidCredentials(1);
+    Properties javaProps1 = gen.getJavaProperties();
+
+    getLogWriter().info("testNoCredentials: For first client credentials: " + credentials1 + " : " + javaProps1);
+
+    createClient1NoException(multiUser, authInit, port1, port2, credentials1, javaProps1);
+
+    // Perform some put operations from client1
+    client1.invoke(() -> doPuts(2));
+
+    // Trying to create the region on client2
+    if (gen.classCode().equals(CredentialGenerator.ClassCode.SSL)) {
+      // For SSL the exception may not come since the server can close socket
+      // before handshake message is sent from client. However exception
+      // should come in any region operations.
+      client2.invoke(() -> ClientAuthenticationUtils.createCacheClient(null, null, null, port1, port2, 0, multiUser, NO_EXCEPTION));
+      client2.invoke(() -> doPuts(2, OTHER_EXCEPTION));
+
+    } else {
+      client2.invoke(() -> ClientAuthenticationUtils.createCacheClient(null, null, null, port1, port2, 0, multiUser, AUTHREQ_EXCEPTION));
+    }
+  }
+
+  protected void doTestInvalidCredentials(boolean multiUser) throws Exception {
+    CredentialGenerator gen = new DummyCredentialGenerator();
+    Properties extraProps = gen.getSystemProperties();
+    Properties javaProps = gen.getJavaProperties();
+    String authenticator = gen.getAuthenticator();
+    String authInit = gen.getAuthInit();
+
+    getLogWriter().info("testInvalidCredentials: Using scheme: " + gen.classCode());
+    getLogWriter().info("testInvalidCredentials: Using authenticator: " + authenticator);
+    getLogWriter().info("testInvalidCredentials: Using authinit: " + authInit);
+
+    // Start the servers
+    Integer locPort1 = getLocatorPort();
+    Integer locPort2 = getLocatorPort();
+    String locString = getLocatorString();
+    Integer port1 = createServer1(extraProps, javaProps, authenticator, locPort1, locString);
+    Integer port2 = server2.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort2, locString, authenticator, extraProps, javaProps));
+
+    // Start first client with valid credentials
+    Properties credentials1 = gen.getValidCredentials(1);
+    Properties javaProps1 = gen.getJavaProperties();
+    getLogWriter().info("testInvalidCredentials: For first client credentials: " + credentials1 + " : " + javaProps1);
+
+    createClient1NoException(multiUser, authInit, port1, port2, credentials1, javaProps1);
+
+    // Perform some put operations from client1
+    client1.invoke(() -> doPuts(2));
+
+    // Start second client with invalid credentials
+    // Trying to create the region on client2 should throw a security
+    // exception
+    Properties credentials2 = gen.getInvalidCredentials(1);
+    Properties javaProps2 = gen.getJavaProperties();
+    getLogWriter().info("testInvalidCredentials: For second client credentials: " + credentials2 + " : " + javaProps2);
+
+    client2.invoke(() -> ClientAuthenticationUtils.createCacheClient(authInit, credentials2, javaProps2, port1, port2, 0, multiUser, AUTHFAIL_EXCEPTION));
+  }
+
+  protected void doTestInvalidAuthInit(boolean multiUser) throws Exception {
+    CredentialGenerator gen = new DummyCredentialGenerator();
+    Properties extraProps = gen.getSystemProperties();
+    final Properties javaProps = gen.getJavaProperties();
+    String authenticator = gen.getAuthenticator();
+
+    getLogWriter().info("testInvalidAuthInit: Using scheme: " + gen.classCode());
+    getLogWriter().info("testInvalidAuthInit: Using authenticator: " + authenticator);
+
+    // Start the server
+    Integer locPort1 = getLocatorPort();
+    String locString = getLocatorString();
+    Integer port1 = createServer1(extraProps, javaProps, authenticator, locPort1, locString);
+
+    Properties credentials = gen.getValidCredentials(1);
+
+    getLogWriter().info("testInvalidAuthInit: For first client credentials: " + credentials + " : " + javaProps);
+    client1.invoke(() -> ClientAuthenticationUtils.createCacheClient("com.gemstone.none", credentials, javaProps, new int[] { port1 }, 0, multiUser, AUTHREQ_EXCEPTION));
+  }
+
+  protected void doTestNoAuthInitWithCredentials(boolean multiUser) throws Exception {
+    CredentialGenerator gen = new DummyCredentialGenerator();
+    Properties extraProps = gen.getSystemProperties();
+    Properties javaProps = gen.getJavaProperties();
+    String authenticator = gen.getAuthenticator();
+
+    getLogWriter().info("testNoAuthInitWithCredentials: Using scheme: " + gen.classCode());
+    getLogWriter().info("testNoAuthInitWithCredentials: Using authenticator: " + authenticator);
+
+    // Start the servers
+    Integer locPort1 = getLocatorPort();
+    Integer locPort2 = getLocatorPort();
+    String locString = getLocatorString();
+    Integer port1 = createServer1(extraProps, javaProps, authenticator, locPort1, locString);
+    Integer port2 = server2.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort2, locString, authenticator, extraProps, javaProps));
+
+    // Start the clients with valid credentials
+    Properties credentials1 = gen.getValidCredentials(1);
+    Properties javaProps1 = gen.getJavaProperties();
+    getLogWriter().info("testNoAuthInitWithCredentials: For first client credentials: " + credentials1 + " : " + javaProps1);
+
+    Properties credentials2 = gen.getValidCredentials(2);
+    Properties javaProps2 = gen.getJavaProperties();
+    getLogWriter().info("testNoAuthInitWithCredentials: For second client credentials: " + credentials2 + " : " + javaProps2);
+
+    client1.invoke(() -> ClientAuthenticationUtils.createCacheClient(null, credentials1, javaProps1, port1, port2, 0, multiUser, AUTHREQ_EXCEPTION));
+    client2.invoke(() -> ClientAuthenticationUtils.createCacheClient(null, credentials2, javaProps2, port1, port2, 0, multiUser, AUTHREQ_EXCEPTION));
+    client2.invoke(() -> closeCache());
+
+    // Now also try with invalid credentials
+    Properties credentials3 = gen.getInvalidCredentials(5);
+    Properties javaProps3 = gen.getJavaProperties();
+    client2.invoke(() -> ClientAuthenticationUtils.createCacheClient(null, credentials3, javaProps3, port1, port2, 0, multiUser, AUTHREQ_EXCEPTION));
+  }
+
+  protected void doTestInvalidAuthenticator(boolean multiUser) throws Exception {
+    CredentialGenerator gen = new DummyCredentialGenerator();
+    Properties extraProps = gen.getSystemProperties();
+    Properties javaProps = gen.getJavaProperties();
+    String authInit = gen.getAuthInit();
+
+    getLogWriter().info("testInvalidAuthenticator: Using scheme: " + gen.classCode());
+    getLogWriter().info("testInvalidAuthenticator: Using authinit: " + authInit);
+
+    // Start the server with invalid authenticator
+    Integer locPort1 = getLocatorPort();
+    String locString = getLocatorString();
+    Integer port1 = server1.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort1, locString, "com.gemstone.gemfire.none", extraProps, javaProps));
+
+    // Trying to create the region on client should throw a security exception
+    Properties credentials2 = gen.getValidCredentials(1);
+    Properties javaProps2 = gen.getJavaProperties();
+    getLogWriter().info("testInvalidAuthenticator: For first client credentials: " + credentials2 + " : " + javaProps2);
+
+    client1.invoke(() -> ClientAuthenticationUtils.createCacheClient(authInit, credentials2, javaProps2, port1, 0, AUTHFAIL_EXCEPTION));
+    client1.invoke(() -> closeCache());
+
+    // Also test with invalid credentials
+    Properties credentials3 = gen.getInvalidCredentials(1);
+    Properties javaProps3 = gen.getJavaProperties();
+    getLogWriter().info("testInvalidAuthenticator: For first client credentials: " + credentials3 + " : " + javaProps3);
+    client1.invoke(() -> ClientAuthenticationUtils.createCacheClient(authInit, credentials3, javaProps3, port1, 0, AUTHFAIL_EXCEPTION));
+  }
+
+  protected void doTestNoAuthenticatorWithCredentials(boolean multiUser) throws Exception {
+    CredentialGenerator gen = new DummyCredentialGenerator();
+    Properties extraProps = gen.getSystemProperties();
+    Properties javaProps = gen.getJavaProperties();
+    String authenticator = gen.getAuthenticator();
+    String authInit = gen.getAuthInit();
+
+    getLogWriter().info("testNoAuthenticatorWithCredentials: Using scheme: " + gen.classCode());
+    getLogWriter().info("testNoAuthenticatorWithCredentials: Using authinit: " + authInit);
+
+    // Start the servers with no authenticator
+    Integer locPort1 = getLocatorPort();
+    Integer locPort2 = getLocatorPort();
+    String locString = getLocatorString();
+    Integer port1 = server1.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort1, locString, null, extraProps, javaProps));
+    Integer port2 = server2.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort2, locString, null, extraProps, javaProps));
+
+    // Clients should connect successfully and work properly with
+    // valid/invalid credentials when none are required on the server side
+    Properties credentials1 = gen.getValidCredentials(3);
+    Properties javaProps1 = gen.getJavaProperties();
+    getLogWriter().info("testNoAuthenticatorWithCredentials: For first client credentials: " + credentials1 + " : " + javaProps1);
+
+    Properties credentials2 = gen.getInvalidCredentials(5);
+    Properties javaProps2 = gen.getJavaProperties();
+    getLogWriter().info("testNoAuthenticatorWithCredentials: For second client credentials: " + credentials2 + " : " + javaProps2);
+
+    createClientsNoException(multiUser, authInit, port1, port2, credentials1, javaProps1, credentials2, javaProps2);
+
+    // Perform some put operations from client1
+    client1.invoke(() -> doPuts(2));
+
+    // Verify that the puts succeeded
+    client2.invoke(() -> doGets(2));
+  }
+
+  protected void doTestCredentialsWithFailover(boolean multiUser) throws Exception {
+    CredentialGenerator gen = new DummyCredentialGenerator();
+    Properties extraProps = gen.getSystemProperties();
+    Properties javaProps = gen.getJavaProperties();
+    String authenticator = gen.getAuthenticator();
+    String authInit = gen.getAuthInit();
+
+    getLogWriter().info("testCredentialsWithFailover: Using scheme: " + gen.classCode());
+    getLogWriter().info("testCredentialsWithFailover: Using authenticator: " + authenticator);
+    getLogWriter().info("testCredentialsWithFailover: Using authinit: " + authInit);
+
+    // Start the first server
+    Integer locPort1 = getLocatorPort();
+    Integer locPort2 = getLocatorPort();
+    String locString = getLocatorString();
+    Integer port1 = server1.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort1, locString, authenticator, extraProps, javaProps));
+    // Get a port for second server but do not start it
+    // This forces the clients to connect to the first server
+    Integer port2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+
+    // Start the clients with valid credentials
+    Properties credentials1 = gen.getValidCredentials(5);
+    Properties javaProps1 = gen.getJavaProperties();
+    getLogWriter().info("testCredentialsWithFailover: For first client credentials: " + credentials1 + " : " + javaProps1);
+
+    Properties credentials2 = gen.getValidCredentials(6);
+    Properties javaProps2 = gen.getJavaProperties();
+    getLogWriter().info("testCredentialsWithFailover: For second client credentials: " + credentials2 + " : " + javaProps2);
+
+    createClientsNoException(multiUser, authInit, port1, port2, credentials1, javaProps1, credentials2, javaProps2);
+
+    // Perform some put operations from client1
+    client1.invoke(() -> doPuts(2));
+    // Verify that the puts succeeded
+    client2.invoke(() -> doGets(2));
+
+    // start the second one and stop the first server to force a failover
+    server2.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort2, locString, port2, authenticator, extraProps, javaProps));
+    server1.invoke(() -> closeCache());
+
+    // Perform some create/update operations from client1
+    client1.invoke(() -> doNPuts(4));
+    // Verify that the creates/updates succeeded
+    client2.invoke(() -> doNGets(4));
+
+    // Try to connect client2 with no credentials
+    // Verify that the creation of region throws security exception
+    if (gen.classCode().equals(CredentialGenerator.ClassCode.SSL)) {
+      // For SSL the exception may not come since the server can close socket
+      // before handshake message is sent from client. However exception
+      // should come in any region operations.
+      client2.invoke(() -> ClientAuthenticationUtils.createCacheClient(null, null, null, port1, port2, 0, multiUser, NOFORCE_AUTHREQ_EXCEPTION));
+      client2.invoke(() -> doPuts(2, OTHER_EXCEPTION));
+
+    } else {
+      client2.invoke(() -> ClientAuthenticationUtils.createCacheClient(null, null, null, port1, port2, 0, multiUser, AUTHREQ_EXCEPTION));
+    }
+
+    // Now try to connect client1 with invalid credentials
+    // Verify that the creation of region throws security exception
+    Properties credentials3 = gen.getInvalidCredentials(7);
+    Properties javaProps3 = gen.getJavaProperties();
+    getLogWriter().info("testCredentialsWithFailover: For first client invalid credentials: " + credentials3 + " : " + javaProps3);
+
+    client1.invoke(() -> ClientAuthenticationUtils.createCacheClient(authInit, credentials3, javaProps3, port1, port2, 0, multiUser, AUTHFAIL_EXCEPTION));
+
+    if (multiUser) {
+      client1.invoke(() -> doProxyCacheClose());
+      client2.invoke(() -> doProxyCacheClose());
+      client1.invoke(() -> doSimplePut("CacheClosedException"));
+      client2.invoke(() -> doSimpleGet("CacheClosedException"));
+    }
+  }
+
+  protected void doTestCredentialsForNotifications(boolean multiUser) throws Exception {
+    CredentialGenerator gen = new DummyCredentialGenerator();
+    Properties extraProps = gen.getSystemProperties();
+    Properties javaProps = gen.getJavaProperties();
+    String authenticator = gen.getAuthenticator();
+    String authInit = gen.getAuthInit();
+
+    getLogWriter().info("testCredentialsForNotifications: Using scheme: " + gen.classCode());
+    getLogWriter().info("testCredentialsForNotifications: Using authenticator: " + authenticator);
+    getLogWriter().info("testCredentialsForNotifications: Using authinit: " + authInit);
+
+    // Start the first server
+    Integer locPort1 = getLocatorPort();
+    Integer locPort2 = getLocatorPort();
+    String locString = getLocatorString();
+    Integer port1 = server1.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort1, locString, authenticator, extraProps, javaProps));
+    // Get a port for second server but do not start it
+    // This forces the clients to connect to the first server
+    Integer port2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+
+    // Start the clients with valid credentials
+    Properties credentials1 = gen.getValidCredentials(3);
+    Properties javaProps1 = gen.getJavaProperties();
+    getLogWriter().info("testCredentialsForNotifications: For first client credentials: " + credentials1 + " : " + javaProps1);
+
+    Properties credentials2 = gen.getValidCredentials(4);
+    Properties javaProps2 = gen.getJavaProperties();
+    getLogWriter().info("testCredentialsForNotifications: For second client credentials: " + credentials2 + " : " + javaProps2);
+
+    createClient1NoException(multiUser, authInit, port1, port2, credentials1, javaProps1);
+
+    // Set up zero forward connections to check notification handshake only
+    int zeroConns = 0;
+    createClient2NoException(multiUser, authInit, port1, port2, credentials2, javaProps2, zeroConns);
+
+    // Register interest on all keys on second client
+    client2.invoke(() -> ClientAuthenticationUtils.registerAllInterest());
+
+    // Perform some put operations from client1
+    client1.invoke(() -> doPuts(2));
+
+    // Verify that the puts succeeded
+    client2.invoke(() -> doLocalGets(2));
+
+    // start the second one and stop the first server to force a failover
+    server2.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort2, locString, port2, authenticator, extraProps, javaProps));
+    server1.invoke(() -> closeCache());
+
+    // Wait for failover to complete
+    pause(500);
+
+    // Perform some create/update operations from client1
+    client1.invoke(() -> doNPuts(4));
+    // Verify that the creates/updates succeeded
+    client2.invoke(() -> doNLocalGets(4));
+
+    // Try to connect client1 with no credentials
+    // Verify that the creation of region throws security exception
+    server1.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort1, locString, port1, authenticator, extraProps, javaProps));
+
+    if (gen.classCode().equals(CredentialGenerator.ClassCode.SSL)) {
+      // For SSL the exception may not come since the server can close socket
+      // before handshake message is sent from client. However exception
+      // should come in any region operations.
+      client1.invoke(() -> ClientAuthenticationUtils.createCacheClient(null, null, null, port1, port2, zeroConns, multiUser, NOFORCE_AUTHREQ_EXCEPTION));
+      client1.invoke(() -> doPuts(2, OTHER_EXCEPTION));
+
+    } else {
+      client1.invoke(() -> ClientAuthenticationUtils.createCacheClient(null, null, null, port1, port2, zeroConns, multiUser, AUTHREQ_EXCEPTION));
+    }
+
+    // Now try to connect client2 with invalid credentials
+    // Verify that the creation of region throws security exception
+    credentials2 = gen.getInvalidCredentials(3);
+    javaProps2 = gen.getJavaProperties();
+    getLogWriter().info("testCredentialsForNotifications: For second client invalid credentials: " + credentials2 + " : " + javaProps2);
+
+    createClient2WithException(multiUser, authInit, port1, port2, credentials2, javaProps2, zeroConns);
+
+    // Now try to connect client2 with invalid auth-init method
+    // Trying to create the region on client with valid credentials should
+    // throw a security exception
+    client2.invoke(() -> ClientAuthenticationUtils.createCacheClient("com.gemstone.none", credentials1, javaProps1, port1, port2, zeroConns, multiUser, AUTHREQ_EXCEPTION));
+
+    // Now start the servers with invalid authenticator method.
+    // Skip this test for a scheme which does not have an authInit in the
+    // first place (e.g. SSL) since that will fail with AuthReqEx before
+    // authenticator is even invoked.
+    if (authInit != null && authInit.length() > 0) {
+      server1.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort1, locString, port1, "com.gemstone.gemfire.none", extraProps, javaProps));
+      server2.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort2, locString, port2, "com.gemstone.gemfire.none", extraProps, javaProps));
+
+      createClient2WithException(multiUser, authInit, port1, port2, credentials1, javaProps1, zeroConns);
+      createClient1WithException(multiUser, authInit, port1, port2, credentials2, javaProps2, zeroConns);
+
+    } else {
+      getLogWriter().info("testCredentialsForNotifications: Skipping invalid authenticator for scheme [" + gen.classCode() + "] which has no authInit");
+    }
+
+    // Try connection with null auth-init on clients.
+    // Skip this test for a scheme which does not have an authInit in the
+    // first place (e.g. SSL).
+    if (authInit != null && authInit.length() > 0) {
+      server1.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort1, locString, port1, authenticator, extraProps, javaProps));
+      server2.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort2, locString, port2, authenticator, extraProps, javaProps));
+      client1.invoke(() -> ClientAuthenticationUtils.createCacheClient(null, credentials1, javaProps1, port1, port2, 0, multiUser, AUTHREQ_EXCEPTION));
+
+      createClient2AuthReqException(multiUser, port1, port2, credentials2, javaProps2, zeroConns);
+      createClient2AuthReqException(multiUser, port1, port2, credentials2, javaProps2, zeroConns);
+
+    } else {
+      getLogWriter().info("testCredentialsForNotifications: Skipping null authInit for scheme [" + gen.classCode() + "] which has no authInit");
+    }
+
+    // Try connection with null authenticator on server and sending
+    // valid/invalid credentials.
+    // If the scheme does not have an authenticator in the first place (e.g.
+    // SSL) then skip it since this test is useless.
+    if (authenticator != null && authenticator.length() > 0) {
+      server1.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort1, locString, port1, null, extraProps, javaProps));
+      server2.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort2, locString, port2, null, extraProps, javaProps));
+
+      createClient1NoException(multiUser, authInit, port1, port2, credentials1, javaProps1);
+      createClient2NoException(multiUser, authInit, port1, port2, credentials2, javaProps2, zeroConns);
+
+      // Register interest on all keys on second client
+      client2.invoke(() -> ClientAuthenticationUtils.registerAllInterest());
+
+      // Perform some put operations from client1
+      client1.invoke(() -> doPuts(4));
+
+      // Verify that the puts succeeded
+      client2.invoke(() -> doLocalGets(4));
+
+      // Now also try with valid credentials on client2
+      createClient1NoException(multiUser, authInit, port1, port2, credentials2, javaProps2);
+      createClient2NoException(multiUser, authInit, port1, port2, credentials1, javaProps1, zeroConns);
+
+      // Register interest on all keys on second client
+      client2.invoke(() -> ClientAuthenticationUtils.registerAllInterest());
+
+      // Perform some put operations from client1
+      client1.invoke(() -> doNPuts(4));
+
+      // Verify that the puts succeeded
+      client2.invoke(() -> doNLocalGets(4));
+
+    } else {
+      getLogWriter().info("testCredentialsForNotifications: Skipping scheme [" + gen.classCode() + "] which has no authenticator");
+    }
+  }
+
+  private Integer createServer1(Properties extraProps, Properties javaProps, String authenticator, int locPort1, String locString) {
+    return server1.invoke(() -> ClientAuthenticationUtils.createCacheServer(locPort1, locString, authenticator, extraProps, javaProps));
+  }
+
+  private void createClient1NoException(boolean multiUser, String authInit, int port1, int port2, Properties credentials2, Properties javaProps2) {
+    client1.invoke(() -> ClientAuthenticationUtils.createCacheClient(authInit, credentials2, javaProps2, port1, port2, 0, multiUser, NO_EXCEPTION));
+  }
+
+  private void createClient2AuthReqException(boolean multiUser, int port1, int port2, Properties credentials2, Properties javaProps2, int zeroConns) {
+    client2.invoke(() -> ClientAuthenticationUtils.createCacheClient(null, credentials2, javaProps2, port1, port2, zeroConns, multiUser, AUTHREQ_EXCEPTION));
+  }
+
+  private void createClient1WithException(boolean multiUser, String authInit, int port1, int port2, Properties credentials2, Properties javaProps2, int zeroConns) {
+    client1.invoke(() -> ClientAuthenticationUtils.createCacheClient(authInit, credentials2, javaProps2, port1, port2, zeroConns, multiUser, AUTHFAIL_EXCEPTION));
+  }
+
+  private void createClient2WithException(boolean multiUser, String authInit, int port1, int port2, Properties credentials2, Properties javaProps2, int zeroConns) {
+    client2.invoke(() -> ClientAuthenticationUtils.createCacheClient(authInit, credentials2, javaProps2, port1, port2, zeroConns, multiUser, AUTHFAIL_EXCEPTION));
+  }
+
+  private void createClient2NoException(boolean multiUser, String authInit, int port1, int port2, Properties credentials2, Properties javaProps2, int zeroConns) {
+    client2.invoke(() -> ClientAuthenticationUtils.createCacheClient(authInit, credentials2, javaProps2, port1, port2, zeroConns, multiUser, NO_EXCEPTION));
+  }
+
+  private void createClientsNoException(boolean multiUser, String authInit, int port1, int port2, Properties credentials1, Properties javaProps1, Properties credentials2, Properties javaProps2) {
+    createClient1NoException(multiUser, authInit, port1, port2, credentials1, javaProps1);
+    client2.invoke(() -> ClientAuthenticationUtils.createCacheClient(authInit, credentials2, javaProps2, port1, port2, 0, multiUser, NO_EXCEPTION));
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationUtils.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationUtils.java
new file mode 100644
index 0000000..09cc2d5
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationUtils.java
@@ -0,0 +1,94 @@
+/*
+ * 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 com.gemstone.gemfire.security;
+
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static org.junit.Assert.*;
+
+import java.util.Properties;
+
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+
+/**
+ * Extracted from ClientAuthenticationDUnitTest
+ */
+public class ClientAuthenticationUtils {
+
+  protected ClientAuthenticationUtils() {
+  }
+
+  public static Integer createCacheServer(int dsPort, String locatorString, String authenticator, Properties extraProps, Properties javaProps) {
+    Properties authProps;
+    if (extraProps == null) {
+      authProps = new Properties();
+    } else {
+      authProps = (Properties)extraProps;
+    }
+
+    if (authenticator != null) {
+      authProps.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator.toString());
+    }
+
+    return SecurityTestUtil.createCacheServer(authProps, javaProps, dsPort, (String)locatorString, 0, NO_EXCEPTION);
+  }
+
+  public static void createCacheServer(int dsPort, String locatorString, int serverPort, String authenticator, Properties extraProps, Properties javaProps) {
+    Properties authProps;
+    if (extraProps == null) {
+      authProps = new Properties();
+    } else {
+      authProps = (Properties)extraProps;
+    }
+
+    if (authenticator != null) {
+      authProps.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator.toString());
+    }
+    SecurityTestUtil.createCacheServer(authProps, javaProps, dsPort, locatorString, serverPort, NO_EXCEPTION);
+  }
+
+  public static void createCacheClient(String authInit, Properties authProps, Properties javaProps, int[] ports, int numConnections, boolean multiUserMode, boolean subscriptionEnabled, int expectedResult) {
+
+    SecurityTestUtil.createCacheClient(authInit, authProps, javaProps, ports, numConnections, false, multiUserMode, subscriptionEnabled, expectedResult);
+  }
+
+  public static void createCacheClient(String authInit, Properties authProps, Properties javaProps, int[] ports, int numConnections, boolean multiUserMode, int expectedResult) {
+    createCacheClient(authInit, (Properties)authProps, (Properties)javaProps, ports, numConnections, multiUserMode, true, expectedResult);
+  }
+
+  public static void createCacheClient(String authInit, Properties authProps, Properties javaProps, int port1, int numConnections, int expectedResult) {
+    createCacheClient(authInit, authProps, javaProps, new int[] { port1 }, numConnections, Boolean.FALSE, Boolean.TRUE, expectedResult);
+  }
+
+  public static void createCacheClient(String authInit, Properties authProps, Properties javaProps, int port1, int port2, int numConnections, int expectedResult) {
+    createCacheClient(authInit, authProps, javaProps, port1, port2, numConnections, Boolean.FALSE, expectedResult);
+  }
+
+  public static void createCacheClient(String authInit, Properties authProps, Properties javaProps, Integer port1, Integer port2, int numConnections, boolean multiUserMode, int expectedResult) {
+    createCacheClient(authInit, authProps, javaProps, port1, port2, numConnections, multiUserMode, Boolean.TRUE, expectedResult);
+  }
+
+  public static void createCacheClient(String authInit, Properties authProps, Properties javaProps, int port1, int port2, int numConnections, boolean multiUserMode, boolean subscriptionEnabled, int expectedResult) {
+    createCacheClient(authInit, authProps, javaProps, new int[] { port1, port2 }, numConnections, multiUserMode, subscriptionEnabled, expectedResult);
+  }
+
+  public static void registerAllInterest() {
+    Region region = SecurityTestUtil.getCache().getRegion(SecurityTestUtil.REGION_NAME);
+    assertNotNull(region);
+    region.registerInterestRegex(".*");
+  }
+}



[3/8] incubator-geode git commit: Keep

Posted by kl...@apache.org.
Keep


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

Branch: refs/heads/feature/GEODE-693
Commit: 5a321ffdf4f8276b6e3e5363f125c6c4438f233e
Parents: 6924ad4
Author: Kirk Lund <kl...@apache.org>
Authored: Wed Mar 23 14:10:14 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Wed Mar 23 14:10:14 2016 -0700

----------------------------------------------------------------------
 .../security/ClientAuthorizationDUnitTest.java  |  51 +--
 .../security/ClientAuthorizationTestBase.java   |  77 +++-
 .../security/ClientMultiUserAuthzDUnitTest.java |  35 +-
 .../DeltaClientAuthorizationDUnitTest.java      | 140 +++---
 .../gemfire/security/SecurityTestUtil.java      | 277 ++++++------
 .../ClientAuthorizationTwoDUnitTest.java        | 204 ++++-----
 .../security/ClientAuthzObjectModDUnitTest.java | 431 +++++++------------
 .../ClientCQPostAuthorizationDUnitTest.java     | 341 +++++----------
 .../ClientPostAuthorizationDUnitTest.java       | 376 ++++++++--------
 .../gemfire/security/MultiuserAPIDUnitTest.java | 238 ++++------
 .../MultiuserDurableCQAuthzDUnitTest.java       | 294 +++++--------
 11 files changed, 996 insertions(+), 1468 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5a321ffd/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
index bcb3d3d..b39fe34 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationDUnitTest.java
@@ -52,18 +52,14 @@ import org.junit.experimental.categories.Category;
 public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
 
   @Override
-  public final void postSetUp() throws Exception {
-    final Host host = Host.getHost(0);
-    server1 = host.getVM(0);
-    server2 = host.getVM(1);
-    client1 = host.getVM(2);
-    client2 = host.getVM(3);
-
-    server1.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    client1.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions ));
-    client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions ));
-    SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions);
+  public final void preTearDownClientAuthorizationTestBase() throws Exception {
+    // close the clients first
+    client1.invoke(() -> SecurityTestUtil.closeCache());
+    client2.invoke(() -> SecurityTestUtil.closeCache());
+    SecurityTestUtil.closeCache();
+    // then close the servers
+    server1.invoke(() -> SecurityTestUtil.closeCache());
+    server2.invoke(() -> SecurityTestUtil.closeCache());
   }
 
   private Properties getUserPassword(String userName) {
@@ -566,7 +562,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
   public void testUnregisterInterestWithFailover() {
 
     OperationWithAction[] unregisterOps = {
-        // Register interest in all keys using one key at a time
+        // Register interest in all KEYS using one key at a time
         new OperationWithAction(OperationCode.REGISTER_INTEREST,
             OperationCode.UNREGISTER_INTEREST, 3, OpFlags.NONE, 4),
         new OperationWithAction(OperationCode.REGISTER_INTEREST, 2),
@@ -575,7 +571,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
         new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
             | OpFlags.LOCAL_OP, 4),
 
-        // Unregister interest in all keys using one key at a time
+        // Unregister interest in all KEYS using one key at a time
         new OperationWithAction(OperationCode.UNREGISTER_INTEREST, 3,
             OpFlags.USE_OLDCONN | OpFlags.CHECK_NOTAUTHZ, 4),
         new OperationWithAction(OperationCode.UNREGISTER_INTEREST, 2,
@@ -588,7 +584,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
 
         OperationWithAction.OPBLOCK_END,
 
-        // Register interest in all keys using list
+        // Register interest in all KEYS using list
         new OperationWithAction(OperationCode.REGISTER_INTEREST,
             OperationCode.UNREGISTER_INTEREST, 3, OpFlags.USE_LIST, 4),
         new OperationWithAction(OperationCode.REGISTER_INTEREST, 1,
@@ -598,7 +594,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
         new OperationWithAction(OperationCode.GET, 1, OpFlags.USE_OLDCONN
             | OpFlags.LOCAL_OP, 4),
 
-        // Unregister interest in all keys using list
+        // Unregister interest in all KEYS using list
         new OperationWithAction(OperationCode.UNREGISTER_INTEREST, 3,
             OpFlags.USE_OLDCONN | OpFlags.USE_LIST | OpFlags.CHECK_NOTAUTHZ, 4),
         new OperationWithAction(OperationCode.UNREGISTER_INTEREST, 1,
@@ -611,7 +607,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
 
         OperationWithAction.OPBLOCK_END,
 
-        // Register interest in all keys using regular expression
+        // Register interest in all KEYS using regular expression
         new OperationWithAction(OperationCode.REGISTER_INTEREST,
             OperationCode.UNREGISTER_INTEREST, 3, OpFlags.USE_REGEX, 4),
         new OperationWithAction(OperationCode.REGISTER_INTEREST, 2,
@@ -621,7 +617,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
         new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
             | OpFlags.LOCAL_OP, 4),
 
-        // Unregister interest in all keys using regular expression
+        // Unregister interest in all KEYS using regular expression
         new OperationWithAction(OperationCode.UNREGISTER_INTEREST, 3,
             OpFlags.USE_OLDCONN | OpFlags.USE_REGEX | OpFlags.CHECK_NOTAUTHZ, 4),
         new OperationWithAction(OperationCode.UNREGISTER_INTEREST, 2,
@@ -742,7 +738,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
         new OperationWithAction(OperationCode.CONTAINS_KEY, 3,
             OpFlags.CHECK_NOTAUTHZ, 4),
         new OperationWithAction(OperationCode.CONTAINS_KEY),
-        // Destroy the keys and check for failure in CONTAINS_KEY
+        // Destroy the KEYS and check for failure in CONTAINS_KEY
         new OperationWithAction(OperationCode.DESTROY, 2),
         new OperationWithAction(OperationCode.CONTAINS_KEY, 3,
             OpFlags.CHECK_FAIL | OpFlags.CHECK_NOTAUTHZ, 4),
@@ -767,7 +763,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
 
         OperationWithAction.OPBLOCK_END,
 
-        // Register interest in all keys using one key at a time
+        // Register interest in all KEYS using one key at a time
         new OperationWithAction(OperationCode.REGISTER_INTEREST, 3,
             OpFlags.CHECK_NOTAUTHZ, 4),
         new OperationWithAction(OperationCode.REGISTER_INTEREST, 2),
@@ -776,7 +772,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
         new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
             | OpFlags.LOCAL_OP, 4),
 
-        // Unregister interest in all keys using one key at a time
+        // Unregister interest in all KEYS using one key at a time
         new OperationWithAction(OperationCode.UNREGISTER_INTEREST, 2,
             OpFlags.USE_OLDCONN, 4),
         // UPDATE and test with GET for no updates
@@ -795,17 +791,4 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
 
     runOpsWithFailover(allOps, "testAllOpsWithFailover");
   }
-
-  // End Region: Tests
-
-  @Override
-  public final void preTearDown() throws Exception {
-    // close the clients first
-    client1.invoke(() -> SecurityTestUtil.closeCache());
-    client2.invoke(() -> SecurityTestUtil.closeCache());
-    SecurityTestUtil.closeCache();
-    // then close the servers
-    server1.invoke(() -> SecurityTestUtil.closeCache());
-    server2.invoke(() -> SecurityTestUtil.closeCache());
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5a321ffd/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
index 67f98aa..5689993 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
@@ -18,6 +18,7 @@
  */
 package com.gemstone.gemfire.security;
 
+//import static com.gemstone.gemfire.security.SecurityTestUtil.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
 
 import java.util.ArrayList;
@@ -59,7 +60,7 @@ import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator.ClassCod
 import com.gemstone.gemfire.security.generator.CredentialGenerator;
 import com.gemstone.gemfire.security.generator.DummyCredentialGenerator;
 import com.gemstone.gemfire.security.generator.XmlAuthzCredentialGenerator;
-import com.gemstone.gemfire.test.dunit.Assert;
+import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.dunit.Wait;
 import com.gemstone.gemfire.test.dunit.WaitCriterion;
@@ -74,18 +75,14 @@ import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
 public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
 
   protected static VM server1 = null;
-
   protected static VM server2 = null;
-
   protected static VM client1 = null;
-
   protected static VM client2 = null;
 
-  protected static final String regionName = SecurityTestUtil.regionName;
-
+  protected static final String regionName = SecurityTestUtil.REGION_NAME;
   protected static final String subregionName = "AuthSubregion";
 
-  protected static final String[] serverExpectedExceptions = {
+  private static final String[] serverIgnoredExceptions = {
       "Connection refused",
       AuthenticationRequiredException.class.getName(),
       AuthenticationFailedException.class.getName(),
@@ -94,11 +91,57 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
       RegionDestroyedException.class.getName(),
       ClassNotFoundException.class.getName() };
 
-  protected static final String[] clientExpectedExceptions = {
+  private static final String[] clientIgnoredExceptions = {
       AuthenticationFailedException.class.getName(),
       NotAuthorizedException.class.getName(),
       RegionDestroyedException.class.getName() };
 
+  @Override
+  public final void preSetUp() throws Exception {
+  }
+
+  @Override
+  public final void postSetUp() throws Exception {
+    preSetUpClientAuthorizationTestBase();
+    setUpClientAuthorizationTestBase();
+    postSetUpClientAuthorizationTestBase();
+  }
+
+  private final void setUpClientAuthorizationTestBase() throws Exception {
+    final Host host = Host.getHost(0);
+    server1 = host.getVM(0);
+    server2 = host.getVM(1);
+    client1 = host.getVM(2);
+    client2 = host.getVM(3);
+
+    server1.invoke(() -> SecurityTestUtil.registerExpectedExceptions(serverIgnoredExceptions));
+    server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions(serverIgnoredExceptions));
+    client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions(clientIgnoredExceptions));
+    SecurityTestUtil.registerExpectedExceptions(clientIgnoredExceptions);
+  }
+
+  protected void preSetUpClientAuthorizationTestBase() throws Exception {
+  }
+
+  protected void postSetUpClientAuthorizationTestBase() throws Exception {
+  }
+
+  @Override
+  public final void preTearDown() throws Exception {
+    preTearDownClientAuthorizationTestBase();
+    postTearDownClientAuthorizationTestBase();
+  }
+
+  @Override
+  public final void postTearDown() throws Exception {
+  }
+
+  protected void preTearDownClientAuthorizationTestBase() throws Exception {
+  }
+
+  protected void postTearDownClientAuthorizationTestBase() throws Exception {
+  }
+
   protected static Properties buildProperties(String authenticator,
       String accessor, boolean isAccessorPP, Properties extraAuthProps,
       Properties extraAuthzProps) {
@@ -244,7 +287,7 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
     else {
       assertNotNull(region);
     }
-    final String[] keys = SecurityTestUtil.keys;
+    final String[] keys = SecurityTestUtil.KEYS;
     final String[] vals;
     if ((flags & OpFlags.USE_NEWVAL) > 0) {
       vals = SecurityTestUtil.nvalues;
@@ -293,7 +336,7 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
               int keyNum = indices[keyNumIndex];
               searchKey = keys[keyNum];
               keyList.add(searchKey);
-              // local invalidate some keys to force fetch of those keys from
+              // local invalidate some KEYS to force fetch of those KEYS from
               // server
               if ((flags & OpFlags.CHECK_NOKEY) > 0) {
                 AbstractRegionEntry entry = (AbstractRegionEntry)((LocalRegion)region).getRegionEntry(searchKey);
@@ -678,7 +721,7 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
           continue;
         }
         else {
-          Assert.fail("doOp: Got unexpected exception when doing operation. Policy = " 
+          fail("doOp: Got unexpected exception when doing operation. Policy = "
               + policy + " flags = " + OpFlags.description(flags), ex);
         }
       }
@@ -984,7 +1027,7 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
         boolean foundKey = false;
         while (eventIter.hasNext()) {
           CqEvent event = (CqEvent)eventIter.next();
-          if (SecurityTestUtil.keys[index].equals(event.getKey())) {
+          if (SecurityTestUtil.KEYS[index].equals(event.getKey())) {
             assertEquals(vals[index], event.getNewValue());
             foundKey = true;
             break;
@@ -1036,7 +1079,7 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
     public static final int USE_NEWVAL = 0x10;
 
     /**
-     * Register all keys. For GET operations indicates using getAll().
+     * Register all KEYS. For GET operations indicates using getAll().
      */
     public static final int USE_ALL_KEYS = 0x20;
 
@@ -1046,7 +1089,7 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
     public static final int USE_REGEX = 0x40;
 
     /**
-     * Register a list of keys.
+     * Register a list of KEYS.
      */
     public static final int USE_LIST = 0x80;
 
@@ -1185,7 +1228,7 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
     private int flags;
 
     /**
-     * Indices of the keys array to be used for operations.
+     * Indices of the KEYS array to be used for operations.
      */
     private int[] indices;
 
@@ -1328,14 +1371,14 @@ public class ClientAuthorizationTestBase extends JUnit4DistributedTestCase {
 
     /**
      * Get allowed credentials for the given set of operations in the given
-     * regions and indices of keys in the <code>keys</code> array
+     * regions and indices of KEYS in the <code>KEYS</code> array
      */
     public Properties getAllowedCredentials(OperationCode[] opCodes,
         String[] regionNames, int[] keyIndices, int num);
 
     /**
      * Get disallowed credentials for the given set of operations in the given
-     * regions and indices of keys in the <code>keys</code> array
+     * regions and indices of KEYS in the <code>KEYS</code> array
      */
     public Properties getDisallowedCredentials(OperationCode[] opCodes,
         String[] regionNames, int[] keyIndices, int num);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5a321ffd/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
index 18da345..7a5b49d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientMultiUserAuthzDUnitTest.java
@@ -29,7 +29,6 @@ import com.gemstone.gemfire.internal.cache.execute.PRClientServerTestBase;
 import com.gemstone.gemfire.internal.cache.functions.TestFunction;
 import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
 import com.gemstone.gemfire.security.generator.CredentialGenerator;
-import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.LogWriterUtils;
 import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
@@ -40,17 +39,14 @@ import org.junit.experimental.categories.Category;
 public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
 
   @Override
-  public final void postSetUp() throws Exception {
-    final Host host = Host.getHost(0);
-    server1 = host.getVM(0);
-    server2 = host.getVM(1);
-    client1 = host.getVM(2);
-    client2 = host.getVM(3);
-
-    server1.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions ));
-    SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions);
+  public final void preTearDownClientAuthorizationTestBase() throws Exception {
+    // close the clients first
+    client1.invoke(() -> SecurityTestUtil.closeCache());
+    client2.invoke(() -> SecurityTestUtil.closeCache());
+    SecurityTestUtil.closeCache();
+    // then close the servers
+    server1.invoke(() -> SecurityTestUtil.closeCache());
+    server2.invoke(() -> SecurityTestUtil.closeCache());
   }
 
   /**
@@ -328,7 +324,7 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
   }
 
   public static void doPuts() {
-    Region region = GemFireCacheImpl.getInstance().getRegion(SecurityTestUtil.regionName);
+    Region region = GemFireCacheImpl.getInstance().getRegion(SecurityTestUtil.REGION_NAME);
     region.put("key1", "value1");
     region.put("key2", "value2");
   }
@@ -506,17 +502,4 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
       verifyContainsKeyDestroys(false, false);
     }
   }
-
-  // End Region: Tests
-
-  @Override
-  public final void preTearDown() throws Exception {
-    // close the clients first
-    client1.invoke(() -> SecurityTestUtil.closeCache());
-    client2.invoke(() -> SecurityTestUtil.closeCache());
-    SecurityTestUtil.closeCache();
-    // then close the servers
-    server1.invoke(() -> SecurityTestUtil.closeCache());
-    server2.invoke(() -> SecurityTestUtil.closeCache());
-  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5a321ffd/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
index a2ed3fd..4ffac74 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
@@ -31,7 +31,6 @@ import com.gemstone.gemfire.internal.cache.PartitionedRegionLocalMaxMemoryDUnitT
 import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
 import com.gemstone.gemfire.security.generator.CredentialGenerator;
 import com.gemstone.gemfire.test.dunit.Assert;
-import com.gemstone.gemfire.test.dunit.Host;
 import com.gemstone.gemfire.test.dunit.LogWriterUtils;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import org.junit.Test;
@@ -46,76 +45,13 @@ public class DeltaClientAuthorizationDUnitTest extends
 
   private DeltaTestImpl[] deltas = new DeltaTestImpl[8];
 
-  private final void setUpDeltas() {
-    for (int i = 0; i < 8; i++) {
-      deltas[i] = new DeltaTestImpl(0, "0", new Double(0), new byte[0],
-          new TestObject1("0", 0));
-    }
-    deltas[1].setIntVar(5);
-    deltas[2].setIntVar(5);
-    deltas[3].setIntVar(5);
-    deltas[4].setIntVar(5);
-    deltas[5].setIntVar(5);
-    deltas[6].setIntVar(5);
-    deltas[7].setIntVar(5);
-
-    deltas[2].resetDeltaStatus();
-    deltas[2].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
-    deltas[3].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
-    deltas[4].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
-    deltas[5].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
-    //deltas[6].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
-    //deltas[7].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
-
-    deltas[3].resetDeltaStatus();
-    deltas[3].setDoubleVar(new Double(5));
-    deltas[4].setDoubleVar(new Double(5));
-    deltas[5].setDoubleVar(new Double(5));
-    deltas[6].setDoubleVar(new Double(5));
-    deltas[7].setDoubleVar(new Double(5));
-
-    deltas[4].resetDeltaStatus();
-    deltas[4].setStr("str changed");
-    deltas[5].setStr("str changed");
-    deltas[6].setStr("str changed");
-    //deltas[7].setStr("str changed");
-
-    deltas[5].resetDeltaStatus();
-    deltas[5].setIntVar(100);
-    deltas[5].setTestObj(new TestObject1("CHANGED", 100));
-    deltas[6].setTestObj(new TestObject1("CHANGED", 100));
-    deltas[7].setTestObj(new TestObject1("CHANGED", 100));
-
-    deltas[6].resetDeltaStatus();
-    deltas[6].setByteArr(new byte[] { 1, 2, 3 });
-    deltas[7].setByteArr(new byte[] { 1, 2, 3 });
-
-    deltas[7].resetDeltaStatus();
-    deltas[7].setStr("delta string");
-    
-  }
-
   @Override
-  public final void preSetUp() throws Exception {
+  protected final void preSetUpClientAuthorizationTestBase() throws Exception {
     setUpDeltas();
   }
 
   @Override
-  public final void postSetUp() throws Exception {
-    final Host host = Host.getHost(0);
-    server1 = host.getVM(0);
-    server2 = host.getVM(1);
-    client1 = host.getVM(2);
-    client2 = host.getVM(3);
-
-    server1.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions ));
-    SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions);
-  }
-
-  @Override
-  public final void preTearDown() throws Exception {
+  public final void preTearDownClientAuthorizationTestBase() throws Exception {
     // close the clients first
     client1.invoke(() -> SecurityTestUtil.closeCache());
     client2.invoke(() -> SecurityTestUtil.closeCache());
@@ -179,36 +115,36 @@ public class DeltaClientAuthorizationDUnitTest extends
           new Integer(2), new Integer(SecurityTestUtil.NO_EXCEPTION), Boolean.FALSE  ));
   }
 
-  protected void createClient2(Properties javaProps, String authInit,
+  private void createClient2(Properties javaProps, String authInit,
       Integer port1, Integer port2, Properties getCredentials) {
     client2.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, getCredentials, javaProps, port1, port2,
             null, new Integer(SecurityTestUtil.NO_EXCEPTION) ));
   }
 
-  protected void createClient1(Properties javaProps, String authInit,
+  private void createClient1(Properties javaProps, String authInit,
       Integer port1, Integer port2, Properties createCredentials) {
     client1.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, createCredentials, javaProps, port1, port2,
             null, new Integer(SecurityTestUtil.NO_EXCEPTION) ));
   }
 
-  protected Integer createServer2(Properties javaProps,
+  private Integer createServer2(Properties javaProps,
       Properties serverProps) {
     Integer port2 = ((Integer)server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
             SecurityTestUtil.getLocatorPort(), serverProps, javaProps )));
     return port2;
   }
 
-  protected Integer createServer1(Properties javaProps,
+  private Integer createServer1(Properties javaProps,
       Properties serverProps) {
     Integer port1 = ((Integer)server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
             SecurityTestUtil.getLocatorPort(), serverProps, javaProps )));
     return port1;
   }
 
-  public void doPuts(Integer num, Integer expectedResult,
+  private void doPuts(Integer num, Integer expectedResult,
       boolean newVals) {
 
-    assertTrue(num.intValue() <= SecurityTestUtil.keys.length);
+    assertTrue(num.intValue() <= SecurityTestUtil.KEYS.length);
     Region region = null;
     try {
       region = SecurityTestUtil.getCache().getRegion(regionName);
@@ -223,11 +159,11 @@ public class DeltaClientAuthorizationDUnitTest extends
       }
     }
     for (int index = 0; index < num.intValue(); ++index) {
-      region.put(SecurityTestUtil.keys[index], deltas[0]);
+      region.put(SecurityTestUtil.KEYS[index], deltas[0]);
     }
     for (int index = 0; index < num.intValue(); ++index) {
       try {
-        region.put(SecurityTestUtil.keys[index], deltas[index]);
+        region.put(SecurityTestUtil.KEYS[index], deltas[index]);
         if (expectedResult.intValue() != SecurityTestUtil.NO_EXCEPTION) {
           fail("Expected a NotAuthorizedException while doing puts");
         }
@@ -283,10 +219,10 @@ public class DeltaClientAuthorizationDUnitTest extends
     }
   }
 
-  public void doGets(Integer num, Integer expectedResult,
+  private void doGets(Integer num, Integer expectedResult,
       boolean newVals) {
 
-    assertTrue(num.intValue() <= SecurityTestUtil.keys.length);
+    assertTrue(num.intValue() <= SecurityTestUtil.KEYS.length);
     Region region = null;
     try {
       region = SecurityTestUtil.getCache().getRegion(regionName);
@@ -304,11 +240,11 @@ public class DeltaClientAuthorizationDUnitTest extends
       Object value = null;
       try {
         try {
-          region.localInvalidate(SecurityTestUtil.keys[index]);
+          region.localInvalidate(SecurityTestUtil.KEYS[index]);
         }
         catch (Exception ex) {
         }
-        value = region.get(SecurityTestUtil.keys[index]);
+        value = region.get(SecurityTestUtil.KEYS[index]);
         if (expectedResult.intValue() != SecurityTestUtil.NO_EXCEPTION) {
           fail("Expected a NotAuthorizedException while doing gets");
         }
@@ -352,4 +288,52 @@ public class DeltaClientAuthorizationDUnitTest extends
     }
   }
 
+  private final void setUpDeltas() {
+    for (int i = 0; i < 8; i++) {
+      deltas[i] = new DeltaTestImpl(0, "0", new Double(0), new byte[0],
+              new TestObject1("0", 0));
+    }
+    deltas[1].setIntVar(5);
+    deltas[2].setIntVar(5);
+    deltas[3].setIntVar(5);
+    deltas[4].setIntVar(5);
+    deltas[5].setIntVar(5);
+    deltas[6].setIntVar(5);
+    deltas[7].setIntVar(5);
+
+    deltas[2].resetDeltaStatus();
+    deltas[2].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
+    deltas[3].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
+    deltas[4].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
+    deltas[5].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
+    //deltas[6].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
+    //deltas[7].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
+
+    deltas[3].resetDeltaStatus();
+    deltas[3].setDoubleVar(new Double(5));
+    deltas[4].setDoubleVar(new Double(5));
+    deltas[5].setDoubleVar(new Double(5));
+    deltas[6].setDoubleVar(new Double(5));
+    deltas[7].setDoubleVar(new Double(5));
+
+    deltas[4].resetDeltaStatus();
+    deltas[4].setStr("str changed");
+    deltas[5].setStr("str changed");
+    deltas[6].setStr("str changed");
+    //deltas[7].setStr("str changed");
+
+    deltas[5].resetDeltaStatus();
+    deltas[5].setIntVar(100);
+    deltas[5].setTestObj(new TestObject1("CHANGED", 100));
+    deltas[6].setTestObj(new TestObject1("CHANGED", 100));
+    deltas[7].setTestObj(new TestObject1("CHANGED", 100));
+
+    deltas[6].resetDeltaStatus();
+    deltas[6].setByteArr(new byte[] { 1, 2, 3 });
+    deltas[7].setByteArr(new byte[] { 1, 2, 3 });
+
+    deltas[7].resetDeltaStatus();
+    deltas[7].setStr("delta string");
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5a321ffd/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java b/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java
index af8c0fe..80a8f6d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java
@@ -1,5 +1,3 @@
-package com.gemstone.gemfire.security;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -8,9 +6,9 @@ package com.gemstone.gemfire.security;
  * 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
@@ -18,7 +16,12 @@ package com.gemstone.gemfire.security;
  * specific language governing permissions and limitations
  * under the License.
  */
+package com.gemstone.gemfire.security;
 
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.DistributedTestUtils.*;
+import static com.gemstone.gemfire.test.dunit.NetworkUtils.*;
+import static com.gemstone.gemfire.test.dunit.Wait.*;
 
 import java.io.File;
 import java.io.FileOutputStream;
@@ -82,11 +85,7 @@ import com.gemstone.gemfire.internal.util.Callable;
 import com.gemstone.gemfire.pdx.PdxReader;
 import com.gemstone.gemfire.pdx.PdxSerializable;
 import com.gemstone.gemfire.pdx.PdxWriter;
-import com.gemstone.gemfire.test.dunit.Assert;
 import com.gemstone.gemfire.test.dunit.DistributedTestCase;
-import com.gemstone.gemfire.test.dunit.DistributedTestUtils;
-import com.gemstone.gemfire.test.dunit.NetworkUtils;
-import com.gemstone.gemfire.test.dunit.Wait;
 import com.gemstone.gemfire.test.dunit.WaitCriterion;
 
 /**
@@ -96,42 +95,29 @@ import com.gemstone.gemfire.test.dunit.WaitCriterion;
  * @author sumedh
  * @since 5.5
  */
-public class SecurityTestUtil extends DistributedTestCase {
+public final class SecurityTestUtil {
 
-  public SecurityTestUtil(String name) {
-    super(name);
-  }
+  private final DistributedTestCase distributedTestCase = new DistributedTestCase(getClass().getSimpleName()) {};
 
   private static Locator locator = null;
-
   private static Cache cache = null;
-
   private static Properties currentJavaProps = null;
-
   private static String locatorString = null;
-
   private static Integer mcastPort = null;
 
   public static final int NO_EXCEPTION = 0;
-
   public static final int AUTHREQ_EXCEPTION = 1;
-
   public static final int AUTHFAIL_EXCEPTION = 2;
-
   public static final int CONNREFUSED_EXCEPTION = 3;
-
   public static final int NOTAUTHZ_EXCEPTION = 4;
-
   public static final int OTHER_EXCEPTION = 5;
-  
   public static final int NO_AVAILABLE_SERVERS = 6;
-
   // Indicates that AuthReqException may not necessarily be thrown
   public static final int NOFORCE_AUTHREQ_EXCEPTION = 16;
 
-  protected static final String regionName = "AuthRegion";
+  protected static final String REGION_NAME = "AuthRegion";
 
-  protected static final String[] keys = { "key1", "key2", "key3", "key4",
+  protected static final String[] KEYS = { "key1", "key2", "key3", "key4",
       "key5", "key6", "key7", "key8" };
 
   protected static final String[] values = { "value1", "value2", "value3",
@@ -141,6 +127,9 @@ public class SecurityTestUtil extends DistributedTestCase {
       "nvalue4", "nvalue5", "nvalue6", "nvalue7", "nvalue8" };
 
   static String[] expectedExceptions = null;
+  static String[] expectedExceptions() {
+    return expectedExceptions;
+  }
 
   private static Pool pool = null;
 
@@ -149,6 +138,9 @@ public class SecurityTestUtil extends DistributedTestCase {
   private static final int numberOfUsers = 1;
 
   static ProxyCache[] proxyCaches = new ProxyCache[numberOfUsers];
+  static ProxyCache[] proxyCaches() {
+    return proxyCaches();
+  }
 
   private static Region regionRef = null;
 
@@ -172,6 +164,9 @@ public class SecurityTestUtil extends DistributedTestCase {
     }
   }
 
+  public SecurityTestUtil(String name) {
+  }
+
   public static void setJavaProps(Properties javaProps) {
 
     removeJavaProperties(currentJavaProps);
@@ -185,7 +180,7 @@ public class SecurityTestUtil extends DistributedTestCase {
     clearStaticSSLContext();
     setJavaProps(javaProps);
 
-    DistributedSystem dsys = getSystem(sysProps);
+    DistributedSystem dsys = distributedTestCase.getSystem(sysProps);
     assertNotNull(dsys);
     addExpectedExceptions(SecurityTestUtil.expectedExceptions, dsys
         .getLogWriter());
@@ -194,9 +189,9 @@ public class SecurityTestUtil extends DistributedTestCase {
 
   void openCache() {
 
-    assertNotNull(basicGetSystem());
-    assertTrue(basicGetSystem().isConnected());
-    cache = CacheFactory.create(basicGetSystem());
+    assertNotNull(distributedTestCase.basicGetSystem());
+    assertTrue(distributedTestCase.basicGetSystem().isConnected());
+    cache = CacheFactory.create(distributedTestCase.basicGetSystem());
     assertNotNull(cache);
   }
 
@@ -216,7 +211,7 @@ public class SecurityTestUtil extends DistributedTestCase {
 
     Integer locatorPort = new Integer(AvailablePort
         .getRandomAvailablePort(AvailablePort.SOCKET));
-    String addr = NetworkUtils.getIPLiteral();
+    String addr = getIPLiteral();
     if (locatorString == null) {
       locatorString = addr + "[" + locatorPort + ']';
     }
@@ -296,10 +291,10 @@ public class SecurityTestUtil extends DistributedTestCase {
       authProps.setProperty(DistributionConfig.LOCATORS_NAME, locatorString);
       if (locatorPort != null) {
         authProps.setProperty(DistributionConfig.START_LOCATOR_NAME,
-            NetworkUtils.getIPLiteral() + "[" + locatorPort.toString() + ']');
+            getIPLiteral() + "[" + locatorPort.toString() + ']');
       }
     } else {
-      authProps.setProperty("locators", "localhost["+DistributedTestUtils.getDUnitLocatorPort()+"]");
+      authProps.setProperty("locators", "localhost["+getDUnitLocatorPort()+"]");
     }
     authProps.setProperty(DistributionConfig.SECURITY_LOG_LEVEL_NAME, "finest");
     com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Set the server properties to: " + authProps);
@@ -318,7 +313,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         return new Integer(0);
       }
       else {
-        Assert.fail("Got unexpected exception when starting peer", ex);
+        fail("Got unexpected exception when starting peer", ex);
       }
     }
     catch (AuthenticationFailedException ex) {
@@ -327,11 +322,11 @@ public class SecurityTestUtil extends DistributedTestCase {
         return new Integer(0);
       }
       else {
-        Assert.fail("Got unexpected exception when starting peer", ex);
+        fail("Got unexpected exception when starting peer", ex);
       }
     }
     catch (Exception ex) {
-      Assert.fail("Got unexpected exception when starting peer", ex);
+      fail("Got unexpected exception when starting peer", ex);
     }
 
     if (setupDynamicRegionFactory.booleanValue()) {
@@ -342,7 +337,7 @@ public class SecurityTestUtil extends DistributedTestCase {
     factory.setScope(Scope.DISTRIBUTED_ACK);
     factory.setDataPolicy(DataPolicy.REPLICATE);
     RegionAttributes attrs = factory.create();
-    cache.createRegion(regionName, attrs);
+    cache.createRegion(REGION_NAME, attrs);
     int port;
     if (serverPort == null || serverPort.intValue() <= 0) {
       port = 0;
@@ -357,7 +352,7 @@ public class SecurityTestUtil extends DistributedTestCase {
       server1.start();
     }
     catch (Exception ex) {
-      Assert.fail("Got unexpected exception when starting CacheServer", ex);
+      fail("Got unexpected exception when starting CacheServer", ex);
     }
     return new Integer(server1.getPort());
   }
@@ -431,7 +426,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         //poolFactory.setSubscriptionEnabled(false);
       }
       pool = ClientServerTestCase.configureConnectionPoolWithNameAndFactory(factory,
-          NetworkUtils.getIPLiteral(), portsI, subscriptionEnabled, 0,
+          getIPLiteral(), portsI, subscriptionEnabled, 0,
           numConnections == null ? -1 : numConnections.intValue(), null, null,
           poolFactory);
 
@@ -450,7 +445,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected UnsupportedOperationException in single-user mode");
         }
         else {
-          Assert.fail("Got unexpected exception in multi-user mode ", uoe);
+          fail("Got unexpected exception in multi-user mode ", uoe);
         }
       }
 
@@ -459,7 +454,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         factory.setDataPolicy(DataPolicy.EMPTY);
       }
       RegionAttributes attrs = factory.create();
-      cache.createRegion(regionName, attrs);
+      cache.createRegion(REGION_NAME, attrs);
 
       if (expectedResult.intValue() != NO_EXCEPTION
           && expectedResult.intValue() != NOFORCE_AUTHREQ_EXCEPTION) {
@@ -475,7 +470,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected exception when starting client: " + ex);
       }
       else {
-        Assert.fail("Got unexpected exception when starting client", ex);
+        fail("Got unexpected exception when starting client", ex);
       }
     }
     catch (AuthenticationFailedException ex) {
@@ -484,7 +479,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected exception when starting client: " + ex);
       }
       else {
-        Assert.fail("Got unexpected exception when starting client", ex);
+        fail("Got unexpected exception when starting client", ex);
       }
     }
     catch (ServerRefusedConnectionException ex) {
@@ -493,11 +488,11 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected exception when starting client: " + ex);
       }
       else {
-        Assert.fail("Got unexpected exception when starting client", ex);
+        fail("Got unexpected exception when starting client", ex);
       }
     }
     catch (Exception ex) {
-      Assert.fail("Got unexpected exception when starting client", ex);
+      fail("Got unexpected exception when starting client", ex);
     }
   }
 
@@ -573,7 +568,7 @@ public class SecurityTestUtil extends DistributedTestCase {
       poolFactory.setMultiuserAuthentication(multiUserAuthMode);
       poolFactory.setSubscriptionEnabled(true);
       pool = ClientServerTestCase.configureConnectionPoolWithNameAndFactory(factory,
-          NetworkUtils.getIPLiteral(), portsI, true, 1,
+          getIPLiteral(), portsI, true, 1,
           numConnections == null ? -1 : numConnections.intValue(), null, null,
           poolFactory);
 
@@ -588,7 +583,7 @@ public class SecurityTestUtil extends DistributedTestCase {
       factory.setScope(Scope.LOCAL);
       factory.setDataPolicy(DataPolicy.EMPTY);
       RegionAttributes attrs = factory.create();
-      cache.createRegion(regionName, attrs);
+      cache.createRegion(REGION_NAME, attrs);
 
       if (expectedResult.intValue() != NO_EXCEPTION
           && expectedResult.intValue() != NOFORCE_AUTHREQ_EXCEPTION) {
@@ -604,7 +599,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected exception when starting client: " + ex);
       }
       else {
-        Assert.fail("Got unexpected exception when starting client", ex);
+        fail("Got unexpected exception when starting client", ex);
       }
     }
     catch (AuthenticationFailedException ex) {
@@ -613,7 +608,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected exception when starting client: " + ex);
       }
       else {
-        Assert.fail("Got unexpected exception when starting client", ex);
+        fail("Got unexpected exception when starting client", ex);
       }
     }
     catch (ServerRefusedConnectionException ex) {
@@ -622,11 +617,11 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected exception when starting client: " + ex);
       }
       else {
-        Assert.fail("Got unexpected exception when starting client", ex);
+        fail("Got unexpected exception when starting client", ex);
       }
     }
     catch (Exception ex) {
-      Assert.fail("Got unexpected exception when starting client", ex);
+      fail("Got unexpected exception when starting client", ex);
     }
   }
 
@@ -656,7 +651,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         server.start();
       }
       catch (Exception ex) {
-        Assert.fail("Unexpected exception when restarting cache servers", ex);
+        fail("Unexpected exception when restarting cache servers", ex);
       }
       assertTrue(server.isRunning());
     }
@@ -673,7 +668,7 @@ public class SecurityTestUtil extends DistributedTestCase {
       }
       authProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
       authProps.setProperty(DistributionConfig.LOCATORS_NAME, 
-                            NetworkUtils.getIPLiteral() + "[" + port + "]");
+                            getIPLiteral() + "[" + port + "]");
       authProps.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
       clearStaticSSLContext();
       setJavaProps((Properties)javaProps);
@@ -687,7 +682,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           authProps);
     }
     catch (IOException ex) {
-      Assert.fail("While starting locator on port " + port.intValue(), ex);
+      fail("While starting locator on port " + port.intValue(), ex);
     }
   }
 
@@ -699,7 +694,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           .getDistributedSystem().getLogWriter());
     }
     catch (Exception ex) {
-      Assert.fail("While stopping locator on port " + port.intValue(), ex);
+      fail("While stopping locator on port " + port.intValue(), ex);
     }
   }
 
@@ -721,7 +716,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           return ((Boolean)cond.call()).booleanValue();
         }
         catch (Exception e) {
-          Assert.fail("Unexpected exception", e);
+          fail("Unexpected exception", e);
         }
         return false; // NOTREACHED
       }
@@ -729,7 +724,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         return null;
       }
     };
-    Wait.waitForCriterion(ev, sleepMillis * numTries, 200, true);
+    waitForCriterion(ev, sleepMillis * numTries, 200, true);
   }
 
   public static Object getLocalValue(Region region, Object key) {
@@ -752,15 +747,15 @@ public class SecurityTestUtil extends DistributedTestCase {
   private static void doPutsP(Integer num, Integer multiUserIndex,
       Integer expectedResult, boolean newVals) {
 
-    assertTrue(num.intValue() <= keys.length);
+    assertTrue(num.intValue() <= KEYS.length);
     Region region = null;
     try {
       if (multiUserAuthMode) {
-        region = proxyCaches[multiUserIndex].getRegion(regionName);
+        region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
         regionRef = region;
       }
       else {
-        region = getCache().getRegion(regionName);
+        region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
     }
@@ -769,16 +764,16 @@ public class SecurityTestUtil extends DistributedTestCase {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing puts: " + ex);
       }
       else {
-        Assert.fail("Got unexpected exception when doing puts", ex);
+        fail("Got unexpected exception when doing puts", ex);
       }
     }
     for (int index = 0; index < num.intValue(); ++index) {
       try {
         if (newVals) {
-          region.put(keys[index], nvalues[index]);
+          region.put(KEYS[index], nvalues[index]);
         }
         else {
-          region.put(keys[index], values[index]);
+          region.put(KEYS[index], values[index]);
         }
         if (expectedResult.intValue() != NO_EXCEPTION) {
           fail("Expected a NotAuthorizedException while doing puts");
@@ -792,7 +787,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           continue;
         }
         else {
-          Assert.fail("Got unexpected exception when doing puts", ex);
+          fail("Got unexpected exception when doing puts", ex);
         }
       }
       catch (ServerConnectivityException ex) {
@@ -821,7 +816,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing puts: " + ex);
         }
         else {
-          Assert.fail("Got unexpected exception when doing puts", ex);
+          fail("Got unexpected exception when doing puts", ex);
         }
       }
       catch (Exception ex) {
@@ -829,7 +824,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing puts: " + ex);
         }
         else {
-          Assert.fail("Got unexpected exception when doing puts", ex);
+          fail("Got unexpected exception when doing puts", ex);
         }
       }
     }
@@ -868,7 +863,7 @@ public class SecurityTestUtil extends DistributedTestCase {
   }
   
   public static void doPutAllP() throws Exception {    
-    Region region = getCache().getRegion(regionName);
+    Region region = getCache().getRegion(REGION_NAME);
     assertNotNull(region);
     Map map = new LinkedHashMap();
     map.put("1010L", new Employee(1010L, "John", "Doe"));
@@ -880,10 +875,10 @@ public class SecurityTestUtil extends DistributedTestCase {
     Region region = null;
     try {
       if (multiUserAuthMode) {
-        region = proxyCaches[multiUserIndex].getRegion(regionName);
+        region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
       }
       else {
-        region = getCache().getRegion(regionName);
+        region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
     }
@@ -892,7 +887,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing getAll: " + ex);
       }
       else {
-        Assert.fail("Got unexpected exception when doing getAll", ex);
+        fail("Got unexpected exception when doing getAll", ex);
       }
     }
     try {
@@ -922,7 +917,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected NoAvailableServers when doing getAll: "
                 + ex.getCause());
       } else {
-        Assert.fail("Got unexpected exception when doing getAll", ex);
+        fail("Got unexpected exception when doing getAll", ex);
       }
     } catch (ServerConnectivityException ex) {
       if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
@@ -933,13 +928,13 @@ public class SecurityTestUtil extends DistributedTestCase {
       } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing getAll: " + ex);
       } else {
-        Assert.fail("Got unexpected exception when doing getAll", ex);
+        fail("Got unexpected exception when doing getAll", ex);
       }
     } catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing getAll: " + ex);
       } else {
-        Assert.fail("Got unexpected exception when doing getAll", ex);
+        fail("Got unexpected exception when doing getAll", ex);
       }
     }
   }
@@ -952,14 +947,14 @@ public class SecurityTestUtil extends DistributedTestCase {
   private static void doGetsP(Integer num, Integer multiUserIndex,
       Integer expectedResult, boolean newVals) {
 
-    assertTrue(num.intValue() <= keys.length);
+    assertTrue(num.intValue() <= KEYS.length);
     Region region = null;
     try {
       if (multiUserAuthMode) {
-        region = proxyCaches[multiUserIndex].getRegion(regionName);
+        region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
       }
       else {
-        region = getCache().getRegion(regionName);
+        region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
     }
@@ -968,18 +963,18 @@ public class SecurityTestUtil extends DistributedTestCase {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing gets: " + ex);
       }
       else {
-        Assert.fail("Got unexpected exception when doing gets", ex);
+        fail("Got unexpected exception when doing gets", ex);
       }
     }
     for (int index = 0; index < num.intValue(); ++index) {
       Object value = null;
       try {
         try {
-          region.localInvalidate(keys[index]);
+          region.localInvalidate(KEYS[index]);
         }
         catch (Exception ex) {
         }
-        value = region.get(keys[index]);
+        value = region.get(KEYS[index]);
         if (expectedResult.intValue() != NO_EXCEPTION) {
           fail("Expected a NotAuthorizedException while doing gets");
         }
@@ -992,7 +987,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           continue;
         }
         else {
-          Assert.fail("Got unexpected exception when doing gets", ex);
+          fail("Got unexpected exception when doing gets", ex);
         }
       }
       catch (ServerConnectivityException ex) {
@@ -1007,7 +1002,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing gets: " + ex);
         }
         else {
-          Assert.fail("Got unexpected exception when doing gets", ex);
+          fail("Got unexpected exception when doing gets", ex);
         }
       }
       catch (Exception ex) {
@@ -1015,7 +1010,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing gets: " + ex);
         }
         else {
-          Assert.fail("Got unexpected exception when doing gets", ex);
+          fail("Got unexpected exception when doing gets", ex);
         }
       }
       assertNotNull(value);
@@ -1030,15 +1025,15 @@ public class SecurityTestUtil extends DistributedTestCase {
 
   private static void doLocalGetsP(int num, boolean checkNVals) {
 
-    assertTrue(num <= keys.length);
+    assertTrue(num <= KEYS.length);
     String[] vals = values;
     if (checkNVals) {
       vals = nvalues;
     }
-    final Region region = getCache().getRegion(regionName);
+    final Region region = getCache().getRegion(REGION_NAME);
     assertNotNull(region);
     for (int index = 0; index < num; ++index) {
-      final String key = keys[index];
+      final String key = KEYS[index];
       final String expectedVal = vals[index];
       waitForCondition(new Callable() {
         public Object call() throws Exception {
@@ -1048,7 +1043,7 @@ public class SecurityTestUtil extends DistributedTestCase {
       }, 1000, 30 / num);
     }
     for (int index = 0; index < num; ++index) {
-      Region.Entry entry = region.getEntry(keys[index]);
+      Region.Entry entry = region.getEntry(KEYS[index]);
       assertNotNull(entry);
       assertEquals(vals[index], entry.getValue());
     }
@@ -1059,9 +1054,9 @@ public class SecurityTestUtil extends DistributedTestCase {
     Region region = null;
     try {
       if (multiUserAuthMode) {
-        region = proxyCaches[multiuserIndex].getRegion(regionName);
+        region = proxyCaches[multiuserIndex].getRegion(REGION_NAME);
       } else {
-        region = getCache().getRegion(regionName);
+        region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
     } catch (Exception ex) {
@@ -1069,7 +1064,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
             "Got expected exception when doing region destroy: " + ex);
       } else {
-        Assert.fail("Got unexpected exception when doing region destroy", ex);
+        fail("Got unexpected exception when doing region destroy", ex);
       }
     }
 
@@ -1079,9 +1074,9 @@ public class SecurityTestUtil extends DistributedTestCase {
         fail("Expected a NotAuthorizedException while doing region destroy");
       }
       if (multiUserAuthMode) {
-        region = proxyCaches[multiuserIndex].getRegion(regionName);
+        region = proxyCaches[multiuserIndex].getRegion(REGION_NAME);
       } else {
-        region = getCache().getRegion(regionName);
+        region = getCache().getRegion(REGION_NAME);
       }
       assertNull(region);
     } catch (NoAvailableServersException ex) {
@@ -1090,7 +1085,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected NoAvailableServers when doing region destroy: "
                 + ex.getCause());
       } else {
-        Assert.fail("Got unexpected exception when doing region destroy", ex);
+        fail("Got unexpected exception when doing region destroy", ex);
       }
     } catch (ServerConnectivityException ex) {
       if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
@@ -1102,14 +1097,14 @@ public class SecurityTestUtil extends DistributedTestCase {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
             "Got expected exception when doing region destroy: " + ex);
       } else {
-        Assert.fail("Got unexpected exception when doing region destroy", ex);
+        fail("Got unexpected exception when doing region destroy", ex);
       }
     } catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
             "Got expected exception when doing region destroy: " + ex);
       } else {
-        Assert.fail("Got unexpected exception when doing region destroy", ex);
+        fail("Got unexpected exception when doing region destroy", ex);
       }
     }
   }
@@ -1117,14 +1112,14 @@ public class SecurityTestUtil extends DistributedTestCase {
   private static void doDestroysP(Integer num, Integer multiUserIndex,
       Integer expectedResult, boolean newVals) {
 
-    assertTrue(num.intValue() <= keys.length);
+    assertTrue(num.intValue() <= KEYS.length);
     Region region = null;
     try {
       if (multiUserAuthMode) {
-        region = proxyCaches[multiUserIndex].getRegion(regionName);
+        region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
       }
       else {
-        region = getCache().getRegion(regionName);
+        region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
     }
@@ -1133,12 +1128,12 @@ public class SecurityTestUtil extends DistributedTestCase {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing destroys: " + ex);
       }
       else {
-        Assert.fail("Got unexpected exception when doing destroys", ex);
+        fail("Got unexpected exception when doing destroys", ex);
       }
     }
     for (int index = 0; index < num.intValue(); ++index) {
       try {
-        region.destroy(keys[index]);
+        region.destroy(KEYS[index]);
         if (expectedResult.intValue() != NO_EXCEPTION) {
           fail("Expected a NotAuthorizedException while doing destroys");
         }
@@ -1151,7 +1146,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           continue;
         }
         else {
-          Assert.fail("Got unexpected exception when doing destroys", ex);
+          fail("Got unexpected exception when doing destroys", ex);
         }
       }
       catch (ServerConnectivityException ex) {
@@ -1166,7 +1161,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing destroys: " + ex);
         }
         else {
-          Assert.fail("Got unexpected exception when doing destroys", ex);
+          fail("Got unexpected exception when doing destroys", ex);
         }
       }
       catch (Exception ex) {
@@ -1174,7 +1169,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing destroys: " + ex);
         }
         else {
-          Assert.fail("Got unexpected exception when doing destroys", ex);
+          fail("Got unexpected exception when doing destroys", ex);
         }
       }
     }
@@ -1183,14 +1178,14 @@ public class SecurityTestUtil extends DistributedTestCase {
   private static void doInvalidatesP(Integer num, Integer multiUserIndex,
       Integer expectedResult, boolean newVals) {
 
-    assertTrue(num.intValue() <= keys.length);
+    assertTrue(num.intValue() <= KEYS.length);
     Region region = null;
     try {
       if (multiUserAuthMode) {
-        region = proxyCaches[multiUserIndex].getRegion(regionName);
+        region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
       }
       else {
-        region = getCache().getRegion(regionName);
+        region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
     }
@@ -1199,12 +1194,12 @@ public class SecurityTestUtil extends DistributedTestCase {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing invalidates: " + ex);
       }
       else {
-        Assert.fail("Got unexpected exception when doing invalidates", ex);
+        fail("Got unexpected exception when doing invalidates", ex);
       }
     }
     for (int index = 0; index < num.intValue(); ++index) {
       try {
-        region.invalidate(keys[index]);
+        region.invalidate(KEYS[index]);
         if (expectedResult.intValue() != NO_EXCEPTION) {
           fail("Expected a NotAuthorizedException while doing invalidates");
         }
@@ -1217,7 +1212,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           continue;
         }
         else {
-          Assert.fail("Got unexpected exception when doing invalidates", ex);
+          fail("Got unexpected exception when doing invalidates", ex);
         }
       }
       catch (ServerConnectivityException ex) {
@@ -1232,7 +1227,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing invalidates: " + ex);
         }
         else {
-          Assert.fail("Got unexpected exception when doing invalidates", ex);
+          fail("Got unexpected exception when doing invalidates", ex);
         }
       }
       catch (Exception ex) {
@@ -1240,7 +1235,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing invalidates: " + ex);
         }
         else {
-          Assert.fail("Got unexpected exception when doing invalidates", ex);
+          fail("Got unexpected exception when doing invalidates", ex);
         }
       }
     }
@@ -1249,14 +1244,14 @@ public class SecurityTestUtil extends DistributedTestCase {
   private static void doContainsKeysP(Integer num, Integer multiUserIndex,
       Integer expectedResult, boolean newVals, boolean expectedValue) {
 
-    assertTrue(num.intValue() <= keys.length);
+    assertTrue(num.intValue() <= KEYS.length);
     Region region = null;
     try {
       if (multiUserAuthMode) {
-        region = proxyCaches[multiUserIndex].getRegion(regionName);
+        region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
       }
       else {
-        region = getCache().getRegion(regionName);
+        region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
     }
@@ -1265,13 +1260,13 @@ public class SecurityTestUtil extends DistributedTestCase {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing containsKey: " + ex);
       }
       else {
-        Assert.fail("Got unexpected exception when doing containsKey", ex);
+        fail("Got unexpected exception when doing containsKey", ex);
       }
     }
     for (int index = 0; index < num.intValue(); ++index) {
       boolean result = false;
       try {
-        result = region.containsKeyOnServer(keys[index]);
+        result = region.containsKeyOnServer(KEYS[index]);
         if (expectedResult.intValue() != NO_EXCEPTION) {
           fail("Expected a NotAuthorizedException while doing containsKey");
         }
@@ -1284,7 +1279,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           continue;
         }
         else {
-          Assert.fail("Got unexpected exception when doing containsKey", ex);
+          fail("Got unexpected exception when doing containsKey", ex);
         }
       }
       catch (ServerConnectivityException ex) {
@@ -1299,7 +1294,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing containsKey: " + ex);
         }
         else {
-          Assert.fail("Got unexpected exception when doing containsKey", ex);
+          fail("Got unexpected exception when doing containsKey", ex);
         }
       }
       catch (Exception ex) {
@@ -1307,7 +1302,7 @@ public class SecurityTestUtil extends DistributedTestCase {
           com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing containsKey: " + ex);
         }
         else {
-          Assert.fail("Got unexpected exception when doing containsKey", ex);
+          fail("Got unexpected exception when doing containsKey", ex);
         }
       }
       assertEquals(expectedValue, result);
@@ -1319,16 +1314,16 @@ public class SecurityTestUtil extends DistributedTestCase {
     Region region = null;
     try {
       if (multiUserAuthMode) {
-        region = proxyCaches[multiUserIndex].getRegion(regionName);
+        region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
       } else {
-        region = getCache().getRegion(regionName);
+        region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
     } catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing queries: " + ex);
       } else {
-        Assert.fail("Got unexpected exception when doing queries", ex);
+        fail("Got unexpected exception when doing queries", ex);
       }
     }
     String queryStr = "SELECT DISTINCT * FROM " + region.getFullPath();
@@ -1345,7 +1340,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected NoAvailableServers when doing queries: "
                 + ex.getCause());
       } else {
-        Assert.fail("Got unexpected exception when doing queries", ex);
+        fail("Got unexpected exception when doing queries", ex);
       }
     } catch (ServerConnectivityException ex) {
       if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
@@ -1356,7 +1351,7 @@ public class SecurityTestUtil extends DistributedTestCase {
       } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing queries: " + ex);
       } else {
-        Assert.fail("Got unexpected exception when doing queries", ex);
+        fail("Got unexpected exception when doing queries", ex);
       }
     } catch (QueryInvocationTargetException qite) {
       if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
@@ -1367,13 +1362,13 @@ public class SecurityTestUtil extends DistributedTestCase {
       } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing queries: " + qite);
       } else {
-        Assert.fail("Got unexpected exception when doing queries", qite);
+        fail("Got unexpected exception when doing queries", qite);
       }
     } catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing queries: " + ex);
       } else {
-        Assert.fail("Got unexpected exception when doing queries", ex);
+        fail("Got unexpected exception when doing queries", ex);
       }
     }
   }
@@ -1384,9 +1379,9 @@ public class SecurityTestUtil extends DistributedTestCase {
     Region region = null;
     try {
       if (multiUserAuthMode) {
-        region = proxyCaches[multiUserIndex].getRegion(regionName);
+        region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
       } else {
-        region = getCache().getRegion(regionName);
+        region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
     } catch (Exception ex) {
@@ -1394,7 +1389,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
             "Got expected exception when executing function: " + ex);
       } else {
-        Assert.fail("Got unexpected exception when executing function", ex);
+        fail("Got unexpected exception when executing function", ex);
       }
     }
     try {
@@ -1425,7 +1420,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected NoAvailableServers when executing function: "
                 + ex.getCause());
       } else {
-        Assert.fail("Got unexpected exception when executing function", ex);
+        fail("Got unexpected exception when executing function", ex);
       }
     } catch (ServerConnectivityException ex) {
       if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
@@ -1437,7 +1432,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
             "Got expected exception when executing function: " + ex);
       } else {
-        Assert.fail("Got unexpected exception when executing function", ex);
+        fail("Got unexpected exception when executing function", ex);
       }
     } catch (FunctionException ex) {
       if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
@@ -1451,14 +1446,14 @@ public class SecurityTestUtil extends DistributedTestCase {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
             "Got expected exception when executing function: " + ex);
       } else {
-        Assert.fail("Got unexpected exception when executing function", ex);
+        fail("Got unexpected exception when executing function", ex);
       }
     } catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
             "Got expected exception when executing function: " + ex);
       } else {
-        Assert.fail("Got unexpected exception when executing function", ex);
+        fail("Got unexpected exception when executing function", ex);
       }
     }
   }
@@ -1468,9 +1463,9 @@ public class SecurityTestUtil extends DistributedTestCase {
     Region region = null;
     try {
       if (multiUserAuthMode) {
-        region = proxyCaches[multiUserIndex].getRegion(regionName);
+        region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
       } else {
-        region = getCache().getRegion(regionName);
+        region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
     } catch (Exception ex) {
@@ -1478,7 +1473,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
             "Got expected exception when executing query: " + ex);
       } else {
-        Assert.fail("Got unexpected exception when executing query", ex);
+        fail("Got unexpected exception when executing query", ex);
       }
     }
     try {
@@ -1501,7 +1496,7 @@ public class SecurityTestUtil extends DistributedTestCase {
             "Got expected NoAvailableServers when executing query: "
                 + ex.getCause());
       } else {
-        Assert.fail("Got unexpected exception when executing query", ex);
+        fail("Got unexpected exception when executing query", ex);
       }
     } catch (ServerConnectivityException ex) {
       if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
@@ -1513,14 +1508,14 @@ public class SecurityTestUtil extends DistributedTestCase {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
             "Got expected exception when executing query: " + ex);
       } else {
-        Assert.fail("Got unexpected exception when executing query", ex);
+        fail("Got unexpected exception when executing query", ex);
       }
     } catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
         com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
             "Got expected exception when executing query: " + ex);
       } else {
-        Assert.fail("Got unexpected exception when executing query", ex);
+        fail("Got unexpected exception when executing query", ex);
       }
     }
   }
@@ -1748,7 +1743,7 @@ public class SecurityTestUtil extends DistributedTestCase {
         }
       } catch (Exception e) {
         if (!e.getClass().getSimpleName().endsWith(expectedResult)) {
-          Assert.fail("Expected " + expectedResult + " but found "
+          fail("Expected " + expectedResult + " but found "
               + e.getClass().getSimpleName() + " in doSimplePut()", e);
         } else {
           com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().fine(
@@ -1875,7 +1870,7 @@ public class SecurityTestUtil extends DistributedTestCase {
   private static LogWriter getLogger() {
 
     LogWriter logger = null;
-    DistributedSystem dsys = getSystemStatic();
+    DistributedSystem dsys = DistributedTestCase.getSystemStatic();
     if (dsys == null || !dsys.isConnected()) {
       while ((dsys = InternalDistributedSystem.getAnyInstance()) != null
           && !dsys.isConnected()) {
@@ -1899,7 +1894,7 @@ public class SecurityTestUtil extends DistributedTestCase {
       sys.disconnect();
       cache = null;
     }
-    disconnectFromDS();
+    DistributedTestCase.disconnectFromDS();
   }
 
   public static void closeCache(Boolean keepAlive) {
@@ -1913,7 +1908,7 @@ public class SecurityTestUtil extends DistributedTestCase {
       sys.disconnect();
       cache = null;
     }
-    disconnectFromDS();
+    DistributedTestCase.disconnectFromDS();
   }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/5a321ffd/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java
index a1a4414..270d0a7 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java
@@ -35,199 +35,139 @@ import org.junit.experimental.categories.Category;
  * @since 5.5
  */
 @Category(DistributedTest.class)
-public class ClientAuthorizationTwoDUnitTest extends
-    ClientAuthorizationTestBase {
+public class ClientAuthorizationTwoDUnitTest extends ClientAuthorizationTestBase {
 
   @Override
-  public final void postSetUp() throws Exception {
-    final Host host = Host.getHost(0);
-    server1 = host.getVM(0);
-    server2 = host.getVM(1);
-    client1 = host.getVM(2);
-    client2 = host.getVM(3);
-
-    server1.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    client1.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions ));
-    client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions ));
-    SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions);
-  }
-
-  @Test
-  public void testAllOpsWithFailover2() {
+  public final void postSetUpClientAuthorizationTestBase() throws Exception {
     IgnoredException.addIgnoredException("Read timed out");
     IgnoredException.addIgnoredException("Connection reset");
     IgnoredException.addIgnoredException("SocketTimeoutException");
     IgnoredException.addIgnoredException("ServerConnectivityException");
     IgnoredException.addIgnoredException("Socket Closed");
+  }
+
+  @Override
+  public final void preTearDownClientAuthorizationTestBase() throws Exception {
+    // close the clients first
+    client1.invoke(() -> SecurityTestUtil.closeCache());
+    client2.invoke(() -> SecurityTestUtil.closeCache());
+    SecurityTestUtil.closeCache();
+    // then close the servers
+    server1.invoke(() -> SecurityTestUtil.closeCache());
+    server2.invoke(() -> SecurityTestUtil.closeCache());
+  }
 
-    OperationWithAction[] allOps = {
-        // Register interest in all keys using list
-        new OperationWithAction(OperationCode.REGISTER_INTEREST, 3,
-            OpFlags.USE_LIST | OpFlags.CHECK_NOTAUTHZ, 4),
-        new OperationWithAction(OperationCode.REGISTER_INTEREST, 1,
-            OpFlags.USE_LIST, 4),
+  @Test
+  public void testAllOpsWithFailover2() {
+    runOpsWithFailover(allOps(), "testAllOpsWithFailover2");
+  }
+
+  private OperationWithAction[] allOps() {
+    return new OperationWithAction[] {
+        // Register interest in all KEYS using list
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, 3, OpFlags.USE_LIST | OpFlags.CHECK_NOTAUTHZ, 4),
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, 1, OpFlags.USE_LIST, 4),
         // UPDATE and test with GET
         new OperationWithAction(OperationCode.PUT, 2),
-        new OperationWithAction(OperationCode.GET, 1, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP, 4),
+        new OperationWithAction(OperationCode.GET, 1, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 4),
 
-        // Unregister interest in all keys using list
-        new OperationWithAction(OperationCode.UNREGISTER_INTEREST, 1,
-            OpFlags.USE_OLDCONN | OpFlags.USE_LIST, 4),
+        // Unregister interest in all KEYS using list
+        new OperationWithAction(OperationCode.UNREGISTER_INTEREST, 1, OpFlags.USE_OLDCONN | OpFlags.USE_LIST, 4),
         // UPDATE and test with GET for no updates
-        new OperationWithAction(OperationCode.PUT, 2, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, 4),
-        new OperationWithAction(OperationCode.GET, 1, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP, 4),
+        new OperationWithAction(OperationCode.PUT, 2, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, 4),
+        new OperationWithAction(OperationCode.GET, 1, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 4),
 
         OperationWithAction.OPBLOCK_END,
 
-        // Register interest in all keys using regular expression
-        new OperationWithAction(OperationCode.REGISTER_INTEREST, 3,
-            OpFlags.USE_REGEX | OpFlags.CHECK_NOTAUTHZ, 4),
-        new OperationWithAction(OperationCode.REGISTER_INTEREST, 2,
-            OpFlags.USE_REGEX, 4),
+        // Register interest in all KEYS using regular expression
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, 3, OpFlags.USE_REGEX | OpFlags.CHECK_NOTAUTHZ, 4),
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, 2, OpFlags.USE_REGEX, 4),
         // UPDATE and test with GET
         new OperationWithAction(OperationCode.PUT),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP, 4),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 4),
 
-        // Unregister interest in all keys using regular expression
-        new OperationWithAction(OperationCode.UNREGISTER_INTEREST, 2,
-            OpFlags.USE_OLDCONN | OpFlags.USE_REGEX, 4),
+        // Unregister interest in all KEYS using regular expression
+        new OperationWithAction(OperationCode.UNREGISTER_INTEREST, 2, OpFlags.USE_OLDCONN | OpFlags.USE_REGEX, 4),
         // UPDATE and test with GET for no updates
-        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, 4),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP, 4),
+        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, 4),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 4),
 
         OperationWithAction.OPBLOCK_END,
 
-        // Register interest in all keys using ALL_KEYS
-        new OperationWithAction(OperationCode.REGISTER_INTEREST, 3,
-            OpFlags.USE_ALL_KEYS | OpFlags.CHECK_NOTAUTHZ, 4),
-        new OperationWithAction(OperationCode.REGISTER_INTEREST, 2,
-            OpFlags.USE_ALL_KEYS, 4),
+        // Register interest in all KEYS using ALL_KEYS
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, 3, OpFlags.USE_ALL_KEYS | OpFlags.CHECK_NOTAUTHZ, 4),
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, 2, OpFlags.USE_ALL_KEYS, 4),
         // UPDATE and test with GET
         new OperationWithAction(OperationCode.PUT),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP, 4),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 4),
 
-        // Unregister interest in all keys using ALL_KEYS
-        new OperationWithAction(OperationCode.UNREGISTER_INTEREST, 2,
-            OpFlags.USE_OLDCONN | OpFlags.USE_ALL_KEYS, 4),
+        // Unregister interest in all KEYS using ALL_KEYS
+        new OperationWithAction(OperationCode.UNREGISTER_INTEREST, 2, OpFlags.USE_OLDCONN | OpFlags.USE_ALL_KEYS, 4),
         // UPDATE and test with GET for no updates
-        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, 4),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP, 4),
+        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, 4),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 4),
 
         OperationWithAction.OPBLOCK_END,
 
         // Register CQ
         new OperationWithAction(OperationCode.PUT, 2, OpFlags.USE_NEWVAL, 4),
-        new OperationWithAction(OperationCode.EXECUTE_CQ, 3,
-            OpFlags.CHECK_NOTAUTHZ, 4),
-        new OperationWithAction(OperationCode.EXECUTE_CQ, 1,
-            OpFlags.USE_NEWVAL, 4),
+        new OperationWithAction(OperationCode.EXECUTE_CQ, 3, OpFlags.CHECK_NOTAUTHZ, 4),
+        new OperationWithAction(OperationCode.EXECUTE_CQ, 1, OpFlags.USE_NEWVAL, 4),
         // UPDATE and test with GET
         new OperationWithAction(OperationCode.PUT, 2, OpFlags.USE_OLDCONN, 4),
-        new OperationWithAction(OperationCode.EXECUTE_CQ, 1,
-            OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 4),
+        new OperationWithAction(OperationCode.EXECUTE_CQ, 1, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 4),
 
         // Stop CQ
-        new OperationWithAction(OperationCode.STOP_CQ, 3, OpFlags.USE_OLDCONN
-            | OpFlags.CHECK_EXCEPTION, 4),
-        new OperationWithAction(OperationCode.STOP_CQ, 1, OpFlags.USE_OLDCONN,
-            4),
+        new OperationWithAction(OperationCode.STOP_CQ, 3, OpFlags.USE_OLDCONN | OpFlags.CHECK_EXCEPTION, 4),
+        new OperationWithAction(OperationCode.STOP_CQ, 1, OpFlags.USE_OLDCONN, 4),
         // UPDATE and test with GET for no updates
-        new OperationWithAction(OperationCode.PUT, 2, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, 4),
-        new OperationWithAction(OperationCode.EXECUTE_CQ, 1,
-            OpFlags.USE_OLDCONN | OpFlags.CHECK_FAIL | OpFlags.LOCAL_OP, 4),
+        new OperationWithAction(OperationCode.PUT, 2, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, 4),
+        new OperationWithAction(OperationCode.EXECUTE_CQ, 1, OpFlags.USE_OLDCONN | OpFlags.CHECK_FAIL | OpFlags.LOCAL_OP, 4),
 
         // Restart the CQ
-        new OperationWithAction(OperationCode.EXECUTE_CQ, 3, OpFlags.USE_NEWVAL
-            | OpFlags.CHECK_NOTAUTHZ, 4),
-        new OperationWithAction(OperationCode.EXECUTE_CQ, 1,
-            OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, 4),
+        new OperationWithAction(OperationCode.EXECUTE_CQ, 3, OpFlags.USE_NEWVAL | OpFlags.CHECK_NOTAUTHZ, 4),
+        new OperationWithAction(OperationCode.EXECUTE_CQ, 1, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, 4),
         // UPDATE and test with GET
         new OperationWithAction(OperationCode.PUT, 2, OpFlags.USE_OLDCONN, 4),
-        new OperationWithAction(OperationCode.EXECUTE_CQ, 1,
-            OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 4),
+        new OperationWithAction(OperationCode.EXECUTE_CQ, 1, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 4),
 
         // Close CQ
-        new OperationWithAction(OperationCode.CLOSE_CQ, 3, OpFlags.USE_OLDCONN,
-            4),
-        new OperationWithAction(OperationCode.CLOSE_CQ, 1, OpFlags.USE_OLDCONN,
-            4),
+        new OperationWithAction(OperationCode.CLOSE_CQ, 3, OpFlags.USE_OLDCONN, 4),
+        new OperationWithAction(OperationCode.CLOSE_CQ, 1, OpFlags.USE_OLDCONN, 4),
         // UPDATE and test with GET for no updates
-        new OperationWithAction(OperationCode.PUT, 2, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, 4),
-        new OperationWithAction(OperationCode.EXECUTE_CQ, 1,
-            OpFlags.USE_OLDCONN | OpFlags.CHECK_FAIL | OpFlags.LOCAL_OP, 4),
+        new OperationWithAction(OperationCode.PUT, 2, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, 4),
+        new OperationWithAction(OperationCode.EXECUTE_CQ, 1, OpFlags.USE_OLDCONN | OpFlags.CHECK_FAIL | OpFlags.LOCAL_OP, 4),
 
         OperationWithAction.OPBLOCK_END,
 
         // Do REGION_CLEAR and check with GET
-        new OperationWithAction(OperationCode.REGION_CLEAR, 3,
-            OpFlags.CHECK_NOTAUTHZ, 1),
+        new OperationWithAction(OperationCode.REGION_CLEAR, 3, OpFlags.CHECK_NOTAUTHZ, 1),
         new OperationWithAction(OperationCode.REGION_CLEAR, 1, OpFlags.NONE, 1),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.CHECK_NOKEY
-            | OpFlags.CHECK_FAIL, 8),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.CHECK_NOKEY | OpFlags.CHECK_FAIL, 8),
         // Repopulate the region
         new OperationWithAction(OperationCode.PUT),
 
         OperationWithAction.OPBLOCK_END,
 
         // Do REGION_CREATE and check with CREATE/GET
-        new OperationWithAction(OperationCode.REGION_CREATE, 3,
-            OpFlags.ENABLE_DRF | OpFlags.CHECK_NOTAUTHZ, 1),
-        new OperationWithAction(OperationCode.REGION_CREATE, 1,
-            OpFlags.ENABLE_DRF, 1),
-        new OperationWithAction(OperationCode.PUT, 3, OpFlags.USE_OLDCONN
-            | OpFlags.USE_SUBREGION | OpFlags.CHECK_NOTAUTHZ, 4),
-        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN
-            | OpFlags.USE_SUBREGION, 4),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.CHECK_NOKEY
-            | OpFlags.USE_SUBREGION, 4),
+        new OperationWithAction(OperationCode.REGION_CREATE, 3, OpFlags.ENABLE_DRF | OpFlags.CHECK_NOTAUTHZ, 1),
+        new OperationWithAction(OperationCode.REGION_CREATE, 1, OpFlags.ENABLE_DRF, 1),
+        new OperationWithAction(OperationCode.PUT, 3, OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION | OpFlags.CHECK_NOTAUTHZ, 4),
+        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION, 4),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.CHECK_NOKEY | OpFlags.USE_SUBREGION, 4),
 
         // Do REGION_DESTROY of the sub-region and check with GET
-        new OperationWithAction(OperationCode.REGION_DESTROY, 3,
-            OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION
-                | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOTAUTHZ, 1),
-        new OperationWithAction(OperationCode.REGION_DESTROY, 1,
-            OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION
-                | OpFlags.NO_CREATE_SUBREGION, 1),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.USE_SUBREGION | OpFlags.CHECK_EXCEPTION, 4),
+        new OperationWithAction(OperationCode.REGION_DESTROY, 3, OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOTAUTHZ, 1),
+        new OperationWithAction(OperationCode.REGION_DESTROY, 1, OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION | OpFlags.NO_CREATE_SUBREGION, 1),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION | OpFlags.CHECK_EXCEPTION, 4),
 
         // Do REGION_DESTROY of the region and check with GET
-        new OperationWithAction(OperationCode.REGION_DESTROY, 3,
-            OpFlags.CHECK_NOTAUTHZ, 1),
-        new OperationWithAction(OperationCode.REGION_DESTROY, 1, OpFlags.NONE,
-            1),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.CHECK_NOKEY
-            | OpFlags.CHECK_EXCEPTION, 4),
+        new OperationWithAction(OperationCode.REGION_DESTROY, 3, OpFlags.CHECK_NOTAUTHZ, 1),
+        new OperationWithAction(OperationCode.REGION_DESTROY, 1, OpFlags.NONE, 1),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.CHECK_NOKEY | OpFlags.CHECK_EXCEPTION, 4),
 
         // Skip failover for region destroy since it shall fail
         // without restarting the server
         OperationWithAction.OPBLOCK_NO_FAILOVER };
-
-    runOpsWithFailover(allOps, "testAllOpsWithFailover2");
-  }
-
-  // End Region: Tests
-
-  @Override
-  public final void preTearDown() throws Exception {
-    // close the clients first
-    client1.invoke(() -> SecurityTestUtil.closeCache());
-    client2.invoke(() -> SecurityTestUtil.closeCache());
-    SecurityTestUtil.closeCache();
-    // then close the servers
-    server1.invoke(() -> SecurityTestUtil.closeCache());
-    server2.invoke(() -> SecurityTestUtil.closeCache());
   }
 }



[6/8] incubator-geode git commit: Tests are passing

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
index 4ffac74..708140c 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientAuthorizationDUnitTest.java
@@ -18,20 +18,18 @@
  */
 package com.gemstone.gemfire.security;
 
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 
 import java.util.Properties;
 
 import com.gemstone.gemfire.DeltaTestImpl;
 import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.client.NoAvailableServersException;
-import com.gemstone.gemfire.cache.client.ServerConnectivityException;
 import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
 import com.gemstone.gemfire.internal.cache.PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1;
 import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
 import com.gemstone.gemfire.security.generator.CredentialGenerator;
-import com.gemstone.gemfire.test.dunit.Assert;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -40,8 +38,7 @@ import org.junit.experimental.categories.Category;
  * @since 6.1
  */
 @Category(DistributedTest.class)
-public class DeltaClientAuthorizationDUnitTest extends
-    ClientAuthorizationTestBase {
+public final class DeltaClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
 
   private DeltaTestImpl[] deltas = new DeltaTestImpl[8];
 
@@ -52,236 +49,98 @@ public class DeltaClientAuthorizationDUnitTest extends
 
   @Override
   public final void preTearDownClientAuthorizationTestBase() throws Exception {
-    // close the clients first
-    client1.invoke(() -> SecurityTestUtil.closeCache());
-    client2.invoke(() -> SecurityTestUtil.closeCache());
-    SecurityTestUtil.closeCache();
-    // then close the servers
-    server1.invoke(() -> SecurityTestUtil.closeCache());
-    server2.invoke(() -> SecurityTestUtil.closeCache());
+    closeCache();
   }
 
   @Test
   public void testAllowPutsGets() throws Exception {
-      AuthzCredentialGenerator gen = this.getXmlAuthzGenerator();
-      CredentialGenerator cGen = gen.getCredentialGenerator();
-      Properties extraAuthProps = cGen.getSystemProperties();
-      Properties javaProps = cGen.getJavaProperties();
-      Properties extraAuthzProps = gen.getSystemProperties();
-      String authenticator = cGen.getAuthenticator();
-      String authInit = cGen.getAuthInit();
-      String accessor = gen.getAuthorizationCallback();
-
-      LogWriterUtils.getLogWriter().info("testAllowPutsGets: Using authinit: " + authInit);
-      LogWriterUtils.getLogWriter().info(
-          "testAllowPutsGets: Using authenticator: " + authenticator);
-      LogWriterUtils.getLogWriter().info("testAllowPutsGets: Using accessor: " + accessor);
-
-      // Start servers with all required properties
-      Properties serverProps = buildProperties(authenticator, accessor, false,
-          extraAuthProps, extraAuthzProps);
-      Integer port1 = createServer1(javaProps, serverProps);
-      Integer port2 = createServer2(javaProps, serverProps);
-
-      // Start client1 with valid CREATE credentials
-      Properties createCredentials = gen.getAllowedCredentials(
-          new OperationCode[] { OperationCode.PUT },
-          new String[] { regionName }, 1);
-      javaProps = cGen.getJavaProperties();
-      LogWriterUtils.getLogWriter().info(
-          "testAllowPutsGets: For first client credentials: "
-              + createCredentials);
-      createClient1(javaProps, authInit, port1, port2, createCredentials);
-
-      // Start client2 with valid GET credentials
-      Properties getCredentials = gen.getAllowedCredentials(
-          new OperationCode[] { OperationCode.GET },
-          new String[] { regionName }, 2);
-      javaProps = cGen.getJavaProperties();
-      LogWriterUtils.getLogWriter()
-          .info(
-              "testAllowPutsGets: For second client credentials: "
-                  + getCredentials);
-      createClient2(javaProps, authInit, port1, port2, getCredentials);
-
-      // Perform some put operations from client1
-      client1.invoke(() -> doPuts(
-          new Integer(2), new Integer(SecurityTestUtil.NO_EXCEPTION), Boolean.FALSE ));
-      Thread.sleep(5000);
-      assertTrue("Delta feature NOT used", (Boolean)client1.invoke(() -> DeltaTestImpl.toDeltaFeatureUsed()));
-
-      // Verify that the gets succeed
-      client2.invoke(() -> doGets(
-          new Integer(2), new Integer(SecurityTestUtil.NO_EXCEPTION), Boolean.FALSE  ));
-  }
+    AuthzCredentialGenerator gen = this.getXmlAuthzGenerator();
+    CredentialGenerator cGen = gen.getCredentialGenerator();
+
+    Properties extraAuthProps = cGen.getSystemProperties();
+    Properties javaProps = cGen.getJavaProperties();
+    Properties extraAuthzProps = gen.getSystemProperties();
+
+    String authenticator = cGen.getAuthenticator();
+    String authInit = cGen.getAuthInit();
+    String accessor = gen.getAuthorizationCallback();
+
+    getLogWriter().info("testAllowPutsGets: Using authinit: " + authInit);
+    getLogWriter().info("testAllowPutsGets: Using authenticator: " + authenticator);
+    getLogWriter().info("testAllowPutsGets: Using accessor: " + accessor);
+
+    // Start servers with all required properties
+    Properties serverProps = buildProperties(authenticator, accessor, false, extraAuthProps, extraAuthzProps);
+
+    Integer port1 = createServer1(javaProps, serverProps);
+    Integer port2 = createServer2(javaProps, serverProps);
+
+    // Start client1 with valid CREATE credentials
+    Properties createCredentials = gen.getAllowedCredentials(new OperationCode[] { OperationCode.PUT }, new String[] { REGION_NAME }, 1);
+    javaProps = cGen.getJavaProperties();
+
+    getLogWriter().info("testAllowPutsGets: For first client credentials: " + createCredentials);
+    createClient1(javaProps, authInit, port1, port2, createCredentials);
 
-  private void createClient2(Properties javaProps, String authInit,
-      Integer port1, Integer port2, Properties getCredentials) {
-    client2.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, getCredentials, javaProps, port1, port2,
-            null, new Integer(SecurityTestUtil.NO_EXCEPTION) ));
+    // Start client2 with valid GET credentials
+    Properties getCredentials = gen.getAllowedCredentials(new OperationCode[] { OperationCode.GET }, new String[] { REGION_NAME }, 2);
+    javaProps = cGen.getJavaProperties();
+    getLogWriter().info("testAllowPutsGets: For second client credentials: " + getCredentials);
+
+    createClient2(javaProps, authInit, port1, port2, getCredentials);
+
+    // Perform some put operations from client1
+    client1.invoke(() -> doPuts(2, NO_EXCEPTION));
+
+    Thread.sleep(5000);
+    assertTrue("Delta feature NOT used", client1.invoke(() -> DeltaTestImpl.toDeltaFeatureUsed()));
+
+    // Verify that the gets succeed
+    client2.invoke(() -> doGets(2, NO_EXCEPTION));
   }
 
-  private void createClient1(Properties javaProps, String authInit,
-      Integer port1, Integer port2, Properties createCredentials) {
-    client1.invoke(() -> ClientAuthenticationDUnitTest.createCacheClient( authInit, createCredentials, javaProps, port1, port2,
-            null, new Integer(SecurityTestUtil.NO_EXCEPTION) ));
+  private void createClient2(Properties javaProps, String authInit, int port1, int port2, Properties getCredentials) {
+    client2.invoke(() -> ClientAuthenticationUtils.createCacheClient(authInit, getCredentials, javaProps, port1, port2, 0, NO_EXCEPTION));
   }
 
-  private Integer createServer2(Properties javaProps,
-      Properties serverProps) {
-    Integer port2 = ((Integer)server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
-            SecurityTestUtil.getLocatorPort(), serverProps, javaProps )));
-    return port2;
+  private void createClient1(Properties javaProps, String authInit, int port1, int port2, Properties createCredentials) {
+    client1.invoke(() -> ClientAuthenticationUtils.createCacheClient(authInit, createCredentials, javaProps, port1, port2, 0, NO_EXCEPTION));
   }
 
-  private Integer createServer1(Properties javaProps,
-      Properties serverProps) {
-    Integer port1 = ((Integer)server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
-            SecurityTestUtil.getLocatorPort(), serverProps, javaProps )));
-    return port1;
+  private Integer createServer2(Properties javaProps, Properties serverProps) {
+    return server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(getLocatorPort(), serverProps, javaProps));
   }
 
-  private void doPuts(Integer num, Integer expectedResult,
-      boolean newVals) {
+  private Integer createServer1(Properties javaProps, Properties serverProps) {
+    return server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(getLocatorPort(), serverProps, javaProps));
+  }
 
-    assertTrue(num.intValue() <= SecurityTestUtil.KEYS.length);
-    Region region = null;
-    try {
-      region = SecurityTestUtil.getCache().getRegion(regionName);
-      assertNotNull(region);
+  private void doPuts(int num, int expectedResult) {
+    assertTrue(num <= KEYS.length);
+    Region region = getCache().getRegion(REGION_NAME);
+    assertNotNull(region);
+    for (int index = 0; index < num; ++index) {
+      region.put(KEYS[index], deltas[0]);
     }
-    catch (Exception ex) {
-      if (expectedResult.intValue() == SecurityTestUtil.OTHER_EXCEPTION) {
-        LogWriterUtils.getLogWriter().info("Got expected exception when doing puts: " + ex);
-      }
-      else {
-        Assert.fail("Got unexpected exception when doing puts", ex);
-      }
-    }
-    for (int index = 0; index < num.intValue(); ++index) {
-      region.put(SecurityTestUtil.KEYS[index], deltas[0]);
-    }
-    for (int index = 0; index < num.intValue(); ++index) {
-      try {
-        region.put(SecurityTestUtil.KEYS[index], deltas[index]);
-        if (expectedResult.intValue() != SecurityTestUtil.NO_EXCEPTION) {
-          fail("Expected a NotAuthorizedException while doing puts");
-        }
-      }
-      catch (NoAvailableServersException ex) {
-        if (expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) {
-          LogWriterUtils.getLogWriter().info(
-              "Got expected NoAvailableServers when doing puts: "
-                  + ex.getCause());
-          continue;
-        }
-        else {
-          Assert.fail("Got unexpected exception when doing puts", ex);
-        }
-      }
-      catch (ServerConnectivityException ex) {
-        if ((expectedResult.intValue() == SecurityTestUtil.NOTAUTHZ_EXCEPTION)
-            && (ex.getCause() instanceof NotAuthorizedException)) {
-          LogWriterUtils.getLogWriter().info(
-              "Got expected NotAuthorizedException when doing puts: "
-                  + ex.getCause());
-          continue;
-        }
-        if ((expectedResult.intValue() == SecurityTestUtil.AUTHREQ_EXCEPTION)
-            && (ex.getCause() instanceof AuthenticationRequiredException)) {
-          LogWriterUtils.getLogWriter().info(
-              "Got expected AuthenticationRequiredException when doing puts: "
-                  + ex.getCause());
-          continue;
-        }
-        if ((expectedResult.intValue() == SecurityTestUtil.AUTHFAIL_EXCEPTION)
-            && (ex.getCause() instanceof AuthenticationFailedException)) {
-          LogWriterUtils.getLogWriter().info(
-              "Got expected AuthenticationFailedException when doing puts: "
-                  + ex.getCause());
-          continue;
-        }
-        else if (expectedResult.intValue() == SecurityTestUtil.OTHER_EXCEPTION) {
-          LogWriterUtils.getLogWriter().info("Got expected exception when doing puts: " + ex);
-        }
-        else {
-          Assert.fail("Got unexpected exception when doing puts", ex);
-        }
-      }
-      catch (Exception ex) {
-        if (expectedResult.intValue() == SecurityTestUtil.OTHER_EXCEPTION) {
-          LogWriterUtils.getLogWriter().info("Got expected exception when doing puts: " + ex);
-        }
-        else {
-          Assert.fail("Got unexpected exception when doing puts", ex);
-        }
+    for (int index = 0; index < num; ++index) {
+      region.put(KEYS[index], deltas[index]);
+      if (expectedResult != NO_EXCEPTION) {
+        fail("Expected a NotAuthorizedException while doing puts");
       }
     }
   }
 
-  private void doGets(Integer num, Integer expectedResult,
-      boolean newVals) {
+  private void doGets(int num, int expectedResult) {
+    assertTrue(num <= KEYS.length);
 
-    assertTrue(num.intValue() <= SecurityTestUtil.KEYS.length);
-    Region region = null;
-    try {
-      region = SecurityTestUtil.getCache().getRegion(regionName);
-      assertNotNull(region);
-    }
-    catch (Exception ex) {
-      if (expectedResult.intValue() == SecurityTestUtil.OTHER_EXCEPTION) {
-        LogWriterUtils.getLogWriter().info("Got expected exception when doing gets: " + ex);
-      }
-      else {
-        Assert.fail("Got unexpected exception when doing gets", ex);
-      }
-    }
-    for (int index = 0; index < num.intValue(); ++index) {
-      Object value = null;
-      try {
-        try {
-          region.localInvalidate(SecurityTestUtil.KEYS[index]);
-        }
-        catch (Exception ex) {
-        }
-        value = region.get(SecurityTestUtil.KEYS[index]);
-        if (expectedResult.intValue() != SecurityTestUtil.NO_EXCEPTION) {
-          fail("Expected a NotAuthorizedException while doing gets");
-        }
-      }
-      catch(NoAvailableServersException ex) {
-        if(expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) {
-          LogWriterUtils.getLogWriter().info(
-              "Got expected NoAvailableServers when doing puts: "
-              + ex.getCause());
-          continue;
-        }
-        else {
-          Assert.fail("Got unexpected exception when doing puts", ex);
-        }
-      }
-      catch (ServerConnectivityException ex) {
-        if ((expectedResult.intValue() == SecurityTestUtil.NOTAUTHZ_EXCEPTION)
-            && (ex.getCause() instanceof NotAuthorizedException)) {
-          LogWriterUtils.getLogWriter().info(
-              "Got expected NotAuthorizedException when doing gets: "
-                  + ex.getCause());
-          continue;
-        }
-        else if (expectedResult.intValue() == SecurityTestUtil.OTHER_EXCEPTION) {
-          LogWriterUtils.getLogWriter().info("Got expected exception when doing gets: " + ex);
-        }
-        else {
-          Assert.fail("Got unexpected exception when doing gets", ex);
-        }
-      }
-      catch (Exception ex) {
-        if (expectedResult.intValue() == SecurityTestUtil.OTHER_EXCEPTION) {
-          LogWriterUtils.getLogWriter().info("Got expected exception when doing gets: " + ex);
-        }
-        else {
-          Assert.fail("Got unexpected exception when doing gets", ex);
-        }
+    Region region = SecurityTestUtil.getCache().getRegion(REGION_NAME);
+    assertNotNull(region);
+
+    for (int index = 0; index < num; ++index) {
+      region.localInvalidate(KEYS[index]);
+      Object value = region.get(KEYS[index]);
+      if (expectedResult != NO_EXCEPTION) {
+        fail("Expected a NotAuthorizedException while doing gets");
       }
       assertNotNull(value);
       assertEquals(deltas[index], value);
@@ -290,8 +149,7 @@ public class DeltaClientAuthorizationDUnitTest extends
 
   private final void setUpDeltas() {
     for (int i = 0; i < 8; i++) {
-      deltas[i] = new DeltaTestImpl(0, "0", new Double(0), new byte[0],
-              new TestObject1("0", 0));
+      deltas[i] = new DeltaTestImpl(0, "0", new Double(0), new byte[0], new TestObject1("0", 0));
     }
     deltas[1].setIntVar(5);
     deltas[2].setIntVar(5);
@@ -334,6 +192,5 @@ public class DeltaClientAuthorizationDUnitTest extends
 
     deltas[7].resetDeltaStatus();
     deltas[7].setStr("delta string");
-
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
index 56e5e2d..b838957 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/DeltaClientPostAuthorizationDUnitTest.java
@@ -18,7 +18,11 @@
  */
 package com.gemstone.gemfire.security;
 
+import static com.gemstone.gemfire.internal.AvailablePort.*;
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.IgnoredException.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -34,15 +38,10 @@ import com.gemstone.gemfire.cache.client.ServerConnectivityException;
 import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
 import com.gemstone.gemfire.cache.query.CqException;
 import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
-import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.cache.PartitionedRegionLocalMaxMemoryDUnitTest;
 import com.gemstone.gemfire.internal.util.Callable;
 import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
 import com.gemstone.gemfire.security.generator.CredentialGenerator;
-import com.gemstone.gemfire.test.dunit.Assert;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.IgnoredException;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
 import com.gemstone.gemfire.test.dunit.VM;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import org.junit.Test;
@@ -52,207 +51,95 @@ import org.junit.experimental.categories.Category;
  * @since 6.1
  */
 @Category(DistributedTest.class)
-public class DeltaClientPostAuthorizationDUnitTest extends
-    ClientAuthorizationTestBase {
+public class DeltaClientPostAuthorizationDUnitTest extends ClientAuthorizationTestBase {
 
   private static final int PAUSE = 5 * 1000; // TODO: replace with Awaitility
 
   private DeltaTestImpl[] deltas = new DeltaTestImpl[8];
 
-  private final void setUpDeltas() {
-    for (int i = 0; i < 8; i++) {
-      deltas[i] = new DeltaTestImpl(0, "0", new Double(0), new byte[0],
-              new PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1("0", 0));
-    }
-    deltas[1].setIntVar(5);
-    deltas[2].setIntVar(5);
-    deltas[3].setIntVar(5);
-    deltas[4].setIntVar(5);
-    deltas[5].setIntVar(5);
-    deltas[6].setIntVar(5);
-    deltas[7].setIntVar(5);
-
-    deltas[2].resetDeltaStatus();
-    deltas[2].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
-    deltas[3].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
-    deltas[4].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
-    deltas[5].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
-    //deltas[6].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
-    //deltas[7].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
-
-    deltas[3].resetDeltaStatus();
-    deltas[3].setDoubleVar(new Double(5));
-    deltas[4].setDoubleVar(new Double(5));
-    deltas[5].setDoubleVar(new Double(5));
-    deltas[6].setDoubleVar(new Double(5));
-    deltas[7].setDoubleVar(new Double(5));
-
-    deltas[4].resetDeltaStatus();
-    deltas[4].setStr("str changed");
-    deltas[5].setStr("str changed");
-    deltas[6].setStr("str changed");
-    //deltas[7].setStr("str changed");
-
-    deltas[5].resetDeltaStatus();
-    deltas[5].setIntVar(100);
-    deltas[5].setTestObj(new PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1("CHANGED", 100));
-    deltas[6].setTestObj(new PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1("CHANGED", 100));
-    deltas[7].setTestObj(new PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1("CHANGED", 100));
-
-    deltas[6].resetDeltaStatus();
-    deltas[6].setByteArr(new byte[] { 1, 2, 3 });
-    deltas[7].setByteArr(new byte[] { 1, 2, 3 });
-
-    deltas[7].resetDeltaStatus();
-    deltas[7].setStr("delta string");
-  }
-
   @Override
-  public final void preSetUp() throws Exception {
+  public final void preSetUpClientAuthorizationTestBase() throws Exception {
     setUpDeltas();
+    addIgnoredException("Unexpected IOException");
+    addIgnoredException("SocketException");
   }
 
   @Override
-  public final void postSetUp() throws Exception {
-    final Host host = Host.getHost(0);
-    server1 = host.getVM(0);
-    server2 = host.getVM(1);
-    client1 = host.getVM(2);
-    client2 = host.getVM(3);
-
-    server1.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    server2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( serverExpectedExceptions ));
-    client2.invoke(() -> SecurityTestUtil.registerExpectedExceptions( clientExpectedExceptions ));
-    SecurityTestUtil.registerExpectedExceptions(clientExpectedExceptions);
-  }
-
-  @Override
-  public final void preTearDown() throws Exception {
-    // close the clients first
-    client1.invoke(() -> SecurityTestUtil.closeCache());
-    client2.invoke(() -> SecurityTestUtil.closeCache());
+  public final void preTearDownClientAuthorizationTestBase() throws Exception {
     SecurityTestUtil.closeCache();
-    // then close the servers
-    server1.invoke(() -> SecurityTestUtil.closeCache());
-    server2.invoke(() -> SecurityTestUtil.closeCache());
   }
 
   @Test
   public void testPutPostOpNotifications() throws Exception {
-    IgnoredException.addIgnoredException("Unexpected IOException");
-    IgnoredException.addIgnoredException("SocketException");
-
-    OperationWithAction[] allOps = {
-        // Test CREATE and verify with a GET
-        new OperationWithAction(OperationCode.REGISTER_INTEREST,
-            OperationCode.GET, 2, OpFlags.USE_REGEX
-                | OpFlags.REGISTER_POLICY_NONE, 8),
-        new OperationWithAction(OperationCode.REGISTER_INTEREST,
-            OperationCode.GET, 3, OpFlags.USE_REGEX
-                | OpFlags.REGISTER_POLICY_NONE | OpFlags.USE_NOTAUTHZ, 8),
-        new OperationWithAction(OperationCode.PUT),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP, 4),
-        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 4),
-
-        // OPBLOCK_END indicates end of an operation block that needs to
-        // be executed on each server when doing failover
-        OperationWithAction.OPBLOCK_END,
-
-        // Test UPDATE and verify with a GET
-        new OperationWithAction(OperationCode.REGISTER_INTEREST,
-            OperationCode.GET, 2, OpFlags.USE_REGEX
-                | OpFlags.REGISTER_POLICY_NONE, 8),
-        new OperationWithAction(OperationCode.REGISTER_INTEREST,
-            OperationCode.GET, 3, OpFlags.USE_REGEX
-                | OpFlags.REGISTER_POLICY_NONE | OpFlags.USE_NOTAUTHZ, 8),
-        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN
-            | OpFlags.USE_NEWVAL, 4),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP | OpFlags.USE_NEWVAL, 4),
-        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-            | OpFlags.LOCAL_OP | OpFlags.USE_NEWVAL | OpFlags.CHECK_FAIL, 4),
-
-        OperationWithAction.OPBLOCK_END };
-
-      AuthzCredentialGenerator gen = this.getXmlAuthzGenerator();
-      CredentialGenerator cGen = gen.getCredentialGenerator();
-      Properties extraAuthProps = cGen.getSystemProperties();
-      Properties javaProps = cGen.getJavaProperties();
-      Properties extraAuthzProps = gen.getSystemProperties();
-      String authenticator = cGen.getAuthenticator();
-      String authInit = cGen.getAuthInit();
-      String accessor = gen.getAuthorizationCallback();
-      TestAuthzCredentialGenerator tgen = new TestAuthzCredentialGenerator(gen);
-
-      LogWriterUtils.getLogWriter().info(
-          "testAllOpsNotifications: Using authinit: " + authInit);
-      LogWriterUtils.getLogWriter().info(
-          "testAllOpsNotifications: Using authenticator: " + authenticator);
-      LogWriterUtils.getLogWriter().info(
-          "testAllOpsNotifications: Using accessor: " + accessor);
-
-      // Start servers with all required properties
-      Properties serverProps = buildProperties(authenticator, accessor, true,
-          extraAuthProps, extraAuthzProps);
-      // Get ports for the servers
-      Integer port1 = new Integer(AvailablePort
-          .getRandomAvailablePort(AvailablePort.SOCKET));
-      Integer port2 = new Integer(AvailablePort
-          .getRandomAvailablePort(AvailablePort.SOCKET));
-
-      // Perform all the ops on the clients
-      List opBlock = new ArrayList();
-      Random rnd = new Random();
-      for (int opNum = 0; opNum < allOps.length; ++opNum) {
-        // Start client with valid credentials as specified in
-        // OperationWithAction
-        OperationWithAction currentOp = allOps[opNum];
-        if (currentOp.equals(OperationWithAction.OPBLOCK_END)
-            || currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
-          // End of current operation block; execute all the operations
-          // on the servers with failover
-          if (opBlock.size() > 0) {
-            // Start the first server and execute the operation block
-            server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
-                    SecurityTestUtil.getLocatorPort(), port1, serverProps,
-                    javaProps ));
-            server2.invoke(() -> SecurityTestUtil.closeCache());
-            executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps,
-                extraAuthzProps, tgen, rnd);
-            if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
-              // Failover to the second server and run the block again
-              server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(
-                      SecurityTestUtil.getLocatorPort(), port2, serverProps,
-                      javaProps ));
-              server1.invoke(() -> SecurityTestUtil.closeCache());
-              executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps,
-                  extraAuthzProps, tgen, rnd);
-            }
-            opBlock.clear();
+    OperationWithAction[] allOps = allOps();
+
+    AuthzCredentialGenerator gen = this.getXmlAuthzGenerator();
+    CredentialGenerator cGen = gen.getCredentialGenerator();
+    Properties extraAuthProps = cGen.getSystemProperties();
+    Properties javaProps = cGen.getJavaProperties();
+    Properties extraAuthzProps = gen.getSystemProperties();
+    String authenticator = cGen.getAuthenticator();
+    String authInit = cGen.getAuthInit();
+    String accessor = gen.getAuthorizationCallback();
+    TestAuthzCredentialGenerator tgen = new TestAuthzCredentialGenerator(gen);
+
+    getLogWriter().info("testAllOpsNotifications: Using authinit: " + authInit);
+    getLogWriter().info("testAllOpsNotifications: Using authenticator: " + authenticator);
+    getLogWriter().info("testAllOpsNotifications: Using accessor: " + accessor);
+
+    // Start servers with all required properties
+    Properties serverProps = buildProperties(authenticator, accessor, true, extraAuthProps, extraAuthzProps);
+
+    // Get ports for the servers
+    int port1 = getRandomAvailablePort(SOCKET);
+    int port2 = getRandomAvailablePort(SOCKET);
+
+    // Perform all the ops on the clients
+    List opBlock = new ArrayList();
+    Random rnd = new Random();
+
+    for (int opNum = 0; opNum < allOps.length; ++opNum) {
+      // Start client with valid credentials as specified in OperationWithAction
+      OperationWithAction currentOp = allOps[opNum];
+      if (currentOp.equals(OperationWithAction.OPBLOCK_END) || currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
+
+        // End of current operation block; execute all the operations on the servers with failover
+        if (opBlock.size() > 0) {
+          // Start the first server and execute the operation block
+          server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port1, serverProps, javaProps ));
+          server2.invoke(() -> SecurityTestUtil.closeCache());
+
+          executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
+
+          if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
+            // Failover to the second server and run the block again
+            server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port2, serverProps, javaProps ));
+            server1.invoke(() -> SecurityTestUtil.closeCache());
+
+            executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
           }
+
+          opBlock.clear();
         }
-        else {
-          currentOp.setOpNum(opNum);
-          opBlock.add(currentOp);
-        }
+
+      } else {
+        currentOp.setOpNum(opNum);
+        opBlock.add(currentOp);
       }
+    }
   }
 
-  protected void executeOpBlock(List opBlock, Integer port1, Integer port2,
-      String authInit, Properties extraAuthProps, Properties extraAuthzProps,
-      TestCredentialGenerator gen, Random rnd) {
-    Iterator opIter = opBlock.iterator();
-    while (opIter.hasNext()) {
-      // Start client with valid credentials as specified in
-      // OperationWithAction
+  @Override
+  protected final void executeOpBlock(List opBlock, Integer port1, Integer port2, String authInit, Properties extraAuthProps, Properties extraAuthzProps, TestCredentialGenerator gen, Random rnd) throws InterruptedException {
+    for (Iterator opIter = opBlock.iterator(); opIter.hasNext();) {
+      // Start client with valid credentials as specified in OperationWithAction
       OperationWithAction currentOp = (OperationWithAction)opIter.next();
       OperationCode opCode = currentOp.getOperationCode();
       int opFlags = currentOp.getFlags();
       int clientNum = currentOp.getClientNum();
       VM clientVM = null;
       boolean useThisVM = false;
+
       switch (clientNum) {
         case 1:
           clientVM = client1;
@@ -267,9 +154,9 @@ public class DeltaClientPostAuthorizationDUnitTest extends
           fail("executeOpBlock: Unknown client number " + clientNum);
           break;
       }
-      LogWriterUtils.getLogWriter().info(
-          "executeOpBlock: performing operation number ["
-              + currentOp.getOpNum() + "]: " + currentOp);
+
+      getLogWriter().info("executeOpBlock: performing operation number [" + currentOp.getOpNum() + "]: " + currentOp);
+
       if ((opFlags & OpFlags.USE_OLDCONN) == 0) {
         Properties opCredentials;
         int newRnd = rnd.nextInt(100) + 1;
@@ -277,315 +164,123 @@ public class DeltaClientPostAuthorizationDUnitTest extends
         if ((opFlags & OpFlags.USE_SUBREGION) > 0) {
           currentRegionName += ('/' + subregionName);
         }
+
         String credentialsTypeStr;
         OperationCode authOpCode = currentOp.getAuthzOperationCode();
         int[] indices = currentOp.getIndices();
         CredentialGenerator cGen = gen.getCredentialGenerator();
-        Properties javaProps = null;
-        if ((opFlags & OpFlags.CHECK_NOTAUTHZ) > 0
-            || (opFlags & OpFlags.USE_NOTAUTHZ) > 0) {
-          opCredentials = gen.getDisallowedCredentials(
-              new OperationCode[] { authOpCode },
-              new String[] { currentRegionName }, indices, newRnd);
+        final Properties javaProps = cGen == null ? null : cGen.getJavaProperties();
+
+        if ((opFlags & OpFlags.CHECK_NOTAUTHZ) > 0 || (opFlags & OpFlags.USE_NOTAUTHZ) > 0) {
+          opCredentials = gen.getDisallowedCredentials(new OperationCode[] { authOpCode }, new String[] { currentRegionName }, indices, newRnd);
           credentialsTypeStr = " unauthorized " + authOpCode;
-        }
-        else {
-          opCredentials = gen.getAllowedCredentials(new OperationCode[] {
-              opCode, authOpCode }, new String[] { currentRegionName },
-              indices, newRnd);
+
+        } else {
+          opCredentials = gen.getAllowedCredentials(new OperationCode[] {opCode, authOpCode }, new String[] { currentRegionName }, indices, newRnd);
           credentialsTypeStr = " authorized " + authOpCode;
         }
-        if (cGen != null) {
-          javaProps = cGen.getJavaProperties();
-        }
-        Properties clientProps = SecurityTestUtil
-            .concatProperties(new Properties[] { opCredentials, extraAuthProps,
-                extraAuthzProps });
-        // Start the client with valid credentials but allowed or disallowed to
-        // perform an operation
-        LogWriterUtils.getLogWriter().info(
-            "executeOpBlock: For client" + clientNum + credentialsTypeStr
-                + " credentials: " + opCredentials);
+
+        Properties clientProps = SecurityTestUtil.concatProperties(new Properties[] { opCredentials, extraAuthProps, extraAuthzProps });
+
+        // Start the client with valid credentials but allowed or disallowed to perform an operation
+        getLogWriter().info("executeOpBlock: For client" + clientNum + credentialsTypeStr + " credentials: " + opCredentials);
         boolean setupDynamicRegionFactory = (opFlags & OpFlags.ENABLE_DRF) > 0;
         if (useThisVM) {
-          createCacheClient(authInit, clientProps, javaProps, new Integer[] {
-              port1, port2 }, null, Boolean.valueOf(setupDynamicRegionFactory),
-              new Integer(SecurityTestUtil.NO_EXCEPTION));
-        }
-        else {
-          clientVM.invoke(ClientAuthorizationTestBase.class,
-              "createCacheClient", new Object[] { authInit, clientProps,
-                  javaProps, new Integer[] { port1, port2 }, null,
-                  Boolean.valueOf(setupDynamicRegionFactory),
-                  new Integer(SecurityTestUtil.NO_EXCEPTION) });
+          createCacheClient(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, setupDynamicRegionFactory, SecurityTestUtil.NO_EXCEPTION);
+
+        } else {
+          clientVM.invoke(() -> createCacheClient(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, setupDynamicRegionFactory, SecurityTestUtil.NO_EXCEPTION));
         }
       }
+
       int expectedResult;
       if ((opFlags & OpFlags.CHECK_NOTAUTHZ) > 0) {
         expectedResult = SecurityTestUtil.NOTAUTHZ_EXCEPTION;
-      }
-      else if ((opFlags & OpFlags.CHECK_EXCEPTION) > 0) {
+      } else if ((opFlags & OpFlags.CHECK_EXCEPTION) > 0) {
         expectedResult = SecurityTestUtil.OTHER_EXCEPTION;
-      }
-      else {
+      } else {
         expectedResult = SecurityTestUtil.NO_EXCEPTION;
       }
 
       // Perform the operation from selected client
       if (useThisVM) {
-        doOp(new Byte(opCode.toOrdinal()), currentOp.getIndices(), new Integer(
-            opFlags), new Integer(expectedResult));
-      }
-      else {
+        doOp(new Byte(opCode.toOrdinal()), currentOp.getIndices(), new Integer(opFlags), new Integer(expectedResult));
+      } else {
         byte ordinal = opCode.toOrdinal();
         int[] indices = currentOp.getIndices();
-        clientVM.invoke(() -> DeltaClientPostAuthorizationDUnitTest.doOp( new Byte(ordinal),
-                indices, new Integer(opFlags),
-                new Integer(expectedResult) ));
+        clientVM.invoke(() -> DeltaClientPostAuthorizationDUnitTest.doOp(new Byte(ordinal), indices, new Integer(opFlags), new Integer(expectedResult) ));
       }
     }
   }
 
-  private Region createSubregion(Region region) {
-
-    Region subregion = getSubregion();
-    if (subregion == null) {
-      subregion = region.createSubregion(subregionName, region.getAttributes());
+  private final void setUpDeltas() {
+    for (int i = 0; i < 8; i++) {
+      deltas[i] = new DeltaTestImpl(0, "0", new Double(0), new byte[0],
+              new PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1("0", 0));
     }
-    return subregion;
-  }
+    deltas[1].setIntVar(5);
+    deltas[2].setIntVar(5);
+    deltas[3].setIntVar(5);
+    deltas[4].setIntVar(5);
+    deltas[5].setIntVar(5);
+    deltas[6].setIntVar(5);
+    deltas[7].setIntVar(5);
 
-  public void doOp(Byte opCode, int[] indices, int flagsI,
-      int expectedResult) {
-
-    OperationCode op = OperationCode.fromOrdinal(opCode.byteValue());
-    boolean operationOmitted = false;
-    final int flags = flagsI;
-    Region region = getRegion();
-//    for (int i = 0; i < indices.length; i++) {
-//      region.put(SecurityTestUtil.keys[i],
-//          DeltaClientAuthorizationDUnitTest.deltas[i]);
-//    }
-    if ((flags & OpFlags.USE_SUBREGION) > 0) {
-      assertNotNull(region);
-      Region subregion = null;
-      if ((flags & OpFlags.NO_CREATE_SUBREGION) > 0) {
-        if ((flags & OpFlags.CHECK_NOREGION) > 0) {
-          // Wait for some time for DRF update to come
-          SecurityTestUtil.waitForCondition(new Callable() {
-            public Object call() throws Exception {
-              return Boolean.valueOf(getSubregion() == null);
-            }
-          });
-          subregion = getSubregion();
-          assertNull(subregion);
-          return;
-        }
-        else {
-          // Wait for some time for DRF update to come
-          SecurityTestUtil.waitForCondition(new Callable() {
-            public Object call() throws Exception {
-              return Boolean.valueOf(getSubregion() != null);
-            }
-          });
-          subregion = getSubregion();
-          assertNotNull(subregion);
-        }
-      }
-      else {
-        subregion = createSubregion(region);
-      }
-      assertNotNull(subregion);
-      region = subregion;
-    }
-    else if ((flags & OpFlags.CHECK_NOREGION) > 0) {
-      // Wait for some time for region destroy update to come
-      SecurityTestUtil.waitForCondition(new Callable() {
-        public Object call() throws Exception {
-          return Boolean.valueOf(getRegion() == null);
-        }
-      });
-      region = getRegion();
-      assertNull(region);
-      return;
-    }
-    else {
-      assertNotNull(region);
-    }
-    final String[] keys = SecurityTestUtil.keys;
-    final DeltaTestImpl[] vals;
-    if ((flags & OpFlags.USE_NEWVAL) > 0) {
-      vals = deltas;
-    }
-    else {
-      vals = deltas;
-    }
-    InterestResultPolicy policy = InterestResultPolicy.KEYS_VALUES;
-    if ((flags & OpFlags.REGISTER_POLICY_NONE) > 0) {
-      policy = InterestResultPolicy.NONE;
-    }
-    final int numOps = indices.length;
-    LogWriterUtils.getLogWriter().info(
-        "Got doOp for op: " + op.toString() + ", numOps: " + numOps
-            + ", indices: " + indicesToString(indices) + ", expect: " + expectedResult);
-    boolean exceptionOccured = false;
-    boolean breakLoop = false;
-    if (op.isGet()) {
-      try {
-        Thread.sleep(PAUSE);
-      }
-      catch (InterruptedException e) {
-        fail("interrupted");
-      }
-    }
-    for (int indexIndex = 0; indexIndex < numOps; ++indexIndex) {
-      if (breakLoop) {
-        break;
-      }
-      int index = indices[indexIndex];
-      try {
-        final Object key = keys[index];
-        final Object expectedVal = vals[index];
-        if (op.isGet()) {
-          Object value = null;
-          // this is the case for testing GET_ALL
-          if ((flags & OpFlags.USE_ALL_KEYS) > 0) {
-            breakLoop = true;
-            List keyList = new ArrayList(numOps);
-            Object searchKey;
-            for (int keyNumIndex = 0; keyNumIndex < numOps; ++keyNumIndex) {
-              int keyNum = indices[keyNumIndex];
-              searchKey = keys[keyNum];
-              keyList.add(searchKey);
-              // local invalidate some keys to force fetch of those keys from
-              // server
-              if ((flags & OpFlags.CHECK_NOKEY) > 0) {
-                assertFalse(region.containsKey(searchKey));
-              }
-              else {
-                if (keyNumIndex % 2 == 1) {
-                  assertTrue(region.containsKey(searchKey));
-                  region.localInvalidate(searchKey);
-                }
-              }
-            }
-            Map entries = region.getAll(keyList);
-            for (int keyNumIndex = 0; keyNumIndex < numOps; ++keyNumIndex) {
-              int keyNum = indices[keyNumIndex];
-              searchKey = keys[keyNum];
-              if ((flags & OpFlags.CHECK_FAIL) > 0) {
-                assertFalse(entries.containsKey(searchKey));
-              }
-              else {
-                assertTrue(entries.containsKey(searchKey));
-                value = entries.get(searchKey);
-                assertEquals(vals[keyNum], value);
-              }
-            }
-            break;
-          }
-          if ((flags & OpFlags.LOCAL_OP) > 0) {
-            Callable cond = new Callable() {
-              private Region region;
-
-              public Object call() throws Exception {
-                Object value = SecurityTestUtil.getLocalValue(region, key);
-                return Boolean
-                    .valueOf((flags & OpFlags.CHECK_FAIL) > 0 ? !expectedVal
-                        .equals(value) : expectedVal.equals(value));
-              }
-
-              public Callable init(Region region) {
-                this.region = region;
-                return this;
-              }
-            }.init(region);
-            SecurityTestUtil.waitForCondition(cond);
-            value = SecurityTestUtil.getLocalValue(region, key);
-          }
-          else {
-            if ((flags & OpFlags.CHECK_NOKEY) > 0) {
-              assertFalse(region.containsKey(key));
-            }
-            else {
-              assertTrue(region.containsKey(key));
-              region.localInvalidate(key);
-            }
-            value = region.get(key);
-          }
-          if ((flags & OpFlags.CHECK_FAIL) > 0) {
-            assertFalse(expectedVal.equals(value));
-          }
-          else {
-            assertNotNull(value);
-            assertEquals(expectedVal, value);
-          }
-        }
-        else if (op.isPut()) {
-          region.put(key, expectedVal);
-        }
-        else if (op.isRegisterInterest()) {
-          if ((flags & OpFlags.USE_LIST) > 0) {
-            breakLoop = true;
-            // Register interest list in this case
-            List keyList = new ArrayList(numOps);
-            for (int keyNumIndex = 0; keyNumIndex < numOps; ++keyNumIndex) {
-              int keyNum = indices[keyNumIndex];
-              keyList.add(keys[keyNum]);
-            }
-            region.registerInterest(keyList, policy);
-          }
-          else if ((flags & OpFlags.USE_REGEX) > 0) {
-            breakLoop = true;
-            region.registerInterestRegex("key[1-" + numOps + ']', policy);
-          }
-          else if ((flags & OpFlags.USE_ALL_KEYS) > 0) {
-            breakLoop = true;
-            region.registerInterest("ALL_KEYS", policy);
-          }
-          else {
-            region.registerInterest(key, policy);
-          }
-        }
-        else {
-          fail("doOp: Unhandled operation " + op);
-        }
-        if (expectedResult != SecurityTestUtil.NO_EXCEPTION) {
-          if (!operationOmitted && !op.isUnregisterInterest()) {
-            fail("Expected an exception while performing operation op =" + op +
-                "flags = " + OpFlags.description(flags));
-          }
-        }
-      }
-      catch (Exception ex) {
-        exceptionOccured = true;
-        if ((ex instanceof ServerConnectivityException
-            || ex instanceof QueryInvocationTargetException || ex instanceof CqException)
-            && (expectedResult == SecurityTestUtil.NOTAUTHZ_EXCEPTION)
-            && (ex.getCause() instanceof NotAuthorizedException)) {
-          LogWriterUtils.getLogWriter().info(
-              "doOp: Got expected NotAuthorizedException when doing operation ["
-                  + op + "] with flags " + OpFlags.description(flags) 
-                  + ": " + ex.getCause());
-          continue;
-        }
-        else if (expectedResult == SecurityTestUtil.OTHER_EXCEPTION) {
-          LogWriterUtils.getLogWriter().info(
-              "doOp: Got expected exception when doing operation: "
-                  + ex.toString());
-          continue;
-        }
-        else {
-          Assert.fail("doOp: Got unexpected exception when doing operation. Policy = " 
-              + policy + " flags = " + OpFlags.description(flags), ex);
-        }
-      }
-    }
-    if (!exceptionOccured && !operationOmitted
-        && expectedResult != SecurityTestUtil.NO_EXCEPTION) {
-      fail("Expected an exception while performing operation: " + op + 
-          " flags = " + OpFlags.description(flags));
-    }
-  }
+    deltas[2].resetDeltaStatus();
+    deltas[2].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
+    deltas[3].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
+    deltas[4].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
+    deltas[5].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
+    //deltas[6].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
+    //deltas[7].setByteArr(new byte[] { 1, 2, 3, 4, 5 });
+
+    deltas[3].resetDeltaStatus();
+    deltas[3].setDoubleVar(new Double(5));
+    deltas[4].setDoubleVar(new Double(5));
+    deltas[5].setDoubleVar(new Double(5));
+    deltas[6].setDoubleVar(new Double(5));
+    deltas[7].setDoubleVar(new Double(5));
+
+    deltas[4].resetDeltaStatus();
+    deltas[4].setStr("str changed");
+    deltas[5].setStr("str changed");
+    deltas[6].setStr("str changed");
+    //deltas[7].setStr("str changed");
 
+    deltas[5].resetDeltaStatus();
+    deltas[5].setIntVar(100);
+    deltas[5].setTestObj(new PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1("CHANGED", 100));
+    deltas[6].setTestObj(new PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1("CHANGED", 100));
+    deltas[7].setTestObj(new PartitionedRegionLocalMaxMemoryDUnitTest.TestObject1("CHANGED", 100));
+
+    deltas[6].resetDeltaStatus();
+    deltas[6].setByteArr(new byte[] { 1, 2, 3 });
+    deltas[7].setByteArr(new byte[] { 1, 2, 3 });
+
+    deltas[7].resetDeltaStatus();
+    deltas[7].setStr("delta string");
+  }
+  
+  private OperationWithAction[] allOps() {
+    return new OperationWithAction[] {
+        // Test CREATE and verify with a GET
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 2, OpFlags.USE_REGEX | OpFlags.REGISTER_POLICY_NONE, 8),
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 3, OpFlags.USE_REGEX | OpFlags.REGISTER_POLICY_NONE | OpFlags.USE_NOTAUTHZ, 8),
+        new OperationWithAction(OperationCode.PUT),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 4),
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 4),
+        
+        // OPBLOCK_END indicates end of an operation block that needs to be executed on each server when doing failover
+        OperationWithAction.OPBLOCK_END,
+        
+        // Test UPDATE and verify with a GET
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 2, OpFlags.USE_REGEX | OpFlags.REGISTER_POLICY_NONE, 8),
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 3, OpFlags.USE_REGEX | OpFlags.REGISTER_POLICY_NONE | OpFlags.USE_NOTAUTHZ, 8),
+        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, 4),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.USE_NEWVAL, 4),
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.USE_NEWVAL | OpFlags.CHECK_FAIL, 4),
+        
+        OperationWithAction.OPBLOCK_END 
+    };
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
index b31f15c..ba6b26f 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/P2PAuthenticationDUnitTest.java
@@ -18,70 +18,65 @@
  */
 package com.gemstone.gemfire.security;
 
-import java.io.File;
-import java.util.Properties;
+import static com.gemstone.gemfire.distributed.internal.DistributionConfig.*;
+import static com.gemstone.gemfire.internal.AvailablePort.*;
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.IgnoredException.*;
+import static com.gemstone.gemfire.test.dunit.NetworkUtils.*;
+import static com.gemstone.gemfire.test.dunit.Wait.*;
 
+import java.util.Properties;
 import javax.net.ssl.SSLHandshakeException;
 
-import com.gemstone.gemfire.LogWriter;
 import com.gemstone.gemfire.distributed.DistributedSystem;
 import com.gemstone.gemfire.distributed.Locator;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
 import com.gemstone.gemfire.distributed.internal.membership.MembershipManager;
 import com.gemstone.gemfire.distributed.internal.membership.gms.MembershipManagerHelper;
-import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.security.generator.CredentialGenerator;
 import com.gemstone.gemfire.security.generator.DummyCredentialGenerator;
 import com.gemstone.gemfire.security.generator.LdapUserCredentialGenerator;
 import com.gemstone.gemfire.security.generator.UserPasswordWithExtraPropsAuthInit;
 import com.gemstone.gemfire.security.templates.LdapUserAuthenticator;
 import com.gemstone.gemfire.security.templates.UserPasswordAuthInit;
-import com.gemstone.gemfire.test.dunit.DistributedTestCase;
 import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.IgnoredException;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
-import com.gemstone.gemfire.test.dunit.NetworkUtils;
 import com.gemstone.gemfire.test.dunit.VM;
-import com.gemstone.gemfire.test.dunit.Wait;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+import com.gemstone.gemfire.test.junit.categories.DistributedTest;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 /**
  * Tests peer to peer authentication in Gemfire
  * 
- * @author Yogesh Mahajan
  * @since 5.5
  */
-public class P2PAuthenticationDUnitTest extends DistributedTestCase {
+@Category(DistributedTest.class)
+public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
 
   private static VM locatorVM = null;
 
-  public static final String USER_NAME = "security-username";
-
-  public static final String PASSWORD = "security-password";
+  private static final String USER_NAME = "security-username";
+  private static final String PASSWORD = "security-password";
 
-  private static final String[] expectedExceptions = {
+  private static final String[] ignoredExceptions = {
       AuthenticationRequiredException.class.getName(),
       AuthenticationFailedException.class.getName(),
       GemFireSecurityException.class.getName(),
       SSLHandshakeException.class.getName(),
       ClassNotFoundException.class.getName(),
       "Authentication failed for",
-      "Failed to obtain credentials"};
-
-  public P2PAuthenticationDUnitTest(String name) {
-    super(name);
-  }
+      "Failed to obtain credentials"
+  };
 
   @Override
   public final void postSetUp() throws Exception {
-    final Host host = Host.getHost(0);
-    locatorVM = host.getVM(0);
-  }
-
-  private void setProperty(Properties props, String key, String value) {
-
-    if (key != null && value != null) {
-      props.setProperty(key, value);
+    disconnectAllFromDS();
+    locatorVM = Host.getHost(0).getVM(0);
+    for (String exceptionString : ignoredExceptions) {
+      addIgnoredException(exceptionString);
     }
   }
 
@@ -89,271 +84,231 @@ public class P2PAuthenticationDUnitTest extends DistributedTestCase {
    * Check that mcast-port setting for discovery or with locator are
    * incompatible with security
    */
+  @Test
   public void testIllegalPropertyCombos() throws Exception {
+    int port = getRandomAvailablePort(SOCKET);
 
-    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    File logFile = new File(getUniqueName() + "-locator" + port + ".log");
     Properties props = new Properties();
-    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "26753");
-    props.setProperty(DistributionConfig.LOCATORS_NAME, 
-                      NetworkUtils.getIPLiteral() + "[" + port + "]");
-    props.setProperty(DistributionConfig.SECURITY_PEER_AUTH_INIT_NAME, UserPasswordAuthInit.class.getName() + ".create");
-    props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
+    props.setProperty(MCAST_PORT_NAME, "26753");
+    props.setProperty(LOCATORS_NAME, getIPLiteral() + "[" + port + "]");
+    props.setProperty(SECURITY_PEER_AUTH_INIT_NAME, UserPasswordAuthInit.class.getName() + ".create");
+    props.setProperty(ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
 
     try {
-      Locator.startLocatorAndDS(port, logFile, null, props);
+      Locator.startLocatorAndDS(port, null, null, props);
       fail("Expected an IllegalArgumentException while starting locator");
-    }
-    catch (IllegalArgumentException ex) {
+
+    } catch (IllegalArgumentException ex) {
       // success
     }
 
     // Also try setting the authenticator
     props = new Properties();
-    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "26753");
-    props.setProperty(DistributionConfig.LOCATORS_NAME, 
-                      NetworkUtils.getIPLiteral() +"[" + port + "]");
-    props.setProperty(DistributionConfig.SECURITY_PEER_AUTHENTICATOR_NAME, LdapUserAuthenticator.class.getName() + ".create");
-    props.setProperty(DistributionConfig.ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
+    props.setProperty(MCAST_PORT_NAME, "26753");
+    props.setProperty(LOCATORS_NAME, getIPLiteral() +"[" + port + "]");
+    props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, LdapUserAuthenticator.class.getName() + ".create");
+    props.setProperty(ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
+
     try {
-      Locator.startLocatorAndDS(port, logFile, null, props);
+      Locator.startLocatorAndDS(port, null, null, props);
       fail("Expected an IllegalArgumentException while starting locator");
-    }
-    catch (IllegalArgumentException ex) {
+
+    } catch (IllegalArgumentException expected) {
       // success
     }
 
     props = new Properties();
-    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "26753");
-    props.setProperty(DistributionConfig.SECURITY_PEER_AUTH_INIT_NAME, UserPasswordAuthInit.class.getName() + ".create");
+    props.setProperty(MCAST_PORT_NAME, "26753");
+    props.setProperty(SECURITY_PEER_AUTH_INIT_NAME, UserPasswordAuthInit.class.getName() + ".create");
+
     try {
       getSystem(props);
       fail("Expected an IllegalArgumentException while connection to DS");
-    }
-    catch (IllegalArgumentException ex) {
+
+    } catch (IllegalArgumentException expected) {
       // success
     }
 
     // Also try setting the authenticator
     props = new Properties();
-    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "26753");
-    props.setProperty(DistributionConfig.SECURITY_PEER_AUTHENTICATOR_NAME, LdapUserAuthenticator.class.getName() + ".create");
+    props.setProperty(MCAST_PORT_NAME, "26753");
+    props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, LdapUserAuthenticator.class.getName() + ".create");
+
     try {
       getSystem(props);
       fail("Expected an IllegalArgumentException while connection to DS");
-    }
-    catch (IllegalArgumentException ex) {
+
+    } catch (IllegalArgumentException expected) {
       // success
     }
   }
 
-  // AuthInitialize is incorrect
+  /**
+   * AuthInitialize is incorrect
+   */
+  @Test
   public void testP2PAuthenticationWithInvalidAuthInitialize() throws Exception {
+    int locatorPort = getRandomAvailablePort(SOCKET);
 
-    disconnectAllFromDS();
     CredentialGenerator gen = new DummyCredentialGenerator();
-    Properties props = gen.getSystemProperties();
-    Properties javaProps = gen.getJavaProperties();
-    String authenticator = gen.getAuthenticator();
-    if (props == null) {
-      props = new Properties();
-    }
-    String authInit = " Incorrect_AuthInitialize";
-    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    final String locators = NetworkUtils.getIPLiteral() + "[" + port + "]";
-    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-    props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTH_INIT_NAME,
-            authInit);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTHENTICATOR_NAME,
-            authenticator);
-    startLocator(props, javaProps, port);
+    assertNotNull(gen.getAuthenticator());
+    assertNull(gen.getJavaProperties());
+
+    Properties props = new Properties();
+    props.setProperty(MCAST_PORT_NAME, "0");
+    props.setProperty(LOCATORS_NAME, getIPLiteral() + "[" + locatorPort + "]");
+    props.setProperty(SECURITY_PEER_AUTH_INIT_NAME, "Incorrect_AuthInitialize");
+    props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, gen.getAuthenticator());
+
+    startLocator(props, gen.getJavaProperties(), locatorPort);
 
-    LogWriter dsLogger = LogWriterUtils.createLogWriter(props);
-    SecurityTestUtil.addExpectedExceptions(expectedExceptions, dsLogger);
     try {
       new SecurityTestUtil("tmp").createSystem(props, null);
       fail("AuthenticationFailedException was expected as the AuthInitialize object passed is incorrect");
+
     } catch (AuthenticationFailedException expected) {
       // success
+
     } finally {
-      SecurityTestUtil.removeExpectedExceptions(expectedExceptions, dsLogger);
-      locatorVM.invoke(() -> SecurityTestUtil.stopLocator(
-              new Integer(port), expectedExceptions));
+      locatorVM.invoke(() -> stopLocator(locatorPort, ignoredExceptions));
     }
-
-  }
-
-  protected void startLocator(Properties props, Properties javaProps,
-      int port) {
-    locatorVM.invoke(() -> SecurityTestUtil.startLocator(
-            getUniqueName(), new Integer(port), props, javaProps,
-            expectedExceptions));
   }
 
-  // Authenticator is incorrect
+  /**
+   * Authenticator is incorrect
+   */
+  @Test
   public void testP2PAuthenticationWithInvalidAuthenticator() throws Exception {
-    disconnectAllFromDS();
+    int locatorPort = getRandomAvailablePort(SOCKET);
+
     CredentialGenerator gen = new DummyCredentialGenerator();
-    Properties props = gen.getSystemProperties();
-    Properties javaProps = gen.getJavaProperties();
-    String authenticator = "xyz";
-    String authInit = gen.getAuthInit();
-    if (props == null) {
-      props = new Properties();
-    }
-    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    final String locators = NetworkUtils.getIPLiteral() +"["+port+"]";
-    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-    props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTH_INIT_NAME,
-            authInit);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTHENTICATOR_NAME,
-            authenticator);
-    startLocator(props, javaProps, port);
+    assertNotNull(gen.getAuthInit());
+    assertNull(gen.getJavaProperties());
+
+    Properties props = new Properties();
+    props.setProperty(MCAST_PORT_NAME, "0");
+    props.setProperty(LOCATORS_NAME, getIPLiteral() +"["+locatorPort+"]");
+    props.setProperty(SECURITY_PEER_AUTH_INIT_NAME, gen.getAuthInit());
+    props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, "xyz");
+
+    startLocator(props, null, locatorPort);
 
-    LogWriter dsLogger = LogWriterUtils.createLogWriter(props);
-    SecurityTestUtil.addExpectedExceptions(expectedExceptions, dsLogger);
     try {
-      new SecurityTestUtil("tmp").createSystem(props, javaProps);
+      new SecurityTestUtil("tmp").createSystem(props, null);
       fail("AuthenticationFailedException was expected as the Authenticator object passed is incorrect");
-    }
-    catch (AuthenticationFailedException expected) {
+
+    } catch (AuthenticationFailedException expected) {
       // success
-    }
-    finally {
-      SecurityTestUtil.removeExpectedExceptions(expectedExceptions, dsLogger);
-      locatorVM.invoke(() -> SecurityTestUtil.stopLocator(
-              new Integer(port), expectedExceptions ));
+
+    } finally {
+      locatorVM.invoke(() -> SecurityTestUtil.stopLocator(locatorPort, ignoredExceptions));
     }
   }
 
+  @Test
   public void testP2PAuthenticationWithNoCredentials() throws Exception {
-
-    disconnectAllFromDS();
+    int locatorPort = getRandomAvailablePort(SOCKET);
 
     CredentialGenerator gen = new DummyCredentialGenerator();
-    Properties props = gen.getSystemProperties();
-    Properties javaProps = gen.getJavaProperties();
-    String authenticator = gen.getAuthenticator();
-    String authInit = gen.getAuthInit();
-    if (props == null) {
-      props = new Properties();
-    }
-    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    final String locators = NetworkUtils.getIPLiteral() +"["+port+"]";
-    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-    props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTH_INIT_NAME,
-            authInit);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTHENTICATOR_NAME,
-            authenticator);
-    startLocator(props, javaProps, port);
+    assertNotNull(gen.getAuthenticator());
+    assertNotNull(gen.getAuthInit());
+    assertNull(gen.getJavaProperties());
+    assertNull(gen.getSystemProperties());
+
+    Properties props = new Properties();
+    props.setProperty(MCAST_PORT_NAME, "0");
+    props.setProperty(LOCATORS_NAME, getIPLiteral() +"["+locatorPort+"]");
+    props.setProperty(SECURITY_PEER_AUTH_INIT_NAME, gen.getAuthInit());
+    props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, gen.getAuthenticator());
+
+    startLocator(props, null, locatorPort);
 
-    LogWriter dsLogger = LogWriterUtils.createLogWriter(props);
-    SecurityTestUtil.addExpectedExceptions(expectedExceptions, dsLogger);
     try {
       new SecurityTestUtil("tmp").createSystem(props, null);
       fail("AuthenticationFailedException was expected as no credentials are set");
-    }
-    catch (AuthenticationFailedException expected) {
+
+    } catch (AuthenticationFailedException expected) {
       // success
-    }
-    finally {
-      SecurityTestUtil.removeExpectedExceptions(expectedExceptions, dsLogger);
-      locatorVM.invoke(() -> SecurityTestUtil.stopLocator(
-              new Integer(port), expectedExceptions ));
+
+    } finally {
+      locatorVM.invoke(() -> SecurityTestUtil.stopLocator(locatorPort, ignoredExceptions));
     }
   }
 
+  @Test
   public void testP2PAuthenticationWithValidCredentials() throws Exception {
+    int locatorPort = getRandomAvailablePort(SOCKET);
 
-    disconnectAllFromDS();
     CredentialGenerator gen = new DummyCredentialGenerator();
-    Properties props = gen.getSystemProperties();
-    String authenticator = gen.getAuthenticator();
-    String authInit = gen.getAuthInit();
-    if (props == null) {
-      props = new Properties();
-    }
-    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    final String locators = NetworkUtils.getIPLiteral() +"["+port+"]";
-    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-    props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTH_INIT_NAME,
-            authInit);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTHENTICATOR_NAME,
-            authenticator);
-    Properties credentials = gen.getValidCredentials(1);
-    Properties javaProps = gen.getJavaProperties();
-    props.putAll(credentials);
-    startLocator(props, javaProps, port);
+    assertNotNull(gen.getAuthenticator());
+    assertNotNull(gen.getAuthInit());
+    assertNull(gen.getJavaProperties());
+    assertNull(gen.getSystemProperties());
+    assertNotNull(gen.getValidCredentials(1));
+
+    Properties props = new Properties();
+    props.setProperty(MCAST_PORT_NAME, "0");
+    props.setProperty(LOCATORS_NAME, getIPLiteral() +"["+locatorPort+"]");
+    props.setProperty(SECURITY_PEER_AUTH_INIT_NAME, gen.getAuthInit());
+    props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, gen.getAuthenticator());
+    props.putAll(gen.getValidCredentials(1));
+
+    startLocator(props, gen.getJavaProperties(), locatorPort);
+
     try {
-      createDS(props, javaProps);
-      verifyMembers(new Integer(2));
+      createDS(props, gen.getJavaProperties());
+      verifyMembers(2);
       disconnectFromDS();
 
     } finally {
-      locatorVM.invoke(() -> SecurityTestUtil.stopLocator(
-              new Integer(port), expectedExceptions ));
+      locatorVM.invoke(() -> SecurityTestUtil.stopLocator(locatorPort, ignoredExceptions));
     }
   }
 
-  public void testP2PAuthenticationWithBothValidAndInValidCredentials()
-      throws Exception {
+  @Test
+  public void testP2PAuthenticationWithBothValidAndInValidCredentials() throws Exception {
+    addIgnoredException("Authentication failed");
 
-    disconnectAllFromDS();
-    IgnoredException.addIgnoredException("Authentication failed");
+    int locatorPort = getRandomAvailablePort(SOCKET);
 
     CredentialGenerator gen = new DummyCredentialGenerator();
-    Properties props = gen.getSystemProperties();
-    String authenticator = gen.getAuthenticator();
-    String authInit = gen.getAuthInit();
-    if (props == null) {
-      props = new Properties();
-    }
-    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    final String locators = NetworkUtils.getIPLiteral() +"["+port+"]";
-    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-    props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTH_INIT_NAME,
-            authInit);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTHENTICATOR_NAME,
-            authenticator);
-    // valid credentials for locator
-    Properties credentials = gen.getValidCredentials(1);
-    Properties javaProps = gen.getJavaProperties();
-    props.putAll(credentials);
-    startLocator(props, javaProps, port);
+    assertNotNull(gen.getAuthenticator());
+    assertNotNull(gen.getAuthInit());
+    assertNotNull(gen.getInvalidCredentials(1));
+    assertNull(gen.getJavaProperties());
+    assertNull(gen.getSystemProperties());
+    assertNotNull(gen.getValidCredentials(1));
+    assertNotNull(gen.getValidCredentials(3));
+
+    Properties props = new Properties();
+    props.setProperty(MCAST_PORT_NAME, "0");
+    props.setProperty(LOCATORS_NAME, getIPLiteral() +"["+locatorPort+"]");
+    props.setProperty(SECURITY_PEER_AUTH_INIT_NAME, gen.getAuthInit());
+    props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, gen.getAuthenticator());
+    props.putAll(gen.getValidCredentials(1));
+
+    startLocator(props, null, locatorPort);
+
     try {
       // invalid credentials for the peer
-      credentials = gen.getInvalidCredentials(1);
-      javaProps = gen.getJavaProperties();
-      props.putAll(credentials);
+      props.putAll(gen.getInvalidCredentials(1));
 
-      LogWriter dsLogger = LogWriterUtils.createLogWriter(props);
-      SecurityTestUtil.addExpectedExceptions(expectedExceptions, dsLogger);
       try {
-        new SecurityTestUtil("tmp").createSystem(props, javaProps);
+        new SecurityTestUtil("tmp").createSystem(props, null);
         fail("AuthenticationFailedException was expected as wrong credentials were passed");
-      }
-      catch (AuthenticationFailedException expected) {
+
+      } catch (AuthenticationFailedException expected) {
         // success
       }
-      finally {
-        SecurityTestUtil.removeExpectedExceptions(expectedExceptions, dsLogger);
-      }
 
-      credentials = gen.getValidCredentials(3);
-      javaProps = gen.getJavaProperties();
-      props.putAll(credentials);
-      createDS(props, javaProps);
-      verifyMembers(new Integer(2));
+      props.putAll(gen.getValidCredentials(3));
+
+      createDS(props, null);
+      verifyMembers(2);
       disconnectFromDS();
 
     } finally {
-      locatorVM.invoke(() -> SecurityTestUtil.stopLocator(
-              new Integer(port), expectedExceptions ));
+      locatorVM.invoke(() -> SecurityTestUtil.stopLocator(locatorPort, ignoredExceptions));
     }
   }
 
@@ -366,9 +321,11 @@ public class P2PAuthenticationDUnitTest extends DistributedTestCase {
    * reported by the first peer should be only two while others will report as
    * three.
    */
-  public void disabled_testP2PViewChangeReject() throws Exception {
+  @Ignore("disabled for some reason?")
+  @Test
+  public void testP2PViewChangeReject() throws Exception {
+    int locatorPort = getRandomAvailablePort(SOCKET);
 
-    disconnectAllFromDS();
     final Host host = Host.getHost(0);
     final VM peer2 = host.getVM(1);
     final VM peer3 = host.getVM(2);
@@ -378,6 +335,7 @@ public class P2PAuthenticationDUnitTest extends DistributedTestCase {
     Properties extraProps = gen.getSystemProperties();
     String authenticator = gen.getAuthenticator();
     String authInit = gen.getAuthInit();
+
     if (extraProps == null) {
       extraProps = new Properties();
     }
@@ -386,93 +344,92 @@ public class P2PAuthenticationDUnitTest extends DistributedTestCase {
     gen2.init();
     Properties extraProps2 = gen2.getSystemProperties();
     String authenticator2 = gen2.getAuthenticator();
+
     if (extraProps2 == null) {
       extraProps2 = new Properties();
     }
 
     // Start the locator with the LDAP authenticator
     Properties props = new Properties();
-    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    final String locators = NetworkUtils.getIPLiteral() +"["+port+"]";
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTH_INIT_NAME,
-        authInit);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTHENTICATOR_NAME,
-        authenticator);
+    int port = getRandomAvailablePort(SOCKET);
+    final String locators = getIPLiteral() +"["+port+"]";
+
+    props.setProperty(SECURITY_PEER_AUTH_INIT_NAME, authInit);
+    props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, authenticator);
     Properties credentials = gen.getValidCredentials(1);
     Properties javaProps = gen.getJavaProperties();
     props.putAll(credentials);
     props.putAll(extraProps);
+
     startLocator(props, javaProps, port);
+
     try {
 
-    // Start the first peer with different authenticator
-    props = new Properties();
-    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-    props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTH_INIT_NAME,
-        authInit);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTHENTICATOR_NAME,
-        authenticator2);
-    credentials = gen.getValidCredentials(3);
-    Properties javaProps2 = gen2.getJavaProperties();
-    props.putAll(credentials);
-    props.putAll(extraProps2);
-    createDS(props, javaProps2);
+      // Start the first peer with different authenticator
+      props = new Properties();
+      props.setProperty(MCAST_PORT_NAME, "0");
+      props.setProperty(LOCATORS_NAME, locators);
+      props.setProperty(SECURITY_PEER_AUTH_INIT_NAME, authInit);
+      props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, authenticator2);
 
-    // Start the second peer with the same authenticator as locator
-    props = new Properties();
-    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-    props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTH_INIT_NAME,
-        authInit);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTHENTICATOR_NAME,
-        authenticator);
-    credentials = gen.getValidCredentials(7);
-    javaProps = gen.getJavaProperties();
-    props.putAll(credentials);
-    props.putAll(extraProps);
-    createDS(peer2, props, javaProps);
-
-    createDS(peer3, props, javaProps);
-
-    // wait for view propagation
-    Wait.pause(2000);
-    // Verify the number of members on all peers and locator
-    locatorVM.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers( new Integer(4) ));
-    verifyMembers(new Integer(2));
-    peer2.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers( new Integer(4) ));
-    peer3.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers( new Integer(4) ));
-
-    // Disconnect the first peer and check again
-    disconnectFromDS();
-    Wait.pause(2000);
-    locatorVM.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers( new Integer(3) ));
-    peer2.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers( new Integer(3) ));
-    peer3.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers( new Integer(3) ));
-
-    // Disconnect the second peer and check again
-    peer2.invoke(() -> DistributedTestCase.disconnectFromDS());
-    Wait.pause(2000);
-    locatorVM.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers( new Integer(2) ));
-    peer3.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers( new Integer(2) ));
-
-    // Same for last peer
-    peer3.invoke(() -> DistributedTestCase.disconnectFromDS());
-    Wait.pause(2000);
-    locatorVM.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers( new Integer(1) ));
+      credentials = gen.getValidCredentials(3);
+      Properties javaProps2 = gen2.getJavaProperties();
+      props.putAll(credentials);
+      props.putAll(extraProps2);
+
+      createDS(props, javaProps2);
+
+      // Start the second peer with the same authenticator as locator
+      props = new Properties();
+      props.setProperty(MCAST_PORT_NAME, "0");
+      props.setProperty(LOCATORS_NAME, locators);
+      props.setProperty(SECURITY_PEER_AUTH_INIT_NAME, authInit);
+      props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, authenticator);
+
+      credentials = gen.getValidCredentials(7);
+      javaProps = gen.getJavaProperties();
+      props.putAll(credentials);
+      props.putAll(extraProps);
+
+      createDS(peer2, props, javaProps);
+
+      createDS(peer3, props, javaProps);
+
+      // wait for view propagation
+      pause(2000);
+
+      // Verify the number of members on all peers and locator
+      locatorVM.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(4));
+      verifyMembers(2);
+      peer2.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(4));
+      peer3.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(4));
+
+      // Disconnect the first peer and check again
+      disconnectFromDS();
+      pause(2000);
+
+      locatorVM.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(3));
+      peer2.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(3));
+      peer3.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(3));
+
+      // Disconnect the second peer and check again
+      peer2.invoke(() -> disconnectFromDS());
+      pause(2000);
+
+      locatorVM.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(2));
+      peer3.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(2));
+
+      // Same for last peer
+      peer3.invoke(() -> disconnectFromDS());
+      pause(2000);
+
+      locatorVM.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers(1));
 
     } finally {
-    locatorVM.invoke(() -> SecurityTestUtil.stopLocator(
-        new Integer(port), expectedExceptions ));
+      locatorVM.invoke(() -> SecurityTestUtil.stopLocator(port, ignoredExceptions));
     }
   }
 
-  protected void createDS(final VM peer2, Properties props,
-      Properties javaProps) {
-    peer2.invoke(() -> P2PAuthenticationDUnitTest.createDS(
-        props, javaProps ));
-  }
-
   /**
    * The strategy is to test credential size greater than UDP datagram size.
    * 
@@ -480,119 +437,103 @@ public class P2PAuthenticationDUnitTest extends DistributedTestCase {
    * from the first peer. Number of members in the DS
    * should be four
    */
+  @Test
   public void testP2PLargeCredentialSucceeds() throws Exception {
+    int locatorPort = getRandomAvailablePort(SOCKET);
 
-    disconnectAllFromDS();
     final Host host = Host.getHost(0);
     final VM peer2 = host.getVM(1);
     final VM peer3 = host.getVM(2);
 
     CredentialGenerator gen = new DummyCredentialGenerator();
     gen.init();
-    Properties extraProps = gen.getSystemProperties();
-    String authenticator = gen.getAuthenticator();
+
+    assertNotNull(gen.getAuthenticator());
+    assertNull(gen.getJavaProperties());
+    assertNull(gen.getSystemProperties());
+    assertNotNull(gen.getValidCredentials(1));
+
     String authInit = UserPasswordWithExtraPropsAuthInit.class.getName() + ".create";
-    if (extraProps == null) {
-      extraProps = new Properties();
-    }
+    Properties credentials = gen.getValidCredentials(1);
 
-    // Start the locator with the Dummy authenticator
     Properties props = new Properties();
-    int port = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
-    final String locators = NetworkUtils.getIPLiteral() +"["+port+"]";
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTH_INIT_NAME,
-        authInit);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTHENTICATOR_NAME,
-        authenticator);
-    Properties credentials = gen.getValidCredentials(1);
-    Properties javaProps = gen.getJavaProperties();
+    props.setProperty(SECURITY_PEER_AUTH_INIT_NAME, authInit);
+    props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, gen.getAuthenticator());
     props.putAll(credentials);
-    props.putAll(extraProps);
-    startLocator(props, javaProps, port);
+
+    startLocator(props, null, locatorPort);
+
     try {
+      // Start the first peer with huge credentials
+      props = new Properties();
+      props.setProperty(MCAST_PORT_NAME, "0");
+      props.setProperty(LOCATORS_NAME, getIPLiteral() +"["+locatorPort+"]");
+      props.setProperty(SECURITY_PEER_AUTH_INIT_NAME, authInit);
+      props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, gen.getAuthenticator());
+
+      String hugeStr = "20KString";
+      for (int i = 0; i <= 20000; i++) {
+        hugeStr += "A";
+      }
 
-    // Start the first peer with huge credentials
-    props = new Properties();
-    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-    props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTH_INIT_NAME,
-        authInit);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTHENTICATOR_NAME,
-        authenticator);
-    credentials = gen.getValidCredentials(3);
-    javaProps = gen.getJavaProperties();
-    String hugeStr = "20KString";
-    for (int i = 0; i <= 20000; i++) {
-      hugeStr += "A";
-    }
-    credentials.setProperty("security-keep-extra-props", "-");
-    credentials.setProperty("security-hugeentryone", hugeStr);
-    credentials.setProperty("security-hugeentrytwo", hugeStr);
-    credentials.setProperty("security-hugeentrythree", hugeStr);
+      credentials = gen.getValidCredentials(3);
+      credentials.setProperty("security-keep-extra-props", "-");
+      credentials.setProperty("security-hugeentryone", hugeStr);
+      credentials.setProperty("security-hugeentrytwo", hugeStr);
+      credentials.setProperty("security-hugeentrythree", hugeStr);
 
-    props.putAll(credentials);
-    props.putAll(extraProps);
+      props.putAll(credentials);
 
-    LogWriter dsLogger = LogWriterUtils.createLogWriter(props);
-    SecurityTestUtil.addExpectedExceptions(
-        new String[] { IllegalArgumentException.class.getName() }, dsLogger);
-    try {
-      createDS(props, javaProps);
-//      fail("AuthenticationFailedException was expected as credentials were passed beyond 50k");
-    }
-    finally {
-      SecurityTestUtil.removeExpectedExceptions(
-          new String[] { IllegalArgumentException.class.getName() }, dsLogger);
-    }
+      createDS(props, null);
+      // fail("AuthenticationFailedException was expected as credentials were passed beyond 50k"); --?
 
-    // Start the second peer with the same authenticator as locator
-    props = new Properties();
-    props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
-    props.setProperty(DistributionConfig.LOCATORS_NAME, locators);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTH_INIT_NAME,
-        authInit);
-    setProperty(props, DistributionConfig.SECURITY_PEER_AUTHENTICATOR_NAME,
-        authenticator);
-    credentials = gen.getValidCredentials(7);
-    javaProps = gen.getJavaProperties();
-    props.putAll(credentials);
-    props.putAll(extraProps);
-    createDS(peer2, props, javaProps);
+      // Start the second peer with the same authenticator as locator
+      props = new Properties();
+      props.setProperty(MCAST_PORT_NAME, "0");
+      props.setProperty(LOCATORS_NAME, getIPLiteral() +"["+locatorPort+"]");
+      props.setProperty(SECURITY_PEER_AUTH_INIT_NAME, authInit);
+      props.setProperty(SECURITY_PEER_AUTHENTICATOR_NAME, gen.getAuthenticator());
 
-    createDS(peer3, props, javaProps);
+      credentials = gen.getValidCredentials(7);
+      props.putAll(credentials);
+
+      createDS(peer2, props, null);
+      createDS(peer3, props, null);
 
-    // wait for view propagation
-    Wait.pause(2000);
-    // Verify the number of members on all peers and locator
-    locatorVM.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers( new Integer(4) ));
-    peer2.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers( new Integer(4) ));
-    peer3.invoke(() -> P2PAuthenticationDUnitTest.verifyMembers( new Integer(4) ));
+      // wait for view propagation
+      pause(2000);
 
+      // Verify the number of members on all peers and locator
+      locatorVM.invoke(() -> verifyMembers(4));
+      peer2.invoke(() -> verifyMembers(4));
+      peer3.invoke(() -> verifyMembers(4));
 
-    // Disconnect the peers
-    disconnectFromDS();
-    peer2.invoke(() -> DistributedTestCase.disconnectFromDS());
-    peer3.invoke(() -> DistributedTestCase.disconnectFromDS());
+      // Disconnect the peers
+      disconnectFromDS();
+      peer2.invoke(() -> disconnectFromDS());
+      peer3.invoke(() -> disconnectFromDS());
 
     } finally {
-    // Stopping the locator
-    locatorVM.invoke(() -> SecurityTestUtil.stopLocator(
-        new Integer(port), expectedExceptions ));
+      locatorVM.invoke(() -> SecurityTestUtil.stopLocator(locatorPort, ignoredExceptions));
     }
   }
 
-  public static void createDS(Properties props, Object javaProps) {
+  private void createDS(VM peer2, Properties props, Properties javaProps) {
+    peer2.invoke(() -> createDS(props, javaProps));
+  }
 
-    SecurityTestUtil tmpUtil = new SecurityTestUtil("tmp");
-    tmpUtil.createSystem(props, (Properties)javaProps);
+  private void startLocator(Properties props, Properties javaProps, int port) {
+    locatorVM.invoke(() -> SecurityTestUtil.startLocator(getUniqueName(), port, props, javaProps, ignoredExceptions));
   }
 
-  public static void verifyMembers(Integer numExpectedMembers) {
+  private static void createDS(Properties props, Properties javaProps) {
+    SecurityTestUtil tmpUtil = new SecurityTestUtil("tmp");
+    tmpUtil.createSystem(props, javaProps);
+  }
 
+  private static void verifyMembers(int numExpectedMembers) {
     DistributedSystem ds = InternalDistributedSystem.getAnyInstance();
-    MembershipManager mgr = MembershipManagerHelper
-        .getMembershipManager(ds);
-    assertEquals(numExpectedMembers.intValue(), mgr.getView().size());
+    MembershipManager mgr = MembershipManagerHelper.getMembershipManager(ds);
+    assertEquals(numExpectedMembers, mgr.getView().size());
   }
-
 }


[5/8] incubator-geode git commit: Tests are passing

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java b/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java
index 80a8f6d..cce3002 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java
@@ -18,8 +18,10 @@
  */
 package com.gemstone.gemfire.security;
 
+import static com.gemstone.gemfire.internal.AvailablePort.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
 import static com.gemstone.gemfire.test.dunit.DistributedTestUtils.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 import static com.gemstone.gemfire.test.dunit.NetworkUtils.*;
 import static com.gemstone.gemfire.test.dunit.Wait.*;
 
@@ -77,8 +79,6 @@ import com.gemstone.gemfire.cache30.ClientServerTestCase;
 import com.gemstone.gemfire.distributed.DistributedSystem;
 import com.gemstone.gemfire.distributed.Locator;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
-import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.logging.InternalLogWriter;
 import com.gemstone.gemfire.internal.logging.PureLogWriter;
 import com.gemstone.gemfire.internal.util.Callable;
@@ -86,136 +86,96 @@ import com.gemstone.gemfire.pdx.PdxReader;
 import com.gemstone.gemfire.pdx.PdxSerializable;
 import com.gemstone.gemfire.pdx.PdxWriter;
 import com.gemstone.gemfire.test.dunit.DistributedTestCase;
+import com.gemstone.gemfire.test.dunit.IgnoredException;
 import com.gemstone.gemfire.test.dunit.WaitCriterion;
 
 /**
  * Contains utility methods for setting up servers/clients for authentication
  * and authorization tests.
  * 
- * @author sumedh
  * @since 5.5
  */
 public final class SecurityTestUtil {
 
   private final DistributedTestCase distributedTestCase = new DistributedTestCase(getClass().getSimpleName()) {};
 
-  private static Locator locator = null;
-  private static Cache cache = null;
-  private static Properties currentJavaProps = null;
-  private static String locatorString = null;
-  private static Integer mcastPort = null;
-
-  public static final int NO_EXCEPTION = 0;
-  public static final int AUTHREQ_EXCEPTION = 1;
-  public static final int AUTHFAIL_EXCEPTION = 2;
-  public static final int CONNREFUSED_EXCEPTION = 3;
-  public static final int NOTAUTHZ_EXCEPTION = 4;
-  public static final int OTHER_EXCEPTION = 5;
-  public static final int NO_AVAILABLE_SERVERS = 6;
+  protected static final int NO_EXCEPTION = 0;
+  protected static final int AUTHREQ_EXCEPTION = 1;
+  protected static final int AUTHFAIL_EXCEPTION = 2;
+  protected static final int CONNREFUSED_EXCEPTION = 3;
+  protected static final int NOTAUTHZ_EXCEPTION = 4;
+  protected static final int OTHER_EXCEPTION = 5;
+  protected static final int NO_AVAILABLE_SERVERS = 6;
   // Indicates that AuthReqException may not necessarily be thrown
-  public static final int NOFORCE_AUTHREQ_EXCEPTION = 16;
+  protected static final int NOFORCE_AUTHREQ_EXCEPTION = 16;
 
   protected static final String REGION_NAME = "AuthRegion";
+  protected static final String[] KEYS = { "key1", "key2", "key3", "key4", "key5", "key6", "key7", "key8" };
+  protected static final String[] VALUES = { "value1", "value2", "value3", "value4", "value5", "value6", "value7", "value8" };
+  protected static final String[] NVALUES = { "nvalue1", "nvalue2", "nvalue3", "nvalue4", "nvalue5", "nvalue6", "nvalue7", "nvalue8" };
 
-  protected static final String[] KEYS = { "key1", "key2", "key3", "key4",
-      "key5", "key6", "key7", "key8" };
+  private static final int NUMBER_OF_USERS = 1;
 
-  protected static final String[] values = { "value1", "value2", "value3",
-      "value4", "value5", "value6", "value7", "value8" };
+  private static String[] ignoredExceptions = null;
 
-  protected static final String[] nvalues = { "nvalue1", "nvalue2", "nvalue3",
-      "nvalue4", "nvalue5", "nvalue6", "nvalue7", "nvalue8" };
-
-  static String[] expectedExceptions = null;
-  static String[] expectedExceptions() {
-    return expectedExceptions;
-  }
+  private static Locator locator = null;
+  private static Cache cache = null;
+  private static Properties currentJavaProps = null;
+  private static String locatorString = null;
+  private static Integer mcastPort = null;
 
   private static Pool pool = null;
-
   private static boolean multiUserAuthMode = false;
 
-  private static final int numberOfUsers = 1;
-
-  static ProxyCache[] proxyCaches = new ProxyCache[numberOfUsers];
-  static ProxyCache[] proxyCaches() {
-    return proxyCaches();
-  }
+  private static ProxyCache[] proxyCaches = new ProxyCache[NUMBER_OF_USERS];
 
   private static Region regionRef = null;
 
-  public static void addExpectedExceptions(String[] expectedExceptions,
-      LogWriter logger) {
+  public SecurityTestUtil(String name) {
+  }
+
+  /**
+   * @deprecated Please {@link IgnoredException} instead
+   */
+  protected static void addIgnoredExceptions(String[] expectedExceptions, LogWriter logWriter) {
     if (expectedExceptions != null) {
       for (int index = 0; index < expectedExceptions.length; index++) {
-        logger.info("<ExpectedException action=add>"
-            + expectedExceptions[index] + "</ExpectedException>");
+        logWriter.info("<ExpectedException action=add>" + expectedExceptions[index] + "</ExpectedException>");
       }
     }
   }
 
-  public static void removeExpectedExceptions(String[] expectedExceptions,
-      LogWriter logger) {
+  /**
+   * @deprecated Please {@link IgnoredException} instead
+   */
+  protected static void removeExpectedExceptions(String[] expectedExceptions, LogWriter logWriter) {
     if (expectedExceptions != null) {
       for (int index = 0; index < expectedExceptions.length; index++) {
-        logger.info("<ExpectedException action=remove>"
-            + expectedExceptions[index] + "</ExpectedException>");
+        logWriter.info("<ExpectedException action=remove>" + expectedExceptions[index] + "</ExpectedException>");
       }
     }
   }
 
-  public SecurityTestUtil(String name) {
-  }
-
-  public static void setJavaProps(Properties javaProps) {
-
+  protected static void setJavaProps(Properties javaProps) {
     removeJavaProperties(currentJavaProps);
     addJavaProperties(javaProps);
     currentJavaProps = javaProps;
   }
 
-  public DistributedSystem createSystem(Properties sysProps, Properties javaProps) {
-
-    closeCache();
-    clearStaticSSLContext();
-    setJavaProps(javaProps);
-
-    DistributedSystem dsys = distributedTestCase.getSystem(sysProps);
-    assertNotNull(dsys);
-    addExpectedExceptions(SecurityTestUtil.expectedExceptions, dsys
-        .getLogWriter());
-    return dsys;
-  }
-
-  void openCache() {
-
-    assertNotNull(distributedTestCase.basicGetSystem());
-    assertTrue(distributedTestCase.basicGetSystem().isConnected());
-    cache = CacheFactory.create(distributedTestCase.basicGetSystem());
-    assertNotNull(cache);
-  }
-
-  private static void initClientDynamicRegionFactory(String poolName) {
-
-    DynamicRegionFactory.get().open(
-        new DynamicRegionFactory.Config(null, poolName, false,true));
+  protected static ProxyCache getProxyCaches(int index) {
+    return proxyCaches[index];
   }
 
-  public static void initDynamicRegionFactory() {
-
-    DynamicRegionFactory.get().open(
-        new DynamicRegionFactory.Config(null, null, false, true));
+  protected static void initDynamicRegionFactory() {
+    DynamicRegionFactory.get().open(new DynamicRegionFactory.Config(null, null, false, true));
   }
 
-  public static Integer getLocatorPort() {
-
-    Integer locatorPort = new Integer(AvailablePort
-        .getRandomAvailablePort(AvailablePort.SOCKET));
+  protected static Integer getLocatorPort() {
+    int locatorPort = getRandomAvailablePort(SOCKET);
     String addr = getIPLiteral();
     if (locatorString == null) {
       locatorString = addr + "[" + locatorPort + ']';
-    }
-    else {
+    } else {
       locatorString += "," + addr + "[" + locatorPort + ']';
     }
     return locatorPort;
@@ -225,15 +185,13 @@ public final class SecurityTestUtil {
    * Note that this clears the string after returning for convenience in reusing
    * for other tests. Hence it should normally be invoked only once for a test.
    */
-  public static String getLocatorString() {
-
+  protected static String getLocatorString() {
     String locString = locatorString;
     locatorString = null;
     return locString;
   }
 
-  public static Properties concatProperties(Properties[] propsList) {
-
+  protected static Properties concatProperties(Properties[] propsList) {
     Properties props = new Properties();
     for (int index = 0; index < propsList.length; ++index) {
       if (propsList[index] != null) {
@@ -243,83 +201,49 @@ public final class SecurityTestUtil {
     return props;
   }
 
-  public static void registerExpectedExceptions(String[] expectedExceptions) {
-    SecurityTestUtil.expectedExceptions = expectedExceptions;
-  }
-
-  private static void addJavaProperties(Properties javaProps) {
-
-    if (javaProps != null) {
-      Iterator iter = javaProps.entrySet().iterator();
-      while (iter.hasNext()) {
-        Map.Entry entry = (Map.Entry)iter.next();
-        System.setProperty((String)entry.getKey(), (String)entry.getValue());
-      }
-    }
-  }
-
-  private static void removeJavaProperties(Properties javaProps) {
-
-    if (javaProps != null) {
-      Properties props = System.getProperties();
-      Iterator iter = javaProps.keySet().iterator();
-      while (iter.hasNext()) {
-        props.remove(iter.next());
-      }
-      System.setProperties(props);
-    }
+  protected static void registerExpectedExceptions(String[] expectedExceptions) {
+    SecurityTestUtil.ignoredExceptions = expectedExceptions;
   }
 
-  public static Integer createCacheServer(Properties authProps,
-      Object javaProps, Integer dsPort, String locatorString,
-      Integer serverPort, Integer expectedResult) {
-
-    return createCacheServer(authProps, javaProps, dsPort, locatorString,
-        serverPort, Boolean.FALSE, expectedResult);
+  protected static int createCacheServer(Properties authProps, Properties javaProps, int dsPort, String locatorString, int serverPort, int expectedResult) {
+    return createCacheServer(authProps, javaProps, dsPort, locatorString, serverPort, false, expectedResult);
   }
 
-  public static Integer createCacheServer(Properties authProps,
-      Object javaProps, Integer locatorPort, String locatorString,
-      Integer serverPort, Boolean setupDynamicRegionFactory,
-      Integer expectedResult) {
-
+  protected static int createCacheServer(Properties authProps, Properties javaProps, int locatorPort, String locatorString, int serverPort, boolean setupDynamicRegionFactory, int expectedResult) {
     if (authProps == null) {
       authProps = new Properties();
     }
     authProps.setProperty(DistributionConfig.MCAST_PORT_NAME, "0");
     if (locatorString != null && locatorString.length() > 0) {
       authProps.setProperty(DistributionConfig.LOCATORS_NAME, locatorString);
-      if (locatorPort != null) {
-        authProps.setProperty(DistributionConfig.START_LOCATOR_NAME,
-            getIPLiteral() + "[" + locatorPort.toString() + ']');
-      }
+      authProps.setProperty(DistributionConfig.START_LOCATOR_NAME, getIPLiteral() + "[" + locatorPort + ']');
     } else {
       authProps.setProperty("locators", "localhost["+getDUnitLocatorPort()+"]");
     }
     authProps.setProperty(DistributionConfig.SECURITY_LOG_LEVEL_NAME, "finest");
-    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Set the server properties to: " + authProps);
-    com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Set the java properties to: " + javaProps);
+    getLogWriter().info("Set the server properties to: " + authProps);
+    getLogWriter().info("Set the java properties to: " + javaProps);
 
     SecurityTestUtil tmpInstance = new SecurityTestUtil("temp");
     try {
-      tmpInstance.createSystem(authProps, (Properties)javaProps);
-      if (expectedResult.intValue() != NO_EXCEPTION) {
+      tmpInstance.createSystem(authProps, javaProps);
+      if (expectedResult != NO_EXCEPTION) {
         fail("Expected a security exception when starting peer");
       }
     }
     catch (AuthenticationRequiredException ex) {
-      if (expectedResult.intValue() == AUTHREQ_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when starting peer: " + ex);
-        return new Integer(0);
+      if (expectedResult == AUTHREQ_EXCEPTION) {
+        getLogWriter().info("Got expected exception when starting peer: " + ex);
+        return 0;
       }
       else {
         fail("Got unexpected exception when starting peer", ex);
       }
     }
     catch (AuthenticationFailedException ex) {
-      if (expectedResult.intValue() == AUTHFAIL_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when starting peer: " + ex);
-        return new Integer(0);
+      if (expectedResult == AUTHFAIL_EXCEPTION) {
+        getLogWriter().info("Got expected exception when starting peer: " + ex);
+        return 0;
       }
       else {
         fail("Got unexpected exception when starting peer", ex);
@@ -329,7 +253,7 @@ public final class SecurityTestUtil {
       fail("Got unexpected exception when starting peer", ex);
     }
 
-    if (setupDynamicRegionFactory.booleanValue()) {
+    if (setupDynamicRegionFactory) {
       initDynamicRegionFactory();
     }
     tmpInstance.openCache();
@@ -339,11 +263,11 @@ public final class SecurityTestUtil {
     RegionAttributes attrs = factory.create();
     cache.createRegion(REGION_NAME, attrs);
     int port;
-    if (serverPort == null || serverPort.intValue() <= 0) {
+    if (serverPort <= 0) {
       port = 0;
     }
     else {
-      port = serverPort.intValue();
+      port = serverPort;
     }
     CacheServer server1 = cache.addCacheServer();
     server1.setPort(port);
@@ -354,45 +278,40 @@ public final class SecurityTestUtil {
     catch (Exception ex) {
       fail("Got unexpected exception when starting CacheServer", ex);
     }
-    return new Integer(server1.getPort());
+    return server1.getPort();
   }
 
-  public static void createCacheClient(String authInitModule,
-      Properties authProps, Properties javaProps, Integer[] ports,
-      Object numConnections, Integer expectedResult) {
-    createCacheClient(authInitModule, authProps, javaProps, ports,
-        numConnections, "false", expectedResult);
+  // 1
+  protected static void createCacheClient(String authInitModule, Properties authProps, Properties javaProps, int[] ports, int numConnections, int expectedResult) {
+    createCacheClient(authInitModule, authProps, javaProps, ports, numConnections, false, expectedResult);
   }
 
-  public static void createCacheClient(String authInitModule,
-      Properties authProps, Properties javaProps, Integer[] ports,
-      Object numConnections, String multiUserMode, Integer expectedResult) {
-    createCacheClient(authInitModule, authProps, javaProps, ports,
-        (Integer)numConnections, Boolean.FALSE, multiUserMode, expectedResult);
+  // 2
+  protected static void createCacheClient(String authInitModule, Properties authProps, Properties javaProps, int[] ports, int numConnections, boolean multiUserMode, int expectedResult) {
+    createCacheClient(authInitModule, authProps, javaProps, ports, numConnections, false, multiUserMode, expectedResult);
   }
 
-  public static void createCacheClient(String authInitModule,
-      Properties authProps, Properties javaProps, Integer[] ports,
-      Integer numConnections, Boolean setupDynamicRegionFactory,
-      Integer expectedResult) {
-    createCacheClient(authInitModule, authProps, javaProps, ports,
-        numConnections, setupDynamicRegionFactory, "false", expectedResult);
+  // 3
+  protected static void createCacheClientWithDynamicRegion(String authInitModule, Properties authProps, Properties javaProps, int[] ports, int numConnections, boolean setupDynamicRegionFactory, int expectedResult) {
+    createCacheClient(authInitModule, authProps, javaProps, ports, numConnections, setupDynamicRegionFactory, false, expectedResult);
   }
 
-  public static void createCacheClient(String authInitModule,
-      Properties authProps, Properties javaProps, Integer[] ports,
-      Integer numConnections, Boolean setupDynamicRegionFactory,
-      String multiUserMode, Integer expectedResult) {
+  // 4
+  protected static void createCacheClient(String authInitModule,
+      Properties authProps, Properties javaProps, int[] ports,
+      int numConnections, boolean setupDynamicRegionFactory,
+      boolean multiUserMode, int expectedResult) {
     createCacheClient(authInitModule, authProps, javaProps, ports,
         numConnections, setupDynamicRegionFactory, multiUserMode, Boolean.TRUE,
         expectedResult);
   }
 
-  public static void createCacheClient(String authInitModule,
-      Properties authProps, Properties javaProps, Integer[] ports,
-      Integer numConnections, Boolean setupDynamicRegionFactory,
-      String multiUserMode, Boolean subscriptionEnabled,
-      Integer expectedResult) {
+  // 5
+  protected static void createCacheClient(String authInitModule,
+      Properties authProps, Properties javaProps, int[] ports,
+      int numConnections, boolean setupDynamicRegionFactory,
+      boolean multiUserMode, boolean subscriptionEnabled,
+      int expectedResult) {
 
     multiUserAuthMode = Boolean.valueOf(multiUserMode);
     if (authProps == null) {
@@ -412,7 +331,7 @@ public final class SecurityTestUtil {
     AttributesFactory factory = new AttributesFactory();
     int[] portsI = new int[ports.length];
     for(int z=0;z<ports.length;z++) {
-      portsI[z] = ports[z].intValue();
+      portsI[z] = ports[z];
     }
    
     try {
@@ -427,22 +346,22 @@ public final class SecurityTestUtil {
       }
       pool = ClientServerTestCase.configureConnectionPoolWithNameAndFactory(factory,
           getIPLiteral(), portsI, subscriptionEnabled, 0,
-          numConnections == null ? -1 : numConnections.intValue(), null, null,
+          numConnections, null, null,
           poolFactory);
 
-      if (setupDynamicRegionFactory.booleanValue()) {
+      if (setupDynamicRegionFactory) {
         initClientDynamicRegionFactory(pool.getName());
       }
       tmpInstance.openCache();
       try {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("multi-user mode " + multiUserAuthMode);
+        getLogWriter().info("multi-user mode " + multiUserAuthMode);
         proxyCaches[0] = (ProxyCache)((PoolImpl) pool).createAuthenticatedCacheView(authProps);
         if (!multiUserAuthMode) {
           fail("Expected a UnsupportedOperationException but got none in single-user mode");
         }
       } catch (UnsupportedOperationException uoe) {
         if (!multiUserAuthMode) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected UnsupportedOperationException in single-user mode");
+          getLogWriter().info("Got expected UnsupportedOperationException in single-user mode");
         }
         else {
           fail("Got unexpected exception in multi-user mode ", uoe);
@@ -456,17 +375,17 @@ public final class SecurityTestUtil {
       RegionAttributes attrs = factory.create();
       cache.createRegion(REGION_NAME, attrs);
 
-      if (expectedResult.intValue() != NO_EXCEPTION
-          && expectedResult.intValue() != NOFORCE_AUTHREQ_EXCEPTION) {
+      if (expectedResult != NO_EXCEPTION
+          && expectedResult != NOFORCE_AUTHREQ_EXCEPTION) {
         if (!multiUserAuthMode) {
           fail("Expected an exception when starting client");
         }
       }
     }
     catch (AuthenticationRequiredException ex) {
-      if (expectedResult.intValue() == AUTHREQ_EXCEPTION
-          || expectedResult.intValue() == NOFORCE_AUTHREQ_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
+      if (expectedResult == AUTHREQ_EXCEPTION
+          || expectedResult == NOFORCE_AUTHREQ_EXCEPTION) {
+        getLogWriter().info(
             "Got expected exception when starting client: " + ex);
       }
       else {
@@ -474,8 +393,8 @@ public final class SecurityTestUtil {
       }
     }
     catch (AuthenticationFailedException ex) {
-      if (expectedResult.intValue() == AUTHFAIL_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
+      if (expectedResult == AUTHFAIL_EXCEPTION) {
+        getLogWriter().info(
             "Got expected exception when starting client: " + ex);
       }
       else {
@@ -483,8 +402,8 @@ public final class SecurityTestUtil {
       }
     }
     catch (ServerRefusedConnectionException ex) {
-      if (expectedResult.intValue() == CONNREFUSED_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
+      if (expectedResult == CONNREFUSED_EXCEPTION) {
+        getLogWriter().info(
             "Got expected exception when starting client: " + ex);
       }
       else {
@@ -496,42 +415,29 @@ public final class SecurityTestUtil {
     }
   }
 
-  public static void createCacheClientForMultiUserMode(Integer numOfUsers,
+  protected static void createCacheClientForMultiUserMode(int numOfUsers,
       String authInitModule, Properties[] authProps, Properties javaProps,
-      Integer[] ports, Integer numConnections,
-      Boolean setupDynamicRegionFactory, Integer expectedResult) {
+      int[] ports, int numConnections,
+      boolean setupDynamicRegionFactory, int expectedResult) {
     createCacheClientForMultiUserMode(numOfUsers, authInitModule, authProps,
         javaProps, ports, numConnections, setupDynamicRegionFactory, null,
         expectedResult);
   }
 
-  public static void createCacheClientForMultiUserMode(Integer numOfUsers,
+  protected static void createCacheClientForMultiUserMode(int numOfUsers,
       String authInitModule, Properties[] authProps, Properties javaProps,
-      Integer[] ports, Integer numConnections,
-      Boolean setupDynamicRegionFactory, String durableClientId,
-      Integer expectedResult) {
+      int[] ports, int numConnections,
+      boolean setupDynamicRegionFactory, String durableClientId,
+      int expectedResult) {
 
-    if (numOfUsers == null || numOfUsers < 1) {
+    if (numOfUsers < 1) {
       fail("Number of users cannot be less than one");
     }
     multiUserAuthMode = true;
-    // Assert that number of users == length of arrays of the provided params
-//    if (numOfUsers != authInitModules.length) {
-//      fail("Number of authInitModules provided does not match with numOfUsers specified, "
-//          + authInitModules.length);
-//    }
     if (numOfUsers != authProps.length) {
       fail("Number of authProps provided does not match with numOfUsers specified, "
           + authProps.length);
     }
-//    if (numOfUsers != javaProps.length) {
-//      fail("Number of javaProps provided does not match with numOfUsers specified, "
-//          + javaProps.length);
-//    }
-//    if (numOfUsers != expectedResult.length) {
-//      fail("Number of expectedResult provided does not match with numOfUsers specified, "
-//          + expectedResult.length);
-//    }
     if (authProps[0] == null) {
       authProps[0] = new Properties();
     }
@@ -558,7 +464,7 @@ public final class SecurityTestUtil {
     AttributesFactory factory = new AttributesFactory();
     int[] portsI = new int[ports.length];
     for(int z=0;z<ports.length;z++) {
-      portsI[z] = ports[z].intValue();
+      portsI[z] = ports[z];
     }
    
     try {
@@ -569,10 +475,10 @@ public final class SecurityTestUtil {
       poolFactory.setSubscriptionEnabled(true);
       pool = ClientServerTestCase.configureConnectionPoolWithNameAndFactory(factory,
           getIPLiteral(), portsI, true, 1,
-          numConnections == null ? -1 : numConnections.intValue(), null, null,
+          numConnections, null, null,
           poolFactory);
 
-      if (setupDynamicRegionFactory.booleanValue()) {
+      if (setupDynamicRegionFactory) {
         initClientDynamicRegionFactory(pool.getName());
       }
       proxyCaches = new ProxyCache[numOfUsers];
@@ -585,17 +491,17 @@ public final class SecurityTestUtil {
       RegionAttributes attrs = factory.create();
       cache.createRegion(REGION_NAME, attrs);
 
-      if (expectedResult.intValue() != NO_EXCEPTION
-          && expectedResult.intValue() != NOFORCE_AUTHREQ_EXCEPTION) {
+      if (expectedResult != NO_EXCEPTION
+          && expectedResult != NOFORCE_AUTHREQ_EXCEPTION) {
         if (!multiUserAuthMode) {
           fail("Expected an exception when starting client");
         }
       }
     }
     catch (AuthenticationRequiredException ex) {
-      if (expectedResult.intValue() == AUTHREQ_EXCEPTION
-          || expectedResult.intValue() == NOFORCE_AUTHREQ_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
+      if (expectedResult == AUTHREQ_EXCEPTION
+          || expectedResult == NOFORCE_AUTHREQ_EXCEPTION) {
+        getLogWriter().info(
             "Got expected exception when starting client: " + ex);
       }
       else {
@@ -603,8 +509,8 @@ public final class SecurityTestUtil {
       }
     }
     catch (AuthenticationFailedException ex) {
-      if (expectedResult.intValue() == AUTHFAIL_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
+      if (expectedResult == AUTHFAIL_EXCEPTION) {
+        getLogWriter().info(
             "Got expected exception when starting client: " + ex);
       }
       else {
@@ -612,8 +518,8 @@ public final class SecurityTestUtil {
       }
     }
     catch (ServerRefusedConnectionException ex) {
-      if (expectedResult.intValue() == CONNREFUSED_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
+      if (expectedResult == CONNREFUSED_EXCEPTION) {
+        getLogWriter().info(
             "Got expected exception when starting client: " + ex);
       }
       else {
@@ -625,16 +531,16 @@ public final class SecurityTestUtil {
     }
   }
 
-  public static void createProxyCache(Integer[] userIndices, Properties[] props) {
+  protected static void createProxyCache(Integer[] userIndices, Properties[] props) {
     int j = 0;
     for (int i : userIndices) {
-      SecurityTestUtil.proxyCaches[i] = (ProxyCache)((PoolImpl) SecurityTestUtil.pool)
+      proxyCaches[i] = (ProxyCache)((PoolImpl) pool)
           .createAuthenticatedCacheView(props[j]);
       j++;
     }
   }
 
-  public static void stopCacheServers() {
+  protected static void stopCacheServers() {
     Iterator iter = getCache().getCacheServers().iterator();
     if (iter.hasNext()) {
       CacheServer server = (CacheServer)iter.next();
@@ -643,7 +549,7 @@ public final class SecurityTestUtil {
     }
   }
 
-  public static void restartCacheServers() {
+  protected static void restartCacheServers() {
     Iterator iter = getCache().getCacheServers().iterator();
     if (iter.hasNext()) {
       CacheServer server = (CacheServer)iter.next();
@@ -657,9 +563,8 @@ public final class SecurityTestUtil {
     }
   }
 
-  public static void startLocator(String name, Integer port, Object extraProps,
+  protected static void startLocator(String name, Integer port, Object extraProps,
       Object javaProps, String[] expectedExceptions) {
-
     File logFile = new File(name + "-locator" + port.intValue() + ".log");
     try {
       Properties authProps = new Properties();
@@ -676,7 +581,7 @@ public final class SecurityTestUtil {
       PrintStream logStream = new PrintStream(logOut);
       LogWriter logger = new PureLogWriter(InternalLogWriter.CONFIG_LEVEL,
           logStream);
-      addExpectedExceptions(expectedExceptions, logger);
+      addIgnoredExceptions(expectedExceptions, logger);
       logStream.flush();
       locator = Locator.startLocatorAndDS(port.intValue(), logFile, null,
           authProps);
@@ -686,29 +591,27 @@ public final class SecurityTestUtil {
     }
   }
 
-  public static void stopLocator(Integer port, String[] expectedExceptions) {
-
+  protected static void stopLocator(Integer port, String[] expectedExceptions) {
     try {
       locator.stop();
-      removeExpectedExceptions(expectedExceptions, locator
-          .getDistributedSystem().getLogWriter());
+      removeExpectedExceptions(expectedExceptions, getLogWriter());
     }
     catch (Exception ex) {
       fail("While stopping locator on port " + port.intValue(), ex);
     }
   }
 
-  public static Cache getCache() {
+  protected static Cache getCache() {
     return cache;
   }
 
   // Some useful region methods used by security tests
 
-  public static void waitForCondition(Callable cond) {
+  protected static void waitForCondition(Callable cond) {
     waitForCondition(cond, 100, 120);
   }
 
-  public static void waitForCondition(final Callable cond, int sleepMillis,
+  protected static void waitForCondition(final Callable cond, int sleepMillis,
       int numTries) {
     WaitCriterion ev = new WaitCriterion() {
       public boolean done() {
@@ -727,231 +630,349 @@ public final class SecurityTestUtil {
     waitForCriterion(ev, sleepMillis * numTries, 200, true);
   }
 
-  public static Object getLocalValue(Region region, Object key) {
-
+  protected static Object getLocalValue(Region region, Object key) {
     Region.Entry entry = region.getEntry(key);
     return (entry != null ? entry.getValue() : null);
   }
 
-  public static void doProxyCacheClose() {
-    for (int i=0; i<proxyCaches.length; i++) {
+  protected static void doProxyCacheClose() {
+    for (int i = 0; i< proxyCaches.length; i++) {
       proxyCaches[i].close();
     }
   }
 
-  private static void doPutsP(Integer num, Integer expectedResult,
-      boolean newVals) {
-    doPutsP(num, Integer.valueOf(0), expectedResult, newVals);
+
+  protected static void doPutAllP() throws Exception {
+    Region region = getCache().getRegion(REGION_NAME);
+    assertNotNull(region);
+    Map map = new LinkedHashMap();
+    map.put("1010L", new Employee(1010L, "John", "Doe"));
+    region.putAll(map);
+  }
+  
+  protected static void doPuts(Integer num) {
+    doPutsP(num, new Integer(NO_EXCEPTION), false);
   }
 
-  private static void doPutsP(Integer num, Integer multiUserIndex,
-      Integer expectedResult, boolean newVals) {
+  protected static void doPuts(Integer num, Integer expectedResult) {
+    doPutsP(num, expectedResult, false);
+  }
 
-    assertTrue(num.intValue() <= KEYS.length);
-    Region region = null;
-    try {
-      if (multiUserAuthMode) {
-        region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
-        regionRef = region;
-      }
-      else {
-        region = getCache().getRegion(REGION_NAME);
-      }
-      assertNotNull(region);
+  protected static void doMultiUserPuts(Integer num, Integer numOfUsers,
+      Integer[] expectedResults) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtil.doMultiUserPuts(): numOfUsers = " + numOfUsers
+          + ", but expected results " + expectedResults.length);
     }
-    catch (Exception ex) {
-      if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing puts: " + ex);
-      }
-      else {
-        fail("Got unexpected exception when doing puts", ex);
-      }
+    for (int i = 0; i < numOfUsers; i++) {
+      getLogWriter().info("PUT: MultiUser# " + i);
+      doPutsP(num, Integer.valueOf(i), expectedResults[i], false);
     }
-    for (int index = 0; index < num.intValue(); ++index) {
-      try {
-        if (newVals) {
-          region.put(KEYS[index], nvalues[index]);
-        }
-        else {
-          region.put(KEYS[index], values[index]);
-        }
-        if (expectedResult.intValue() != NO_EXCEPTION) {
-          fail("Expected a NotAuthorizedException while doing puts");
-        }
-      }
-      catch(NoAvailableServersException ex) {
-        if(expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-              "Got expected NoAvailableServers when doing puts: "
-              + ex.getCause());
-          continue;
-        }
-        else {
-          fail("Got unexpected exception when doing puts", ex);
-        }
-      }
-      catch (ServerConnectivityException ex) {
-        if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-            && (ex.getCause() instanceof NotAuthorizedException)) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-              "Got expected NotAuthorizedException when doing puts: "
-                  + ex.getCause());
-          continue;
-        }
-        if ((expectedResult.intValue() == AUTHREQ_EXCEPTION)
-            && (ex.getCause() instanceof AuthenticationRequiredException)) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-              "Got expected AuthenticationRequiredException when doing puts: "
-                  + ex.getCause());
-          continue;
-        }
-        if ((expectedResult.intValue() == AUTHFAIL_EXCEPTION)
-            && (ex.getCause() instanceof AuthenticationFailedException)) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-              "Got expected AuthenticationFailedException when doing puts: "
-                  + ex.getCause());
-          continue;
-        }
-        else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing puts: " + ex);
-        }
-        else {
-          fail("Got unexpected exception when doing puts", ex);
-        }
-      }
-      catch (Exception ex) {
-        if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing puts: " + ex);
-        }
-        else {
-          fail("Got unexpected exception when doing puts", ex);
-        }
-      }
+  }
+
+  protected static void doGets(Integer num) {
+    doGetsP(num, new Integer(NO_EXCEPTION), false);
+  }
+
+  protected static void doGets(Integer num, Integer expectedResult) {
+    doGetsP(num, expectedResult, false);
+  }
+
+  protected static void doMultiUserGetAll(Integer numOfUsers, Integer[] expectedResults) {
+    doMultiUserGetAll(numOfUsers, expectedResults, false);
+  }
+
+  protected static void doMultiUserGetAll(Integer numOfUsers,
+      Integer[] expectedResults, boolean useTX) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtil.doMultiUserGetAll(): numOfUsers = " + numOfUsers
+          + ", but expected results " + expectedResults.length);
+    }
+    for (int i = 0; i < numOfUsers; i++) {
+      getLogWriter().info(
+          "GET_ALL" + (useTX ? " in TX" : "") + ": MultiUser# " + i);
+      doGetAllP(Integer.valueOf(i), expectedResults[i], useTX);
     }
   }
 
-  public static class Employee implements PdxSerializable
-  {
-    private Long Id;
-    private String fname;
-    private String lname;
-    
-    public Employee() {}
-    
-    public Employee(Long id, String fn, String ln){
-      this.Id = id;
-      this.fname = fn;
-      this.lname = ln;
+  protected static void doMultiUserGets(Integer num, Integer numOfUsers,
+      Integer[] expectedResults) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtil.doMultiUserGets(): numOfUsers = " + numOfUsers
+          + ", but expected results " + expectedResults.length);
     }
-        
-    /**
-     * For test purpose, to make sure
-     * the object is not deserialized
-     */
-    @Override
-    public void fromData(PdxReader in) {
-      throw new UnsupportedOperationException();
+    for (int i = 0; i < numOfUsers; i++) {
+      getLogWriter().info("GET: MultiUser# " + i);
+      doGetsP(num, Integer.valueOf(i), expectedResults[i], false);
     }
+  }
 
-    @Override
-    public void toData(PdxWriter out) {
-      out.writeLong("Id", Id);
-      out.writeString("fname", fname);
-      out.writeString("lname", lname);
+  protected static void doMultiUserRegionDestroys(Integer numOfUsers,
+      Integer[] expectedResults) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtil.doMultiUserRegionDestroys(): numOfUsers = " + numOfUsers
+          + ", but expected results " + expectedResults.length);
+    }
+    for (int i = numOfUsers-1; i >= 0; i--) {
+      getLogWriter().info("DESTROY: MultiUser# " + i);
+      doRegionDestroysP(Integer.valueOf(i), expectedResults[i]);
     }
-    
   }
-  
-  public static void doPutAllP() throws Exception {    
-    Region region = getCache().getRegion(REGION_NAME);
-    assertNotNull(region);
-    Map map = new LinkedHashMap();
-    map.put("1010L", new Employee(1010L, "John", "Doe"));
-    region.putAll(map);
+
+  protected static void doMultiUserDestroys(Integer num, Integer numOfUsers,
+      Integer[] expectedResults) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtil.doMultiUserDestroys(): numOfUsers = " + numOfUsers
+          + ", but expected results " + expectedResults.length);
+    }
+    for (int i = 0; i < numOfUsers; i++) {
+      getLogWriter().info("DESTROY: MultiUser# " + i);
+      doDestroysP(num, Integer.valueOf(i), expectedResults[i], false);
+    }
   }
-  
-  private static void doGetAllP(Integer multiUserIndex,
-      Integer expectedResult, boolean useTX) {
-    Region region = null;
-    try {
-      if (multiUserAuthMode) {
-        region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
-      }
-      else {
-        region = getCache().getRegion(REGION_NAME);
-      }
-      assertNotNull(region);
+
+  protected static void doMultiUserInvalidates(Integer num, Integer numOfUsers,
+      Integer[] expectedResults) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtil.doMultiUserInvalidates(): numOfUsers = " + numOfUsers
+          + ", but expected results " + expectedResults.length);
     }
-    catch (Exception ex) {
-      if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing getAll: " + ex);
-      }
-      else {
-        fail("Got unexpected exception when doing getAll", ex);
-      }
+    for (int i = 0; i < numOfUsers; i++) {
+      getLogWriter().info("INVALIDATE: MultiUser# " + i);
+      doInvalidatesP(num, Integer.valueOf(i), expectedResults[i], false);
     }
-    try {
-      List keys = new ArrayList();
-      keys.add("key1");
-      keys.add("key2");
-      if (useTX) {
-        getCache().getCacheTransactionManager().begin();
-      }
-      Map entries = region.getAll(keys);
-      // Also check getEntry()
-      region.getEntry("key1");
-      if (useTX) {
-        getCache().getCacheTransactionManager().commit();
-      }
-      assertNotNull(entries);
-      if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)) {
-        assertEquals(0, entries.size());
-      } else if ((expectedResult.intValue() == NO_EXCEPTION)) {
-        assertEquals(2, entries.size());
-        assertEquals("value1", entries.get("key1"));
-        assertEquals("value2", entries.get("key2"));
+  }
+
+  protected static void doMultiUserContainsKeys(Integer num, Integer numOfUsers,
+      Integer[] expectedResults, Boolean[] results) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtil.doMultiUserContainsKeys(): numOfUsers = " + numOfUsers
+          + ", but #expected results " + expectedResults.length);
+    }
+    if (numOfUsers != results.length) {
+      fail("SecurityTestUtil.doMultiUserContainsKeys(): numOfUsers = " + numOfUsers
+          + ", but #expected output " + results.length);
+    }
+    for (int i = 0; i < numOfUsers; i++) {
+      getLogWriter().info("CONTAINS_KEY: MultiUser# " + i);
+      doContainsKeysP(num, Integer.valueOf(i), expectedResults[i], false, results[i]);
+    }
+  }
+
+  protected static void doMultiUserQueries(Integer numOfUsers,
+      Integer[] expectedResults, Integer valueSize) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtil.doMultiUserQueries(): numOfUsers = " + numOfUsers
+          + ", but #expected results " + expectedResults.length);
+    }
+    for (int i = 0; i < numOfUsers; i++) {
+      getLogWriter().info("QUERY: MultiUser# " + i);
+      doQueriesP(Integer.valueOf(i), expectedResults[i], valueSize);
+    }
+  }
+
+  protected static void doMultiUserFE(Integer numOfUsers, Function function,
+      Integer[] expectedResults, Object[] results, Boolean isFailoverCase) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtil.doMultiUserFE(): numOfUsers = " + numOfUsers
+          + ", but #expected results " + expectedResults.length);
+    }
+    if (numOfUsers != results.length) {
+      fail("SecurityTestUtil.doMultiUserFE(): numOfUsers = " + numOfUsers
+          + ", but #expected output " + results.length);
+    }
+    for (int i = 0; i < numOfUsers; i++) {
+      getLogWriter().info("FunctionExecute:onRegion MultiUser# " + i);
+      doFunctionExecuteP(Integer.valueOf(i), function, expectedResults[i], results[i], "region");
+    }
+    for (int i = 0; i < numOfUsers; i++) {
+      getLogWriter().info("FunctionExecute:onServer MultiUser# " + i);
+      doFunctionExecuteP(Integer.valueOf(i), function, expectedResults[i], results[i], "server");
+    }
+    if (!isFailoverCase) {
+      for (int i = 0; i < numOfUsers; i++) {
+        getLogWriter().info("FunctionExecute:onServers MultiUser# " + i);
+        doFunctionExecuteP(Integer.valueOf(i), function, expectedResults[i],
+            results[i], "servers");
       }
-    } catch (NoAvailableServersException ex) {
-      if (expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-            "Got expected NoAvailableServers when doing getAll: "
-                + ex.getCause());
-      } else {
-        fail("Got unexpected exception when doing getAll", ex);
+    }
+  }
+
+  protected static void doMultiUserQueryExecute(Integer numOfUsers,
+      Integer[] expectedResults, Integer result) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtil.doMultiUserFE(): numOfUsers = " + numOfUsers
+          + ", but #expected results " + expectedResults.length);
+    }
+    for (int i = 0; i < numOfUsers; i++) {
+      getLogWriter().info("QueryExecute: MultiUser# " + i);
+      doQueryExecuteP(Integer.valueOf(i), expectedResults[i], result);
+    }
+  }
+
+  protected static void doLocalGets(Integer num) {
+    doLocalGetsP(num.intValue(), false);
+  }
+
+  protected static void doNPuts(Integer num) {
+    doPutsP(num, new Integer(NO_EXCEPTION), true);
+  }
+
+  protected static void doNPuts(Integer num, Integer expectedResult) {
+    doPutsP(num, expectedResult, true);
+  }
+
+  protected static void doNGets(Integer num) {
+    doGetsP(num, new Integer(NO_EXCEPTION), true);
+  }
+
+  protected static void doNGets(Integer num, Integer expectedResult) {
+    doGetsP(num, expectedResult, true);
+  }
+
+  protected static void doNLocalGets(Integer num) {
+    doLocalGetsP(num.intValue(), true);
+  }
+
+  protected static void doSimpleGet(String expectedResult) {
+    if (regionRef != null) {
+      try {
+        regionRef.get("KEY");
+        if (expectedResult != null && expectedResult.endsWith("Exception")) {
+          fail("Expected " + expectedResult + " but found none in doSimpleGet()");
+        }
+      } catch (Exception e) {
+        if (!e.getClass().getSimpleName().endsWith(expectedResult)) {
+          fail("Expected " + expectedResult + " but found "
+              + e.getClass().getSimpleName() + " in doSimpleGet()");
+        } else {
+          getLogWriter().fine(
+              "Got expected " + e.getClass().getSimpleName()
+                  + " in doSimpleGet()");
+        }
       }
-    } catch (ServerConnectivityException ex) {
-      if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-          && (ex.getCause() instanceof NotAuthorizedException)) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-            "Got expected NotAuthorizedException when doing getAll: "
-                + ex.getCause());
-      } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing getAll: " + ex);
-      } else {
-        fail("Got unexpected exception when doing getAll", ex);
+    }
+  }
+
+  protected static void doSimplePut(String expectedResult) {
+    if (regionRef != null) {
+      try {
+        regionRef.put("KEY", "VALUE");
+        if (expectedResult != null && expectedResult.endsWith("Exception")) {
+          fail("Expected " + expectedResult + " but found none in doSimplePut()");
+        }
+      } catch (Exception e) {
+        if (!e.getClass().getSimpleName().endsWith(expectedResult)) {
+          fail("Expected " + expectedResult + " but found "
+              + e.getClass().getSimpleName() + " in doSimplePut()", e);
+        } else {
+          getLogWriter().fine(
+              "Got expected " + e.getClass().getSimpleName()
+                  + " in doSimplePut()");
+        }
       }
-    } catch (Exception ex) {
-      if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing getAll: " + ex);
-      } else {
-        fail("Got unexpected exception when doing getAll", ex);
+    }
+  }
+
+  // This is a hack using reflection to clear the static objects in JSSE since
+  // otherwise changing the javax.* store related properties has no effect
+  // during the course of running dunit suite unless the VMs are restarted.
+  protected static void clearStaticSSLContext() {
+    ServerSocketFactory defaultServerFact = SSLServerSocketFactory.getDefault();
+    // Get the class of this and use reflection to blank out any static
+    // SSLContext objects inside
+    Map contextMap = getSSLFields(defaultServerFact, new Class[] {
+        SSLContext.class, SSLContextSpi.class });
+    makeNullSSLFields(defaultServerFact, contextMap);
+    Iterator contextObjsIter = contextMap.values().iterator();
+    while (contextObjsIter.hasNext()) {
+      Object contextObj = contextObjsIter.next();
+      Map contextObjsMap = getSSLFields(contextObj, new Class[] {
+          TrustManager.class, KeyManager.class, TrustManager[].class,
+          KeyManager[].class });
+      makeNullSSLFields(contextObj, contextObjsMap);
+    }
+    makeNullStaticField(SSLServerSocketFactory.class);
+
+    // Do the same for normal SSL socket factory
+    SocketFactory defaultFact = SSLSocketFactory.getDefault();
+    contextMap = getSSLFields(defaultFact, new Class[] { SSLContext.class,
+        SSLContextSpi.class });
+    makeNullSSLFields(defaultFact, contextMap);
+    contextObjsIter = contextMap.values().iterator();
+    while (contextObjsIter.hasNext()) {
+      Object contextObj = contextObjsIter.next();
+      Map contextObjsMap = getSSLFields(contextObj, new Class[] {
+          TrustManager.class, KeyManager.class, TrustManager[].class,
+          KeyManager[].class });
+      makeNullSSLFields(contextObj, contextObjsMap);
+    }
+    makeNullStaticField(SSLSocketFactory.class);
+    makeNullStaticField(SSLContext.class);
+  }
+
+  protected static void closeCache() {
+    removeExpectedExceptions(ignoredExceptions, getLogWriter());
+    if (cache != null && !cache.isClosed()) {
+      DistributedSystem sys = cache.getDistributedSystem();
+      cache.close();
+      sys.disconnect();
+      cache = null;
+    }
+    DistributedTestCase.disconnectFromDS();
+  }
+
+  protected static void closeCache(Boolean keepAlive) {
+    removeExpectedExceptions(ignoredExceptions, getLogWriter());
+    if (cache != null && !cache.isClosed()) {
+      DistributedSystem sys = cache.getDistributedSystem();
+      cache.close(keepAlive);
+      sys.disconnect();
+      cache = null;
+    }
+    DistributedTestCase.disconnectFromDS();
+  }
+
+  // ------------------------- private static methods -------------------------
+
+  private static void initClientDynamicRegionFactory(String poolName) {
+    DynamicRegionFactory.get().open(new DynamicRegionFactory.Config(null, poolName, false, true));
+  }
+
+  private static void addJavaProperties(Properties javaProps) {
+    if (javaProps != null) {
+      Iterator iter = javaProps.entrySet().iterator();
+      while (iter.hasNext()) {
+        Map.Entry entry = (Map.Entry)iter.next();
+        System.setProperty((String)entry.getKey(), (String)entry.getValue());
       }
     }
   }
 
-  private static void doGetsP(Integer num, Integer expectedResult,
-      boolean newVals) {
-    doGetsP(num, Integer.valueOf(0), expectedResult, newVals);
+  private static void removeJavaProperties(Properties javaProps) {
+    if (javaProps != null) {
+      Properties props = System.getProperties();
+      Iterator iter = javaProps.keySet().iterator();
+      while (iter.hasNext()) {
+        props.remove(iter.next());
+      }
+      System.setProperties(props);
+    }
   }
 
-  private static void doGetsP(Integer num, Integer multiUserIndex,
-      Integer expectedResult, boolean newVals) {
+  private static void doPutsP(Integer num, Integer expectedResult,
+                              boolean newVals) {
+    doPutsP(num, Integer.valueOf(0), expectedResult, newVals);
+  }
 
+  private static void doPutsP(Integer num, Integer multiUserIndex,
+                              Integer expectedResult, boolean newVals) {
     assertTrue(num.intValue() <= KEYS.length);
     Region region = null;
     try {
       if (multiUserAuthMode) {
         region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
+        regionRef = region;
       }
       else {
         region = getCache().getRegion(REGION_NAME);
@@ -960,157 +981,360 @@ public final class SecurityTestUtil {
     }
     catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing gets: " + ex);
+        getLogWriter().info("Got expected exception when doing puts: " + ex);
       }
       else {
-        fail("Got unexpected exception when doing gets", ex);
+        fail("Got unexpected exception when doing puts", ex);
       }
     }
     for (int index = 0; index < num.intValue(); ++index) {
-      Object value = null;
       try {
-        try {
-          region.localInvalidate(KEYS[index]);
+        if (newVals) {
+          region.put(KEYS[index], NVALUES[index]);
         }
-        catch (Exception ex) {
+        else {
+          region.put(KEYS[index], VALUES[index]);
         }
-        value = region.get(KEYS[index]);
         if (expectedResult.intValue() != NO_EXCEPTION) {
-          fail("Expected a NotAuthorizedException while doing gets");
+          fail("Expected a NotAuthorizedException while doing puts");
         }
       }
       catch(NoAvailableServersException ex) {
-        if(expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-              "Got expected NoAvailableServers when doing gets: "
-              + ex.getCause());
+        if(expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
+          getLogWriter().info(
+                  "Got expected NoAvailableServers when doing puts: "
+                          + ex.getCause());
           continue;
         }
         else {
-          fail("Got unexpected exception when doing gets", ex);
+          fail("Got unexpected exception when doing puts", ex);
         }
       }
       catch (ServerConnectivityException ex) {
         if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-            && (ex.getCause() instanceof NotAuthorizedException)) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-              "Got expected NotAuthorizedException when doing gets: "
-                  + ex.getCause());
+                && (ex.getCause() instanceof NotAuthorizedException)) {
+          getLogWriter().info(
+                  "Got expected NotAuthorizedException when doing puts: "
+                          + ex.getCause());
+          continue;
+        }
+        if ((expectedResult.intValue() == AUTHREQ_EXCEPTION)
+                && (ex.getCause() instanceof AuthenticationRequiredException)) {
+          getLogWriter().info(
+                  "Got expected AuthenticationRequiredException when doing puts: "
+                          + ex.getCause());
+          continue;
+        }
+        if ((expectedResult.intValue() == AUTHFAIL_EXCEPTION)
+                && (ex.getCause() instanceof AuthenticationFailedException)) {
+          getLogWriter().info(
+                  "Got expected AuthenticationFailedException when doing puts: "
+                          + ex.getCause());
           continue;
         }
         else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing gets: " + ex);
+          getLogWriter().info("Got expected exception when doing puts: " + ex);
         }
         else {
-          fail("Got unexpected exception when doing gets", ex);
+          fail("Got unexpected exception when doing puts", ex);
         }
       }
       catch (Exception ex) {
         if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing gets: " + ex);
+          getLogWriter().info("Got expected exception when doing puts: " + ex);
         }
         else {
-          fail("Got unexpected exception when doing gets", ex);
+          fail("Got unexpected exception when doing puts", ex);
         }
       }
-      assertNotNull(value);
-      if (newVals) {
-        assertEquals(nvalues[index], value);
-      }
-      else {
-        assertEquals(values[index], value);
-      }
     }
   }
 
-  private static void doLocalGetsP(int num, boolean checkNVals) {
-
-    assertTrue(num <= KEYS.length);
-    String[] vals = values;
-    if (checkNVals) {
-      vals = nvalues;
-    }
-    final Region region = getCache().getRegion(REGION_NAME);
-    assertNotNull(region);
-    for (int index = 0; index < num; ++index) {
-      final String key = KEYS[index];
-      final String expectedVal = vals[index];
-      waitForCondition(new Callable() {
-        public Object call() throws Exception {
-          Object value = getLocalValue(region, key);
-          return Boolean.valueOf(expectedVal.equals(value));
+  private static HashMap getSSLFields(Object obj, Class[] classes) {
+    HashMap resultFields = new HashMap();
+    Field[] fields = obj.getClass().getDeclaredFields();
+    for (int index = 0; index < fields.length; ++index) {
+      Field field = fields[index];
+      try {
+        field.setAccessible(true);
+        Object fieldObj = field.get(obj);
+        boolean isInstance = false;
+        for (int classIndex = 0; classIndex < classes.length; ++classIndex) {
+          if ((isInstance = classes[classIndex].isInstance(fieldObj)) == true) {
+            break;
+          }
         }
-      }, 1000, 30 / num);
+        if (isInstance) {
+          resultFields.put(field, fieldObj);
+        }
+      }
+      catch (IllegalAccessException ex) {
+        getLogWriter().warning("Exception while getting SSL fields.", ex);
+      }
     }
-    for (int index = 0; index < num; ++index) {
-      Region.Entry entry = region.getEntry(KEYS[index]);
-      assertNotNull(entry);
-      assertEquals(vals[index], entry.getValue());
+    return resultFields;
+  }
+
+  private static void makeNullSSLFields(Object obj, Map fieldMap) {
+    Iterator fieldIter = fieldMap.entrySet().iterator();
+    while (fieldIter.hasNext()) {
+      Map.Entry entry = (Map.Entry)fieldIter.next();
+      Field field = (Field)entry.getKey();
+      Object fieldObj = entry.getValue();
+      try {
+        field.setAccessible(true);
+        makeNullStaticField(fieldObj.getClass());
+        field.set(obj, null);
+        assertNull(field.get(obj));
+      }
+      catch (IllegalAccessException ex) {
+        getLogWriter().warning("Exception while clearing SSL fields.", ex);
+      }
     }
   }
 
-  private static void doRegionDestroysP(Integer multiuserIndex,
-      Integer expectedResult) {
+  // Deal with javax SSL properties
+  private static void makeNullStaticField(Class cls) {
+    Field[] fields = cls.getDeclaredFields();
+    for (int index = 0; index < fields.length; ++index) {
+      Field field = fields[index];
+      try {
+        if (Modifier.isStatic(field.getModifiers())) {
+          field.setAccessible(true);
+          if (field.getClass().equals(boolean.class)) {
+            field.setBoolean(null, false);
+            assertFalse(field.getBoolean(null));
+          }
+          else if (cls.isInstance(field.get(null))) {
+            field.set(null, null);
+            assertNull(field.get(null));
+          }
+        }
+      }
+      catch (IllegalAccessException ex) {
+        getLogWriter()
+                .warning("Exception while clearing static SSL field.", ex);
+      }
+      catch (ClassCastException ex) {
+        getLogWriter()
+                .warning("Exception while clearing static SSL field.", ex);
+      }
+    }
+  }
+
+  private static void doQueryExecuteP(Integer multiUserIndex,
+                                      Integer expectedResult, Integer expectedValue) {
     Region region = null;
     try {
       if (multiUserAuthMode) {
-        region = proxyCaches[multiuserIndex].getRegion(REGION_NAME);
+        region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
       } else {
         region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
     } catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-            "Got expected exception when doing region destroy: " + ex);
+        getLogWriter().info(
+                "Got expected exception when executing query: " + ex);
       } else {
-        fail("Got unexpected exception when doing region destroy", ex);
+        fail("Got unexpected exception when executing query", ex);
+      }
+    }
+    try {
+      String queryString = "SELECT DISTINCT * FROM " + region.getFullPath();
+      Query query = null;
+      if (multiUserAuthMode) {
+        query = proxyCaches[multiUserIndex].getQueryService().newQuery(queryString);
+      }
+      else {
+        region.getCache().getQueryService().newQuery(queryString);
+      }
+      SelectResults result = (SelectResults)query.execute();
+      if (expectedResult.intValue() != NO_EXCEPTION) {
+        fail("Expected a NotAuthorizedException while executing function");
+      }
+      assertEquals(expectedValue.intValue(), result.asList().size());
+    } catch (NoAvailableServersException ex) {
+      if (expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
+        getLogWriter().info(
+                "Got expected NoAvailableServers when executing query: "
+                        + ex.getCause());
+      } else {
+        fail("Got unexpected exception when executing query", ex);
+      }
+    } catch (ServerConnectivityException ex) {
+      if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
+              && (ex.getCause() instanceof NotAuthorizedException)) {
+        getLogWriter().info(
+                "Got expected NotAuthorizedException when executing query: "
+                        + ex.getCause());
+      } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        getLogWriter().info(
+                "Got expected exception when executing query: " + ex);
+      } else {
+        fail("Got unexpected exception when executing query", ex);
+      }
+    } catch (Exception ex) {
+      if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        getLogWriter().info(
+                "Got expected exception when executing query: " + ex);
+      } else {
+        fail("Got unexpected exception when executing query", ex);
       }
     }
+  }
 
+  private static void doFunctionExecuteP(Integer multiUserIndex,
+                                         Function function, Integer expectedResult, Object expectedValue,
+                                         String method) {
+    Region region = null;
     try {
-      region.destroyRegion();
+      if (multiUserAuthMode) {
+        region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
+      } else {
+        region = getCache().getRegion(REGION_NAME);
+      }
+      assertNotNull(region);
+    } catch (Exception ex) {
+      if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        getLogWriter().info(
+                "Got expected exception when executing function: " + ex);
+      } else {
+        fail("Got unexpected exception when executing function", ex);
+      }
+    }
+    try {
+      FunctionService.registerFunction(function);
+      Execution execution = null;
+      if ("region".equals(method)) {
+        execution = FunctionService.onRegion(region);
+      } else if ("server".equals(method)) {
+        if (multiUserAuthMode) {
+          execution = FunctionService.onServer(proxyCaches[multiUserIndex]);
+        } else {
+          execution = FunctionService.onServer(pool);
+        }
+      } else { // if ("servers".equals(method)) {
+        if (multiUserAuthMode) {
+          execution = FunctionService.onServers(proxyCaches[multiUserIndex]);
+        } else {
+          execution = FunctionService.onServers(pool);
+        }
+      }
+      execution.execute(function.getId());
       if (expectedResult.intValue() != NO_EXCEPTION) {
-        fail("Expected a NotAuthorizedException while doing region destroy");
+        fail("Expected a NotAuthorizedException while executing function");
+      }
+    } catch (NoAvailableServersException ex) {
+      if (expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
+        getLogWriter().info(
+                "Got expected NoAvailableServers when executing function: "
+                        + ex.getCause());
+      } else {
+        fail("Got unexpected exception when executing function", ex);
+      }
+    } catch (ServerConnectivityException ex) {
+      if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
+              && (ex.getCause() instanceof NotAuthorizedException)) {
+        getLogWriter().info(
+                "Got expected NotAuthorizedException when executing function: "
+                        + ex.getCause());
+      } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        getLogWriter().info(
+                "Got expected exception when executing function: " + ex);
+      } else {
+        fail("Got unexpected exception when executing function", ex);
+      }
+    } catch (FunctionException ex) {
+      if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
+              && ((ex.getCause() instanceof NotAuthorizedException) || ((ex
+              .getCause() instanceof ServerOperationException) && (((ServerOperationException)ex
+              .getCause()).getCause() instanceof NotAuthorizedException)))) {
+        getLogWriter().info(
+                "Got expected NotAuthorizedException when executing function: "
+                        + ex.getCause());
+      } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        getLogWriter().info(
+                "Got expected exception when executing function: " + ex);
+      } else {
+        fail("Got unexpected exception when executing function", ex);
+      }
+    } catch (Exception ex) {
+      if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        getLogWriter().info(
+                "Got expected exception when executing function: " + ex);
+      } else {
+        fail("Got unexpected exception when executing function", ex);
       }
+    }
+  }
+
+  private static void doQueriesP(Integer multiUserIndex,
+                                 Integer expectedResult, Integer expectedValue) {
+    Region region = null;
+    try {
       if (multiUserAuthMode) {
-        region = proxyCaches[multiuserIndex].getRegion(REGION_NAME);
+        region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
       } else {
         region = getCache().getRegion(REGION_NAME);
       }
-      assertNull(region);
+      assertNotNull(region);
+    } catch (Exception ex) {
+      if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        getLogWriter().info("Got expected exception when doing queries: " + ex);
+      } else {
+        fail("Got unexpected exception when doing queries", ex);
+      }
+    }
+    String queryStr = "SELECT DISTINCT * FROM " + region.getFullPath();
+    try {
+      SelectResults queryResults = region.query(queryStr);
+      Set resultSet = queryResults.asSet();
+      assertEquals(expectedValue.intValue(), resultSet.size());
+      if (expectedResult.intValue() != NO_EXCEPTION) {
+        fail("Expected a NotAuthorizedException while doing queries");
+      }
     } catch (NoAvailableServersException ex) {
-      if (expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-            "Got expected NoAvailableServers when doing region destroy: "
-                + ex.getCause());
+      if (expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
+        getLogWriter().info(
+                "Got expected NoAvailableServers when doing queries: "
+                        + ex.getCause());
       } else {
-        fail("Got unexpected exception when doing region destroy", ex);
+        fail("Got unexpected exception when doing queries", ex);
       }
     } catch (ServerConnectivityException ex) {
       if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-          && (ex.getCause() instanceof NotAuthorizedException)) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-            "Got expected NotAuthorizedException when doing region destroy: "
-                + ex.getCause());
+              && (ex.getCause() instanceof NotAuthorizedException)) {
+        getLogWriter().info(
+                "Got expected NotAuthorizedException when doing queries: "
+                        + ex.getCause());
       } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-            "Got expected exception when doing region destroy: " + ex);
+        getLogWriter().info("Got expected exception when doing queries: " + ex);
       } else {
-        fail("Got unexpected exception when doing region destroy", ex);
+        fail("Got unexpected exception when doing queries", ex);
+      }
+    } catch (QueryInvocationTargetException qite) {
+      if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
+              && (qite.getCause() instanceof NotAuthorizedException)) {
+        getLogWriter().info(
+                "Got expected NotAuthorizedException when doing queries: "
+                        + qite.getCause());
+      } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        getLogWriter().info("Got expected exception when doing queries: " + qite);
+      } else {
+        fail("Got unexpected exception when doing queries", qite);
       }
     } catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-            "Got expected exception when doing region destroy: " + ex);
+        getLogWriter().info("Got expected exception when doing queries: " + ex);
       } else {
-        fail("Got unexpected exception when doing region destroy", ex);
+        fail("Got unexpected exception when doing queries", ex);
       }
     }
   }
-  
-  private static void doDestroysP(Integer num, Integer multiUserIndex,
-      Integer expectedResult, boolean newVals) {
+
+  private static void doContainsKeysP(Integer num, Integer multiUserIndex,
+                                      Integer expectedResult, boolean newVals, boolean expectedValue) {
 
     assertTrue(num.intValue() <= KEYS.length);
     Region region = null;
@@ -1125,59 +1349,60 @@ public final class SecurityTestUtil {
     }
     catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing destroys: " + ex);
+        getLogWriter().info("Got expected exception when doing containsKey: " + ex);
       }
       else {
-        fail("Got unexpected exception when doing destroys", ex);
+        fail("Got unexpected exception when doing containsKey", ex);
       }
     }
     for (int index = 0; index < num.intValue(); ++index) {
+      boolean result = false;
       try {
-        region.destroy(KEYS[index]);
+        result = region.containsKeyOnServer(KEYS[index]);
         if (expectedResult.intValue() != NO_EXCEPTION) {
-          fail("Expected a NotAuthorizedException while doing destroys");
+          fail("Expected a NotAuthorizedException while doing containsKey");
         }
       }
       catch(NoAvailableServersException ex) {
-        if(expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-              "Got expected NoAvailableServers when doing destroys: "
-              + ex.getCause());
+        if(expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
+          getLogWriter().info(
+                  "Got expected NoAvailableServers when doing containsKey: "
+                          + ex.getCause());
           continue;
         }
         else {
-          fail("Got unexpected exception when doing destroys", ex);
+          fail("Got unexpected exception when doing containsKey", ex);
         }
       }
       catch (ServerConnectivityException ex) {
         if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-            && (ex.getCause() instanceof NotAuthorizedException)) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-              "Got expected NotAuthorizedException when doing destroys: "
-                  + ex.getCause());
+                && (ex.getCause() instanceof NotAuthorizedException)) {
+          getLogWriter().info(
+                  "Got expected NotAuthorizedException when doing containsKey: "
+                          + ex.getCause());
           continue;
         }
         else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing destroys: " + ex);
+          getLogWriter().info("Got expected exception when doing containsKey: " + ex);
         }
         else {
-          fail("Got unexpected exception when doing destroys", ex);
+          fail("Got unexpected exception when doing containsKey", ex);
         }
       }
       catch (Exception ex) {
         if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing destroys: " + ex);
+          getLogWriter().info("Got expected exception when doing containsKey: " + ex);
         }
         else {
-          fail("Got unexpected exception when doing destroys", ex);
+          fail("Got unexpected exception when doing containsKey", ex);
         }
       }
+      assertEquals(expectedValue, result);
     }
   }
 
   private static void doInvalidatesP(Integer num, Integer multiUserIndex,
-      Integer expectedResult, boolean newVals) {
-
+                                     Integer expectedResult, boolean newVals) {
     assertTrue(num.intValue() <= KEYS.length);
     Region region = null;
     try {
@@ -1191,7 +1416,7 @@ public final class SecurityTestUtil {
     }
     catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing invalidates: " + ex);
+        getLogWriter().info("Got expected exception when doing invalidates: " + ex);
       }
       else {
         fail("Got unexpected exception when doing invalidates", ex);
@@ -1205,10 +1430,10 @@ public final class SecurityTestUtil {
         }
       }
       catch(NoAvailableServersException ex) {
-        if(expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-              "Got expected NoAvailableServers when doing invalidates: "
-              + ex.getCause());
+        if(expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
+          getLogWriter().info(
+                  "Got expected NoAvailableServers when doing invalidates: "
+                          + ex.getCause());
           continue;
         }
         else {
@@ -1217,14 +1442,14 @@ public final class SecurityTestUtil {
       }
       catch (ServerConnectivityException ex) {
         if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-            && (ex.getCause() instanceof NotAuthorizedException)) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-              "Got expected NotAuthorizedException when doing invalidates: "
-                  + ex.getCause());
+                && (ex.getCause() instanceof NotAuthorizedException)) {
+          getLogWriter().info(
+                  "Got expected NotAuthorizedException when doing invalidates: "
+                          + ex.getCause());
           continue;
         }
         else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing invalidates: " + ex);
+          getLogWriter().info("Got expected exception when doing invalidates: " + ex);
         }
         else {
           fail("Got unexpected exception when doing invalidates", ex);
@@ -1232,7 +1457,7 @@ public final class SecurityTestUtil {
       }
       catch (Exception ex) {
         if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing invalidates: " + ex);
+          getLogWriter().info("Got expected exception when doing invalidates: " + ex);
         }
         else {
           fail("Got unexpected exception when doing invalidates", ex);
@@ -1241,9 +1466,8 @@ public final class SecurityTestUtil {
     }
   }
 
-  private static void doContainsKeysP(Integer num, Integer multiUserIndex,
-      Integer expectedResult, boolean newVals, boolean expectedValue) {
-
+  private static void doDestroysP(Integer num, Integer multiUserIndex,
+                                  Integer expectedResult, boolean newVals) {
     assertTrue(num.intValue() <= KEYS.length);
     Region region = null;
     try {
@@ -1257,658 +1481,343 @@ public final class SecurityTestUtil {
     }
     catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing containsKey: " + ex);
+        getLogWriter().info("Got expected exception when doing destroys: " + ex);
       }
       else {
-        fail("Got unexpected exception when doing containsKey", ex);
+        fail("Got unexpected exception when doing destroys", ex);
       }
     }
     for (int index = 0; index < num.intValue(); ++index) {
-      boolean result = false;
       try {
-        result = region.containsKeyOnServer(KEYS[index]);
+        region.destroy(KEYS[index]);
         if (expectedResult.intValue() != NO_EXCEPTION) {
-          fail("Expected a NotAuthorizedException while doing containsKey");
+          fail("Expected a NotAuthorizedException while doing destroys");
         }
       }
       catch(NoAvailableServersException ex) {
-        if(expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-              "Got expected NoAvailableServers when doing containsKey: "
-              + ex.getCause());
+        if(expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
+          getLogWriter().info(
+                  "Got expected NoAvailableServers when doing destroys: "
+                          + ex.getCause());
           continue;
         }
         else {
-          fail("Got unexpected exception when doing containsKey", ex);
+          fail("Got unexpected exception when doing destroys", ex);
         }
       }
       catch (ServerConnectivityException ex) {
         if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-            && (ex.getCause() instanceof NotAuthorizedException)) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-              "Got expected NotAuthorizedException when doing containsKey: "
-                  + ex.getCause());
+                && (ex.getCause() instanceof NotAuthorizedException)) {
+          getLogWriter().info(
+                  "Got expected NotAuthorizedException when doing destroys: "
+                          + ex.getCause());
           continue;
         }
         else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing containsKey: " + ex);
+          getLogWriter().info("Got expected exception when doing destroys: " + ex);
         }
         else {
-          fail("Got unexpected exception when doing containsKey", ex);
+          fail("Got unexpected exception when doing destroys", ex);
         }
       }
       catch (Exception ex) {
         if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing containsKey: " + ex);
+          getLogWriter().info("Got expected exception when doing destroys: " + ex);
         }
         else {
-          fail("Got unexpected exception when doing containsKey", ex);
+          fail("Got unexpected exception when doing destroys", ex);
         }
       }
-      assertEquals(expectedValue, result);
     }
   }
 
-  private static void doQueriesP(Integer multiUserIndex,
-      Integer expectedResult, Integer expectedValue) {
+  private static void doRegionDestroysP(Integer multiuserIndex,
+                                        Integer expectedResult) {
     Region region = null;
     try {
       if (multiUserAuthMode) {
-        region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
+        region = proxyCaches[multiuserIndex].getRegion(REGION_NAME);
       } else {
         region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
     } catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing queries: " + ex);
+        getLogWriter().info(
+                "Got expected exception when doing region destroy: " + ex);
       } else {
-        fail("Got unexpected exception when doing queries", ex);
+        fail("Got unexpected exception when doing region destroy", ex);
       }
     }
-    String queryStr = "SELECT DISTINCT * FROM " + region.getFullPath();
+
     try {
-      SelectResults queryResults = region.query(queryStr);
-      Set resultSet = queryResults.asSet();
-      assertEquals(expectedValue.intValue(), resultSet.size());
+      region.destroyRegion();
       if (expectedResult.intValue() != NO_EXCEPTION) {
-        fail("Expected a NotAuthorizedException while doing queries");
+        fail("Expected a NotAuthorizedException while doing region destroy");
       }
-    } catch (NoAvailableServersException ex) {
-      if (expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-            "Got expected NoAvailableServers when doing queries: "
-                + ex.getCause());
+      if (multiUserAuthMode) {
+        region = proxyCaches[multiuserIndex].getRegion(REGION_NAME);
       } else {
-        fail("Got unexpected exception when doing queries", ex);
+        region = getCache().getRegion(REGION_NAME);
       }
-    } catch (ServerConnectivityException ex) {
-      if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-          && (ex.getCause() instanceof NotAuthorizedException)) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-            "Got expected NotAuthorizedException when doing queries: "
-                + ex.getCause());
-      } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing queries: " + ex);
+      assertNull(region);
+    } catch (NoAvailableServersException ex) {
+      if (expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
+        getLogWriter().info(
+                "Got expected NoAvailableServers when doing region destroy: "
+                        + ex.getCause());
       } else {
-        fail("Got unexpected exception when doing queries", ex);
+        fail("Got unexpected exception when doing region destroy", ex);
       }
-    } catch (QueryInvocationTargetException qite) {
+    } catch (ServerConnectivityException ex) {
       if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-          && (qite.getCause() instanceof NotAuthorizedException)) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-            "Got expected NotAuthorizedException when doing queries: "
-                + qite.getCause());
+              && (ex.getCause() instanceof NotAuthorizedException)) {
+        getLogWriter().info(
+                "Got expected NotAuthorizedException when doing region destroy: "
+                        + ex.getCause());
       } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing queries: " + qite);
+        getLogWriter().info(
+                "Got expected exception when doing region destroy: " + ex);
       } else {
-        fail("Got unexpected exception when doing queries", qite);
+        fail("Got unexpected exception when doing region destroy", ex);
       }
     } catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info("Got expected exception when doing queries: " + ex);
+        getLogWriter().info(
+                "Got expected exception when doing region destroy: " + ex);
       } else {
-        fail("Got unexpected exception when doing queries", ex);
+        fail("Got unexpected exception when doing region destroy", ex);
       }
     }
   }
 
-  private static void doFunctionExecuteP(Integer multiUserIndex,
-      Function function, Integer expectedResult, Object expectedValue,
-      String method) {
+  private static void doLocalGetsP(int num, boolean checkNVals) {
+    assertTrue(num <= KEYS.length);
+    String[] vals = VALUES;
+    if (checkNVals) {
+      vals = NVALUES;
+    }
+    final Region region = getCache().getRegion(REGION_NAME);
+    assertNotNull(region);
+    for (int index = 0; index < num; ++index) {
+      final String key = KEYS[index];
+      final String expectedVal = vals[index];
+      waitForCondition(new Callable() {
+        public Object call() throws Exception {
+          Object value = getLocalValue(region, key);
+          return Boolean.valueOf(expectedVal.equals(value));
+        }
+      }, 1000, 30 / num);
+    }
+    for (int index = 0; index < num; ++index) {
+      Region.Entry entry = region.getEntry(KEYS[index]);
+      assertNotNull(entry);
+      assertEquals(vals[index], entry.getValue());
+    }
+  }
+
+  private static void doGetAllP(Integer multiUserIndex,
+                                Integer expectedResult, boolean useTX) {
     Region region = null;
     try {
       if (multiUserAuthMode) {
         region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
-      } else {
+      }
+      else {
         region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
-    } catch (Exception ex) {
+    }
+    catch (Exception ex) {
       if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-            "Got expected exception when executing function: " + ex);
-      } else {
-        fail("Got unexpected exception when executing function", ex);
+        getLogWriter().info("Got expected exception when doing getAll: " + ex);
+      }
+      else {
+        fail("Got unexpected exception when doing getAll", ex);
       }
     }
     try {
-      FunctionService.registerFunction(function);
-      Execution execution = null;
-      if ("region".equals(method)) {
-        execution = FunctionService.onRegion(region);
-      } else if ("server".equals(method)) {
-        if (multiUserAuthMode) {
-          execution = FunctionService.onServer(proxyCaches[multiUserIndex]);
-        } else {
-          execution = FunctionService.onServer(pool);
-        }
-      } else { // if ("servers".equals(method)) {
-        if (multiUserAuthMode) {
-          execution = FunctionService.onServers(proxyCaches[multiUserIndex]);
-        } else {
-          execution = FunctionService.onServers(pool);
-        }
+      List keys = new ArrayList();
+      keys.add("key1");
+      keys.add("key2");
+      if (useTX) {
+        getCache().getCacheTransactionManager().begin();
       }
-      execution.execute(function.getId());
-      if (expectedResult.intValue() != NO_EXCEPTION) {
-        fail("Expected a NotAuthorizedException while executing function");
+      Map entries = region.getAll(keys);
+      // Also check getEntry()
+      region.getEntry("key1");
+      if (useTX) {
+        getCache().getCacheTransactionManager().commit();
+      }
+      assertNotNull(entries);
+      if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)) {
+        assertEquals(0, entries.size());
+      } else if ((expectedResult.intValue() == NO_EXCEPTION)) {
+        assertEquals(2, entries.size());
+        assertEquals("value1", entries.get("key1"));
+        assertEquals("value2", entries.get("key2"));
       }
     } catch (NoAvailableServersException ex) {
-      if (expectedResult.intValue() == SecurityTestUtil.NO_AVAILABLE_SERVERS) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-            "Got expected NoAvailableServers when executing function: "
-                + ex.getCause());
+      if (expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
+        getLogWriter().info(
+                "Got expected NoAvailableServers when doing getAll: "
+                        + ex.getCause());
       } else {
-        fail("Got unexpected exception when executing function", ex);
+        fail("Got unexpected exception when doing getAll", ex);
       }
     } catch (ServerConnectivityException ex) {
       if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-          && (ex.getCause() instanceof NotAuthorizedException)) {
-        com.gemstone.gemfire.test.dunit.LogWriterUtils.getLogWriter().info(
-            "Got expected NotAuthorizedException when executing function: "
-                + ex.getCause());
-      } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        com.gemstone.gemfire.test.dunit.LogW

<TRUNCATED>


[4/8] incubator-geode git commit: Tests are passing

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java
index 270d0a7..724fa72 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java
@@ -16,9 +16,10 @@
  */
 package com.gemstone.gemfire.security;
 
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.test.dunit.IgnoredException.*;
+
 import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.IgnoredException;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -39,26 +40,20 @@ public class ClientAuthorizationTwoDUnitTest extends ClientAuthorizationTestBase
 
   @Override
   public final void postSetUpClientAuthorizationTestBase() throws Exception {
-    IgnoredException.addIgnoredException("Read timed out");
-    IgnoredException.addIgnoredException("Connection reset");
-    IgnoredException.addIgnoredException("SocketTimeoutException");
-    IgnoredException.addIgnoredException("ServerConnectivityException");
-    IgnoredException.addIgnoredException("Socket Closed");
+    addIgnoredException("Read timed out");
+    addIgnoredException("Connection reset");
+    addIgnoredException("SocketTimeoutException");
+    addIgnoredException("ServerConnectivityException");
+    addIgnoredException("Socket Closed");
   }
 
   @Override
   public final void preTearDownClientAuthorizationTestBase() throws Exception {
-    // close the clients first
-    client1.invoke(() -> SecurityTestUtil.closeCache());
-    client2.invoke(() -> SecurityTestUtil.closeCache());
-    SecurityTestUtil.closeCache();
-    // then close the servers
-    server1.invoke(() -> SecurityTestUtil.closeCache());
-    server2.invoke(() -> SecurityTestUtil.closeCache());
+    closeCache();
   }
 
   @Test
-  public void testAllOpsWithFailover2() {
+  public void testAllOpsWithFailover2() throws Exception {
     runOpsWithFailover(allOps(), "testAllOpsWithFailover2");
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
index 8ef10c1..2a1fa7b 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
@@ -16,6 +16,10 @@
  */
 package com.gemstone.gemfire.security;
 
+import static com.gemstone.gemfire.internal.AvailablePort.*;
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
+
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
@@ -25,7 +29,6 @@ import com.gemstone.gemfire.DataSerializable;
 import com.gemstone.gemfire.Instantiator;
 import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
 import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.security.FilterPostAuthorization;
 import com.gemstone.gemfire.internal.security.FilterPreAuthorization;
 import com.gemstone.gemfire.internal.security.ObjectWithAuthz;
@@ -33,8 +36,6 @@ import com.gemstone.gemfire.security.generator.CredentialGenerator;
 import com.gemstone.gemfire.security.generator.DummyAuthzCredentialGenerator;
 import com.gemstone.gemfire.security.generator.DummyCredentialGenerator;
 import com.gemstone.gemfire.security.templates.UserPasswordAuthInit;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
 import com.gemstone.gemfire.test.dunit.SerializableRunnable;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import org.junit.Test;
@@ -78,7 +79,7 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase {
   }
   
   @Test
-  public void testAllOpsObjectModWithFailover() {
+  public void testAllOpsObjectModWithFailover() throws Exception {
     OperationWithAction[] allOps = allOps();
 
     TestPostCredentialGenerator tgen = new TestPostCredentialGenerator();
@@ -90,16 +91,17 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase {
     String authInit = credentialGenerator.getAuthInit();
     String authenticator = credentialGenerator.getAuthenticator();
 
-    LogWriterUtils.getLogWriter().info("testPutsGetsObjectModWithFailover: Using authinit: " + authInit);
-    LogWriterUtils.getLogWriter().info("testPutsGetsObjectModWithFailover: Using authenticator: " + authenticator);
-    LogWriterUtils.getLogWriter().info("testPutsGetsObjectModWithFailover: Using pre-operation accessor: " + preAccessor);
-    LogWriterUtils.getLogWriter().info("testPutsGetsObjectModWithFailover: Using post-operation accessor: " + postAccessor);
+    getLogWriter().info("testPutsGetsObjectModWithFailover: Using authinit: " + authInit);
+    getLogWriter().info("testPutsGetsObjectModWithFailover: Using authenticator: " + authenticator);
+    getLogWriter().info("testPutsGetsObjectModWithFailover: Using pre-operation accessor: " + preAccessor);
+    getLogWriter().info("testPutsGetsObjectModWithFailover: Using post-operation accessor: " + postAccessor);
 
     // Start servers with all required properties
     Properties serverProps = buildProperties(authenticator, extraProps, preAccessor, postAccessor);
+
     // Get ports for the servers
-    Integer port1 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
-    Integer port2 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+    int port1 = getRandomAvailablePort(SOCKET);
+    int port2 =getRandomAvailablePort(SOCKET);
 
     // Perform all the ops on the clients
     List opBlock = new ArrayList();
@@ -112,13 +114,13 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase {
         // End of current operation block; execute all the operations on the servers with failover
         if (opBlock.size() > 0) {
           // Start the first server and execute the operation block
-          server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port1, serverProps, javaProps ));
-          server2.invoke(() -> SecurityTestUtil.closeCache());
+          server1.invoke(() -> createCacheServer(getLocatorPort(), port1, serverProps, javaProps ));
+          server2.invoke(() -> closeCache());
           executeOpBlock(opBlock, port1, port2, authInit, extraProps, null, tgen, rnd);
           if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
             // Failover to the second server and run the block again
-            server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port2, serverProps, javaProps ));
-            server1.invoke(() -> SecurityTestUtil.closeCache());
+            server2.invoke(() -> createCacheServer(getLocatorPort(), port2, serverProps, javaProps ));
+            server1.invoke(() -> closeCache());
             executeOpBlock(opBlock, port1, port2, authInit, extraProps, null, tgen, rnd);
           }
           opBlock.clear();
@@ -209,7 +211,7 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase {
   }
 
 
-  private Properties buildProperties(String authenticator, Properties extraProps, String preAccessor, String postAccessor) {
+  private Properties buildProperties(final String authenticator, final Properties extraProps, final String preAccessor, final String postAccessor) {
     Properties authProps = new Properties();
     if (authenticator != null) {
       authProps.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator);
@@ -232,7 +234,7 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase {
       this(ObjectWithAuthz.class, ObjectWithAuthz.CLASSID);
     }
 
-    public MyInstantiator(Class clazz, int classId) {
+    public MyInstantiator(final Class clazz, final int classId) {
       super(clazz, classId);
     }
 
@@ -248,7 +250,7 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase {
     }
 
     @Override
-    public Properties getAllowedCredentials(OperationCode[] opCodes, String[] regionNames, int[] keyIndices, int num) {
+    public Properties getAllowedCredentials(final OperationCode[] opCodes, final String[] regionNames, final int[] keyIndices, final int num) {
       int userIndex = 1;
       byte role = DummyAuthzCredentialGenerator.getRequiredRole(opCodes);
       if (role == DummyAuthzCredentialGenerator.READER_ROLE) {
@@ -261,7 +263,7 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase {
     }
 
     @Override
-    public Properties getDisallowedCredentials(OperationCode[] opCodes, String[] regionNames, int[] keyIndices, int num) {
+    public Properties getDisallowedCredentials(final OperationCode[] opCodes, final String[] regionNames, final int[] keyIndices, final int num) {
       int userIndex = 0;
       for (int index = 0; index < keyIndices.length; ++index) {
         if (keyIndices[index] != index) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
index 6bca85f..8d3876f 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
@@ -16,7 +16,12 @@
  */
 package com.gemstone.gemfire.security;
 
+import static com.gemstone.gemfire.internal.AvailablePort.*;
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.Invoke.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
+import static com.gemstone.gemfire.test.dunit.Wait.*;
 
 import java.util.Collection;
 import java.util.HashMap;
@@ -39,17 +44,10 @@ import com.gemstone.gemfire.cache.query.cq.dunit.CqQueryTestListener;
 import com.gemstone.gemfire.cache.query.internal.cq.ClientCQImpl;
 import com.gemstone.gemfire.cache.query.internal.cq.CqService;
 import com.gemstone.gemfire.cache.query.internal.cq.InternalCqQuery;
-import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
-import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-import com.gemstone.gemfire.internal.logging.InternalLogWriter;
 import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
 import com.gemstone.gemfire.security.generator.CredentialGenerator;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.Invoke;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
 import com.gemstone.gemfire.test.dunit.SerializableRunnable;
-import com.gemstone.gemfire.test.dunit.Wait;
 import com.gemstone.gemfire.test.dunit.WaitCriterion;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import org.junit.Test;
@@ -61,30 +59,26 @@ import org.junit.experimental.categories.Category;
 @Category(DistributedTest.class)
 public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestBase {
 
-  private Map<String, String> cqNameToQueryStrings = new HashMap<String, String>();
+  private Map<String, String> cqNameToQueryStrings = new HashMap<>();
 
   @Override
   protected final void preSetUpClientAuthorizationTestBase() throws Exception {
     getSystem();
-    Invoke.invokeInEveryVM(new SerializableRunnable("getSystem") {
+    invokeInEveryVM(new SerializableRunnable("getSystem") {
       public void run() {
         getSystem();
       }
     });
-  }
-
-  @Override
-  protected final void postSetUpClientAuthorizationTestBase() throws Exception {
     this.cqNameToQueryStrings.put("CQ_0", "SELECT * FROM ");
     this.cqNameToQueryStrings.put("CQ_1", "SELECT * FROM ");
   }
 
   @Override
   public final void preTearDownClientAuthorizationTestBase() throws Exception {
-    client1.invoke(() -> SecurityTestUtil.closeCache());
-    client2.invoke(() -> SecurityTestUtil.closeCache());
-    server1.invoke(() -> SecurityTestUtil.closeCache());
-    server2.invoke(() -> SecurityTestUtil.closeCache());
+    client1.invoke(() -> closeCache());
+    client2.invoke(() -> closeCache());
+    server1.invoke(() -> closeCache());
+    server2.invoke(() -> closeCache());
     this.cqNameToQueryStrings.clear();
   }
 
@@ -97,7 +91,7 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
      * Client2 does some operations on the region which satisfies both the CQs
      * Validate that listeners for both the CQs are invoked.
      */
-    doStartUp(Integer.valueOf(2), Integer.valueOf(5), new Boolean[] {true, true});
+    doStartUp(2, 5, new boolean[] {true, true}, false);
   }
 
   @Test
@@ -109,7 +103,7 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
      * Client2 does some operations on the region which satisfies both the CQs
      * Validate that listeners for none of the CQs are invoked.
      */
-    doStartUp(Integer.valueOf(2), Integer.valueOf(5), new Boolean[] {false, false});
+    doStartUp(2, 5, new boolean[] {false, false}, false);
   }
 
   @Test
@@ -122,7 +116,7 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
      * Client2 does some operations on the region which satisfies both the CQs
      * Validate that listener for User1's CQ is invoked but that for User2's CQ is not invoked.
      */
-    doStartUp(Integer.valueOf(2), Integer.valueOf(5), new Boolean[] {true, false});
+    doStartUp(2, 5, new boolean[] {true, false}, false);
   }
 
   @Test
@@ -137,14 +131,10 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
      * Client2 does some operations on the region which satisfies both the CQs
      * Validate that listeners for both the CQs are get updates.
      */
-    doStartUp(Integer.valueOf(2), Integer.valueOf(5), new Boolean[] {true, true}, Boolean.TRUE);
-  }
-
-  private void doStartUp(Integer numOfUsers, Integer numOfPuts, Boolean[] postAuthzAllowed) throws Exception {
-    doStartUp(numOfUsers, numOfPuts, postAuthzAllowed, Boolean.FALSE /* failover */);
+    doStartUp(2, 5, new boolean[] {true, true}, true);
   }
 
-  private void doStartUp(Integer numOfUsers, Integer numOfPuts, Boolean[] postAuthzAllowed, Boolean failover) throws Exception {
+  private void doStartUp(final int numOfUsers, final int numOfPuts, final boolean[] postAuthzAllowed, final boolean failover) throws Exception {
     AuthzCredentialGenerator authzGenerator = getXmlAuthzGenerator();
     CredentialGenerator credentialGenerator = authzGenerator.getCredentialGenerator();
     Properties extraAuthProps = credentialGenerator.getSystemProperties();
@@ -170,78 +160,78 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
     Properties[] authProps = new Properties[numOfUsers];
     for (int i = 0; i < numOfUsers; i++) {
       int rand = rnd.nextInt(100) + 1;
+
       if (postAuthzAllowed[i]) {
-        opCredentials = tgen.getAllowedCredentials(new OperationCode[] {OperationCode.EXECUTE_CQ, OperationCode.GET}, /* For callback, GET should be allowed */ new String[] {regionName}, indices, rand);
+        // For callback, GET should be allowed
+        opCredentials = tgen.getAllowedCredentials(new OperationCode[] {OperationCode.EXECUTE_CQ, OperationCode.GET}, new String[] {REGION_NAME}, indices, rand);
       } else {
-        opCredentials = tgen.getDisallowedCredentials(new OperationCode[] { OperationCode.GET}, /* For callback, GET should be disallowed */ new String[] {regionName}, indices, rand);
+        // For callback, GET should be disallowed
+        opCredentials = tgen.getDisallowedCredentials(new OperationCode[] { OperationCode.GET}, new String[] {REGION_NAME}, indices, rand);
       }
-      authProps[i] = SecurityTestUtil.concatProperties(new Properties[] {opCredentials, extraAuthProps, extraAuthzProps});
+
+      authProps[i] = concatProperties(new Properties[] {opCredentials, extraAuthProps, extraAuthzProps});
     }
 
     // Get ports for the servers
-    Integer port1 = Integer.valueOf(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
-    Integer port2 = Integer.valueOf(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
-    Integer locatorPort = Integer.valueOf(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+    int port1 = getRandomAvailablePort(SOCKET);
+    int port2 = getRandomAvailablePort(SOCKET);
+    int locatorPort = getRandomAvailablePort(SOCKET);
 
     // Close down any running servers
-    server1.invoke(() -> SecurityTestUtil.closeCache());
-    server2.invoke(() -> SecurityTestUtil.closeCache());
+    server1.invoke(() -> closeCache());
+    server2.invoke(() -> closeCache());
 
     server1.invoke(() -> createServerCache(serverProps, javaProps, locatorPort, port1));
-    client1.invoke(() -> createClientCache(javaProps2, authInit, authProps, new Integer[] {port1, port2}, numOfUsers, postAuthzAllowed));
-    client2.invoke(() -> createClientCache(javaProps2, authInit, authProps, new Integer[] {port1, port2}, numOfUsers, postAuthzAllowed));
+    client1.invoke(() -> createClientCache(javaProps2, authInit, authProps, new int[] {port1, port2}, numOfUsers, postAuthzAllowed));
+    client2.invoke(() -> createClientCache(javaProps2, authInit, authProps, new int[] {port1, port2}, numOfUsers, postAuthzAllowed));
 
     client1.invoke(() -> createCQ(numOfUsers));
-    client1.invoke(() -> executeCQ(numOfUsers, new Boolean[] {false, false}, numOfPuts, new String[numOfUsers], postAuthzAllowed));
+    client1.invoke(() -> executeCQ(numOfUsers, new boolean[] {false, false}, numOfPuts, new String[numOfUsers], postAuthzAllowed));
 
-    client2.invoke(() -> doPuts(numOfPuts, Boolean.TRUE/* put last key */));
+    client2.invoke(() -> doPuts(numOfPuts, true/* put last key */));
 
     if (!postAuthzAllowed[0]) {
       // There is no point waiting as no user is authorized to receive cq events.
       try {Thread.sleep(1000);} catch (InterruptedException ie) {} // TODO: replace with Awaitility
     } else {
-      client1.invoke(() -> waitForLastKey(Integer.valueOf(0)));
+      client1.invoke(() -> waitForLastKey(0));
       if (postAuthzAllowed[1]) {
-        client1.invoke(() -> waitForLastKey(Integer.valueOf(1)));
+        client1.invoke(() -> waitForLastKey(1));
       }
     }
 
     client1.invoke(() -> checkCQListeners(numOfUsers, postAuthzAllowed, numOfPuts + 1/* last key */, 0, !failover));
+
     if (failover) {
       server2.invoke(() -> createServerCache(serverProps, javaProps, locatorPort, port2));
-      server1.invoke(() -> SecurityTestUtil.closeCache());
+      server1.invoke(() -> closeCache());
 
       // Allow time for client1 to register its CQs on server2
-      server2.invoke(() -> allowCQsToRegister(Integer.valueOf(2)));
+      server2.invoke(() -> allowCQsToRegister(2));
 
-      client2.invoke(() -> doPuts(numOfPuts, Boolean.TRUE/* put last key */));
-      client1.invoke(() -> waitForLastKeyUpdate(Integer.valueOf(0)));
-      client1.invoke(() -> checkCQListeners(numOfUsers, postAuthzAllowed, numOfPuts + 1/* last key */, numOfPuts + 1/* last key */, Boolean.TRUE));
+      client2.invoke(() -> doPuts(numOfPuts, true/* put last key */));
+      client1.invoke(() -> waitForLastKeyUpdate(0));
+      client1.invoke(() -> checkCQListeners(numOfUsers, postAuthzAllowed, numOfPuts + 1/* last key */, numOfPuts + 1/* last key */, true));
     }
   }
 
-  private void createServerCache(Properties serverProps, Properties javaProps, Integer serverPort) {
-    Integer locatorPort = Integer.valueOf(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
-    SecurityTestUtil.createCacheServer((Properties)serverProps, javaProps, locatorPort, null, serverPort, Boolean.TRUE, Integer.valueOf(SecurityTestUtil.NO_EXCEPTION));
-  }
-
-  private void createServerCache(Properties serverProps, Properties javaProps, Integer locatorPort, Integer serverPort) {
-    SecurityTestUtil.createCacheServer((Properties)serverProps, javaProps, locatorPort, null, serverPort, Boolean.TRUE, Integer.valueOf(SecurityTestUtil.NO_EXCEPTION));
+  private void createServerCache(final Properties serverProps, final Properties javaProps, final int locatorPort, final  int serverPort) {
+    SecurityTestUtil.createCacheServer(serverProps, javaProps, locatorPort, null, serverPort, true, NO_EXCEPTION);
   }
 
-  private void createClientCache(Properties javaProps, String authInit, Properties[] authProps, Integer ports[], Integer numOfUsers, Boolean[] postAuthzAllowed) {
-    SecurityTestUtil.createCacheClientForMultiUserMode(numOfUsers, authInit, authProps, javaProps, ports, null, Boolean.FALSE, SecurityTestUtil.NO_EXCEPTION);
+  private void createClientCache(final Properties javaProps, final String authInit, final Properties[] authProps, final int ports[], final int numOfUsers, final boolean[] postAuthzAllowed) {
+    createCacheClientForMultiUserMode(numOfUsers, authInit, authProps, javaProps, ports, 0, false, NO_EXCEPTION);
   }
 
-  private void createCQ(Integer num) throws CqException, CqExistsException {
+  private void createCQ(final int num) throws CqException, CqExistsException {
     for (int i = 0; i < num; i++) {
-      QueryService cqService = SecurityTestUtil.proxyCaches[i].getQueryService();
+      QueryService cqService = getProxyCaches(i).getQueryService();
       String cqName = "CQ_" + i;
-      String queryStr = cqNameToQueryStrings.get(cqName) + SecurityTestUtil.proxyCaches[i].getRegion(regionName).getFullPath();
+      String queryStr = cqNameToQueryStrings.get(cqName) + getProxyCaches(i).getRegion(REGION_NAME).getFullPath();
 
       // Create CQ Attributes.
       CqAttributesFactory cqf = new CqAttributesFactory();
-      CqListener[] cqListeners = {new CqQueryTestListener(LogWriterUtils.getLogWriter())};
+      CqListener[] cqListeners = {new CqQueryTestListener(getLogWriter())};
       ((CqQueryTestListener)cqListeners[0]).cqName = cqName;
 
       cqf.initCqListeners(cqListeners);
@@ -253,27 +243,24 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
     }
   }
 
-  private void executeCQ(Integer num, Boolean[] initialResults, Integer expectedResultsSize, String[] expectedErr, Boolean[] postAuthzAllowed) throws RegionNotFoundException {
-    InternalLogWriter logWriter = InternalDistributedSystem.getStaticInternalLogWriter();
-
+  private void executeCQ(final int num, final boolean[] initialResults, final int expectedResultsSize, final String[] expectedErr, final boolean[] postAuthzAllowed) throws RegionNotFoundException, CqException {
     for (int i = 0; i < num; i++) {
       try {
         if (expectedErr[i] != null) {
-          logWriter.info("<ExpectedException action=add>" + expectedErr[i] + "</ExpectedException>");
+          getLogWriter().info("<ExpectedException action=add>" + expectedErr[i] + "</ExpectedException>");
         }
         CqQuery cq1 = null;
         String cqName = "CQ_" + i;
-        String queryStr = cqNameToQueryStrings.get(cqName) + SecurityTestUtil.proxyCaches[i].getRegion(regionName).getFullPath();
-        QueryService cqService = SecurityTestUtil.proxyCaches[i].getQueryService();
+        //String queryStr = cqNameToQueryStrings.get(cqName) + getProxyCaches(i).getRegion(REGION_NAME).getFullPath();
+        QueryService cqService = getProxyCaches(i).getQueryService();
 
         // Get CqQuery object.
         cq1 = cqService.getCq(cqName);
         if (cq1 == null) {
-          LogWriterUtils.getLogWriter().info(
-              "Failed to get CqQuery object for CQ name: " + cqName);
+          getLogWriter().info("Failed to get CqQuery object for CQ name: " + cqName);
           fail("Failed to get CQ " + cqName);
         } else {
-          LogWriterUtils.getLogWriter().info("Obtained CQ, CQ name: " + cq1.getName());
+          getLogWriter().info("Obtained CQ, CQ name: " + cq1.getName());
           assertTrue("newCq() state mismatch", cq1.getState().isStopped());
         }
 
@@ -284,16 +271,17 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
             cqResults = cq1.executeWithInitialResults();
           } catch (CqException ce) {
             if (ce.getCause() instanceof NotAuthorizedException && !postAuthzAllowed[i]) {
-              LogWriterUtils.getLogWriter().info("Got expected exception for CQ " + cqName);
+              getLogWriter().info("Got expected exception for CQ " + cqName);
             } else {
-              LogWriterUtils.getLogWriter().info("CqService is: " + cqService);
+              getLogWriter().info("CqService is: " + cqService);
               throw new AssertionError("Failed to execute CQ " + cqName, ce);
             }
           }
-          LogWriterUtils.getLogWriter().info("initial result size = " + cqResults.size());
+
+          getLogWriter().info("initial result size = " + cqResults.size());
           assertTrue("executeWithInitialResults() state mismatch", cq1.getState().isRunning());
           if (expectedResultsSize >= 0) {
-            assertEquals("unexpected results size", expectedResultsSize.intValue(), cqResults.size());
+            assertEquals("unexpected results size", expectedResultsSize, cqResults.size());
           }
 
         } else {
@@ -302,34 +290,24 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
             cq1.execute();
           } catch (CqException ce) {
             if (ce.getCause() instanceof NotAuthorizedException && !postAuthzAllowed[i]) {
-              LogWriterUtils.getLogWriter().info("Got expected exception for CQ " + cqName);
+              getLogWriter().info("Got expected exception for CQ " + cqName);
             } else {
-              LogWriterUtils.getLogWriter().info("CqService is: " + cqService);
-              ce.printStackTrace();
-              throw new AssertionError("Failed to execute CQ " + cqName, ce);
-            }
-
-          } catch (Exception ex) {
-            AssertionError err = new AssertionError("Failed to execute CQ "
-                + cqName);
-            err.initCause(ex);
-            if (expectedErr == null) {
-              LogWriterUtils.getLogWriter().info("CqService is: " + cqService, err);
+              throw ce;
             }
-            throw err;
           }
+
           assertTrue("execute() state mismatch", cq1.getState().isRunning() == postAuthzAllowed[i]);
         }
       } finally {
         if (expectedErr[i] != null) {
-          logWriter.info("<ExpectedException action=remove>" + expectedErr[i] + "</ExpectedException>");
+          getLogWriter().info("<ExpectedException action=remove>" + expectedErr[i] + "</ExpectedException>");
         }
       }
     }
   }
 
-  private void doPuts(Integer num, Boolean putLastKey) {
-    Region region = SecurityTestUtil.proxyCaches[0].getRegion(regionName);
+  private void doPuts(final int num, final boolean putLastKey) {
+    Region region = getProxyCaches(0).getRegion(REGION_NAME);
     for (int i = 0; i < num; i++) {
       region.put("CQ_key"+i, "CQ_value"+i);
     }
@@ -338,28 +316,24 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
     }
   }
 
-  private void putLastKey() {
-    Region region = GemFireCacheImpl.getInstance().getRegion(regionName);
-    region.put("LAST_KEY", "LAST_KEY");
-  }
-
-  private void waitForLastKey(Integer cqIndex) {
+  private void waitForLastKey(final int cqIndex) {
     String cqName = "CQ_" + cqIndex;
-    QueryService qService = SecurityTestUtil.proxyCaches[cqIndex].getQueryService();
+    QueryService qService = SecurityTestUtil.getProxyCaches(cqIndex).getQueryService();
     ClientCQImpl cqQuery = (ClientCQImpl)qService.getCq(cqName);
     ((CqQueryTestListener)cqQuery.getCqListeners()[0]).waitForCreated("LAST_KEY");
   }
 
-  private void waitForLastKeyUpdate(Integer cqIndex) {
+  private void waitForLastKeyUpdate(final int cqIndex) {
     String cqName = "CQ_" + cqIndex;
-    QueryService qService = SecurityTestUtil.proxyCaches[cqIndex].getQueryService();
+    QueryService qService = getProxyCaches(cqIndex).getQueryService();
     ClientCQImpl cqQuery = (ClientCQImpl)qService.getCq(cqName);
     ((CqQueryTestListener)cqQuery.getCqListeners()[0]).waitForUpdated("LAST_KEY");
   }
 
-  private void allowCQsToRegister(Integer number) {
+  private void allowCQsToRegister(final int number) {
     final int num = number;
     WaitCriterion wc = new WaitCriterion() {
+      @Override
       public boolean done() {
         CqService cqService = GemFireCacheImpl.getInstance().getCqService();
         cqService.start();
@@ -370,24 +344,24 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
           return false;
         }
       }
-
+      @Override
       public String description() {
         return num + "Waited for " + num + " CQs to be registered on this server.";
       }
     };
-    Wait.waitForCriterion(wc, 60 * 1000, 100, false);
+    waitForCriterion(wc, 60 * 1000, 100, false);
   }
 
-  private void checkCQListeners(Integer numOfUsers, Boolean[] expectedListenerInvocation, Integer createEventsSize, Integer updateEventsSize, Boolean closeCache) {
+  private boolean checkCQListeners(final int numOfUsers, final boolean[] expectedListenerInvocation, final int createEventsSize, final int updateEventsSize, final boolean closeCache) {
     for (int i = 0; i < numOfUsers; i++) {
       String cqName = "CQ_" + i;
-      QueryService qService = SecurityTestUtil.proxyCaches[i].getQueryService();
+      QueryService qService = getProxyCaches(i).getQueryService();
       ClientCQImpl cqQuery = (ClientCQImpl)qService.getCq(cqName);
 
       if (expectedListenerInvocation[i]) {
         for (CqListener listener : cqQuery.getCqListeners()) {
-          assertEquals(createEventsSize.intValue(), ((CqQueryTestListener)listener).getCreateEventCount());
-          assertEquals(updateEventsSize.intValue(), ((CqQueryTestListener)listener).getUpdateEventCount());
+          assertEquals(createEventsSize, ((CqQueryTestListener)listener).getCreateEventCount());
+          assertEquals(updateEventsSize, ((CqQueryTestListener)listener).getUpdateEventCount());
         }
       } else {
         for (CqListener listener : cqQuery.getCqListeners()) {
@@ -395,8 +369,9 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
         }
       }
       if (closeCache) {
-        SecurityTestUtil.proxyCaches[i].close();
+        getProxyCaches(i).close();
       }
     }
+    return true;
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
index 931a53e..b234741 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
@@ -16,6 +16,9 @@
  */
 package com.gemstone.gemfire.security;
 
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
+
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -26,8 +29,6 @@ import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
 import com.gemstone.gemfire.internal.AvailablePort;
 import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
 import com.gemstone.gemfire.security.generator.CredentialGenerator;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
 import com.gemstone.gemfire.test.junit.Retry;
 import com.gemstone.gemfire.test.junit.categories.DistributedTest;
 import com.gemstone.gemfire.test.junit.rules.RetryRule;
@@ -43,26 +44,14 @@ import org.junit.experimental.categories.Category;
  * @since 5.5
  */
 @Category(DistributedTest.class)
-public class ClientPostAuthorizationDUnitTest extends
-    ClientAuthorizationTestBase {
+public class ClientPostAuthorizationDUnitTest extends ClientAuthorizationTestBase {
 
   @Rule
   public RetryRule retryRule = new RetryRule();
 
-  @Override
-  public final void preTearDownClientAuthorizationTestBase() throws Exception {
-    // close the clients first
-    client1.invoke(() -> SecurityTestUtil.closeCache());
-    client2.invoke(() -> SecurityTestUtil.closeCache());
-    SecurityTestUtil.closeCache();
-    // then close the servers
-    server1.invoke(() -> SecurityTestUtil.closeCache());
-    server2.invoke(() -> SecurityTestUtil.closeCache());
-  }
-
   @Test
   @Retry(2)
-  public void testAllPostOps() {
+  public void testAllPostOps() throws Exception {
     OperationWithAction[] allOps = allOpsForTestAllPostOps();
 
     for (Iterator iter = getDummyGeneratorCombos().iterator(); iter.hasNext();) {
@@ -77,41 +66,39 @@ public class ClientPostAuthorizationDUnitTest extends
       String accessor = gen.getAuthorizationCallback();
       TestAuthzCredentialGenerator tgen = new TestAuthzCredentialGenerator(gen);
 
-      LogWriterUtils.getLogWriter().info("testAllPostOps: Using authinit: " + authInit);
-      LogWriterUtils.getLogWriter().info("testAllPostOps: Using authenticator: " + authenticator);
-      LogWriterUtils.getLogWriter().info("testAllPostOps: Using accessor: " + accessor);
+      getLogWriter().info("testAllPostOps: Using authinit: " + authInit);
+      getLogWriter().info("testAllPostOps: Using authenticator: " + authenticator);
+      getLogWriter().info("testAllPostOps: Using accessor: " + accessor);
 
       // Start servers with all required properties
       Properties serverProps = buildProperties(authenticator, accessor, true, extraAuthProps, extraAuthzProps);
 
       // Get ports for the servers
-      Integer port1 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
-      Integer port2 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+      Integer port1 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+      Integer port2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
 
       // Close down any running servers
-      server1.invoke(() -> SecurityTestUtil.closeCache());
-      server2.invoke(() -> SecurityTestUtil.closeCache());
+      server1.invoke(() -> closeCache());
+      server2.invoke(() -> closeCache());
 
       // Perform all the ops on the clients
       List opBlock = new ArrayList();
       Random rnd = new Random();
 
       for (int opNum = 0; opNum < allOps.length; ++opNum) {
-        // Start client with valid credentials as specified in
-        // OperationWithAction
+        // Start client with valid credentials as specified in OperationWithAction
         OperationWithAction currentOp = allOps[opNum];
         if (currentOp.equals(OperationWithAction.OPBLOCK_END) || currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
-          // End of current operation block; execute all the operations
-          // on the servers with failover
+          // End of current operation block; execute all the operations on the servers with failover
           if (opBlock.size() > 0) {
             // Start the first server and execute the operation block
-            server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port1, serverProps, javaProps ));
-            server2.invoke(() -> SecurityTestUtil.closeCache());
+            server1.invoke(() -> createCacheServer(getLocatorPort(), port1, serverProps, javaProps ));
+            server2.invoke(() -> closeCache());
             executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
             if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
               // Failover to the second server and run the block again
-              server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port2, serverProps, javaProps ));
-              server1.invoke(() -> SecurityTestUtil.closeCache());
+              server2.invoke(() -> createCacheServer(SecurityTestUtil.getLocatorPort(), port2, serverProps, javaProps ));
+              server1.invoke(() -> closeCache());
               executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
             }
             opBlock.clear();
@@ -126,11 +113,13 @@ public class ClientPostAuthorizationDUnitTest extends
   }
 
   @Test
-  public void testAllOpsNotifications() {
+  public void testAllOpsNotifications() throws Exception {
     OperationWithAction[] allOps = allOpsForTestAllOpsNotifications();
 
     AuthzCredentialGenerator authzGenerator = getXmlAuthzGenerator();
-    LogWriterUtils.getLogWriter().info("Executing opblocks with credential generator " + authzGenerator);
+
+    getLogWriter().info("Executing opblocks with credential generator " + authzGenerator);
+
     CredentialGenerator credentialGenerator = authzGenerator.getCredentialGenerator();
     Properties extraAuthProps = credentialGenerator.getSystemProperties();
     Properties javaProps = credentialGenerator.getJavaProperties();
@@ -140,36 +129,34 @@ public class ClientPostAuthorizationDUnitTest extends
     String accessor = authzGenerator.getAuthorizationCallback();
     TestAuthzCredentialGenerator tgen = new TestAuthzCredentialGenerator(authzGenerator);
 
-    LogWriterUtils.getLogWriter().info("testAllOpsNotifications: Using authinit: " + authInit);
-    LogWriterUtils.getLogWriter().info("testAllOpsNotifications: Using authenticator: " + authenticator);
-    LogWriterUtils.getLogWriter().info("testAllOpsNotifications: Using accessor: " + accessor);
+    getLogWriter().info("testAllOpsNotifications: Using authinit: " + authInit);
+    getLogWriter().info("testAllOpsNotifications: Using authenticator: " + authenticator);
+    getLogWriter().info("testAllOpsNotifications: Using accessor: " + accessor);
 
     // Start servers with all required properties
     Properties serverProps = buildProperties(authenticator, accessor, true, extraAuthProps, extraAuthzProps);
     // Get ports for the servers
-    Integer port1 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
-    Integer port2 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+    Integer port1 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+    Integer port2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
 
     // Perform all the ops on the clients
     List opBlock = new ArrayList();
     Random rnd = new Random();
 
     for (int opNum = 0; opNum < allOps.length; ++opNum) {
-      // Start client with valid credentials as specified in
-      // OperationWithAction
+      // Start client with valid credentials as specified in OperationWithAction
       OperationWithAction currentOp = allOps[opNum];
       if (currentOp.equals(OperationWithAction.OPBLOCK_END) || currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
-        // End of current operation block; execute all the operations
-        // on the servers with failover
+        // End of current operation block; execute all the operations on the servers with failover
         if (opBlock.size() > 0) {
           // Start the first server and execute the operation block
-          server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port1, serverProps, javaProps ));
-          server2.invoke(() -> SecurityTestUtil.closeCache());
+          server1.invoke(() -> createCacheServer(getLocatorPort(), port1, serverProps, javaProps ));
+          server2.invoke(() -> closeCache());
           executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
           if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
             // Failover to the second server and run the block again
-            server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port2, serverProps, javaProps ));
-            server1.invoke(() -> SecurityTestUtil.closeCache());
+            server2.invoke(() -> createCacheServer(getLocatorPort(), port2, serverProps, javaProps ));
+            server1.invoke(() -> closeCache());
             executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
           }
           opBlock.clear();
@@ -189,8 +176,7 @@ public class ClientPostAuthorizationDUnitTest extends
         new OperationWithAction(OperationCode.GET, 2, OpFlags.CHECK_NOKEY, 4),
         new OperationWithAction(OperationCode.GET, 3, OpFlags.CHECK_NOKEY | OpFlags.CHECK_NOTAUTHZ, 4),
 
-        // OPBLOCK_END indicates end of an operation block that needs to
-        // be executed on each server when doing failover
+        // OPBLOCK_END indicates end of an operation block that needs to be executed on each server when doing failover
         OperationWithAction.OPBLOCK_END,
 
         // Test UPDATE and verify with a GET
@@ -219,59 +205,40 @@ public class ClientPostAuthorizationDUnitTest extends
         new OperationWithAction(OperationCode.EXECUTE_CQ, 2, OpFlags.NONE, 8),
         new OperationWithAction(OperationCode.EXECUTE_CQ, 3, OpFlags.CHECK_NOTAUTHZ, 8),
 
-        OperationWithAction.OPBLOCK_END };
+        OperationWithAction.OPBLOCK_END
+    };
   }
 
   private OperationWithAction[] allOpsForTestAllOpsNotifications() {
     return new OperationWithAction[]{
         // Test CREATE and verify with a GET
-        new OperationWithAction(OperationCode.REGISTER_INTEREST,
-                OperationCode.GET, 2, OpFlags.USE_REGEX
-                | OpFlags.REGISTER_POLICY_NONE, 8),
-        new OperationWithAction(OperationCode.REGISTER_INTEREST,
-                OperationCode.GET, 3, OpFlags.USE_REGEX
-                | OpFlags.REGISTER_POLICY_NONE | OpFlags.USE_NOTAUTHZ, 8),
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 2, OpFlags.USE_REGEX | OpFlags.REGISTER_POLICY_NONE, 8),
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 3, OpFlags.USE_REGEX | OpFlags.REGISTER_POLICY_NONE | OpFlags.USE_NOTAUTHZ, 8),
         new OperationWithAction(OperationCode.PUT),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-                | OpFlags.LOCAL_OP, 4),
-        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-                | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 4),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 4),
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 4),
 
-        // OPBLOCK_END indicates end of an operation block that needs to
-        // be executed on each server when doing failover
+        // OPBLOCK_END indicates end of an operation block that needs to be executed on each server when doing failover
         OperationWithAction.OPBLOCK_END,
 
         // Test UPDATE and verify with a GET
-        new OperationWithAction(OperationCode.REGISTER_INTEREST,
-                OperationCode.GET, 2, OpFlags.USE_REGEX
-                | OpFlags.REGISTER_POLICY_NONE, 8),
-        new OperationWithAction(OperationCode.REGISTER_INTEREST,
-                OperationCode.GET, 3, OpFlags.USE_REGEX
-                | OpFlags.REGISTER_POLICY_NONE | OpFlags.USE_NOTAUTHZ, 8),
-        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN
-                | OpFlags.USE_NEWVAL, 4),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-                | OpFlags.LOCAL_OP | OpFlags.USE_NEWVAL, 4),
-        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-                | OpFlags.LOCAL_OP | OpFlags.USE_NEWVAL | OpFlags.CHECK_FAIL, 4),
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 2, OpFlags.USE_REGEX | OpFlags.REGISTER_POLICY_NONE, 8),
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 3, OpFlags.USE_REGEX | OpFlags.REGISTER_POLICY_NONE | OpFlags.USE_NOTAUTHZ, 8),
+        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, 4),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.USE_NEWVAL, 4),
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.USE_NEWVAL | OpFlags.CHECK_FAIL, 4),
 
         OperationWithAction.OPBLOCK_END,
 
         // Test DESTROY and verify with GET that KEYS should not exist
         new OperationWithAction(OperationCode.PUT, 3, OpFlags.NONE, 8),
-        new OperationWithAction(OperationCode.REGISTER_INTEREST,
-                OperationCode.GET, 2, OpFlags.USE_REGEX, 8),
-        new OperationWithAction(OperationCode.REGISTER_INTEREST, 3,
-                OpFlags.USE_REGEX | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 8),
-        // registerInterest now clears the KEYS, so a dummy put to add
-        // those KEYS back for the case when updates should not come
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 2, OpFlags.USE_REGEX, 8),
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, 3, OpFlags.USE_REGEX | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 8),
+        // registerInterest now clears the KEYS, so a dummy put to add those KEYS back for the case when updates should not come
         new OperationWithAction(OperationCode.PUT, 3, OpFlags.USE_OLDCONN, 8),
-        new OperationWithAction(OperationCode.DESTROY, 1, OpFlags.USE_OLDCONN,
-                4),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-                | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 4),
-        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-                | OpFlags.LOCAL_OP, 4),
+        new OperationWithAction(OperationCode.DESTROY, 1, OpFlags.USE_OLDCONN, 4),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 4),
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 4),
         // Repopulate the region
         new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN, 8),
 
@@ -279,75 +246,46 @@ public class ClientPostAuthorizationDUnitTest extends
 
         // Do REGION_CLEAR and check with GET
         new OperationWithAction(OperationCode.PUT, 3, OpFlags.NONE, 8),
-        new OperationWithAction(OperationCode.REGISTER_INTEREST,
-                OperationCode.GET, 2, OpFlags.USE_ALL_KEYS, 1),
-        new OperationWithAction(OperationCode.REGISTER_INTEREST, 3,
-                OpFlags.USE_ALL_KEYS | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 1),
-        // registerInterest now clears the KEYS, so a dummy put to add
-        // those KEYS back for the case when updates should not come
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 2, OpFlags.USE_ALL_KEYS, 1),
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, 3, OpFlags.USE_ALL_KEYS | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 1),
+        // registerInterest now clears the KEYS, so a dummy put to add those KEYS back for the case when updates should not come
         new OperationWithAction(OperationCode.PUT, 3, OpFlags.USE_OLDCONN, 8),
-        new OperationWithAction(OperationCode.REGION_CLEAR, 1,
-                OpFlags.USE_OLDCONN, 1),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-                | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 8),
-        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-                | OpFlags.LOCAL_OP, 8),
+        new OperationWithAction(OperationCode.REGION_CLEAR, 1, OpFlags.USE_OLDCONN, 1),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 8),
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 8),
         // Repopulate the region
         new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN, 8),
 
         OperationWithAction.OPBLOCK_END,
 
         // Do REGION_CREATE and check with CREATE/GET
-        new OperationWithAction(OperationCode.REGISTER_INTEREST,
-                OperationCode.GET, 2, OpFlags.USE_ALL_KEYS | OpFlags.ENABLE_DRF, 1),
-        new OperationWithAction(OperationCode.REGISTER_INTEREST,
-                OperationCode.GET, 3, OpFlags.USE_ALL_KEYS | OpFlags.ENABLE_DRF
-                | OpFlags.USE_NOTAUTHZ | OpFlags.REGISTER_POLICY_NONE, 1),
-        new OperationWithAction(OperationCode.REGION_CREATE, 1,
-                OpFlags.ENABLE_DRF, 1),
-        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN
-                | OpFlags.USE_SUBREGION, 4),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-                | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION
-                | OpFlags.NO_CREATE_SUBREGION, 4),
-        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-                | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION
-                | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 2, OpFlags.USE_ALL_KEYS | OpFlags.ENABLE_DRF, 1),
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 3, OpFlags.USE_ALL_KEYS | OpFlags.ENABLE_DRF | OpFlags.USE_NOTAUTHZ | OpFlags.REGISTER_POLICY_NONE, 1),
+        new OperationWithAction(OperationCode.REGION_CREATE, 1, OpFlags.ENABLE_DRF, 1),
+        new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION, 4),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION | OpFlags.NO_CREATE_SUBREGION, 4),
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
 
         // Do REGION_DESTROY of the sub-region and check with GET
-        new OperationWithAction(OperationCode.REGION_DESTROY, 1,
-                OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION, 1),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-                | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION
-                | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-                | OpFlags.USE_SUBREGION | OpFlags.CHECK_NOKEY
-                | OpFlags.CHECK_EXCEPTION, 4),
-        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-                | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION
-                | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
-        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-                | OpFlags.USE_SUBREGION | OpFlags.CHECK_NOKEY
-                | OpFlags.CHECK_EXCEPTION, 4),
+        new OperationWithAction(OperationCode.REGION_DESTROY, 1, OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION, 1),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION | OpFlags.CHECK_NOKEY | OpFlags.CHECK_EXCEPTION, 4),
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION | OpFlags.CHECK_NOKEY | OpFlags.CHECK_EXCEPTION, 4),
 
         OperationWithAction.OPBLOCK_END,
 
         // Do REGION_DESTROY of the region and check with GET
         new OperationWithAction(OperationCode.PUT, 3, OpFlags.NONE, 8),
-        new OperationWithAction(OperationCode.REGISTER_INTEREST,
-                OperationCode.GET, 2, OpFlags.USE_ALL_KEYS, 1),
-        new OperationWithAction(OperationCode.REGISTER_INTEREST, 3,
-                OpFlags.USE_ALL_KEYS | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 1),
-        // registerInterest now clears the KEYS, so a dummy put to add
-        // those KEYS back for the case when updates should not come
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 2, OpFlags.USE_ALL_KEYS, 1),
+        new OperationWithAction(OperationCode.REGISTER_INTEREST, 3, OpFlags.USE_ALL_KEYS | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 1),
+        // registerInterest now clears the KEYS, so a dummy put to add those KEYS back for the case when updates should not come
         new OperationWithAction(OperationCode.PUT, 3, OpFlags.USE_OLDCONN, 8),
-        new OperationWithAction(OperationCode.REGION_DESTROY, 1, OpFlags.NONE,
-                1),
-        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
-                | OpFlags.LOCAL_OP | OpFlags.CHECK_NOREGION, 4),
-        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
-                | OpFlags.LOCAL_OP, 4),
-
-        OperationWithAction.OPBLOCK_NO_FAILOVER};
+        new OperationWithAction(OperationCode.REGION_DESTROY, 1, OpFlags.NONE, 1),
+        new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.CHECK_NOREGION, 4),
+        new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 4),
+
+        OperationWithAction.OPBLOCK_NO_FAILOVER
+    };
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java
index 3cf8cac..931cc6d 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java
@@ -106,7 +106,7 @@ public class MultiUserAPIDUnitTest extends ClientAuthorizationTestBase {
 
     } else { // multiuser mode
       Region realRegion = GemFireCacheImpl.getInstance().getRegion(SecurityTestUtil.REGION_NAME);
-      Region proxyRegion = SecurityTestUtil.proxyCaches[0].getRegion(SecurityTestUtil.REGION_NAME);
+      Region proxyRegion = SecurityTestUtil.getProxyCaches(0).getRegion(SecurityTestUtil.REGION_NAME);
       Pool pool = PoolManagerImpl.getPMI().find("testPool");
 
       for (int i = 0; i <= 27; i++) {
@@ -235,15 +235,15 @@ public class MultiUserAPIDUnitTest extends ClientAuthorizationTestBase {
             // expect an exception, fail otherwise.
             case 23:
               op = "ProxyQueryService().getIndexes()";
-              SecurityTestUtil.proxyCaches[0].getQueryService().getIndexes(null);
+              SecurityTestUtil.getProxyCaches(0).getQueryService().getIndexes(null);
               break;
             case 24:
               op = "ProxyQueryService().createIndex()";
-              SecurityTestUtil.proxyCaches[0].getQueryService().createIndex(null, null, null );
+              SecurityTestUtil.getProxyCaches(0).getQueryService().createIndex(null, null, null );
               break;
             case 25:
               op = "ProxyQueryService().removeIndexes()";
-              SecurityTestUtil.proxyCaches[0].getQueryService().removeIndexes();
+              SecurityTestUtil.getProxyCaches(0).getQueryService().removeIndexes();
               break;
             case 26:
               op = "ProxyRegion.localDestroy()";
@@ -280,40 +280,44 @@ public class MultiUserAPIDUnitTest extends ClientAuthorizationTestBase {
     getLogWriter().info("testValidCredentials: Using authinit: " + authInit);
 
     // Start the servers
-    Integer locPort1 = SecurityTestUtil.getLocatorPort();
-    Integer locPort2 = SecurityTestUtil.getLocatorPort();
+    int locPort1 = SecurityTestUtil.getLocatorPort();
+    int locPort2 = SecurityTestUtil.getLocatorPort();
     String locString = SecurityTestUtil.getLocatorString();
-    Integer port1 = (Integer)server1.invoke(() -> createCacheServer(locPort1, locString, authenticator, extraProps, javaProps));
-    Integer port2 = (Integer)server2.invoke(() -> createCacheServer(locPort2, locString, authenticator, extraProps, javaProps));
+
+    int port1 = server1.invoke(() -> createCacheServer(locPort1, locString, authenticator, extraProps, javaProps));
+    int port2 = server2.invoke(() -> createCacheServer(locPort2, locString, authenticator, extraProps, javaProps));
 
     // Start the clients with valid credentials
     Properties credentials1 = gen.getValidCredentials(1);
     Properties javaProps1 = gen.getJavaProperties();
     getLogWriter().info("testValidCredentials: For first client credentials: " + credentials1 + " : " + javaProps1);
+
     Properties credentials2 = gen.getValidCredentials(2);
     Properties javaProps2 = gen.getJavaProperties();
     getLogWriter().info("testValidCredentials: For second client credentials: " + credentials2 + " : " + javaProps2);
-    client1.invoke(() -> createCacheClient(authInit, credentials1, javaProps1, port1, port2, null, multiUser, new Integer(SecurityTestUtil.NO_EXCEPTION)));
+
+    client1.invoke(() -> createCacheClient(authInit, credentials1, javaProps1, port1, port2, 0, multiUser, NO_EXCEPTION));
   }
 
-  private Integer createCacheServer(Object dsPort, Object locatorString, Object authenticator, Object extraProps, Object javaProps) {
+  private Integer createCacheServer(int dsPort, String locatorString, String authenticator, Properties extraProps, Properties javaProps) {
     Properties authProps = new Properties();
     if (extraProps != null) {
-      authProps.putAll((Properties)extraProps);
+      authProps.putAll(extraProps);
     }
 
     if (authenticator != null) {
       authProps.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator.toString());
     }
-    return SecurityTestUtil.createCacheServer(authProps, javaProps, (Integer)dsPort, (String)locatorString, null, new Integer(SecurityTestUtil.NO_EXCEPTION));
+    return SecurityTestUtil.createCacheServer(authProps, javaProps, dsPort, locatorString, 0, NO_EXCEPTION);
   }
 
-  private void createCacheClient(Object authInit, Object authProps, Object javaProps, Integer port1, Integer port2, Object numConnections, Boolean multiUserMode, Integer expectedResult) {
-    createCacheClient(authInit, (Properties)authProps, (Properties)javaProps, new Integer[] {port1, port2}, numConnections, multiUserMode, expectedResult);
+  // a
+  protected static void createCacheClient(String authInit, Properties authProps, Properties javaProps, int[] ports, int numConnections, boolean multiUserMode, int expectedResult) {
+    SecurityTestUtil.createCacheClient(authInit, authProps, javaProps, ports, numConnections, multiUserMode, expectedResult); // invokes SecurityTestUtil 2
   }
 
-  private void createCacheClient(Object authInit, Properties authProps, Properties javaProps, Integer[] ports, Object numConnections, Boolean multiUserMode, Integer expectedResult) {
-    String authInitStr = (authInit == null ? null : authInit.toString());
-    SecurityTestUtil.createCacheClient(authInitStr, authProps, javaProps, ports, numConnections, multiUserMode.toString(), expectedResult);
+  // b
+  private void createCacheClient(String authInit, Properties authProps, Properties javaProps, int port1, int port2, int numConnections, boolean multiUserMode, int expectedResult) {
+    createCacheClient(authInit, authProps, javaProps, new int[] {port1, port2}, numConnections, multiUserMode, expectedResult); // invokes a
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java
index 9c32a77..c425969 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java
@@ -88,9 +88,9 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
      *  7. Confirm that the users receive the events which were enqueued at server while they were away.
      *  8. Same for ProxyCache.close()
      */
-    Integer numOfUsers = 2;
-    Integer numOfPuts = 5;
-    Boolean[] postAuthzAllowed = new Boolean[] {Boolean.TRUE, Boolean.TRUE};
+    int numOfUsers = 2;
+    int numOfPuts = 5;
+    boolean[] postAuthzAllowed = new boolean[] {true, true};
 
     doTest(numOfUsers, numOfPuts, postAuthzAllowed, getXmlAuthzGenerator(), null);
   }
@@ -107,9 +107,9 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
      *  7. Observer the behaviour.
      *  8. Same for ProxyCache.close(false)
      */
-    Integer numOfUsers = 2;
-    Integer numOfPuts = 5;
-    Boolean[] postAuthzAllowed = new Boolean[] {Boolean.TRUE, Boolean.TRUE};
+    int numOfUsers = 2;
+    int numOfPuts = 5;
+    boolean[] postAuthzAllowed = new boolean[] {true, true};
 
     doTest(numOfUsers, numOfPuts, postAuthzAllowed, getXmlAuthzGenerator(), Boolean.TRUE);
   }
@@ -126,14 +126,14 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
      *  7. Observer the behaviour.
      *  8. Same for ProxyCache.close(true)
      */
-    Integer numOfUsers = 2;
-    Integer numOfPuts = 5;
-    Boolean[] postAuthzAllowed = new Boolean[] {Boolean.TRUE, Boolean.TRUE};
+    int numOfUsers = 2;
+    int numOfPuts = 5;
+    boolean[] postAuthzAllowed = new boolean[] {true, true};
 
     doTest(numOfUsers, numOfPuts, postAuthzAllowed, getXmlAuthzGenerator(), Boolean.FALSE);
   }
 
-  private void doTest(Integer numOfUsers, Integer numOfPuts, Boolean[] postAuthzAllowed, AuthzCredentialGenerator authzGenerator, Boolean keepAlive) throws Exception {
+  private void doTest(int numOfUsers, int numOfPuts, boolean[] postAuthzAllowed, final AuthzCredentialGenerator authzGenerator, final Boolean keepAlive) throws Exception {
     CredentialGenerator credentialGenerator = authzGenerator.getCredentialGenerator();
     Properties extraAuthProps = credentialGenerator.getSystemProperties();
     Properties javaProps = credentialGenerator.getJavaProperties();
@@ -198,10 +198,10 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
     server2.invoke(() -> SecurityTestUtil.closeCache());
 
     server1.invoke(() -> createServerCache(serverProps, javaProps, locatorPort, port1));
-    client1.invoke(() -> createClientCache(javaProps2, authInit, authProps, new Integer[] {port1, port2}, numOfUsers, durableClientId, postAuthzAllowed));
+    client1.invoke(() -> createClientCache(javaProps2, authInit, authProps, new int[] {port1, port2}, numOfUsers, durableClientId, postAuthzAllowed));
 
     client1.invoke(() -> createCQ(numOfUsers, Boolean.TRUE));
-    client1.invoke(() -> executeCQ(numOfUsers, new Boolean[] {false, false}, numOfPuts, new String[numOfUsers]));
+    client1.invoke(() -> executeCQ(numOfUsers, new boolean[] {false, false}, numOfPuts, new String[numOfUsers]));
     client1.invoke(() -> readyForEvents());
 
     if (keepAlive == null) {
@@ -212,9 +212,9 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
 
     server1.invoke(() -> doPuts(numOfPuts, Boolean.TRUE/* put last key */));
 
-    client1.invoke(() -> createClientCache(javaProps2, authInit, authProps, new Integer[] {port1, port2}, numOfUsers, durableClientId, postAuthzAllowed));
+    client1.invoke(() -> createClientCache(javaProps2, authInit, authProps, new int[] {port1, port2}, numOfUsers, durableClientId, postAuthzAllowed));
     client1.invoke(() -> createCQ(numOfUsers, Boolean.TRUE));
-    client1.invoke(() ->executeCQ(numOfUsers, new Boolean[] {false, false}, numOfPuts, new String[numOfUsers]));
+    client1.invoke(() ->executeCQ(numOfUsers, new boolean[] {false, false}, numOfPuts, new String[numOfUsers]));
     client1.invoke(() -> readyForEvents());
 
     if (!postAuthzAllowed[0] || keepAlive == null || !keepAlive) {
@@ -226,10 +226,10 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
 
     Integer numOfCreates = keepAlive == null ? 0 : (keepAlive ? numOfPuts + 1/* last key */ : 0);
     client1.invoke(() -> checkCQListeners(numOfUsers, postAuthzAllowed, numOfCreates, 0));
-    client1.invoke(() -> proxyCacheClose(new Integer[] {0, 1}, keepAlive));
+    client1.invoke(() -> proxyCacheClose(new int[] {0, 1}, keepAlive));
     client1.invoke(() -> SecurityTestUtil.createProxyCache(new Integer[] {0, 1}, authProps));
     client1.invoke(() -> createCQ(numOfUsers, Boolean.TRUE));
-    client1.invoke(() -> executeCQ(numOfUsers, new Boolean[] {false, false}, numOfPuts, new String[numOfUsers]));
+    client1.invoke(() -> executeCQ(numOfUsers, new boolean[] {false, false}, numOfPuts, new String[numOfUsers]));
 
     server1.invoke(() -> doPuts(numOfPuts, Boolean.TRUE/* put last key */));
 
@@ -245,30 +245,30 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
   }
 
   private void createServerCache(Properties serverProps, Properties javaProps, Integer locatorPort, Integer serverPort) {
-    SecurityTestUtil.createCacheServer((Properties)serverProps, javaProps, locatorPort, null, serverPort, Boolean.TRUE, new Integer(SecurityTestUtil.NO_EXCEPTION));
+    SecurityTestUtil.createCacheServer((Properties)serverProps, javaProps, locatorPort, null, serverPort, true, NO_EXCEPTION);
   }
 
-  private void createClientCache(Properties javaProps, String authInit, Properties[] authProps, Integer ports[], Integer numOfUsers, Boolean[] postAuthzAllowed) {
-    SecurityTestUtil.createCacheClientForMultiUserMode(numOfUsers, authInit, authProps, javaProps, ports, null, Boolean.FALSE, SecurityTestUtil.NO_EXCEPTION);
+  private void createClientCache(Properties javaProps, String authInit, Properties[] authProps, int ports[], int numOfUsers, boolean[] postAuthzAllowed) {
+    SecurityTestUtil.createCacheClientForMultiUserMode(numOfUsers, authInit, authProps, javaProps, ports, 0, false, NO_EXCEPTION);
   }
 
   private void readyForEvents() {
     GemFireCacheImpl.getInstance().readyForEvents();
   }
 
-  private void createClientCache(Properties javaProps, String authInit, Properties[] authProps, Integer ports[], Integer numOfUsers, String durableId, Boolean[] postAuthzAllowed) {
-    SecurityTestUtil.createCacheClientForMultiUserMode(numOfUsers, authInit, authProps, javaProps, ports, null, Boolean.FALSE, durableId, SecurityTestUtil.NO_EXCEPTION);
+  private void createClientCache(Properties javaProps, String authInit, Properties[] authProps, int ports[], int numOfUsers, String durableId, boolean[] postAuthzAllowed) {
+    SecurityTestUtil.createCacheClientForMultiUserMode(numOfUsers, authInit, authProps, javaProps, ports, 0, false, durableId, NO_EXCEPTION);
   }
 
   private void createCQ(Integer num) throws CqException, CqExistsException {
     createCQ(num, false);
   }
 
-  private void createCQ(Integer num, Boolean isDurable) throws CqException, CqExistsException {
+  private void createCQ(int num, boolean isDurable) throws CqException, CqExistsException {
     for (int i = 0; i < num; i++) {
-      QueryService cqService = SecurityTestUtil.proxyCaches[i].getQueryService();
+      QueryService cqService = SecurityTestUtil.getProxyCaches(i).getQueryService();
       String cqName = "CQ_" + i;
-      String queryStr = cqNameToQueryStrings.get(cqName) + SecurityTestUtil.proxyCaches[i].getRegion(regionName).getFullPath();
+      String queryStr = cqNameToQueryStrings.get(cqName) + SecurityTestUtil.getProxyCaches(i).getRegion(regionName).getFullPath();
 
       // Create CQ Attributes.
       CqAttributesFactory cqf = new CqAttributesFactory();
@@ -284,7 +284,7 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
     }
   }
 
-  private void executeCQ(Integer num, Boolean[] initialResults, Integer expectedResultsSize, String[] expectedErr) throws CqException, RegionNotFoundException {
+  private void executeCQ(int num, boolean[] initialResults, int expectedResultsSize, String[] expectedErr) throws CqException, RegionNotFoundException {
     InternalLogWriter logWriter = InternalDistributedSystem.getStaticInternalLogWriter();
 
     for (int i = 0; i < num; i++) {
@@ -295,8 +295,8 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
 
         CqQuery cq1 = null;
         String cqName = "CQ_" + i;
-        String queryStr = cqNameToQueryStrings.get(cqName) + SecurityTestUtil.proxyCaches[i].getRegion(regionName).getFullPath();
-        QueryService cqService = SecurityTestUtil.proxyCaches[i].getQueryService();
+        String queryStr = cqNameToQueryStrings.get(cqName) + SecurityTestUtil.getProxyCaches(i).getRegion(regionName).getFullPath();
+        QueryService cqService = SecurityTestUtil.getProxyCaches(i).getQueryService();
 
         // Get CqQuery object.
         cq1 = cqService.getCq(cqName);
@@ -318,8 +318,7 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
           assertTrue("executeWithInitialResults() state mismatch", cq1
               .getState().isRunning());
           if (expectedResultsSize >= 0) {
-            assertEquals("unexpected results size", expectedResultsSize
-                .intValue(), cqResults.size());
+            assertEquals("unexpected results size", expectedResultsSize, cqResults.size());
           }
 
         } else {
@@ -350,9 +349,9 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
     region.put("LAST_KEY", "LAST_KEY");
   }
 
-  private void waitForLastKey(Integer cqIndex, Boolean isCreate) {
+  private void waitForLastKey(int cqIndex, boolean isCreate) {
     String cqName = "CQ_" + cqIndex;
-    QueryService qService = SecurityTestUtil.proxyCaches[cqIndex].getQueryService();
+    QueryService qService = SecurityTestUtil.getProxyCaches(cqIndex).getQueryService();
     ClientCQImpl cqQuery = (ClientCQImpl)qService.getCq(cqName);
     if (isCreate) {
       ((CqQueryTestListener)cqQuery.getCqListeners()[cqIndex]).waitForCreated("LAST_KEY");
@@ -361,16 +360,16 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
     }
   }
 
-  private void checkCQListeners(Integer numOfUsers,Boolean[] expectedListenerInvocation, Integer createEventsSize, Integer updateEventsSize) {
+  private void checkCQListeners(int numOfUsers, boolean[] expectedListenerInvocation, int createEventsSize, int updateEventsSize) {
     for (int i = 0; i < numOfUsers; i++) {
       String cqName = "CQ_" + i;
-      QueryService qService = SecurityTestUtil.proxyCaches[i].getQueryService();
+      QueryService qService = SecurityTestUtil.getProxyCaches(i).getQueryService();
       ClientCQImpl cqQuery = (ClientCQImpl)qService.getCq(cqName);
 
       if (expectedListenerInvocation[i]) {
         for (CqListener listener : cqQuery.getCqListeners()) {
-          assertEquals(createEventsSize.intValue(), ((CqQueryTestListener)listener).getCreateEventCount());
-          assertEquals(updateEventsSize.intValue(), ((CqQueryTestListener)listener).getUpdateEventCount());
+          assertEquals(createEventsSize, ((CqQueryTestListener)listener).getCreateEventCount());
+          assertEquals(updateEventsSize, ((CqQueryTestListener)listener).getUpdateEventCount());
         }
 
       } else {
@@ -381,19 +380,19 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
     }
   }
 
-  private void proxyCacheClose(Integer[] userIndices) {
+  private void proxyCacheClose(int[] userIndices) {
     proxyCacheClose(userIndices, null);
   }
 
-  private void proxyCacheClose(Integer[] userIndices, Boolean keepAliveFlags) {
+  private void proxyCacheClose(int[] userIndices, Boolean keepAliveFlags) {
     if (keepAliveFlags != null) {
       for (int i : userIndices) {
-        SecurityTestUtil.proxyCaches[i].close(keepAliveFlags);
+        SecurityTestUtil.getProxyCaches(i).close(keepAliveFlags);
       }
 
     } else {
       for (int i : userIndices) {
-        SecurityTestUtil.proxyCaches[i].close();
+        SecurityTestUtil.getProxyCaches(i).close();
       }
     }
   }