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/30 02:00:15 UTC

[1/7] incubator-geode git commit: Rename security utility classes

Repository: incubator-geode
Updated Branches:
  refs/heads/feature/GEODE-693 b79974474 -> e93932aab


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java b/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
new file mode 100644
index 0000000..4474279
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
@@ -0,0 +1,1793 @@
+/*
+ * 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.distributed.internal.DistributionConfig.*;
+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.*;
+
+import static com.gemstone.gemfire.cache30.ClientServerTestCase.configureConnectionPoolWithNameAndFactory;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import javax.net.ServerSocketFactory;
+import javax.net.SocketFactory;
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLContextSpi;
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.TrustManager;
+
+import com.gemstone.gemfire.cache.AttributesFactory;
+import com.gemstone.gemfire.cache.Cache;
+import com.gemstone.gemfire.cache.CacheFactory;
+import com.gemstone.gemfire.cache.DataPolicy;
+import com.gemstone.gemfire.cache.DynamicRegionFactory;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.RegionAttributes;
+import com.gemstone.gemfire.cache.Scope;
+import com.gemstone.gemfire.cache.client.NoAvailableServersException;
+import com.gemstone.gemfire.cache.client.Pool;
+import com.gemstone.gemfire.cache.client.PoolFactory;
+import com.gemstone.gemfire.cache.client.PoolManager;
+import com.gemstone.gemfire.cache.client.ServerConnectivityException;
+import com.gemstone.gemfire.cache.client.ServerOperationException;
+import com.gemstone.gemfire.cache.client.ServerRefusedConnectionException;
+import com.gemstone.gemfire.cache.client.internal.PoolImpl;
+import com.gemstone.gemfire.cache.client.internal.ProxyCache;
+import com.gemstone.gemfire.cache.execute.Execution;
+import com.gemstone.gemfire.cache.execute.Function;
+import com.gemstone.gemfire.cache.execute.FunctionException;
+import com.gemstone.gemfire.cache.execute.FunctionService;
+import com.gemstone.gemfire.cache.query.Query;
+import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
+import com.gemstone.gemfire.cache.query.SelectResults;
+import com.gemstone.gemfire.cache.server.CacheServer;
+import com.gemstone.gemfire.distributed.DistributedSystem;
+import com.gemstone.gemfire.distributed.Locator;
+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.DistributedTestCase;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
+
+/**
+ * Contains utility methods for setting up servers/clients for authentication
+ * and authorization tests.
+ * 
+ * @since 5.5
+ */
+public final class SecurityTestUtils {
+
+  private final DistributedTestCase distributedTestCase = new DistributedTestCase(getClass().getSimpleName()) {}; // TODO: delete
+
+  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
+  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" };
+
+  private static final int NUMBER_OF_USERS = 1;
+
+  private static String[] ignoredExceptions = null;
+
+  private static Locator locator = null;
+  private static Cache cache = null;
+  private static Properties currentJavaProps = null;
+  private static String locatorString = null;
+
+  private static Pool pool = null;
+  private static boolean multiUserAuthMode = false;
+
+  private static ProxyCache[] proxyCaches = new ProxyCache[NUMBER_OF_USERS];
+
+  private static Region regionRef = null;
+
+  public SecurityTestUtils(String name) { // TODO: delete
+  }
+
+  /**
+   * @deprecated Please use {@link com.gemstone.gemfire.test.dunit.IgnoredException} instead
+   */
+  private static void addIgnoredExceptions(final String[] expectedExceptions) { // TODO: delete
+    if (expectedExceptions != null) {
+      for (int index = 0; index < expectedExceptions.length; index++) {
+        getLogWriter().info("<ExpectedException action=add>" + expectedExceptions[index] + "</ExpectedException>");
+      }
+    }
+  }
+
+  /**
+   * @deprecated Please use {@link com.gemstone.gemfire.test.dunit.IgnoredException} instead
+   */
+  private static void removeExpectedExceptions(final String[] expectedExceptions) { // TODO: delete
+    if (expectedExceptions != null) {
+      for (int index = 0; index < expectedExceptions.length; index++) {
+        getLogWriter().info("<ExpectedException action=remove>" + expectedExceptions[index] + "</ExpectedException>");
+      }
+    }
+  }
+
+  protected static void setJavaProps(final Properties javaProps) {
+    removeJavaProperties(currentJavaProps);
+    addJavaProperties(javaProps);
+    currentJavaProps = javaProps;
+  }
+
+  protected static ProxyCache getProxyCaches(final int index) {
+    return proxyCaches[index];
+  }
+
+  protected static void initDynamicRegionFactory() {
+    DynamicRegionFactory.get().open(new DynamicRegionFactory.Config(null, null, false, true));
+  }
+
+  protected static Integer getLocatorPort() {
+    int locatorPort = getRandomAvailablePort(SOCKET);
+    String addr = getIPLiteral();
+    if (locatorString == null) {
+      locatorString = addr + "[" + locatorPort + ']';
+    } else {
+      locatorString += "," + addr + "[" + locatorPort + ']';
+    }
+    return locatorPort;
+  }
+
+  /**
+   * 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.
+   */
+  protected static String getLocatorString() { // TODO: rename
+    String locString = locatorString;
+    locatorString = null;
+    return locString;
+  }
+
+  protected static Properties concatProperties(final Properties[] propsList) {
+    Properties props = new Properties();
+    for (int index = 0; index < propsList.length; ++index) {
+      if (propsList[index] != null) {
+        props.putAll(propsList[index]);
+      }
+    }
+    return props;
+  }
+
+  protected static void registerExpectedExceptions(final String[] expectedExceptions) { // TODO: delete
+    SecurityTestUtils.ignoredExceptions = expectedExceptions;
+  }
+
+  protected static int createCacheServer(final Properties authProps, final Properties javaProps, final int dsPort, final String locatorString, final int serverPort, final int expectedResult) {
+    return createCacheServer(authProps, javaProps, dsPort, locatorString, serverPort, false, expectedResult);
+  }
+
+  protected static int createCacheServer(Properties authProps, final Properties javaProps, final int locatorPort, final String locatorString, final int serverPort, final boolean setupDynamicRegionFactory, final int expectedResult) {
+    if (authProps == null) {
+      authProps = new Properties();
+    }
+    authProps.setProperty(MCAST_PORT_NAME, "0");
+    if (locatorString != null && locatorString.length() > 0) {
+      authProps.setProperty(LOCATORS_NAME, locatorString);
+      authProps.setProperty(START_LOCATOR_NAME, getIPLiteral() + "[" + locatorPort + ']');
+    } else {
+      authProps.setProperty("locators", "localhost["+getDUnitLocatorPort()+"]");
+    }
+    authProps.setProperty(SECURITY_LOG_LEVEL_NAME, "finest");
+    getLogWriter().info("Set the server properties to: " + authProps);
+    getLogWriter().info("Set the java properties to: " + javaProps);
+
+    SecurityTestUtils tmpInstance = new SecurityTestUtils("temp");
+    try {
+      tmpInstance.createSystem(authProps, javaProps);
+      if (expectedResult != NO_EXCEPTION) {
+        fail("Expected a security exception when starting peer");
+      }
+    }
+    catch (AuthenticationRequiredException ex) {
+      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 == AUTHFAIL_EXCEPTION) {
+        getLogWriter().info("Got expected exception when starting peer: " + ex);
+        return 0;
+      }
+      else {
+        fail("Got unexpected exception when starting peer", ex);
+      }
+    }
+    catch (Exception ex) {
+      fail("Got unexpected exception when starting peer", ex);
+    }
+
+    if (setupDynamicRegionFactory) {
+      initDynamicRegionFactory();
+    }
+    tmpInstance.openCache();
+    AttributesFactory factory = new AttributesFactory();
+    factory.setScope(Scope.DISTRIBUTED_ACK);
+    factory.setDataPolicy(DataPolicy.REPLICATE);
+    RegionAttributes attrs = factory.create();
+    cache.createRegion(REGION_NAME, attrs);
+    int port;
+    if (serverPort <= 0) {
+      port = 0;
+    }
+    else {
+      port = serverPort;
+    }
+    CacheServer server1 = cache.addCacheServer();
+    server1.setPort(port);
+    server1.setNotifyBySubscription(true);
+    try {
+      server1.start();
+    }
+    catch (Exception ex) {
+      fail("Got unexpected exception when starting CacheServer", ex);
+    }
+    return server1.getPort();
+  }
+
+  // 1
+  protected static void createCacheClient(final String authInitModule, final Properties authProps, final Properties javaProps, final int[] ports, final int numConnections, final int expectedResult) {
+    createCacheClient(authInitModule, authProps, javaProps, ports, numConnections, false, expectedResult);
+  }
+
+  // 2 a
+  protected static void createCacheClient(final String authInitModule, final Properties authProps, final Properties javaProps, final int[] ports, final int numConnections, final boolean multiUserMode, final int expectedResult) {
+    createCacheClient(authInitModule, authProps, javaProps, ports, numConnections, false, multiUserMode, expectedResult);
+  }
+
+  // 3
+  protected static void createCacheClientWithDynamicRegion(final String authInitModule, final Properties authProps, final Properties javaProps, final int[] ports, final int numConnections, final boolean setupDynamicRegionFactory, final int expectedResult) {
+    createCacheClient(authInitModule, authProps, javaProps, ports, numConnections, setupDynamicRegionFactory, false, expectedResult);
+  }
+
+  // 4
+  protected static void createCacheClient(final String authInitModule,
+                                          final Properties authProps, final Properties javaProps, final int[] ports,
+                                          final int numConnections, final boolean setupDynamicRegionFactory,
+                                          final boolean multiUserMode, final int expectedResult) {
+    createCacheClient(authInitModule, authProps, javaProps, ports,
+        numConnections, setupDynamicRegionFactory, multiUserMode, Boolean.TRUE,
+        expectedResult);
+  }
+
+  // 5
+  protected static void createCacheClient(final String authInitModule,
+                                          Properties authProps, final Properties javaProps, int[] ports,
+                                          final int numConnections, final boolean setupDynamicRegionFactory,
+                                          final boolean multiUserMode, final boolean subscriptionEnabled,
+                                          final int expectedResult) {
+
+    multiUserAuthMode = Boolean.valueOf(multiUserMode);
+    if (authProps == null) {
+      authProps = new Properties();
+    }
+    authProps.setProperty(MCAST_PORT_NAME, "0");
+    authProps.setProperty(LOCATORS_NAME, "");
+    authProps.setProperty(SECURITY_LOG_LEVEL_NAME, "finest");
+    // TODO (ashetkar) Add " && (!multiUserAuthMode)" below.
+    if (authInitModule != null) {
+      authProps.setProperty(SECURITY_CLIENT_AUTH_INIT_NAME,
+          authInitModule);
+    }
+
+    SecurityTestUtils tmpInstance = new SecurityTestUtils("temp");
+    tmpInstance.createSystem(authProps, javaProps);
+    AttributesFactory factory = new AttributesFactory();
+    int[] portsI = new int[ports.length];
+    for(int z=0;z<ports.length;z++) {
+      portsI[z] = ports[z];
+    }
+   
+    try {
+      PoolFactory poolFactory = PoolManager.createFactory();
+      poolFactory.setRetryAttempts(200);
+      if (multiUserAuthMode) {
+        poolFactory.setMultiuserAuthentication(multiUserAuthMode);
+        // [sumedh] Why is this false here only to be overridden in
+        // ClientServerTestCase.configureConnectionPoolWithNameAndFactory below?
+        // Actually setting it to false causes MultiuserAPIDUnitTest to fail.
+        //poolFactory.setSubscriptionEnabled(false);
+      }
+      pool = configureConnectionPoolWithNameAndFactory(factory,
+          getIPLiteral(), portsI, subscriptionEnabled, 0,
+          numConnections, null, null,
+          poolFactory);
+
+      if (setupDynamicRegionFactory) {
+        initClientDynamicRegionFactory(pool.getName());
+      }
+      tmpInstance.openCache();
+      try {
+        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) {
+          getLogWriter().info("Got expected UnsupportedOperationException in single-user mode");
+        }
+        else {
+          fail("Got unexpected exception in multi-user mode ", uoe);
+        }
+      }
+
+      factory.setScope(Scope.LOCAL);
+      if (multiUserAuthMode) {
+        factory.setDataPolicy(DataPolicy.EMPTY);
+      }
+      RegionAttributes attrs = factory.create();
+      cache.createRegion(REGION_NAME, attrs);
+
+      if (expectedResult != NO_EXCEPTION
+          && expectedResult != NOFORCE_AUTHREQ_EXCEPTION) {
+        if (!multiUserAuthMode) {
+          fail("Expected an exception when starting client");
+        }
+      }
+    }
+    catch (AuthenticationRequiredException ex) {
+      if (expectedResult == AUTHREQ_EXCEPTION
+          || expectedResult == NOFORCE_AUTHREQ_EXCEPTION) {
+        getLogWriter().info(
+            "Got expected exception when starting client: " + ex);
+      }
+      else {
+        fail("Got unexpected exception when starting client", ex);
+      }
+    }
+    catch (AuthenticationFailedException ex) {
+      if (expectedResult == AUTHFAIL_EXCEPTION) {
+        getLogWriter().info(
+            "Got expected exception when starting client: " + ex);
+      }
+      else {
+        fail("Got unexpected exception when starting client", ex);
+      }
+    }
+    catch (ServerRefusedConnectionException ex) {
+      if (expectedResult == CONNREFUSED_EXCEPTION) {
+        getLogWriter().info(
+            "Got expected exception when starting client: " + ex);
+      }
+      else {
+        fail("Got unexpected exception when starting client", ex);
+      }
+    }
+    catch (Exception ex) {
+      fail("Got unexpected exception when starting client", ex);
+    }
+  }
+
+  protected static void createCacheClientForMultiUserMode(final int numOfUsers,
+                                                          final String authInitModule, final Properties[] authProps, final Properties javaProps,
+                                                          final int[] ports, final int numConnections,
+                                                          final boolean setupDynamicRegionFactory, final int expectedResult) {
+    createCacheClientForMultiUserMode(numOfUsers, authInitModule, authProps,
+        javaProps, ports, numConnections, setupDynamicRegionFactory, null,
+        expectedResult);
+  }
+
+  protected static void createCacheClientForMultiUserMode(final int numOfUsers,
+                                                          final String authInitModule, final Properties[] authProps, final Properties javaProps,
+                                                          final int[] ports, final int numConnections,
+                                                          final boolean setupDynamicRegionFactory, final String durableClientId,
+                                                          final int expectedResult) {
+
+    if (numOfUsers < 1) {
+      fail("Number of users cannot be less than one");
+    }
+    multiUserAuthMode = true;
+    if (numOfUsers != authProps.length) {
+      fail("Number of authProps provided does not match with numOfUsers specified, "
+          + authProps.length);
+    }
+    if (authProps[0] == null) {
+      authProps[0] = new Properties();
+    }
+    authProps[0].setProperty(MCAST_PORT_NAME, "0");
+    authProps[0].setProperty(LOCATORS_NAME, "");
+    authProps[0].setProperty(SECURITY_LOG_LEVEL_NAME,
+        "finest");
+    Properties props = new Properties();
+    if (authInitModule != null) {
+      authProps[0].setProperty(
+          SECURITY_CLIENT_AUTH_INIT_NAME, authInitModule);
+      props.setProperty(SECURITY_CLIENT_AUTH_INIT_NAME,
+          authInitModule);
+    }
+    if (durableClientId != null) {
+      props.setProperty(DURABLE_CLIENT_ID_NAME,
+          durableClientId);
+      props.setProperty(DURABLE_CLIENT_TIMEOUT_NAME, String
+          .valueOf(DEFAULT_DURABLE_CLIENT_TIMEOUT));
+    }
+
+    SecurityTestUtils tmpInstance = new SecurityTestUtils("temp");
+    tmpInstance.createSystem(props, javaProps);
+    AttributesFactory factory = new AttributesFactory();
+    int[] portsI = new int[ports.length];
+    for(int z=0;z<ports.length;z++) {
+      portsI[z] = ports[z];
+    }
+   
+    try {
+      tmpInstance.openCache();
+      PoolFactory poolFactory = PoolManager.createFactory();
+      poolFactory.setRetryAttempts(200);
+      poolFactory.setMultiuserAuthentication(multiUserAuthMode);
+      poolFactory.setSubscriptionEnabled(true);
+      pool = configureConnectionPoolWithNameAndFactory(factory,
+          getIPLiteral(), portsI, true, 1,
+          numConnections, null, null,
+          poolFactory);
+
+      if (setupDynamicRegionFactory) {
+        initClientDynamicRegionFactory(pool.getName());
+      }
+      proxyCaches = new ProxyCache[numOfUsers];
+      for (int i=0; i<numOfUsers; i++) {
+        proxyCaches[i] = (ProxyCache)((PoolImpl) pool).createAuthenticatedCacheView(authProps[i]);
+      }
+
+      factory.setScope(Scope.LOCAL);
+      factory.setDataPolicy(DataPolicy.EMPTY);
+      RegionAttributes attrs = factory.create();
+      cache.createRegion(REGION_NAME, attrs);
+
+      if (expectedResult != NO_EXCEPTION
+          && expectedResult != NOFORCE_AUTHREQ_EXCEPTION) {
+        if (!multiUserAuthMode) {
+          fail("Expected an exception when starting client");
+        }
+      }
+    }
+    catch (AuthenticationRequiredException ex) {
+      if (expectedResult == AUTHREQ_EXCEPTION
+          || expectedResult == NOFORCE_AUTHREQ_EXCEPTION) {
+        getLogWriter().info(
+            "Got expected exception when starting client: " + ex);
+      }
+      else {
+        fail("Got unexpected exception when starting client", ex);
+      }
+    }
+    catch (AuthenticationFailedException ex) {
+      if (expectedResult == AUTHFAIL_EXCEPTION) {
+        getLogWriter().info(
+            "Got expected exception when starting client: " + ex);
+      }
+      else {
+        fail("Got unexpected exception when starting client", ex);
+      }
+    }
+    catch (ServerRefusedConnectionException ex) {
+      if (expectedResult == CONNREFUSED_EXCEPTION) {
+        getLogWriter().info(
+            "Got expected exception when starting client: " + ex);
+      }
+      else {
+        fail("Got unexpected exception when starting client", ex);
+      }
+    }
+    catch (Exception ex) {
+      fail("Got unexpected exception when starting client", ex);
+    }
+  }
+
+  protected static void createProxyCache(final int[] userIndices, final Properties[] props) {
+    int j = 0;
+    for (int i : userIndices) {
+      proxyCaches[i] = (ProxyCache)((PoolImpl) pool)
+          .createAuthenticatedCacheView(props[j]);
+      j++;
+    }
+  }
+
+  protected static void startLocator(final String name, Integer port, final Object extraProps,
+                                     final Object javaProps, final String[] expectedExceptions) {
+    File logFile = new File(name + "-locator" + port.intValue() + ".log");
+    try {
+      Properties authProps = new Properties();
+      if (extraProps != null) {
+        authProps.putAll((Properties)extraProps);
+      }
+      authProps.setProperty(MCAST_PORT_NAME, "0");
+      authProps.setProperty(LOCATORS_NAME, 
+                            getIPLiteral() + "[" + port + "]");
+      authProps.setProperty(ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
+      clearStaticSSLContext();
+      setJavaProps((Properties)javaProps);
+      FileOutputStream logOut = new FileOutputStream(logFile);
+      PrintStream logStream = new PrintStream(logOut);
+      addIgnoredExceptions(expectedExceptions);
+      logStream.flush();
+      locator = Locator.startLocatorAndDS(port.intValue(), logFile, null,
+          authProps);
+    }
+    catch (IOException ex) {
+      fail("While starting locator on port " + port.intValue(), ex);
+    }
+  }
+
+  protected static void stopLocator(final Integer port, final String[] expectedExceptions) {
+    try {
+      locator.stop();
+      removeExpectedExceptions(expectedExceptions);
+    }
+    catch (Exception ex) {
+      fail("While stopping locator on port " + port.intValue(), ex);
+    }
+  }
+
+  protected static Cache getCache() {
+    return cache;
+  }
+
+  // Some useful region methods used by security tests
+
+  protected static void waitForCondition(final Callable cond) {
+    waitForCondition(cond, 100, 120);
+  }
+
+  protected static void waitForCondition(final Callable cond, final int sleepMillis,
+                                         final int numTries) {
+    WaitCriterion ev = new WaitCriterion() {
+      public boolean done() {
+        try {
+          return ((Boolean)cond.call()).booleanValue();
+        }
+        catch (Exception e) {
+          fail("Unexpected exception", e);
+        }
+        return false; // NOTREACHED
+      }
+      public String description() {
+        return null;
+      }
+    };
+    waitForCriterion(ev, sleepMillis * numTries, 200, true);
+  }
+
+  protected static Object getLocalValue(final Region region, final Object key) {
+    Region.Entry entry = region.getEntry(key);
+    return (entry != null ? entry.getValue() : null);
+  }
+
+  protected static void doProxyCacheClose() {
+    for (int i = 0; i< proxyCaches.length; i++) {
+      proxyCaches[i].close();
+    }
+  }
+
+
+  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(final Integer num) {
+    doPutsP(num, new Integer(NO_EXCEPTION), false);
+  }
+
+  protected static void doPuts(final Integer num, final Integer expectedResult) {
+    doPutsP(num, expectedResult, false);
+  }
+
+  protected static void doMultiUserPuts(final Integer num, final Integer numOfUsers,
+                                        final Integer[] expectedResults) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtils.doMultiUserPuts(): numOfUsers = " + numOfUsers
+          + ", but expected results " + expectedResults.length);
+    }
+    for (int i = 0; i < numOfUsers; i++) {
+      getLogWriter().info("PUT: MultiUser# " + i);
+      doPutsP(num, Integer.valueOf(i), expectedResults[i], false);
+    }
+  }
+
+  protected static void doGets(final Integer num) {
+    doGetsP(num, new Integer(NO_EXCEPTION), false);
+  }
+
+  protected static void doGets(final Integer num, final Integer expectedResult) {
+    doGetsP(num, expectedResult, false);
+  }
+
+  protected static void doMultiUserGetAll(final Integer numOfUsers, final Integer[] expectedResults) {
+    doMultiUserGetAll(numOfUsers, expectedResults, false);
+  }
+
+  protected static void doMultiUserGetAll(final Integer numOfUsers,
+                                          final Integer[] expectedResults, final boolean useTX) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtils.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);
+    }
+  }
+
+  protected static void doMultiUserGets(final Integer num, final Integer numOfUsers,
+                                        final Integer[] expectedResults) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtils.doMultiUserGets(): numOfUsers = " + numOfUsers
+          + ", but expected results " + expectedResults.length);
+    }
+    for (int i = 0; i < numOfUsers; i++) {
+      getLogWriter().info("GET: MultiUser# " + i);
+      doGetsP(num, Integer.valueOf(i), expectedResults[i], false);
+    }
+  }
+
+  protected static void doMultiUserRegionDestroys(final Integer numOfUsers,
+                                                  final Integer[] expectedResults) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtils.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]);
+    }
+  }
+
+  protected static void doMultiUserDestroys(final Integer num, final Integer numOfUsers,
+                                            final Integer[] expectedResults) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtils.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);
+    }
+  }
+
+  protected static void doMultiUserInvalidates(final Integer num, final Integer numOfUsers,
+                                               final Integer[] expectedResults) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtils.doMultiUserInvalidates(): numOfUsers = " + numOfUsers
+          + ", but expected results " + expectedResults.length);
+    }
+    for (int i = 0; i < numOfUsers; i++) {
+      getLogWriter().info("INVALIDATE: MultiUser# " + i);
+      doInvalidatesP(num, Integer.valueOf(i), expectedResults[i], false);
+    }
+  }
+
+  protected static void doMultiUserContainsKeys(final Integer num, final Integer numOfUsers,
+                                                final Integer[] expectedResults, final Boolean[] results) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtils.doMultiUserContainsKeys(): numOfUsers = " + numOfUsers
+          + ", but #expected results " + expectedResults.length);
+    }
+    if (numOfUsers != results.length) {
+      fail("SecurityTestUtils.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(final Integer numOfUsers,
+                                           final Integer[] expectedResults, final Integer valueSize) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtils.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(final Integer numOfUsers, final Function function,
+                                      final Integer[] expectedResults, final Object[] results, final Boolean isFailoverCase) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtils.doMultiUserFE(): numOfUsers = " + numOfUsers
+          + ", but #expected results " + expectedResults.length);
+    }
+    if (numOfUsers != results.length) {
+      fail("SecurityTestUtils.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");
+      }
+    }
+  }
+
+  protected static void doMultiUserQueryExecute(final Integer numOfUsers,
+                                                final Integer[] expectedResults, final Integer result) {
+    if (numOfUsers != expectedResults.length) {
+      fail("SecurityTestUtils.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(final Integer num) {
+    doLocalGetsP(num.intValue(), false);
+  }
+
+  protected static void doNPuts(final Integer num) {
+    doPutsP(num, new Integer(NO_EXCEPTION), true);
+  }
+
+  protected static void doNPuts(final Integer num, final Integer expectedResult) {
+    doPutsP(num, expectedResult, true);
+  }
+
+  protected static void doNGets(final Integer num) {
+    doGetsP(num, new Integer(NO_EXCEPTION), true);
+  }
+
+  protected static void doNGets(final Integer num, final Integer expectedResult) {
+    doGetsP(num, expectedResult, true);
+  }
+
+  protected static void doNLocalGets(final Integer num) {
+    doLocalGetsP(num.intValue(), true);
+  }
+
+  protected static void doSimpleGet(final 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()");
+        }
+      }
+    }
+  }
+
+  protected static void doSimplePut(final 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()");
+        }
+      }
+    }
+  }
+
+  // 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);
+    if (cache != null && !cache.isClosed()) {
+      DistributedSystem sys = cache.getDistributedSystem();
+      cache.close();
+      sys.disconnect();
+      cache = null;
+    }
+    DistributedTestCase.disconnectFromDS();
+  }
+
+  protected static void closeCache(final Boolean keepAlive) {
+    removeExpectedExceptions(ignoredExceptions);
+    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(final String poolName) {
+    DynamicRegionFactory.get().open(new DynamicRegionFactory.Config(null, poolName, false, true));
+  }
+
+  private static void addJavaProperties(final 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(final 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 doPutsP(final Integer num, final Integer expectedResult,
+                              final boolean newVals) {
+    doPutsP(num, Integer.valueOf(0), expectedResult, newVals);
+  }
+
+  private static void doPutsP(final Integer num, final Integer multiUserIndex,
+                              final Integer expectedResult, final 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);
+      }
+      assertNotNull(region);
+    }
+    catch (Exception ex) {
+      if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        getLogWriter().info("Got expected exception when doing puts: " + ex);
+      }
+      else {
+        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]);
+        }
+        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() == NO_AVAILABLE_SERVERS) {
+          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)) {
+          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) {
+          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) {
+          getLogWriter().info("Got expected exception when doing puts: " + ex);
+        }
+        else {
+          fail("Got unexpected exception when doing puts", ex);
+        }
+      }
+    }
+  }
+
+  private static HashMap getSSLFields(final Object obj, final 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;
+          }
+        }
+        if (isInstance) {
+          resultFields.put(field, fieldObj);
+        }
+      }
+      catch (IllegalAccessException ex) {
+        getLogWriter().warning("Exception while getting SSL fields.", ex);
+      }
+    }
+    return resultFields;
+  }
+
+  private static void makeNullSSLFields(final Object obj, final 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);
+      }
+    }
+  }
+
+  // Deal with javax SSL properties
+  private static void makeNullStaticField(final 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(final Integer multiUserIndex,
+                                      final Integer expectedResult, final Integer expectedValue) {
+    Region region = null;
+    try {
+      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 query: " + ex);
+      } else {
+        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(final Integer multiUserIndex,
+                                         final Function function, Integer expectedResult, final Object expectedValue,
+                                         final String method) {
+    Region region = null;
+    try {
+      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 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(final Integer multiUserIndex,
+                                 final Integer expectedResult, final Integer expectedValue) {
+    Region region = null;
+    try {
+      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 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() == NO_AVAILABLE_SERVERS) {
+        getLogWriter().info(
+                "Got expected NoAvailableServers when doing queries: "
+                        + ex.getCause());
+      } else {
+        fail("Got unexpected exception when doing queries", ex);
+      }
+    } catch (ServerConnectivityException ex) {
+      if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
+              && (ex.getCause() instanceof NotAuthorizedException)) {
+        getLogWriter().info(
+                "Got expected NotAuthorizedException when doing queries: "
+                        + ex.getCause());
+      } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        getLogWriter().info("Got expected exception when doing queries: " + ex);
+      } else {
+        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) {
+        getLogWriter().info("Got expected exception when doing queries: " + ex);
+      } else {
+        fail("Got unexpected exception when doing queries", ex);
+      }
+    }
+  }
+
+  private static void doContainsKeysP(final Integer num, final Integer multiUserIndex,
+                                      final Integer expectedResult, final boolean newVals, final boolean expectedValue) {
+
+    assertTrue(num.intValue() <= KEYS.length);
+    Region region = null;
+    try {
+      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 doing containsKey: " + ex);
+      }
+      else {
+        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]);
+        if (expectedResult.intValue() != NO_EXCEPTION) {
+          fail("Expected a NotAuthorizedException while doing containsKey");
+        }
+      }
+      catch(NoAvailableServersException ex) {
+        if(expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
+          getLogWriter().info(
+                  "Got expected NoAvailableServers when doing containsKey: "
+                          + ex.getCause());
+          continue;
+        }
+        else {
+          fail("Got unexpected exception when doing containsKey", ex);
+        }
+      }
+      catch (ServerConnectivityException ex) {
+        if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
+                && (ex.getCause() instanceof NotAuthorizedException)) {
+          getLogWriter().info(
+                  "Got expected NotAuthorizedException when doing containsKey: "
+                          + ex.getCause());
+          continue;
+        }
+        else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+          getLogWriter().info("Got expected exception when doing containsKey: " + ex);
+        }
+        else {
+          fail("Got unexpected exception when doing containsKey", ex);
+        }
+      }
+      catch (Exception ex) {
+        if (expectedResult.intValue() == OTHER_EXCEPTION) {
+          getLogWriter().info("Got expected exception when doing containsKey: " + ex);
+        }
+        else {
+          fail("Got unexpected exception when doing containsKey", ex);
+        }
+      }
+      assertEquals(expectedValue, result);
+    }
+  }
+
+  private static void doInvalidatesP(final Integer num, final Integer multiUserIndex,
+                                     final Integer expectedResult, final boolean newVals) {
+    assertTrue(num.intValue() <= KEYS.length);
+    Region region = null;
+    try {
+      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 doing invalidates: " + ex);
+      }
+      else {
+        fail("Got unexpected exception when doing invalidates", ex);
+      }
+    }
+    for (int index = 0; index < num.intValue(); ++index) {
+      try {
+        region.invalidate(KEYS[index]);
+        if (expectedResult.intValue() != NO_EXCEPTION) {
+          fail("Expected a NotAuthorizedException while doing invalidates");
+        }
+      }
+      catch(NoAvailableServersException ex) {
+        if(expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
+          getLogWriter().info(
+                  "Got expected NoAvailableServers when doing invalidates: "
+                          + ex.getCause());
+          continue;
+        }
+        else {
+          fail("Got unexpected exception when doing invalidates", ex);
+        }
+      }
+      catch (ServerConnectivityException ex) {
+        if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
+                && (ex.getCause() instanceof NotAuthorizedException)) {
+          getLogWriter().info(
+                  "Got expected NotAuthorizedException when doing invalidates: "
+                          + ex.getCause());
+          continue;
+        }
+        else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+          getLogWriter().info("Got expected exception when doing invalidates: " + ex);
+        }
+        else {
+          fail("Got unexpected exception when doing invalidates", ex);
+        }
+      }
+      catch (Exception ex) {
+        if (expectedResult.intValue() == OTHER_EXCEPTION) {
+          getLogWriter().info("Got expected exception when doing invalidates: " + ex);
+        }
+        else {
+          fail("Got unexpected exception when doing invalidates", ex);
+        }
+      }
+    }
+  }
+
+  private static void doDestroysP(final Integer num, final Integer multiUserIndex,
+                                  final Integer expectedResult, final boolean newVals) {
+    assertTrue(num.intValue() <= KEYS.length);
+    Region region = null;
+    try {
+      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 doing destroys: " + ex);
+      }
+      else {
+        fail("Got unexpected exception when doing destroys", ex);
+      }
+    }
+    for (int index = 0; index < num.intValue(); ++index) {
+      try {
+        region.destroy(KEYS[index]);
+        if (expectedResult.intValue() != NO_EXCEPTION) {
+          fail("Expected a NotAuthorizedException while doing destroys");
+        }
+      }
+      catch(NoAvailableServersException ex) {
+        if(expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
+          getLogWriter().info(
+                  "Got expected NoAvailableServers when doing destroys: "
+                          + ex.getCause());
+          continue;
+        }
+        else {
+          fail("Got unexpected exception when doing destroys", ex);
+        }
+      }
+      catch (ServerConnectivityException ex) {
+        if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
+                && (ex.getCause() instanceof NotAuthorizedException)) {
+          getLogWriter().info(
+                  "Got expected NotAuthorizedException when doing destroys: "
+                          + ex.getCause());
+          continue;
+        }
+        else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+          getLogWriter().info("Got expected exception when doing destroys: " + ex);
+        }
+        else {
+          fail("Got unexpected exception when doing destroys", ex);
+        }
+      }
+      catch (Exception ex) {
+        if (expectedResult.intValue() == OTHER_EXCEPTION) {
+          getLogWriter().info("Got expected exception when doing destroys: " + ex);
+        }
+        else {
+          fail("Got unexpected exception when doing destroys", ex);
+        }
+      }
+    }
+  }
+
+  private static void doRegionDestroysP(final Integer multiuserIndex,
+                                        final Integer expectedResult) {
+    Region region = null;
+    try {
+      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 doing region destroy: " + ex);
+      } else {
+        fail("Got unexpected exception when doing region destroy", ex);
+      }
+    }
+
+    try {
+      region.destroyRegion();
+      if (expectedResult.intValue() != NO_EXCEPTION) {
+        fail("Expected a NotAuthorizedException while doing region destroy");
+      }
+      if (multiUserAuthMode) {
+        region = proxyCaches[multiuserIndex].getRegion(REGION_NAME);
+      } else {
+        region = getCache().getRegion(REGION_NAME);
+      }
+      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 region destroy", ex);
+      }
+    } catch (ServerConnectivityException ex) {
+      if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
+              && (ex.getCause() instanceof NotAuthorizedException)) {
+        getLogWriter().info(
+                "Got expected NotAuthorizedException when doing region destroy: "
+                        + ex.getCause());
+      } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        getLogWriter().info(
+                "Got expected exception when doing region destroy: " + ex);
+      } else {
+        fail("Got unexpected exception when doing region destroy", ex);
+      }
+    } catch (Exception ex) {
+      if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        getLogWriter().info(
+                "Got expected exception when doing region destroy: " + ex);
+      } else {
+        fail("Got unexpected exception when doing region destroy", ex);
+      }
+    }
+  }
+
+  private static void doLocalGetsP(final int num, final 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(final Integer multiUserIndex,
+                                final Integer expectedResult, final boolean useTX) {
+    Region region = null;
+    try {
+      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 doing getAll: " + ex);
+      }
+      else {
+        fail("Got unexpected exception when doing getAll", ex);
+      }
+    }
+    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"));
+      }
+    } catch (NoAvailableServersException ex) {
+      if (expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
+        getLogWriter().info(
+                "Got expected NoAvailableServers when doing getAll: "
+                        + ex.getCause());
+      } else {
+        fail("Got unexpected exception when doing getAll", ex);
+      }
+    } catch (ServerConnectivityException ex) {
+      if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
+              && (ex.getCause() instanceof NotAuthorizedException)) {
+        getLogWriter().info(
+                "Got expected NotAuthorizedException when doing getAll: "
+                        + ex.getCause());
+      } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        getLogWriter().info("Got expected exception when doing getAll: " + ex);
+      } else {
+        fail("Got unexpected exception when doing getAll", ex);
+      }
+    } catch (Exception ex) {
+      if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        getLogWriter().info("Got expected exception when doing getAll: " + ex);
+      } else {
+        fail("Got unexpected exception when doing getAll", ex);
+      }
+    }
+  }
+
+  private static void doGetsP(final Integer num, final Integer expectedResult,
+                              final boolean newVals) {
+    doGetsP(num, Integer.valueOf(0), expectedResult, newVals);
+  }
+
+  private static void doGetsP(final Integer num, final Integer multiUserIndex,
+                              final Integer expectedResult, final boolean newVals) {
+    assertTrue(num.intValue() <= KEYS.length);
+    Region region = null;
+    try {
+      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 doing gets: " + ex);
+      }
+      else {
+        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]);
+        }
+        catch (Exception ex) {
+        }
+        value = region.get(KEYS[index]);
+        if (expectedResult.intValue() != NO_EXCEPTION) {
+          fail("Expected a NotAuthorizedException while doing gets");
+        }
+      }
+      catch(NoAvailableServersException ex) {
+        if(expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
+          getLogWriter().info(
+                  "Got expected NoAvailableServers when doing gets: "
+                          + ex.getCause());
+          continue;
+        }
+        else {
+          fail("Got unexpected exception when doing gets", ex);
+        }
+      }
+      catch (ServerConnectivityException ex) {
+        if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
+                && (ex.getCause() instanceof NotAuthorizedException)) {
+          getLogWriter().info(
+                  "Got expected NotAuthorizedException when doing gets: "
+                          + ex.getCause());
+          continue;
+        }
+        else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+          getLogWriter().info("Got expected exception when doing gets: " + ex);
+        }
+        else {
+          fail("Got unexpected exception when doing gets", ex);
+        }
+      }
+      catch (Exception ex) {
+        if (expectedResult.intValue() == OTHER_EXCEPTION) {
+          getLogWriter().info("Got expected exception when doing gets: " + ex);
+        }
+        else {
+          fail("Got unexpected exception when doing gets", ex);
+        }
+      }
+      assertNotNull(value);
+      if (newVals) {
+        assertEquals(NVALUES[index], value);
+      }
+      else {
+        assertEquals(VALUES[index], value);
+      }
+    }
+  }
+
+  // ----------------------------- member methods -----------------------------
+
+  public DistributedSystem createSystem(final Properties sysProps, final Properties javaProps) {
+    closeCache();
+    clearStaticSSLContext();
+    setJavaProps(javaProps);
+
+    DistributedSystem dsys = distributedTestCase.getSystem(sysProps);
+    assertNotNull(dsys);
+    addIgnoredExceptions(ignoredExceptions);
+    return dsys;
+  }
+
+  private void openCache() {
+    assertNotNull(distributedTestCase.basicGetSystem());
+    assertTrue(distributedTestCase.basicGetSystem().isConnected());
+    cache = CacheFactory.create(distributedTestCase.basicGetSystem());
+    assertNotNull(cache);
+  }
+
+  // ------------------------------- inner classes ----------------------------
+
+  private 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;
+    }
+
+    /**
+     * For test purpose, to make sure
+     * the object is not deserialized
+     */
+    @Override
+    public void fromData(PdxReader in) {
+      throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void toData(PdxWriter out) {
+      out.writeLong("Id", Id);
+      out.writeString("fname", fname);
+      out.writeString("lname", lname);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/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 e55d7a6..64ab4ee 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,7 +16,7 @@
  */
 package com.gemstone.gemfire.security;
 
-import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.security.SecurityTestUtils.*;
 import static com.gemstone.gemfire.test.dunit.IgnoredException.*;
 
 import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
@@ -36,7 +36,7 @@ import org.junit.experimental.categories.Category;
  * @since 5.5
  */
 @Category(DistributedTest.class)
-public class ClientAuthorizationTwoDUnitTest extends ClientAuthorizationTestBase {
+public class ClientAuthorizationTwoDUnitTest extends ClientAuthorizationTestCase {
 
   @Override
   public final void postSetUpClientAuthorizationTestBase() throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/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 3f08ff1..0e8e57f 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
@@ -18,7 +18,7 @@ package com.gemstone.gemfire.security;
 
 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.security.SecurityTestUtils.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 
 import java.util.ArrayList;
@@ -58,7 +58,7 @@ import org.junit.experimental.categories.Category;
  * @since 5.5
  */
 @Category(DistributedTest.class)
-public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase {
+public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestCase {
 
   private static final String preAccessor = FilterPreAuthorization.class.getName() + ".create";
   private static final String postAccessor = FilterPostAuthorization.class.getName() + ".create";

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/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 4ea494e..dfa89f9 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
@@ -17,7 +17,7 @@
 package com.gemstone.gemfire.security;
 
 import static com.gemstone.gemfire.internal.AvailablePort.*;
-import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.security.SecurityTestUtils.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
 import static com.gemstone.gemfire.test.dunit.Invoke.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
@@ -57,7 +57,7 @@ import org.junit.experimental.categories.Category;
  * This is for multiuser-authentication
  */
 @Category(DistributedTest.class)
-public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestBase {
+public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestCase {
 
   private Map<String, String> cqNameToQueryStrings = new HashMap<>();
 
@@ -212,7 +212,7 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
   }
 
   private void createTheServerCache(final Properties serverProps, final Properties javaProps, final int locatorPort, final  int serverPort) {
-    SecurityTestUtil.createCacheServer(serverProps, javaProps, locatorPort, (String)null, serverPort, true, NO_EXCEPTION);
+    SecurityTestUtils.createCacheServer(serverProps, javaProps, locatorPort, (String)null, serverPort, true, NO_EXCEPTION);
   }
 
   private void createClientCache(final Properties javaProps, final String authInit, final Properties[] authProps, final int ports[], final int numOfUsers, final boolean[] postAuthzAllowed) {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/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 54ae3f4..d84cd43 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
@@ -17,7 +17,7 @@
 package com.gemstone.gemfire.security;
 
 import static com.gemstone.gemfire.internal.AvailablePort.*;
-import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.security.SecurityTestUtils.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 
 import java.util.ArrayList;
@@ -44,7 +44,7 @@ import org.junit.experimental.categories.Category;
  * @since 5.5
  */
 @Category(DistributedTest.class)
-public class ClientPostAuthorizationDUnitTest extends ClientAuthorizationTestBase {
+public class ClientPostAuthorizationDUnitTest extends ClientAuthorizationTestCase {
 
   @Rule
   public RetryRule retryRule = new RetryRule();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/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 9ca06e9..bdff2c2 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
@@ -17,7 +17,7 @@
 package com.gemstone.gemfire.security;
 
 import static com.gemstone.gemfire.distributed.internal.DistributionConfig.*;
-import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.security.SecurityTestUtils.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 
@@ -42,7 +42,7 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 @Category(DistributedTest.class)
-public class MultiUserAPIDUnitTest extends ClientAuthorizationTestBase {
+public class MultiUserAPIDUnitTest extends ClientAuthorizationTestCase {
 
   private static final String[] serverIgnoredExceptions = {
       AuthenticationRequiredException.class.getName(),
@@ -95,8 +95,8 @@ public class MultiUserAPIDUnitTest extends ClientAuthorizationTestBase {
       }
 
     } else { // multiuser mode
-      Region realRegion = GemFireCacheImpl.getInstance().getRegion(SecurityTestUtil.REGION_NAME);
-      Region proxyRegion = SecurityTestUtil.getProxyCaches(0).getRegion(SecurityTestUtil.REGION_NAME);
+      Region realRegion = GemFireCacheImpl.getInstance().getRegion(SecurityTestUtils.REGION_NAME);
+      Region proxyRegion = SecurityTestUtils.getProxyCaches(0).getRegion(SecurityTestUtils.REGION_NAME);
       Pool pool = PoolManagerImpl.getPMI().find("testPool");
 
       for (int i = 0; i <= 27; i++) {
@@ -200,12 +200,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.REGION_NAME);
+              Query query = pool.getQueryService().newQuery("SELECT * FROM /" + SecurityTestUtils.REGION_NAME);
               query.execute();
               break;
             case 21:
               op = "QueryService.newCq.execute()";
-              CqQuery cqQuery = pool.getQueryService().newCq("SELECT * FROM /" + SecurityTestUtil.REGION_NAME, new CqAttributesFactory().create());
+              CqQuery cqQuery = pool.getQueryService().newCq("SELECT * FROM /" + SecurityTestUtils.REGION_NAME, new CqAttributesFactory().create());
               try {
                 cqQuery.execute();
               } catch (CqException ce) {
@@ -214,7 +214,7 @@ public class MultiUserAPIDUnitTest extends ClientAuthorizationTestBase {
               break;
             case 22:
               op = "QueryService.newCq.executeWithInitialResults()";
-              cqQuery = pool.getQueryService().newCq("SELECT * FROM /" + SecurityTestUtil.REGION_NAME, new CqAttributesFactory().create());
+              cqQuery = pool.getQueryService().newCq("SELECT * FROM /" + SecurityTestUtils.REGION_NAME, new CqAttributesFactory().create());
               try {
                 cqQuery.executeWithInitialResults();
               } catch (CqException ce) {
@@ -225,15 +225,15 @@ public class MultiUserAPIDUnitTest extends ClientAuthorizationTestBase {
             // expect an exception, fail otherwise.
             case 23:
               op = "ProxyQueryService().getIndexes()";
-              SecurityTestUtil.getProxyCaches(0).getQueryService().getIndexes(null);
+              SecurityTestUtils.getProxyCaches(0).getQueryService().getIndexes(null);
               break;
             case 24:
               op = "ProxyQueryService().createIndex()";
-              SecurityTestUtil.getProxyCaches(0).getQueryService().createIndex(null, null, null );
+              SecurityTestUtils.getProxyCaches(0).getQueryService().createIndex(null, null, null );
               break;
             case 25:
               op = "ProxyQueryService().removeIndexes()";
-              SecurityTestUtil.getProxyCaches(0).getQueryService().removeIndexes();
+              SecurityTestUtils.getProxyCaches(0).getQueryService().removeIndexes();
               break;
             case 26:
               op = "ProxyRegion.localDestroy()";
@@ -270,9 +270,9 @@ public class MultiUserAPIDUnitTest extends ClientAuthorizationTestBase {
     getLogWriter().info("testValidCredentials: Using authinit: " + authInit);
 
     // Start the servers
-    int locPort1 = SecurityTestUtil.getLocatorPort();
-    int locPort2 = SecurityTestUtil.getLocatorPort();
-    String locString = SecurityTestUtil.getLocatorString();
+    int locPort1 = SecurityTestUtils.getLocatorPort();
+    int locPort2 = SecurityTestUtils.getLocatorPort();
+    String locString = SecurityTestUtils.getLocatorString();
 
     int port1 = server1.invoke(() -> createCacheServer(locPort1, locString, authenticator, extraProps, javaProps));
     int port2 = server2.invoke(() -> createCacheServer(locPort2, locString, authenticator, extraProps, javaProps));
@@ -299,12 +299,12 @@ public class MultiUserAPIDUnitTest extends ClientAuthorizationTestBase {
       authProps.setProperty(SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator);
     }
 
-    return SecurityTestUtil.createCacheServer(authProps, javaProps, dsPort, locatorString, 0, NO_EXCEPTION);
+    return SecurityTestUtils.createCacheServer(authProps, javaProps, dsPort, locatorString, 0, NO_EXCEPTION);
   }
 
   // a
   protected static void createCacheClient(final String authInit, final Properties authProps, final Properties javaProps, final int[] ports, final int numConnections, final boolean multiUserMode, final int expectedResult) {
-    SecurityTestUtil.createCacheClient(authInit, authProps, javaProps, ports, numConnections, multiUserMode, expectedResult); // invokes SecurityTestUtil 2
+    SecurityTestUtils.createCacheClient(authInit, authProps, javaProps, ports, numConnections, multiUserMode, expectedResult); // invokes SecurityTestUtils 2
   }
 
   // b

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/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 4be434a..632a997 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
@@ -17,7 +17,7 @@
 package com.gemstone.gemfire.security;
 
 import static com.gemstone.gemfire.internal.AvailablePort.*;
-import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.security.SecurityTestUtils.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
 import static com.gemstone.gemfire.test.dunit.Invoke.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
@@ -49,7 +49,7 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 @Category(DistributedTest.class)
-public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBase {
+public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestCase {
 
   private final Map<String, String> cqNameToQueryStrings = new HashMap<>();
 
@@ -246,7 +246,7 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
   }
 
   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);
+    SecurityTestUtils.createCacheServer(serverProps, javaProps, locatorPort, null, serverPort, true, NO_EXCEPTION);
   }
 
   private void readyForEvents() {


[4/7] incubator-geode git commit: Rename security utility classes

Posted by kl...@apache.org.
Rename security utility classes


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

Branch: refs/heads/feature/GEODE-693
Commit: 310698c1ece896717f574bac3c18d9804f2139a1
Parents: b799744
Author: Kirk Lund <kl...@apache.org>
Authored: Tue Mar 29 12:26:09 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue Mar 29 12:26:09 2016 -0700

----------------------------------------------------------------------
 .../security/ClientAuthenticationTestCase.java  |    4 +-
 .../security/ClientAuthenticationTestUtils.java |   93 +
 .../security/ClientAuthenticationUtils.java     |   93 -
 .../security/ClientAuthorizationDUnitTest.java  |   28 +-
 .../security/ClientAuthorizationTestBase.java   | 1333 -------------
 .../security/ClientAuthorizationTestCase.java   | 1333 +++++++++++++
 .../security/ClientMultiUserAuthzDUnitTest.java |   10 +-
 .../DeltaClientAuthorizationDUnitTest.java      |    7 +-
 .../DeltaClientPostAuthorizationDUnitTest.java  |    9 +-
 .../security/P2PAuthenticationDUnitTest.java    |   12 +-
 .../gemfire/security/SecurityTestUtil.java      | 1793 ------------------
 .../gemfire/security/SecurityTestUtils.java     | 1793 ++++++++++++++++++
 .../ClientAuthorizationTwoDUnitTest.java        |    4 +-
 .../security/ClientAuthzObjectModDUnitTest.java |    4 +-
 .../ClientCQPostAuthorizationDUnitTest.java     |    6 +-
 .../ClientPostAuthorizationDUnitTest.java       |    4 +-
 .../gemfire/security/MultiuserAPIDUnitTest.java |   30 +-
 .../MultiuserDurableCQAuthzDUnitTest.java       |    6 +-
 18 files changed, 3280 insertions(+), 3282 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/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
index 3c1ab1d..ea3d941 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestCase.java
@@ -17,8 +17,8 @@
 package com.gemstone.gemfire.security;
 
 import static com.gemstone.gemfire.internal.AvailablePort.*;
-import static com.gemstone.gemfire.security.ClientAuthenticationUtils.*;
-import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.security.ClientAuthenticationTestUtils.*;
+import static com.gemstone.gemfire.security.SecurityTestUtils.*;
 import static com.gemstone.gemfire.test.dunit.IgnoredException.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 import static com.gemstone.gemfire.test.dunit.Wait.*;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestUtils.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestUtils.java
new file mode 100644
index 0000000..dc78a5a
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestUtils.java
@@ -0,0 +1,93 @@
+/*
+ * 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.SecurityTestUtils.*;
+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 abstract class ClientAuthenticationTestUtils {
+
+  protected ClientAuthenticationTestUtils() {
+  }
+
+  protected static Integer createCacheServer(int dsPort, String locatorString, String authenticator, Properties extraProps, Properties javaProps) {
+    Properties authProps;
+    if (extraProps == null) {
+      authProps = new Properties();
+    } else {
+      authProps = extraProps;
+    }
+
+    if (authenticator != null) {
+      authProps.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator);
+    }
+
+    return SecurityTestUtils.createCacheServer(authProps, javaProps, dsPort, locatorString, 0, NO_EXCEPTION);
+  }
+
+  protected 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 = extraProps;
+    }
+
+    if (authenticator != null) {
+      authProps.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator);
+    }
+    SecurityTestUtils.createCacheServer(authProps, javaProps, dsPort, locatorString, serverPort, NO_EXCEPTION);
+  }
+
+  protected static void createCacheClient(String authInit, Properties authProps, Properties javaProps, int[] ports, int numConnections, boolean multiUserMode, boolean subscriptionEnabled, int expectedResult) {
+    SecurityTestUtils.createCacheClient(authInit, authProps, javaProps, ports, numConnections, false, multiUserMode, subscriptionEnabled, expectedResult);
+  }
+
+  protected static void createCacheClient(String authInit, Properties authProps, Properties javaProps, int[] ports, int numConnections, boolean multiUserMode, int expectedResult) {
+    createCacheClient(authInit, authProps, javaProps, ports, numConnections, multiUserMode, true, expectedResult);
+  }
+
+  protected 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);
+  }
+
+  protected 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);
+  }
+
+  protected 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);
+  }
+
+  protected 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);
+  }
+
+  protected static void registerAllInterest() {
+    Region region = getCache().getRegion(REGION_NAME);
+    assertNotNull(region);
+    region.registerInterestRegex(".*");
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/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
deleted file mode 100644
index 459ab0c..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationUtils.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package 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 abstract class ClientAuthenticationUtils {
-
-  protected ClientAuthenticationUtils() {
-  }
-
-  protected static Integer createCacheServer(int dsPort, String locatorString, String authenticator, Properties extraProps, Properties javaProps) {
-    Properties authProps;
-    if (extraProps == null) {
-      authProps = new Properties();
-    } else {
-      authProps = extraProps;
-    }
-
-    if (authenticator != null) {
-      authProps.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator);
-    }
-
-    return SecurityTestUtil.createCacheServer(authProps, javaProps, dsPort, locatorString, 0, NO_EXCEPTION);
-  }
-
-  protected 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 = extraProps;
-    }
-
-    if (authenticator != null) {
-      authProps.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator);
-    }
-    SecurityTestUtil.createCacheServer(authProps, javaProps, dsPort, locatorString, serverPort, NO_EXCEPTION);
-  }
-
-  protected 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);
-  }
-
-  protected static void createCacheClient(String authInit, Properties authProps, Properties javaProps, int[] ports, int numConnections, boolean multiUserMode, int expectedResult) {
-    createCacheClient(authInit, authProps, javaProps, ports, numConnections, multiUserMode, true, expectedResult);
-  }
-
-  protected 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);
-  }
-
-  protected 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);
-  }
-
-  protected 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);
-  }
-
-  protected 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);
-  }
-
-  protected static void registerAllInterest() {
-    Region region = getCache().getRegion(REGION_NAME);
-    assertNotNull(region);
-    region.registerInterestRegex(".*");
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/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 69e2843..33a32ff 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
@@ -19,9 +19,9 @@
 package com.gemstone.gemfire.security;
 
 import static com.gemstone.gemfire.internal.AvailablePort.*;
-//import static com.gemstone.gemfire.security.ClientAuthenticationUtils.*;
-//import static com.gemstone.gemfire.security.ClientAuthorizationTestBase.*;
-import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+//import static com.gemstone.gemfire.security.ClientAuthenticationTestUtils.*;
+//import static com.gemstone.gemfire.security.ClientAuthorizationTestCase.*;
+import static com.gemstone.gemfire.security.SecurityTestUtils.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
 import static com.gemstone.gemfire.test.dunit.IgnoredException.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
@@ -51,7 +51,7 @@ import org.junit.experimental.categories.Category;
  * @since 5.5
  */
 @Category(DistributedTest.class)
-public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
+public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestCase {
 
   @Override
   public final void preTearDownClientAuthorizationTestBase() throws Exception {
@@ -223,10 +223,10 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
 
     getLogWriter().info("testInvalidAccessor: For second client GET credentials: " + getCredentials);
 
-    client1.invoke(() -> ClientAuthenticationUtils.createCacheClient( authInit, createCredentials, createJavaProps, port1, port2, 0, false, false, NO_EXCEPTION));
+    client1.invoke(() -> ClientAuthenticationTestUtils.createCacheClient( authInit, createCredentials, createJavaProps, port1, port2, 0, false, false, NO_EXCEPTION));
     client1.invoke(() -> doPuts(1, AUTHFAIL_EXCEPTION));
 
-    client2.invoke(() -> ClientAuthenticationUtils.createCacheClient( authInit, getCredentials, getJavaProps, port1, port2, 0, false, false, NO_EXCEPTION));
+    client2.invoke(() -> ClientAuthenticationTestUtils.createCacheClient( authInit, getCredentials, getJavaProps, port1, port2, 0, false, false, NO_EXCEPTION));
     client2.invoke(() -> doPuts(1, AUTHFAIL_EXCEPTION));
 
     // Now start server2 that has valid accessor
@@ -314,7 +314,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
     client2.invoke(() -> doGets(4, NOTAUTHZ_EXCEPTION));
 
     // force a failover and do the drill again
-    server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer( getLocatorPort(), port1, serverProps, javaProps ));
+    server1.invoke(() -> ClientAuthorizationTestCase.createCacheServer( getLocatorPort(), port1, serverProps, javaProps ));
     server2.invoke(() -> closeCache());
 
     // Perform some put operations from client1
@@ -369,7 +369,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
         // End of current operation block; execute all the operations on the servers with/without failover
         if (opBlock.size() > 0) {
           // Start the first server and execute the operation block
-          server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(getLocatorPort(), port1, serverProps, javaProps));
+          server1.invoke(() -> ClientAuthorizationTestCase.createCacheServer(getLocatorPort(), port1, serverProps, javaProps));
           server2.invoke(() -> closeCache());
 
           executeRIOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, javaProps);
@@ -619,28 +619,28 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
       } else {
         byte ordinal = opCode.toOrdinal();
         int[] indices = currentOp.getIndices();
-        clientVM.invoke(() -> ClientAuthorizationTestBase.doOp(ordinal, indices, opFlags, expectedResult));
+        clientVM.invoke(() -> ClientAuthorizationTestCase.doOp(ordinal, indices, opFlags, expectedResult));
       }
     }
   }
 
   private void createClient2NoException(final Properties javaProps, final String authInit, final int port1, final int port2, final Properties getCredentials) {
-    client2.invoke(() -> ClientAuthenticationUtils.createCacheClient(authInit, getCredentials, javaProps, port1, port2, 0, NO_EXCEPTION));
+    client2.invoke(() -> ClientAuthenticationTestUtils.createCacheClient(authInit, getCredentials, javaProps, port1, port2, 0, NO_EXCEPTION));
   }
 
   private void createClient1NoException(final Properties javaProps, final String authInit, final int port1, final int port2, final Properties createCredentials) {
-    client1.invoke(() -> ClientAuthenticationUtils.createCacheClient(authInit, createCredentials, javaProps, port1, port2, 0, NO_EXCEPTION));
+    client1.invoke(() -> ClientAuthenticationTestUtils.createCacheClient(authInit, createCredentials, javaProps, port1, port2, 0, NO_EXCEPTION));
   }
 
   private int createServer2(final Properties javaProps, final Properties serverProps) {
-    return server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(getLocatorPort(), serverProps, javaProps));
+    return server2.invoke(() -> ClientAuthorizationTestCase.createCacheServer(getLocatorPort(), serverProps, javaProps));
   }
 
   private int createServer1(final Properties javaProps, final Properties serverProps) {
-    return server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(getLocatorPort(), serverProps, javaProps));
+    return server1.invoke(() -> ClientAuthorizationTestCase.createCacheServer(getLocatorPort(), serverProps, javaProps));
   }
 
   private void createServer2(Properties javaProps, Properties serverProps, int port2) {
-    server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(getLocatorPort(), port2, serverProps, javaProps));
+    server2.invoke(() -> ClientAuthorizationTestCase.createCacheServer(getLocatorPort(), port2, serverProps, javaProps));
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/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
deleted file mode 100644
index 0f32306..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestBase.java
+++ /dev/null
@@ -1,1333 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package 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.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;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Random;
-import java.util.Set;
-
-import com.gemstone.gemfire.cache.DynamicRegionFactory;
-import com.gemstone.gemfire.cache.InterestResultPolicy;
-import com.gemstone.gemfire.cache.Operation;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.Region.Entry;
-import com.gemstone.gemfire.cache.RegionDestroyedException;
-import com.gemstone.gemfire.cache.client.ServerConnectivityException;
-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.CqEvent;
-import com.gemstone.gemfire.cache.query.CqException;
-import com.gemstone.gemfire.cache.query.CqListener;
-import com.gemstone.gemfire.cache.query.CqQuery;
-import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
-import com.gemstone.gemfire.cache.query.QueryService;
-import com.gemstone.gemfire.cache.query.SelectResults;
-import com.gemstone.gemfire.cache.query.Struct;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.AvailablePort.Keeper;
-import com.gemstone.gemfire.internal.cache.AbstractRegionEntry;
-import com.gemstone.gemfire.internal.cache.LocalRegion;
-import com.gemstone.gemfire.internal.util.Callable;
-import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
-import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator.ClassCode;
-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.VM;
-import com.gemstone.gemfire.test.dunit.WaitCriterion;
-import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
-
-/**
- * Base class for tests for authorization from client to server. It contains
- * utility functions for the authorization tests from client to server.
- * 
- * @since 5.5
- */
-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 = REGION_NAME;
-  protected static final String subregionName = "AuthSubregion";
-
-  private static final String[] serverIgnoredExceptions = {
-      "Connection refused",
-      AuthenticationRequiredException.class.getName(),
-      AuthenticationFailedException.class.getName(),
-      NotAuthorizedException.class.getName(),
-      GemFireSecurityException.class.getName(),
-      RegionDestroyedException.class.getName(),
-      ClassNotFoundException.class.getName()
-  };
-
-  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 {
-    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 {
-  }
-
-  protected void postSetUpClientAuthorizationTestBase() throws Exception {
-  }
-
-  @Override
-  public final void preTearDown() throws Exception {
-    preTearDownClientAuthorizationTestBase();
-    tearDownClientAuthorizationTestBase();
-    postTearDownClientAuthorizationTestBase();
-  }
-
-  @Override
-  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) {
-    Properties authProps = new Properties();
-    if (authenticator != null) {
-      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);
-      }
-    }
-    return concatProperties(new Properties[] { authProps, extraAuthProps, extraAuthzProps });
-  }
-
-  protected static Integer createCacheServer(int locatorPort, Properties authProps, Properties javaProps) {
-    if (locatorPort == 0) {
-      locatorPort = getRandomAvailablePort(SOCKET);
-    }
-    return SecurityTestUtil.createCacheServer(authProps, javaProps, locatorPort, null, 0, true, NO_EXCEPTION);
-  }
-
-  protected static int createCacheServer(int locatorPort, int serverPort, Properties authProps, Properties javaProps) {
-    if (locatorPort == 0) {
-      locatorPort = getRandomAvailablePort(SOCKET);
-    }
-    return SecurityTestUtil.createCacheServer(authProps, javaProps, locatorPort, null, serverPort, true, NO_EXCEPTION);
-  }
-
-  protected static Region getRegion() {
-    return getCache().getRegion(regionName);
-  }
-
-  protected static Region getSubregion() {
-    return getCache().getRegion(regionName + '/' + subregionName);
-  }
-
-  private static Region createSubregion(Region region) {
-    Region subregion = getSubregion();
-    if (subregion == null) {
-      subregion = region.createSubregion(subregionName, region.getAttributes());
-    }
-    return subregion;
-  }
-
-  protected static String indicesToString(int[] indices) {
-    String str = "";
-    if (indices != null && indices.length > 0) {
-      str += indices[0];
-      for (int index = 1; index < indices.length; ++index) {
-        str += ",";
-        str += indices[index];
-      }
-    }
-    return str;
-  }
-
-  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
-          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
-          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
-      waitForCondition(new Callable() {
-        public Object call() throws Exception {
-          return Boolean.valueOf(getRegion() == null);
-        }
-      });
-      region = getRegion();
-      assertNull(region);
-      return;
-
-    } else {
-      assertNotNull(region);
-    }
-
-    final String[] keys = KEYS;
-    final String[] vals;
-    if ((flags & OpFlags.USE_NEWVAL) > 0) {
-      vals = NVALUES;
-    }
-    else {
-      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);
-    boolean exceptionOccured = false;
-    boolean breakLoop = false;
-
-    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
-          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) {
-                AbstractRegionEntry entry = (AbstractRegionEntry)((LocalRegion)region).getRegionEntry(searchKey);
-                System.out.println(""+keyNum+": key is " + searchKey + " and entry is " + entry);
-                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;
-
-              @Override
-              public Object call() throws Exception {
-                Object value = 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);
-
-            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);
-
-            getCache().getCacheTransactionManager().commit();
-            value = e.getValue();
-
-          } else {
-            if ((flags & OpFlags.CHECK_NOKEY) > 0) {
-              assertFalse(region.containsKey(key));
-            } 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 {
-            assertNotNull(value);
-            assertEquals(expectedVal, value);
-          }
-
-        } else if (op.isPut()) {
-          region.put(key, expectedVal);
-
-        } 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()) {
-          // if (!region.containsKey(key)) {
-          // // Since DESTROY will fail unless the value is present
-          // // in the local cache, this is a workaround for two cases:
-          // // 1. When the operation is supposed to succeed then in
-          // // the current AuthzCredentialGenerators the clients having
-          // // DESTROY permission also has CREATE/UPDATE permission
-          // // so that calling region.put() will work for that case.
-          // // 2. When the operation is supposed to fail with
-          // // NotAuthorizedException then in the current
-          // // AuthzCredentialGenerators the clients not
-          // // having DESTROY permission are those with reader role that have
-          // // GET permission.
-          // //
-          // // If either of these assumptions fails, then this has to be
-          // // adjusted or reworked accordingly.
-          // if ((flags & OpFlags.CHECK_NOTAUTHZ) > 0) {
-          // Object value = region.get(key);
-          // assertNotNull(value);
-          // assertEquals(vals[index], value);
-          // }
-          // else {
-          // region.put(key, vals[index]);
-          // }
-          // }
-          if ((flags & OpFlags.LOCAL_OP) > 0) {
-            region.localDestroy(key);
-          }
-          else {
-            region.destroy(key);
-          }
-
-        } else if (op.isInvalidate()) {
-          if (region.containsKey(key)) {
-            if ((flags & OpFlags.LOCAL_OP) > 0) {
-              region.localInvalidate(key);
-            } else {
-              region.invalidate(key);
-            }
-          }
-
-        } else if (op.isContainsKey()) {
-          boolean result;
-          if ((flags & OpFlags.LOCAL_OP) > 0) {
-            result = region.containsKey(key);
-          } else {
-            result = region.containsKeyOnServer(key);
-          }
-          if ((flags & OpFlags.CHECK_FAIL) > 0) {
-            assertFalse(result);
-          } else {
-            assertTrue(result);
-          }
-
-        } 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 if (op.isUnregisterInterest()) {
-          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.unregisterInterest(keyList);
-
-          } else if ((flags & OpFlags.USE_REGEX) > 0) {
-            breakLoop = true;
-            region.unregisterInterestRegex("key[1-" + numOps + ']');
-
-          } else if ((flags & OpFlags.USE_ALL_KEYS) > 0) {
-            breakLoop = true;
-            region.unregisterInterest("ALL_KEYS");
-
-          } else {
-            region.unregisterInterest(key);
-          }
-
-        } else if (op.isKeySet()) {
-          breakLoop = true;
-          Set keySet;
-          if ((flags & OpFlags.LOCAL_OP) > 0) {
-            keySet = region.keySet();
-          } else {
-            keySet = region.keySetOnServer();
-          }
-
-          assertNotNull(keySet);
-          if ((flags & OpFlags.CHECK_FAIL) == 0) {
-            assertEquals(numOps, keySet.size());
-          }
-          for (int keyNumIndex = 0; keyNumIndex < numOps; ++keyNumIndex) {
-            int keyNum = indices[keyNumIndex];
-            if ((flags & OpFlags.CHECK_FAIL) > 0) {
-              assertFalse(keySet.contains(keys[keyNum]));
-            } else {
-              assertTrue(keySet.contains(keys[keyNum]));
-            }
-          }
-
-        } else if (op.isQuery()) {
-          breakLoop = true;
-          SelectResults queryResults = region.query("SELECT DISTINCT * FROM " + region.getFullPath());
-          assertNotNull(queryResults);
-          Set queryResultSet = queryResults.asSet();
-          if ((flags & OpFlags.CHECK_FAIL) == 0) {
-            assertEquals(numOps, queryResultSet.size());
-          }
-          for (int keyNumIndex = 0; keyNumIndex < numOps; ++keyNumIndex) {
-            int keyNum = indices[keyNumIndex];
-            if ((flags & OpFlags.CHECK_FAIL) > 0) {
-              assertFalse(queryResultSet.contains(vals[keyNum]));
-            } else {
-              assertTrue(queryResultSet.contains(vals[keyNum]));
-            }
-          }
-
-        } else if (op.isExecuteCQ()) {
-          breakLoop = true;
-          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);
-          }
-
-          if ((flags & OpFlags.LOCAL_OP) > 0) {
-            // Interpret this as testing results using CqListener
-            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 {
-                  return numOps == listener.getNumUpdates();
-                }
-              }
-              @Override
-              public String description() {
-                return null;
-              }
-            };
-            waitForCriterion(ev, 3 * 1000, 200, true);
-
-            if ((flags & OpFlags.CHECK_FAIL) > 0) {
-              assertEquals(0, listener.getNumUpdates());
-            } 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 {
-            SelectResults cqResults = cqQuery.executeWithInitialResults();
-            assertNotNull(cqResults);
-            Set cqResultValues = new HashSet();
-            for (Object o : cqResults.asList()) {
-              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 {
-                assertTrue(cqResultValues.contains(vals[keyNum]));
-              }
-            }
-          }
-
-        } else if (op.isStopCQ()) {
-          breakLoop = true;
-          CqQuery cqQuery = getCache().getQueryService().getCq("cq1");
-          ((AuthzCqListener)cqQuery.getCqAttributes().getCqListener()).reset();
-          cqQuery.stop();
-
-        } else if (op.isCloseCQ()) {
-          breakLoop = true;
-          CqQuery cqQuery = getCache().getQueryService().getCq("cq1");
-          ((AuthzCqListener)cqQuery.getCqAttributes().getCqListener()).reset();
-          cqQuery.close();
-
-        } else if (op.isRegionClear()) {
-          breakLoop = true;
-          if ((flags & OpFlags.LOCAL_OP) > 0) {
-            region.localClear();
-          } else {
-            region.clear();
-          }
-
-        } else if (op.isRegionCreate()) {
-          breakLoop = true;
-          // Region subregion = createSubregion(region);
-          // subregion.createRegionOnServer();
-          // Create region on server using the DynamicRegionFactory
-          // 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()) {
-          breakLoop = true;
-          if ((flags & OpFlags.LOCAL_OP) > 0) {
-            region.localDestroyRegion();
-
-          } else {
-            if ((flags & OpFlags.USE_SUBREGION) > 0) {
-              try {
-                DynamicRegionFactory.get().destroyDynamicRegion(region.getFullPath());
-              } catch (RegionDestroyedException ex) {
-                // harmless to ignore this
-                System.out.println("doOp: sub-region " + region.getFullPath() + " already destroyed");
-                operationOmitted = true;
-              }
-            } else {
-              region.destroyRegion();
-            }
-          }
-
-        } else {
-          fail("doOp: Unhandled operation " + op);
-        }
-
-        if (expectedResult.intValue() != 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.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() == 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);
-        }
-      }
-    }
-    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) 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;
-          break;
-        case 2:
-          clientVM = client2;
-          break;
-        case 3:
-          useThisVM = true;
-          break;
-        default:
-          fail("executeOpBlock: Unknown client number " + clientNum);
-          break;
-      }
-
-      System.out.println("executeOpBlock: performing operation number [" + currentOp.getOpNum() + "]: " + currentOp);
-      if ((opFlags & OpFlags.USE_OLDCONN) == 0) {
-        Properties opCredentials;
-        int newRnd = rnd.nextInt(100) + 1;
-        String currentRegionName = '/' + regionName;
-        if ((opFlags & OpFlags.USE_SUBREGION) > 0) {
-          currentRegionName += ('/' + subregionName);
-        }
-
-        String credentialsTypeStr;
-        OperationCode authOpCode = currentOp.getAuthzOperationCode();
-        int[] indices = currentOp.getIndices();
-        CredentialGenerator cGen = gen.getCredentialGenerator();
-        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);
-          credentialsTypeStr = " authorized " + authOpCode;
-        }
-
-        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) {
-          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 = 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 {
-        byte ordinal = opCode.toOrdinal();
-        int[] indices = currentOp.getIndices();
-        clientVM.invoke(() -> ClientAuthorizationTestBase.doOp( new Byte(ordinal), indices, new Integer(opFlags), new Integer(expectedResult) ));
-      }
-    }
-  }
-
-  protected AuthzCredentialGenerator getXmlAuthzGenerator(){
-    AuthzCredentialGenerator authzGen = new XmlAuthzCredentialGenerator();
-    CredentialGenerator cGen = new DummyCredentialGenerator();
-    cGen.init();
-    authzGen.init(cGen);
-    return authzGen;
-  }
-
-  protected List getDummyGeneratorCombos() {
-    List generators = new ArrayList();
-    Iterator authzCodeIter = AuthzCredentialGenerator.ClassCode.getAll().iterator();
-
-    while (authzCodeIter.hasNext()) {
-      ClassCode authzClassCode = (ClassCode) authzCodeIter.next();
-      AuthzCredentialGenerator authzGen = AuthzCredentialGenerator.create(authzClassCode);
-
-      if (authzGen != null) {
-        CredentialGenerator cGen = new DummyCredentialGenerator();
-        cGen.init();
-        if (authzGen.init(cGen)) {
-          generators.add(authzGen);
-        }
-      }
-    }
-
-    assertTrue(generators.size() > 0);
-    return generators;
-  }
-
-  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 = getRandomAvailablePortKeeper(SOCKET);
-    Keeper locator2PortKeeper = getRandomAvailablePortKeeper(SOCKET);
-    Keeper port1Keeper = getRandomAvailablePortKeeper(SOCKET);
-    Keeper port2Keeper = getRandomAvailablePortKeeper(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);
-      }
-    }
-  }
-
-  /**
-   * Implements the {@link CqListener} interface and counts the number of
-   * different operations and also queues up the received updates to precise
-   * checking of each update.
-   * 
-   * @since 5.5
-   */
-  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() {
-      this.eventList = new ArrayList();
-      reset();
-    }
-
-    public void reset() {
-      this.eventList.clear();
-      this.numCreates = 0;
-      this.numUpdates = 0;
-      this.numErrors = 0;
-    }
-
-    public void onEvent(CqEvent aCqEvent) {
-      Operation op = aCqEvent.getBaseOperation();
-      if (op.isCreate()) {
-        ++this.numCreates;
-      } else if (op.isUpdate()) {
-        ++this.numUpdates;
-      } else if (op.isDestroy()) {
-        ++this.numDestroys;
-      } else {
-        ++this.numOtherOps;
-      }
-      eventList.add(aCqEvent);
-    }
-
-    public void onError(CqEvent aCqEvent) {
-      ++this.numErrors;
-    }
-
-    public void close() {
-      this.eventList.clear();
-    }
-
-    public int getNumCreates() {
-      return this.numCreates;
-    }
-
-    public int getNumUpdates() {
-      return this.numUpdates;
-    }
-
-    public int getNumDestroys() {
-      return this.numDestroys;
-    }
-
-    public int getNumOtherOps() {
-      return this.numOtherOps;
-    }
-
-    public int getNumErrors() {
-      return this.numErrors;
-    }
-
-    public void checkPuts(String[] vals, int[] indices) {
-      for (int indexIndex = 0; indexIndex < indices.length; ++indexIndex) {
-        int index = indices[indexIndex];
-        Iterator eventIter = this.eventList.iterator();
-        boolean foundKey = false;
-
-        while (eventIter.hasNext()) {
-          CqEvent event = (CqEvent)eventIter.next();
-          if (KEYS[index].equals(event.getKey())) {
-            assertEquals(vals[index], event.getNewValue());
-            foundKey = true;
-            break;
-          }
-        }
-
-        assertTrue(foundKey);
-      }
-    }
-  }
-
-  /**
-   * This class specifies flags that can be used to alter the behaviour of
-   * operations being performed by the <code>doOp</code> function.
-   * 
-   * @since 5.5
-   */
-  protected static class OpFlags {
-
-    /**
-     * Default behaviour.
-     */
-    public static final int NONE = 0x0;
-
-    /**
-     * Check that the operation should fail.
-     */
-    public static final int CHECK_FAIL = 0x1;
-
-    /**
-     * Check that the operation should throw <code>NotAuthorizedException</code>.
-     */
-    public static final int CHECK_NOTAUTHZ = 0x2;
-
-    /**
-     * Check that the region should not be available.
-     */
-    public static final int CHECK_NOREGION = 0x4;
-
-    /**
-     * Check that the operation should throw an exception other than the
-     * <code>NotAuthorizedException</code>.
-     */
-    public static final int CHECK_EXCEPTION = 0x8;
-
-    /**
-     * Check for nvalues[] instead of values[].
-     */
-    public static final int USE_NEWVAL = 0x10;
-
-    /**
-     * Register all KEYS. For GET operations indicates using getAll().
-     */
-    public static final int USE_ALL_KEYS = 0x20;
-
-    /**
-     * Register a regular expression.
-     */
-    public static final int USE_REGEX = 0x40;
-
-    /**
-     * Register a list of KEYS.
-     */
-    public static final int USE_LIST = 0x80;
-
-    /**
-     * Perform the local version of the operation.
-     */
-    public static final int LOCAL_OP = 0x100;
-
-    /**
-     * Check that the key for the operation should not be present.
-     */
-    public static final int CHECK_NOKEY = 0x200;
-
-    /**
-     * Use the sub-region for performing the operation.
-     */
-    public static final int USE_SUBREGION = 0x400;
-
-    /**
-     * Do not try to create the sub-region.
-     */
-    public static final int NO_CREATE_SUBREGION = 0x800;
-
-    /**
-     * Do not re-connect using new credentials rather use the previous
-     * connection.
-     */
-    public static final int USE_OLDCONN = 0x1000;
-
-    /**
-     * Do the connection with unauthorized credentials but do not check that the
-     * operation throws <code>NotAuthorizedException</code>.
-     */
-    public static final int USE_NOTAUTHZ = 0x2000;
-
-    /**
-     * Enable {@link DynamicRegionFactory} on the client.
-     */
-    public static final int ENABLE_DRF = 0x4000;
-
-    /**
-     * Use the {@link InterestResultPolicy#NONE} for register interest.
-     */
-    public static final int REGISTER_POLICY_NONE = 0x8000;
-    
-    /**
-     * Use the {@link LocalRegion#getEntry} under transaction.
-     */
-    public static final int USE_GET_ENTRY_IN_TX = 0x10000;
-
-    public static String description(int f) {
-      StringBuffer sb = new StringBuffer();
-      sb.append("[");
-      if ((f & CHECK_FAIL) != 0) {
-        sb.append("CHECK_FAIL,");
-      }
-      if ((f & CHECK_NOTAUTHZ) != 0) {
-        sb.append("CHECK_NOTAUTHZ,");
-      }
-      if ((f & CHECK_NOREGION) != 0) {
-        sb.append("CHECK_NOREGION,");
-      }
-      if ((f & CHECK_EXCEPTION) != 0) {
-        sb.append("CHECK_EXCEPTION,");
-      }
-      if ((f & USE_NEWVAL) != 0) {
-        sb.append("USE_NEWVAL,");
-      }
-      if ((f & USE_ALL_KEYS) != 0) {
-        sb.append("USE_ALL_KEYS,");
-      }
-      if ((f & USE_REGEX) != 0) {
-        sb.append("USE_REGEX,");
-      }
-      if ((f & USE_LIST) != 0) {
-        sb.append("USE_LIST,");
-      }
-      if ((f & LOCAL_OP) != 0) {
-        sb.append("LOCAL_OP,");
-      }
-      if ((f & CHECK_NOKEY) != 0) {
-        sb.append("CHECK_NOKEY,");
-      }
-      if ((f & USE_SUBREGION) != 0) {
-        sb.append("USE_SUBREGION,");
-      }
-      if ((f & NO_CREATE_SUBREGION) != 0) {
-        sb.append("NO_CREATE_SUBREGION,");
-      }
-      if ((f & USE_OLDCONN) != 0) {
-        sb.append("USE_OLDCONN,");
-      }
-      if ((f & USE_NOTAUTHZ) != 0) {
-        sb.append("USE_NOTAUTHZ");
-      }
-      if ((f & ENABLE_DRF) != 0) {
-        sb.append("ENABLE_DRF,");
-      }
-      if ((f & REGISTER_POLICY_NONE) != 0) {
-        sb.append("REGISTER_POLICY_NONE,");
-      }
-      sb.append("]");
-      return sb.toString();
-    }
-  }
-
-  /**
-   * This class encapsulates an {@link OperationCode} with associated flags, the
-   * client to perform the operation, and the number of operations to perform.
-   * 
-   * @since 5.5
-   */
-  protected static class OperationWithAction {
-
-    /**
-     * The operation to be performed.
-     */
-    private OperationCode opCode;
-
-    /**
-     * The operation for which authorized or unauthorized credentials have to be
-     * generated. This is the same as {@link #opCode} when not specified.
-     */
-    private OperationCode authzOpCode;
-
-    /**
-     * The client number on which the operation has to be performed.
-     */
-    private int clientNum;
-
-    /**
-     * Bitwise or'd {@link OpFlags} integer to change/specify the behaviour of
-     * the operations.
-     */
-    private int flags;
-
-    /**
-     * Indices of the KEYS array to be used for operations.
-     */
-    private int[] indices;
-
-    /**
-     * An index for the operation used for logging.
-     */
-    private int opNum;
-
-    /**
-     * Indicates end of an operation block which can be used for testing with
-     * failover
-     */
-    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);
-
-    private void setIndices(int numOps) {
-      this.indices = new int[numOps];
-      for (int index = 0; index < numOps; ++index) {
-        this.indices[index] = index;
-      }
-    }
-
-    public OperationWithAction(OperationCode opCode) {
-      this.opCode = opCode;
-      this.authzOpCode = opCode;
-      this.clientNum = 1;
-      this.flags = OpFlags.NONE;
-      setIndices(4);
-      this.opNum = 0;
-    }
-
-    public OperationWithAction(OperationCode opCode, int clientNum) {
-      this.opCode = opCode;
-      this.authzOpCode = opCode;
-      this.clientNum = clientNum;
-      this.flags = OpFlags.NONE;
-      setIndices(4);
-      this.opNum = 0;
-    }
-
-    public OperationWithAction(OperationCode opCode, int clientNum, int flags, int numOps) {
-      this.opCode = opCode;
-      this.authzOpCode = opCode;
-      this.clientNum = clientNum;
-      this.flags = flags;
-      setIndices(numOps);
-      this.opNum = 0;
-    }
-
-    public OperationWithAction(OperationCode opCode, OperationCode deniedOpCode, int clientNum, int flags, int numOps) {
-      this.opCode = opCode;
-      this.authzOpCode = deniedOpCode;
-      this.clientNum = clientNum;
-      this.flags = flags;
-      setIndices(numOps);
-      this.opNum = 0;
-    }
-
-    public OperationWithAction(OperationCode opCode, int clientNum, int flags, int[] indices) {
-      this.opCode = opCode;
-      this.authzOpCode = opCode;
-      this.clientNum = clientNum;
-      this.flags = flags;
-      this.indices = indices;
-      this.opNum = 0;
-    }
-
-    public OperationWithAction(OperationCode opCode, OperationCode deniedOpCode, int clientNum, int flags, int[] indices) {
-      this.opCode = opCode;
-      this.authzOpCode = deniedOpCode;
-      this.clientNum = clientNum;
-      this.flags = flags;
-      this.indices = indices;
-      this.opNum = 0;
-    }
-
-    public OperationCode getOperationCode() {
-      return this.opCode;
-    }
-
-    public OperationCode getAuthzOperationCode() {
-      return this.authzOpCode;
-    }
-
-    public int getClientNum() {
-      return this.clientNum;
-    }
-
-    public int getFlags() {
-      return this.flags;
-    }
-
-    public int[] getIndices() {
-      return this.indices;
-    }
-
-    public int getOpNum() {
-      return this.opNum;
-    }
-
-    public void setOpNum(int opNum) {
-      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);
-    }
-  }
-
-  /**
-   * Simple interface to generate credentials with authorization based on key
-   * indices also. This is utilized by the post-operation authorization tests
-   * where authorization is based on key indices.
-   * 
-   * @since 5.5
-   */
-  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);
-
-    /**
-     * 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);
-
-    /**
-     * Get the {@link CredentialGenerator} if any.
-     */
-    public CredentialGenerator getCredentialGenerator();
-  }
-
-  /**
-   * Contains a {@link AuthzCredentialGenerator} and implements the
-   * {@link TestCredentialGenerator} interface.
-   * 
-   * @since 5.5
-   */
-  protected static class TestAuthzCredentialGenerator implements TestCredentialGenerator {
-
-    private AuthzCredentialGenerator authzGen;
-
-    public TestAuthzCredentialGenerator(AuthzCredentialGenerator authzGen) {
-      this.authzGen = authzGen;
-    }
-
-    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) {
-      return this.authzGen.getDisallowedCredentials(opCodes, regionNames, num);
-    }
-
-    public CredentialGenerator getCredentialGenerator() {
-      return authzGen.getCredentialGenerator();
-    }
-  }
-}


[3/7] incubator-geode git commit: Rename security utility classes

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
new file mode 100644
index 0000000..be3de47
--- /dev/null
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
@@ -0,0 +1,1333 @@
+/*
+ * 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.internal.AvailablePort.*;
+import static com.gemstone.gemfire.security.SecurityTestUtils.*;
+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;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Random;
+import java.util.Set;
+
+import com.gemstone.gemfire.cache.DynamicRegionFactory;
+import com.gemstone.gemfire.cache.InterestResultPolicy;
+import com.gemstone.gemfire.cache.Operation;
+import com.gemstone.gemfire.cache.Region;
+import com.gemstone.gemfire.cache.Region.Entry;
+import com.gemstone.gemfire.cache.RegionDestroyedException;
+import com.gemstone.gemfire.cache.client.ServerConnectivityException;
+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.CqEvent;
+import com.gemstone.gemfire.cache.query.CqException;
+import com.gemstone.gemfire.cache.query.CqListener;
+import com.gemstone.gemfire.cache.query.CqQuery;
+import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
+import com.gemstone.gemfire.cache.query.QueryService;
+import com.gemstone.gemfire.cache.query.SelectResults;
+import com.gemstone.gemfire.cache.query.Struct;
+import com.gemstone.gemfire.distributed.internal.DistributionConfig;
+import com.gemstone.gemfire.internal.AvailablePort.Keeper;
+import com.gemstone.gemfire.internal.cache.AbstractRegionEntry;
+import com.gemstone.gemfire.internal.cache.LocalRegion;
+import com.gemstone.gemfire.internal.util.Callable;
+import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
+import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator.ClassCode;
+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.VM;
+import com.gemstone.gemfire.test.dunit.WaitCriterion;
+import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
+
+/**
+ * Base class for tests for authorization from client to server. It contains
+ * utility functions for the authorization tests from client to server.
+ * 
+ * @since 5.5
+ */
+public class ClientAuthorizationTestCase 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 = REGION_NAME;
+  protected static final String subregionName = "AuthSubregion";
+
+  private static final String[] serverIgnoredExceptions = {
+      "Connection refused",
+      AuthenticationRequiredException.class.getName(),
+      AuthenticationFailedException.class.getName(),
+      NotAuthorizedException.class.getName(),
+      GemFireSecurityException.class.getName(),
+      RegionDestroyedException.class.getName(),
+      ClassNotFoundException.class.getName()
+  };
+
+  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 {
+    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 {
+  }
+
+  protected void postSetUpClientAuthorizationTestBase() throws Exception {
+  }
+
+  @Override
+  public final void preTearDown() throws Exception {
+    preTearDownClientAuthorizationTestBase();
+    tearDownClientAuthorizationTestBase();
+    postTearDownClientAuthorizationTestBase();
+  }
+
+  @Override
+  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) {
+    Properties authProps = new Properties();
+    if (authenticator != null) {
+      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);
+      }
+    }
+    return concatProperties(new Properties[] { authProps, extraAuthProps, extraAuthzProps });
+  }
+
+  protected static Integer createCacheServer(int locatorPort, Properties authProps, Properties javaProps) {
+    if (locatorPort == 0) {
+      locatorPort = getRandomAvailablePort(SOCKET);
+    }
+    return SecurityTestUtils.createCacheServer(authProps, javaProps, locatorPort, null, 0, true, NO_EXCEPTION);
+  }
+
+  protected static int createCacheServer(int locatorPort, int serverPort, Properties authProps, Properties javaProps) {
+    if (locatorPort == 0) {
+      locatorPort = getRandomAvailablePort(SOCKET);
+    }
+    return SecurityTestUtils.createCacheServer(authProps, javaProps, locatorPort, null, serverPort, true, NO_EXCEPTION);
+  }
+
+  protected static Region getRegion() {
+    return getCache().getRegion(regionName);
+  }
+
+  protected static Region getSubregion() {
+    return getCache().getRegion(regionName + '/' + subregionName);
+  }
+
+  private static Region createSubregion(Region region) {
+    Region subregion = getSubregion();
+    if (subregion == null) {
+      subregion = region.createSubregion(subregionName, region.getAttributes());
+    }
+    return subregion;
+  }
+
+  protected static String indicesToString(int[] indices) {
+    String str = "";
+    if (indices != null && indices.length > 0) {
+      str += indices[0];
+      for (int index = 1; index < indices.length; ++index) {
+        str += ",";
+        str += indices[index];
+      }
+    }
+    return str;
+  }
+
+  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
+          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
+          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
+      waitForCondition(new Callable() {
+        public Object call() throws Exception {
+          return Boolean.valueOf(getRegion() == null);
+        }
+      });
+      region = getRegion();
+      assertNull(region);
+      return;
+
+    } else {
+      assertNotNull(region);
+    }
+
+    final String[] keys = KEYS;
+    final String[] vals;
+    if ((flags & OpFlags.USE_NEWVAL) > 0) {
+      vals = NVALUES;
+    }
+    else {
+      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);
+    boolean exceptionOccured = false;
+    boolean breakLoop = false;
+
+    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
+          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) {
+                AbstractRegionEntry entry = (AbstractRegionEntry)((LocalRegion)region).getRegionEntry(searchKey);
+                System.out.println(""+keyNum+": key is " + searchKey + " and entry is " + entry);
+                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;
+
+              @Override
+              public Object call() throws Exception {
+                Object value = 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);
+
+            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);
+
+            getCache().getCacheTransactionManager().commit();
+            value = e.getValue();
+
+          } else {
+            if ((flags & OpFlags.CHECK_NOKEY) > 0) {
+              assertFalse(region.containsKey(key));
+            } 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 {
+            assertNotNull(value);
+            assertEquals(expectedVal, value);
+          }
+
+        } else if (op.isPut()) {
+          region.put(key, expectedVal);
+
+        } 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()) {
+          // if (!region.containsKey(key)) {
+          // // Since DESTROY will fail unless the value is present
+          // // in the local cache, this is a workaround for two cases:
+          // // 1. When the operation is supposed to succeed then in
+          // // the current AuthzCredentialGenerators the clients having
+          // // DESTROY permission also has CREATE/UPDATE permission
+          // // so that calling region.put() will work for that case.
+          // // 2. When the operation is supposed to fail with
+          // // NotAuthorizedException then in the current
+          // // AuthzCredentialGenerators the clients not
+          // // having DESTROY permission are those with reader role that have
+          // // GET permission.
+          // //
+          // // If either of these assumptions fails, then this has to be
+          // // adjusted or reworked accordingly.
+          // if ((flags & OpFlags.CHECK_NOTAUTHZ) > 0) {
+          // Object value = region.get(key);
+          // assertNotNull(value);
+          // assertEquals(vals[index], value);
+          // }
+          // else {
+          // region.put(key, vals[index]);
+          // }
+          // }
+          if ((flags & OpFlags.LOCAL_OP) > 0) {
+            region.localDestroy(key);
+          }
+          else {
+            region.destroy(key);
+          }
+
+        } else if (op.isInvalidate()) {
+          if (region.containsKey(key)) {
+            if ((flags & OpFlags.LOCAL_OP) > 0) {
+              region.localInvalidate(key);
+            } else {
+              region.invalidate(key);
+            }
+          }
+
+        } else if (op.isContainsKey()) {
+          boolean result;
+          if ((flags & OpFlags.LOCAL_OP) > 0) {
+            result = region.containsKey(key);
+          } else {
+            result = region.containsKeyOnServer(key);
+          }
+          if ((flags & OpFlags.CHECK_FAIL) > 0) {
+            assertFalse(result);
+          } else {
+            assertTrue(result);
+          }
+
+        } 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 if (op.isUnregisterInterest()) {
+          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.unregisterInterest(keyList);
+
+          } else if ((flags & OpFlags.USE_REGEX) > 0) {
+            breakLoop = true;
+            region.unregisterInterestRegex("key[1-" + numOps + ']');
+
+          } else if ((flags & OpFlags.USE_ALL_KEYS) > 0) {
+            breakLoop = true;
+            region.unregisterInterest("ALL_KEYS");
+
+          } else {
+            region.unregisterInterest(key);
+          }
+
+        } else if (op.isKeySet()) {
+          breakLoop = true;
+          Set keySet;
+          if ((flags & OpFlags.LOCAL_OP) > 0) {
+            keySet = region.keySet();
+          } else {
+            keySet = region.keySetOnServer();
+          }
+
+          assertNotNull(keySet);
+          if ((flags & OpFlags.CHECK_FAIL) == 0) {
+            assertEquals(numOps, keySet.size());
+          }
+          for (int keyNumIndex = 0; keyNumIndex < numOps; ++keyNumIndex) {
+            int keyNum = indices[keyNumIndex];
+            if ((flags & OpFlags.CHECK_FAIL) > 0) {
+              assertFalse(keySet.contains(keys[keyNum]));
+            } else {
+              assertTrue(keySet.contains(keys[keyNum]));
+            }
+          }
+
+        } else if (op.isQuery()) {
+          breakLoop = true;
+          SelectResults queryResults = region.query("SELECT DISTINCT * FROM " + region.getFullPath());
+          assertNotNull(queryResults);
+          Set queryResultSet = queryResults.asSet();
+          if ((flags & OpFlags.CHECK_FAIL) == 0) {
+            assertEquals(numOps, queryResultSet.size());
+          }
+          for (int keyNumIndex = 0; keyNumIndex < numOps; ++keyNumIndex) {
+            int keyNum = indices[keyNumIndex];
+            if ((flags & OpFlags.CHECK_FAIL) > 0) {
+              assertFalse(queryResultSet.contains(vals[keyNum]));
+            } else {
+              assertTrue(queryResultSet.contains(vals[keyNum]));
+            }
+          }
+
+        } else if (op.isExecuteCQ()) {
+          breakLoop = true;
+          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);
+          }
+
+          if ((flags & OpFlags.LOCAL_OP) > 0) {
+            // Interpret this as testing results using CqListener
+            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 {
+                  return numOps == listener.getNumUpdates();
+                }
+              }
+              @Override
+              public String description() {
+                return null;
+              }
+            };
+            waitForCriterion(ev, 3 * 1000, 200, true);
+
+            if ((flags & OpFlags.CHECK_FAIL) > 0) {
+              assertEquals(0, listener.getNumUpdates());
+            } 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 {
+            SelectResults cqResults = cqQuery.executeWithInitialResults();
+            assertNotNull(cqResults);
+            Set cqResultValues = new HashSet();
+            for (Object o : cqResults.asList()) {
+              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 {
+                assertTrue(cqResultValues.contains(vals[keyNum]));
+              }
+            }
+          }
+
+        } else if (op.isStopCQ()) {
+          breakLoop = true;
+          CqQuery cqQuery = getCache().getQueryService().getCq("cq1");
+          ((AuthzCqListener)cqQuery.getCqAttributes().getCqListener()).reset();
+          cqQuery.stop();
+
+        } else if (op.isCloseCQ()) {
+          breakLoop = true;
+          CqQuery cqQuery = getCache().getQueryService().getCq("cq1");
+          ((AuthzCqListener)cqQuery.getCqAttributes().getCqListener()).reset();
+          cqQuery.close();
+
+        } else if (op.isRegionClear()) {
+          breakLoop = true;
+          if ((flags & OpFlags.LOCAL_OP) > 0) {
+            region.localClear();
+          } else {
+            region.clear();
+          }
+
+        } else if (op.isRegionCreate()) {
+          breakLoop = true;
+          // Region subregion = createSubregion(region);
+          // subregion.createRegionOnServer();
+          // Create region on server using the DynamicRegionFactory
+          // 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()) {
+          breakLoop = true;
+          if ((flags & OpFlags.LOCAL_OP) > 0) {
+            region.localDestroyRegion();
+
+          } else {
+            if ((flags & OpFlags.USE_SUBREGION) > 0) {
+              try {
+                DynamicRegionFactory.get().destroyDynamicRegion(region.getFullPath());
+              } catch (RegionDestroyedException ex) {
+                // harmless to ignore this
+                System.out.println("doOp: sub-region " + region.getFullPath() + " already destroyed");
+                operationOmitted = true;
+              }
+            } else {
+              region.destroyRegion();
+            }
+          }
+
+        } else {
+          fail("doOp: Unhandled operation " + op);
+        }
+
+        if (expectedResult.intValue() != 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.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() == 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);
+        }
+      }
+    }
+    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) 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;
+          break;
+        case 2:
+          clientVM = client2;
+          break;
+        case 3:
+          useThisVM = true;
+          break;
+        default:
+          fail("executeOpBlock: Unknown client number " + clientNum);
+          break;
+      }
+
+      System.out.println("executeOpBlock: performing operation number [" + currentOp.getOpNum() + "]: " + currentOp);
+      if ((opFlags & OpFlags.USE_OLDCONN) == 0) {
+        Properties opCredentials;
+        int newRnd = rnd.nextInt(100) + 1;
+        String currentRegionName = '/' + regionName;
+        if ((opFlags & OpFlags.USE_SUBREGION) > 0) {
+          currentRegionName += ('/' + subregionName);
+        }
+
+        String credentialsTypeStr;
+        OperationCode authOpCode = currentOp.getAuthzOperationCode();
+        int[] indices = currentOp.getIndices();
+        CredentialGenerator cGen = gen.getCredentialGenerator();
+        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);
+          credentialsTypeStr = " authorized " + authOpCode;
+        }
+
+        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) {
+          SecurityTestUtils.createCacheClientWithDynamicRegion(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, setupDynamicRegionFactory, NO_EXCEPTION);
+        } else {
+          clientVM.invoke(() -> SecurityTestUtils.createCacheClientWithDynamicRegion(authInit, clientProps, javaProps, new int[] { port1, port2 }, 0, setupDynamicRegionFactory, NO_EXCEPTION));
+        }
+      }
+
+      int expectedResult;
+      if ((opFlags & OpFlags.CHECK_NOTAUTHZ) > 0) {
+        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 {
+        byte ordinal = opCode.toOrdinal();
+        int[] indices = currentOp.getIndices();
+        clientVM.invoke(() -> ClientAuthorizationTestCase.doOp( new Byte(ordinal), indices, new Integer(opFlags), new Integer(expectedResult) ));
+      }
+    }
+  }
+
+  protected AuthzCredentialGenerator getXmlAuthzGenerator(){
+    AuthzCredentialGenerator authzGen = new XmlAuthzCredentialGenerator();
+    CredentialGenerator cGen = new DummyCredentialGenerator();
+    cGen.init();
+    authzGen.init(cGen);
+    return authzGen;
+  }
+
+  protected List getDummyGeneratorCombos() {
+    List generators = new ArrayList();
+    Iterator authzCodeIter = AuthzCredentialGenerator.ClassCode.getAll().iterator();
+
+    while (authzCodeIter.hasNext()) {
+      ClassCode authzClassCode = (ClassCode) authzCodeIter.next();
+      AuthzCredentialGenerator authzGen = AuthzCredentialGenerator.create(authzClassCode);
+
+      if (authzGen != null) {
+        CredentialGenerator cGen = new DummyCredentialGenerator();
+        cGen.init();
+        if (authzGen.init(cGen)) {
+          generators.add(authzGen);
+        }
+      }
+    }
+
+    assertTrue(generators.size() > 0);
+    return generators;
+  }
+
+  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 = getRandomAvailablePortKeeper(SOCKET);
+    Keeper locator2PortKeeper = getRandomAvailablePortKeeper(SOCKET);
+    Keeper port1Keeper = getRandomAvailablePortKeeper(SOCKET);
+    Keeper port2Keeper = getRandomAvailablePortKeeper(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(() -> ClientAuthorizationTestCase.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(() -> ClientAuthorizationTestCase.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);
+      }
+    }
+  }
+
+  /**
+   * Implements the {@link CqListener} interface and counts the number of
+   * different operations and also queues up the received updates to precise
+   * checking of each update.
+   * 
+   * @since 5.5
+   */
+  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() {
+      this.eventList = new ArrayList();
+      reset();
+    }
+
+    public void reset() {
+      this.eventList.clear();
+      this.numCreates = 0;
+      this.numUpdates = 0;
+      this.numErrors = 0;
+    }
+
+    public void onEvent(CqEvent aCqEvent) {
+      Operation op = aCqEvent.getBaseOperation();
+      if (op.isCreate()) {
+        ++this.numCreates;
+      } else if (op.isUpdate()) {
+        ++this.numUpdates;
+      } else if (op.isDestroy()) {
+        ++this.numDestroys;
+      } else {
+        ++this.numOtherOps;
+      }
+      eventList.add(aCqEvent);
+    }
+
+    public void onError(CqEvent aCqEvent) {
+      ++this.numErrors;
+    }
+
+    public void close() {
+      this.eventList.clear();
+    }
+
+    public int getNumCreates() {
+      return this.numCreates;
+    }
+
+    public int getNumUpdates() {
+      return this.numUpdates;
+    }
+
+    public int getNumDestroys() {
+      return this.numDestroys;
+    }
+
+    public int getNumOtherOps() {
+      return this.numOtherOps;
+    }
+
+    public int getNumErrors() {
+      return this.numErrors;
+    }
+
+    public void checkPuts(String[] vals, int[] indices) {
+      for (int indexIndex = 0; indexIndex < indices.length; ++indexIndex) {
+        int index = indices[indexIndex];
+        Iterator eventIter = this.eventList.iterator();
+        boolean foundKey = false;
+
+        while (eventIter.hasNext()) {
+          CqEvent event = (CqEvent)eventIter.next();
+          if (KEYS[index].equals(event.getKey())) {
+            assertEquals(vals[index], event.getNewValue());
+            foundKey = true;
+            break;
+          }
+        }
+
+        assertTrue(foundKey);
+      }
+    }
+  }
+
+  /**
+   * This class specifies flags that can be used to alter the behaviour of
+   * operations being performed by the <code>doOp</code> function.
+   * 
+   * @since 5.5
+   */
+  protected static class OpFlags {
+
+    /**
+     * Default behaviour.
+     */
+    public static final int NONE = 0x0;
+
+    /**
+     * Check that the operation should fail.
+     */
+    public static final int CHECK_FAIL = 0x1;
+
+    /**
+     * Check that the operation should throw <code>NotAuthorizedException</code>.
+     */
+    public static final int CHECK_NOTAUTHZ = 0x2;
+
+    /**
+     * Check that the region should not be available.
+     */
+    public static final int CHECK_NOREGION = 0x4;
+
+    /**
+     * Check that the operation should throw an exception other than the
+     * <code>NotAuthorizedException</code>.
+     */
+    public static final int CHECK_EXCEPTION = 0x8;
+
+    /**
+     * Check for nvalues[] instead of values[].
+     */
+    public static final int USE_NEWVAL = 0x10;
+
+    /**
+     * Register all KEYS. For GET operations indicates using getAll().
+     */
+    public static final int USE_ALL_KEYS = 0x20;
+
+    /**
+     * Register a regular expression.
+     */
+    public static final int USE_REGEX = 0x40;
+
+    /**
+     * Register a list of KEYS.
+     */
+    public static final int USE_LIST = 0x80;
+
+    /**
+     * Perform the local version of the operation.
+     */
+    public static final int LOCAL_OP = 0x100;
+
+    /**
+     * Check that the key for the operation should not be present.
+     */
+    public static final int CHECK_NOKEY = 0x200;
+
+    /**
+     * Use the sub-region for performing the operation.
+     */
+    public static final int USE_SUBREGION = 0x400;
+
+    /**
+     * Do not try to create the sub-region.
+     */
+    public static final int NO_CREATE_SUBREGION = 0x800;
+
+    /**
+     * Do not re-connect using new credentials rather use the previous
+     * connection.
+     */
+    public static final int USE_OLDCONN = 0x1000;
+
+    /**
+     * Do the connection with unauthorized credentials but do not check that the
+     * operation throws <code>NotAuthorizedException</code>.
+     */
+    public static final int USE_NOTAUTHZ = 0x2000;
+
+    /**
+     * Enable {@link DynamicRegionFactory} on the client.
+     */
+    public static final int ENABLE_DRF = 0x4000;
+
+    /**
+     * Use the {@link InterestResultPolicy#NONE} for register interest.
+     */
+    public static final int REGISTER_POLICY_NONE = 0x8000;
+    
+    /**
+     * Use the {@link LocalRegion#getEntry} under transaction.
+     */
+    public static final int USE_GET_ENTRY_IN_TX = 0x10000;
+
+    public static String description(int f) {
+      StringBuffer sb = new StringBuffer();
+      sb.append("[");
+      if ((f & CHECK_FAIL) != 0) {
+        sb.append("CHECK_FAIL,");
+      }
+      if ((f & CHECK_NOTAUTHZ) != 0) {
+        sb.append("CHECK_NOTAUTHZ,");
+      }
+      if ((f & CHECK_NOREGION) != 0) {
+        sb.append("CHECK_NOREGION,");
+      }
+      if ((f & CHECK_EXCEPTION) != 0) {
+        sb.append("CHECK_EXCEPTION,");
+      }
+      if ((f & USE_NEWVAL) != 0) {
+        sb.append("USE_NEWVAL,");
+      }
+      if ((f & USE_ALL_KEYS) != 0) {
+        sb.append("USE_ALL_KEYS,");
+      }
+      if ((f & USE_REGEX) != 0) {
+        sb.append("USE_REGEX,");
+      }
+      if ((f & USE_LIST) != 0) {
+        sb.append("USE_LIST,");
+      }
+      if ((f & LOCAL_OP) != 0) {
+        sb.append("LOCAL_OP,");
+      }
+      if ((f & CHECK_NOKEY) != 0) {
+        sb.append("CHECK_NOKEY,");
+      }
+      if ((f & USE_SUBREGION) != 0) {
+        sb.append("USE_SUBREGION,");
+      }
+      if ((f & NO_CREATE_SUBREGION) != 0) {
+        sb.append("NO_CREATE_SUBREGION,");
+      }
+      if ((f & USE_OLDCONN) != 0) {
+        sb.append("USE_OLDCONN,");
+      }
+      if ((f & USE_NOTAUTHZ) != 0) {
+        sb.append("USE_NOTAUTHZ");
+      }
+      if ((f & ENABLE_DRF) != 0) {
+        sb.append("ENABLE_DRF,");
+      }
+      if ((f & REGISTER_POLICY_NONE) != 0) {
+        sb.append("REGISTER_POLICY_NONE,");
+      }
+      sb.append("]");
+      return sb.toString();
+    }
+  }
+
+  /**
+   * This class encapsulates an {@link OperationCode} with associated flags, the
+   * client to perform the operation, and the number of operations to perform.
+   * 
+   * @since 5.5
+   */
+  protected static class OperationWithAction {
+
+    /**
+     * The operation to be performed.
+     */
+    private OperationCode opCode;
+
+    /**
+     * The operation for which authorized or unauthorized credentials have to be
+     * generated. This is the same as {@link #opCode} when not specified.
+     */
+    private OperationCode authzOpCode;
+
+    /**
+     * The client number on which the operation has to be performed.
+     */
+    private int clientNum;
+
+    /**
+     * Bitwise or'd {@link OpFlags} integer to change/specify the behaviour of
+     * the operations.
+     */
+    private int flags;
+
+    /**
+     * Indices of the KEYS array to be used for operations.
+     */
+    private int[] indices;
+
+    /**
+     * An index for the operation used for logging.
+     */
+    private int opNum;
+
+    /**
+     * Indicates end of an operation block which can be used for testing with
+     * failover
+     */
+    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);
+
+    private void setIndices(int numOps) {
+      this.indices = new int[numOps];
+      for (int index = 0; index < numOps; ++index) {
+        this.indices[index] = index;
+      }
+    }
+
+    public OperationWithAction(OperationCode opCode) {
+      this.opCode = opCode;
+      this.authzOpCode = opCode;
+      this.clientNum = 1;
+      this.flags = OpFlags.NONE;
+      setIndices(4);
+      this.opNum = 0;
+    }
+
+    public OperationWithAction(OperationCode opCode, int clientNum) {
+      this.opCode = opCode;
+      this.authzOpCode = opCode;
+      this.clientNum = clientNum;
+      this.flags = OpFlags.NONE;
+      setIndices(4);
+      this.opNum = 0;
+    }
+
+    public OperationWithAction(OperationCode opCode, int clientNum, int flags, int numOps) {
+      this.opCode = opCode;
+      this.authzOpCode = opCode;
+      this.clientNum = clientNum;
+      this.flags = flags;
+      setIndices(numOps);
+      this.opNum = 0;
+    }
+
+    public OperationWithAction(OperationCode opCode, OperationCode deniedOpCode, int clientNum, int flags, int numOps) {
+      this.opCode = opCode;
+      this.authzOpCode = deniedOpCode;
+      this.clientNum = clientNum;
+      this.flags = flags;
+      setIndices(numOps);
+      this.opNum = 0;
+    }
+
+    public OperationWithAction(OperationCode opCode, int clientNum, int flags, int[] indices) {
+      this.opCode = opCode;
+      this.authzOpCode = opCode;
+      this.clientNum = clientNum;
+      this.flags = flags;
+      this.indices = indices;
+      this.opNum = 0;
+    }
+
+    public OperationWithAction(OperationCode opCode, OperationCode deniedOpCode, int clientNum, int flags, int[] indices) {
+      this.opCode = opCode;
+      this.authzOpCode = deniedOpCode;
+      this.clientNum = clientNum;
+      this.flags = flags;
+      this.indices = indices;
+      this.opNum = 0;
+    }
+
+    public OperationCode getOperationCode() {
+      return this.opCode;
+    }
+
+    public OperationCode getAuthzOperationCode() {
+      return this.authzOpCode;
+    }
+
+    public int getClientNum() {
+      return this.clientNum;
+    }
+
+    public int getFlags() {
+      return this.flags;
+    }
+
+    public int[] getIndices() {
+      return this.indices;
+    }
+
+    public int getOpNum() {
+      return this.opNum;
+    }
+
+    public void setOpNum(int opNum) {
+      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);
+    }
+  }
+
+  /**
+   * Simple interface to generate credentials with authorization based on key
+   * indices also. This is utilized by the post-operation authorization tests
+   * where authorization is based on key indices.
+   * 
+   * @since 5.5
+   */
+  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);
+
+    /**
+     * 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);
+
+    /**
+     * Get the {@link CredentialGenerator} if any.
+     */
+    public CredentialGenerator getCredentialGenerator();
+  }
+
+  /**
+   * Contains a {@link AuthzCredentialGenerator} and implements the
+   * {@link TestCredentialGenerator} interface.
+   * 
+   * @since 5.5
+   */
+  protected static class TestAuthzCredentialGenerator implements TestCredentialGenerator {
+
+    private AuthzCredentialGenerator authzGen;
+
+    public TestAuthzCredentialGenerator(AuthzCredentialGenerator authzGen) {
+      this.authzGen = authzGen;
+    }
+
+    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) {
+      return this.authzGen.getDisallowedCredentials(opCodes, regionNames, num);
+    }
+
+    public CredentialGenerator getCredentialGenerator() {
+      return authzGen.getCredentialGenerator();
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/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 835c241..0830104 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
@@ -18,9 +18,9 @@
  */
 package com.gemstone.gemfire.security;
 
-//import static com.gemstone.gemfire.security.ClientAuthenticationUtils.*;
-//import static com.gemstone.gemfire.security.ClientAuthorizationTestBase.*;
-import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+//import static com.gemstone.gemfire.security.ClientAuthenticationTestUtils.*;
+//import static com.gemstone.gemfire.security.ClientAuthorizationTestCase.*;
+import static com.gemstone.gemfire.security.SecurityTestUtils.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 
 import java.util.Iterator;
@@ -40,7 +40,7 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 @Category(DistributedTest.class)
-public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
+public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestCase {
 
   @Override
   public final void preTearDownClientAuthorizationTestBase() throws Exception {
@@ -340,6 +340,6 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestBase {
   }
 
   private int createCacheServerOnVM(final VM server, final Properties javaProps, final Properties serverProps) {
-    return server.invoke(() -> ClientAuthorizationTestBase.createCacheServer(getLocatorPort(), serverProps, javaProps));
+    return server.invoke(() -> ClientAuthorizationTestCase.createCacheServer(getLocatorPort(), serverProps, javaProps));
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/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 58e05a0..904a53c 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,9 +18,8 @@
  */
 package com.gemstone.gemfire.security;
 
-import static com.gemstone.gemfire.security.ClientAuthenticationUtils.*;
-import static com.gemstone.gemfire.security.ClientAuthorizationTestBase.*;
-import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.security.ClientAuthenticationTestUtils.*;
+import static com.gemstone.gemfire.security.SecurityTestUtils.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
 
@@ -40,7 +39,7 @@ import org.junit.experimental.categories.Category;
  * @since 6.1
  */
 @Category(DistributedTest.class)
-public final class DeltaClientAuthorizationDUnitTest extends ClientAuthorizationTestBase {
+public final class DeltaClientAuthorizationDUnitTest extends ClientAuthorizationTestCase {
 
   private DeltaTestImpl[] deltas = new DeltaTestImpl[8];
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/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 7c7fe9b..56d712f 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
@@ -19,8 +19,7 @@
 package com.gemstone.gemfire.security;
 
 import static com.gemstone.gemfire.internal.AvailablePort.*;
-import static com.gemstone.gemfire.security.DeltaClientPostAuthorizationDUnitTest.*;
-import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.security.SecurityTestUtils.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
 import static com.gemstone.gemfire.test.dunit.IgnoredException.*;
 import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
@@ -45,7 +44,7 @@ import org.junit.experimental.categories.Category;
  * @since 6.1
  */
 @Category(DistributedTest.class)
-public class DeltaClientPostAuthorizationDUnitTest extends ClientAuthorizationTestBase {
+public class DeltaClientPostAuthorizationDUnitTest extends ClientAuthorizationTestCase {
 
   private static final int PAUSE = 5 * 1000; // TODO: replace with Awaitility
 
@@ -100,14 +99,14 @@ public class DeltaClientPostAuthorizationDUnitTest extends ClientAuthorizationTe
         // 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(getLocatorPort(), port1, serverProps, javaProps ));
+          server1.invoke(() -> ClientAuthorizationTestCase.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(getLocatorPort(), port2, serverProps, javaProps ));
+            server2.invoke(() -> ClientAuthorizationTestCase.createCacheServer(getLocatorPort(), port2, serverProps, javaProps ));
             server1.invoke(() -> closeCache());
 
             executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/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 e514b1c..1db599f 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
@@ -20,7 +20,7 @@ package com.gemstone.gemfire.security;
 
 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.security.SecurityTestUtils.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
 import static com.gemstone.gemfire.test.dunit.IgnoredException.*;
 import static com.gemstone.gemfire.test.dunit.NetworkUtils.*;
@@ -160,7 +160,7 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
     startTheLocator(props, gen.getJavaProperties(), locatorPort);
 
     try {
-      new SecurityTestUtil("tmp").createSystem(props, null);
+      new SecurityTestUtils("tmp").createSystem(props, null);
       fail("AuthenticationFailedException was expected as the AuthInitialize object passed is incorrect");
 
     } catch (AuthenticationFailedException expected) {
@@ -191,7 +191,7 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
     startTheLocator(props, null, locatorPort);
 
     try {
-      new SecurityTestUtil("tmp").createSystem(props, null);
+      new SecurityTestUtils("tmp").createSystem(props, null);
       fail("AuthenticationFailedException was expected as the Authenticator object passed is incorrect");
 
     } catch (AuthenticationFailedException expected) {
@@ -221,7 +221,7 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
     startTheLocator(props, null, locatorPort);
 
     try {
-      new SecurityTestUtil("tmp").createSystem(props, null);
+      new SecurityTestUtils("tmp").createSystem(props, null);
       fail("AuthenticationFailedException was expected as no credentials are set");
 
     } catch (AuthenticationFailedException expected) {
@@ -291,7 +291,7 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
       props.putAll(gen.getInvalidCredentials(1));
 
       try {
-        new SecurityTestUtil("tmp").createSystem(props, null);
+        new SecurityTestUtils("tmp").createSystem(props, null);
         fail("AuthenticationFailedException was expected as wrong credentials were passed");
 
       } catch (AuthenticationFailedException expected) {
@@ -524,7 +524,7 @@ public class P2PAuthenticationDUnitTest extends JUnit4DistributedTestCase {
   }
 
   private static void createDS(final Properties props, final Properties javaProps) {
-    SecurityTestUtil tmpUtil = new SecurityTestUtil("tmp");
+    SecurityTestUtils tmpUtil = new SecurityTestUtils("tmp");
     tmpUtil.createSystem(props, javaProps);
   }
 


[2/7] incubator-geode git commit: Rename security utility classes

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/310698c1/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
deleted file mode 100644
index e456689..0000000
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtil.java
+++ /dev/null
@@ -1,1793 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package com.gemstone.gemfire.security;
-
-import static com.gemstone.gemfire.distributed.internal.DistributionConfig.*;
-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.*;
-
-import static com.gemstone.gemfire.cache30.ClientServerTestCase.configureConnectionPoolWithNameAndFactory;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import javax.net.ServerSocketFactory;
-import javax.net.SocketFactory;
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLContextSpi;
-import javax.net.ssl.SSLServerSocketFactory;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.TrustManager;
-
-import com.gemstone.gemfire.cache.AttributesFactory;
-import com.gemstone.gemfire.cache.Cache;
-import com.gemstone.gemfire.cache.CacheFactory;
-import com.gemstone.gemfire.cache.DataPolicy;
-import com.gemstone.gemfire.cache.DynamicRegionFactory;
-import com.gemstone.gemfire.cache.Region;
-import com.gemstone.gemfire.cache.RegionAttributes;
-import com.gemstone.gemfire.cache.Scope;
-import com.gemstone.gemfire.cache.client.NoAvailableServersException;
-import com.gemstone.gemfire.cache.client.Pool;
-import com.gemstone.gemfire.cache.client.PoolFactory;
-import com.gemstone.gemfire.cache.client.PoolManager;
-import com.gemstone.gemfire.cache.client.ServerConnectivityException;
-import com.gemstone.gemfire.cache.client.ServerOperationException;
-import com.gemstone.gemfire.cache.client.ServerRefusedConnectionException;
-import com.gemstone.gemfire.cache.client.internal.PoolImpl;
-import com.gemstone.gemfire.cache.client.internal.ProxyCache;
-import com.gemstone.gemfire.cache.execute.Execution;
-import com.gemstone.gemfire.cache.execute.Function;
-import com.gemstone.gemfire.cache.execute.FunctionException;
-import com.gemstone.gemfire.cache.execute.FunctionService;
-import com.gemstone.gemfire.cache.query.Query;
-import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
-import com.gemstone.gemfire.cache.query.SelectResults;
-import com.gemstone.gemfire.cache.server.CacheServer;
-import com.gemstone.gemfire.distributed.DistributedSystem;
-import com.gemstone.gemfire.distributed.Locator;
-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.DistributedTestCase;
-import com.gemstone.gemfire.test.dunit.WaitCriterion;
-
-/**
- * Contains utility methods for setting up servers/clients for authentication
- * and authorization tests.
- * 
- * @since 5.5
- */
-public final class SecurityTestUtil {
-
-  private final DistributedTestCase distributedTestCase = new DistributedTestCase(getClass().getSimpleName()) {}; // TODO: delete
-
-  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
-  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" };
-
-  private static final int NUMBER_OF_USERS = 1;
-
-  private static String[] ignoredExceptions = null;
-
-  private static Locator locator = null;
-  private static Cache cache = null;
-  private static Properties currentJavaProps = null;
-  private static String locatorString = null;
-
-  private static Pool pool = null;
-  private static boolean multiUserAuthMode = false;
-
-  private static ProxyCache[] proxyCaches = new ProxyCache[NUMBER_OF_USERS];
-
-  private static Region regionRef = null;
-
-  public SecurityTestUtil(String name) { // TODO: delete
-  }
-
-  /**
-   * @deprecated Please use {@link com.gemstone.gemfire.test.dunit.IgnoredException} instead
-   */
-  private static void addIgnoredExceptions(final String[] expectedExceptions) { // TODO: delete
-    if (expectedExceptions != null) {
-      for (int index = 0; index < expectedExceptions.length; index++) {
-        getLogWriter().info("<ExpectedException action=add>" + expectedExceptions[index] + "</ExpectedException>");
-      }
-    }
-  }
-
-  /**
-   * @deprecated Please use {@link com.gemstone.gemfire.test.dunit.IgnoredException} instead
-   */
-  private static void removeExpectedExceptions(final String[] expectedExceptions) { // TODO: delete
-    if (expectedExceptions != null) {
-      for (int index = 0; index < expectedExceptions.length; index++) {
-        getLogWriter().info("<ExpectedException action=remove>" + expectedExceptions[index] + "</ExpectedException>");
-      }
-    }
-  }
-
-  protected static void setJavaProps(final Properties javaProps) {
-    removeJavaProperties(currentJavaProps);
-    addJavaProperties(javaProps);
-    currentJavaProps = javaProps;
-  }
-
-  protected static ProxyCache getProxyCaches(final int index) {
-    return proxyCaches[index];
-  }
-
-  protected static void initDynamicRegionFactory() {
-    DynamicRegionFactory.get().open(new DynamicRegionFactory.Config(null, null, false, true));
-  }
-
-  protected static Integer getLocatorPort() {
-    int locatorPort = getRandomAvailablePort(SOCKET);
-    String addr = getIPLiteral();
-    if (locatorString == null) {
-      locatorString = addr + "[" + locatorPort + ']';
-    } else {
-      locatorString += "," + addr + "[" + locatorPort + ']';
-    }
-    return locatorPort;
-  }
-
-  /**
-   * 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.
-   */
-  protected static String getLocatorString() { // TODO: rename
-    String locString = locatorString;
-    locatorString = null;
-    return locString;
-  }
-
-  protected static Properties concatProperties(final Properties[] propsList) {
-    Properties props = new Properties();
-    for (int index = 0; index < propsList.length; ++index) {
-      if (propsList[index] != null) {
-        props.putAll(propsList[index]);
-      }
-    }
-    return props;
-  }
-
-  protected static void registerExpectedExceptions(final String[] expectedExceptions) { // TODO: delete
-    SecurityTestUtil.ignoredExceptions = expectedExceptions;
-  }
-
-  protected static int createCacheServer(final Properties authProps, final Properties javaProps, final int dsPort, final String locatorString, final int serverPort, final int expectedResult) {
-    return createCacheServer(authProps, javaProps, dsPort, locatorString, serverPort, false, expectedResult);
-  }
-
-  protected static int createCacheServer(Properties authProps, final Properties javaProps, final int locatorPort, final String locatorString, final int serverPort, final boolean setupDynamicRegionFactory, final int expectedResult) {
-    if (authProps == null) {
-      authProps = new Properties();
-    }
-    authProps.setProperty(MCAST_PORT_NAME, "0");
-    if (locatorString != null && locatorString.length() > 0) {
-      authProps.setProperty(LOCATORS_NAME, locatorString);
-      authProps.setProperty(START_LOCATOR_NAME, getIPLiteral() + "[" + locatorPort + ']');
-    } else {
-      authProps.setProperty("locators", "localhost["+getDUnitLocatorPort()+"]");
-    }
-    authProps.setProperty(SECURITY_LOG_LEVEL_NAME, "finest");
-    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, javaProps);
-      if (expectedResult != NO_EXCEPTION) {
-        fail("Expected a security exception when starting peer");
-      }
-    }
-    catch (AuthenticationRequiredException ex) {
-      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 == AUTHFAIL_EXCEPTION) {
-        getLogWriter().info("Got expected exception when starting peer: " + ex);
-        return 0;
-      }
-      else {
-        fail("Got unexpected exception when starting peer", ex);
-      }
-    }
-    catch (Exception ex) {
-      fail("Got unexpected exception when starting peer", ex);
-    }
-
-    if (setupDynamicRegionFactory) {
-      initDynamicRegionFactory();
-    }
-    tmpInstance.openCache();
-    AttributesFactory factory = new AttributesFactory();
-    factory.setScope(Scope.DISTRIBUTED_ACK);
-    factory.setDataPolicy(DataPolicy.REPLICATE);
-    RegionAttributes attrs = factory.create();
-    cache.createRegion(REGION_NAME, attrs);
-    int port;
-    if (serverPort <= 0) {
-      port = 0;
-    }
-    else {
-      port = serverPort;
-    }
-    CacheServer server1 = cache.addCacheServer();
-    server1.setPort(port);
-    server1.setNotifyBySubscription(true);
-    try {
-      server1.start();
-    }
-    catch (Exception ex) {
-      fail("Got unexpected exception when starting CacheServer", ex);
-    }
-    return server1.getPort();
-  }
-
-  // 1
-  protected static void createCacheClient(final String authInitModule, final Properties authProps, final Properties javaProps, final int[] ports, final int numConnections, final int expectedResult) {
-    createCacheClient(authInitModule, authProps, javaProps, ports, numConnections, false, expectedResult);
-  }
-
-  // 2 a
-  protected static void createCacheClient(final String authInitModule, final Properties authProps, final Properties javaProps, final int[] ports, final int numConnections, final boolean multiUserMode, final int expectedResult) {
-    createCacheClient(authInitModule, authProps, javaProps, ports, numConnections, false, multiUserMode, expectedResult);
-  }
-
-  // 3
-  protected static void createCacheClientWithDynamicRegion(final String authInitModule, final Properties authProps, final Properties javaProps, final int[] ports, final int numConnections, final boolean setupDynamicRegionFactory, final int expectedResult) {
-    createCacheClient(authInitModule, authProps, javaProps, ports, numConnections, setupDynamicRegionFactory, false, expectedResult);
-  }
-
-  // 4
-  protected static void createCacheClient(final String authInitModule,
-                                          final Properties authProps, final Properties javaProps, final int[] ports,
-                                          final int numConnections, final boolean setupDynamicRegionFactory,
-                                          final boolean multiUserMode, final int expectedResult) {
-    createCacheClient(authInitModule, authProps, javaProps, ports,
-        numConnections, setupDynamicRegionFactory, multiUserMode, Boolean.TRUE,
-        expectedResult);
-  }
-
-  // 5
-  protected static void createCacheClient(final String authInitModule,
-                                          Properties authProps, final Properties javaProps, int[] ports,
-                                          final int numConnections, final boolean setupDynamicRegionFactory,
-                                          final boolean multiUserMode, final boolean subscriptionEnabled,
-                                          final int expectedResult) {
-
-    multiUserAuthMode = Boolean.valueOf(multiUserMode);
-    if (authProps == null) {
-      authProps = new Properties();
-    }
-    authProps.setProperty(MCAST_PORT_NAME, "0");
-    authProps.setProperty(LOCATORS_NAME, "");
-    authProps.setProperty(SECURITY_LOG_LEVEL_NAME, "finest");
-    // TODO (ashetkar) Add " && (!multiUserAuthMode)" below.
-    if (authInitModule != null) {
-      authProps.setProperty(SECURITY_CLIENT_AUTH_INIT_NAME,
-          authInitModule);
-    }
-
-    SecurityTestUtil tmpInstance = new SecurityTestUtil("temp");
-    tmpInstance.createSystem(authProps, javaProps);
-    AttributesFactory factory = new AttributesFactory();
-    int[] portsI = new int[ports.length];
-    for(int z=0;z<ports.length;z++) {
-      portsI[z] = ports[z];
-    }
-   
-    try {
-      PoolFactory poolFactory = PoolManager.createFactory();
-      poolFactory.setRetryAttempts(200);
-      if (multiUserAuthMode) {
-        poolFactory.setMultiuserAuthentication(multiUserAuthMode);
-        // [sumedh] Why is this false here only to be overridden in
-        // ClientServerTestCase.configureConnectionPoolWithNameAndFactory below?
-        // Actually setting it to false causes MultiuserAPIDUnitTest to fail.
-        //poolFactory.setSubscriptionEnabled(false);
-      }
-      pool = configureConnectionPoolWithNameAndFactory(factory,
-          getIPLiteral(), portsI, subscriptionEnabled, 0,
-          numConnections, null, null,
-          poolFactory);
-
-      if (setupDynamicRegionFactory) {
-        initClientDynamicRegionFactory(pool.getName());
-      }
-      tmpInstance.openCache();
-      try {
-        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) {
-          getLogWriter().info("Got expected UnsupportedOperationException in single-user mode");
-        }
-        else {
-          fail("Got unexpected exception in multi-user mode ", uoe);
-        }
-      }
-
-      factory.setScope(Scope.LOCAL);
-      if (multiUserAuthMode) {
-        factory.setDataPolicy(DataPolicy.EMPTY);
-      }
-      RegionAttributes attrs = factory.create();
-      cache.createRegion(REGION_NAME, attrs);
-
-      if (expectedResult != NO_EXCEPTION
-          && expectedResult != NOFORCE_AUTHREQ_EXCEPTION) {
-        if (!multiUserAuthMode) {
-          fail("Expected an exception when starting client");
-        }
-      }
-    }
-    catch (AuthenticationRequiredException ex) {
-      if (expectedResult == AUTHREQ_EXCEPTION
-          || expectedResult == NOFORCE_AUTHREQ_EXCEPTION) {
-        getLogWriter().info(
-            "Got expected exception when starting client: " + ex);
-      }
-      else {
-        fail("Got unexpected exception when starting client", ex);
-      }
-    }
-    catch (AuthenticationFailedException ex) {
-      if (expectedResult == AUTHFAIL_EXCEPTION) {
-        getLogWriter().info(
-            "Got expected exception when starting client: " + ex);
-      }
-      else {
-        fail("Got unexpected exception when starting client", ex);
-      }
-    }
-    catch (ServerRefusedConnectionException ex) {
-      if (expectedResult == CONNREFUSED_EXCEPTION) {
-        getLogWriter().info(
-            "Got expected exception when starting client: " + ex);
-      }
-      else {
-        fail("Got unexpected exception when starting client", ex);
-      }
-    }
-    catch (Exception ex) {
-      fail("Got unexpected exception when starting client", ex);
-    }
-  }
-
-  protected static void createCacheClientForMultiUserMode(final int numOfUsers,
-                                                          final String authInitModule, final Properties[] authProps, final Properties javaProps,
-                                                          final int[] ports, final int numConnections,
-                                                          final boolean setupDynamicRegionFactory, final int expectedResult) {
-    createCacheClientForMultiUserMode(numOfUsers, authInitModule, authProps,
-        javaProps, ports, numConnections, setupDynamicRegionFactory, null,
-        expectedResult);
-  }
-
-  protected static void createCacheClientForMultiUserMode(final int numOfUsers,
-                                                          final String authInitModule, final Properties[] authProps, final Properties javaProps,
-                                                          final int[] ports, final int numConnections,
-                                                          final boolean setupDynamicRegionFactory, final String durableClientId,
-                                                          final int expectedResult) {
-
-    if (numOfUsers < 1) {
-      fail("Number of users cannot be less than one");
-    }
-    multiUserAuthMode = true;
-    if (numOfUsers != authProps.length) {
-      fail("Number of authProps provided does not match with numOfUsers specified, "
-          + authProps.length);
-    }
-    if (authProps[0] == null) {
-      authProps[0] = new Properties();
-    }
-    authProps[0].setProperty(MCAST_PORT_NAME, "0");
-    authProps[0].setProperty(LOCATORS_NAME, "");
-    authProps[0].setProperty(SECURITY_LOG_LEVEL_NAME,
-        "finest");
-    Properties props = new Properties();
-    if (authInitModule != null) {
-      authProps[0].setProperty(
-          SECURITY_CLIENT_AUTH_INIT_NAME, authInitModule);
-      props.setProperty(SECURITY_CLIENT_AUTH_INIT_NAME,
-          authInitModule);
-    }
-    if (durableClientId != null) {
-      props.setProperty(DURABLE_CLIENT_ID_NAME,
-          durableClientId);
-      props.setProperty(DURABLE_CLIENT_TIMEOUT_NAME, String
-          .valueOf(DEFAULT_DURABLE_CLIENT_TIMEOUT));
-    }
-
-    SecurityTestUtil tmpInstance = new SecurityTestUtil("temp");
-    tmpInstance.createSystem(props, javaProps);
-    AttributesFactory factory = new AttributesFactory();
-    int[] portsI = new int[ports.length];
-    for(int z=0;z<ports.length;z++) {
-      portsI[z] = ports[z];
-    }
-   
-    try {
-      tmpInstance.openCache();
-      PoolFactory poolFactory = PoolManager.createFactory();
-      poolFactory.setRetryAttempts(200);
-      poolFactory.setMultiuserAuthentication(multiUserAuthMode);
-      poolFactory.setSubscriptionEnabled(true);
-      pool = configureConnectionPoolWithNameAndFactory(factory,
-          getIPLiteral(), portsI, true, 1,
-          numConnections, null, null,
-          poolFactory);
-
-      if (setupDynamicRegionFactory) {
-        initClientDynamicRegionFactory(pool.getName());
-      }
-      proxyCaches = new ProxyCache[numOfUsers];
-      for (int i=0; i<numOfUsers; i++) {
-        proxyCaches[i] = (ProxyCache)((PoolImpl) pool).createAuthenticatedCacheView(authProps[i]);
-      }
-
-      factory.setScope(Scope.LOCAL);
-      factory.setDataPolicy(DataPolicy.EMPTY);
-      RegionAttributes attrs = factory.create();
-      cache.createRegion(REGION_NAME, attrs);
-
-      if (expectedResult != NO_EXCEPTION
-          && expectedResult != NOFORCE_AUTHREQ_EXCEPTION) {
-        if (!multiUserAuthMode) {
-          fail("Expected an exception when starting client");
-        }
-      }
-    }
-    catch (AuthenticationRequiredException ex) {
-      if (expectedResult == AUTHREQ_EXCEPTION
-          || expectedResult == NOFORCE_AUTHREQ_EXCEPTION) {
-        getLogWriter().info(
-            "Got expected exception when starting client: " + ex);
-      }
-      else {
-        fail("Got unexpected exception when starting client", ex);
-      }
-    }
-    catch (AuthenticationFailedException ex) {
-      if (expectedResult == AUTHFAIL_EXCEPTION) {
-        getLogWriter().info(
-            "Got expected exception when starting client: " + ex);
-      }
-      else {
-        fail("Got unexpected exception when starting client", ex);
-      }
-    }
-    catch (ServerRefusedConnectionException ex) {
-      if (expectedResult == CONNREFUSED_EXCEPTION) {
-        getLogWriter().info(
-            "Got expected exception when starting client: " + ex);
-      }
-      else {
-        fail("Got unexpected exception when starting client", ex);
-      }
-    }
-    catch (Exception ex) {
-      fail("Got unexpected exception when starting client", ex);
-    }
-  }
-
-  protected static void createProxyCache(final int[] userIndices, final Properties[] props) {
-    int j = 0;
-    for (int i : userIndices) {
-      proxyCaches[i] = (ProxyCache)((PoolImpl) pool)
-          .createAuthenticatedCacheView(props[j]);
-      j++;
-    }
-  }
-
-  protected static void startLocator(final String name, Integer port, final Object extraProps,
-                                     final Object javaProps, final String[] expectedExceptions) {
-    File logFile = new File(name + "-locator" + port.intValue() + ".log");
-    try {
-      Properties authProps = new Properties();
-      if (extraProps != null) {
-        authProps.putAll((Properties)extraProps);
-      }
-      authProps.setProperty(MCAST_PORT_NAME, "0");
-      authProps.setProperty(LOCATORS_NAME, 
-                            getIPLiteral() + "[" + port + "]");
-      authProps.setProperty(ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
-      clearStaticSSLContext();
-      setJavaProps((Properties)javaProps);
-      FileOutputStream logOut = new FileOutputStream(logFile);
-      PrintStream logStream = new PrintStream(logOut);
-      addIgnoredExceptions(expectedExceptions);
-      logStream.flush();
-      locator = Locator.startLocatorAndDS(port.intValue(), logFile, null,
-          authProps);
-    }
-    catch (IOException ex) {
-      fail("While starting locator on port " + port.intValue(), ex);
-    }
-  }
-
-  protected static void stopLocator(final Integer port, final String[] expectedExceptions) {
-    try {
-      locator.stop();
-      removeExpectedExceptions(expectedExceptions);
-    }
-    catch (Exception ex) {
-      fail("While stopping locator on port " + port.intValue(), ex);
-    }
-  }
-
-  protected static Cache getCache() {
-    return cache;
-  }
-
-  // Some useful region methods used by security tests
-
-  protected static void waitForCondition(final Callable cond) {
-    waitForCondition(cond, 100, 120);
-  }
-
-  protected static void waitForCondition(final Callable cond, final int sleepMillis,
-                                         final int numTries) {
-    WaitCriterion ev = new WaitCriterion() {
-      public boolean done() {
-        try {
-          return ((Boolean)cond.call()).booleanValue();
-        }
-        catch (Exception e) {
-          fail("Unexpected exception", e);
-        }
-        return false; // NOTREACHED
-      }
-      public String description() {
-        return null;
-      }
-    };
-    waitForCriterion(ev, sleepMillis * numTries, 200, true);
-  }
-
-  protected static Object getLocalValue(final Region region, final Object key) {
-    Region.Entry entry = region.getEntry(key);
-    return (entry != null ? entry.getValue() : null);
-  }
-
-  protected static void doProxyCacheClose() {
-    for (int i = 0; i< proxyCaches.length; i++) {
-      proxyCaches[i].close();
-    }
-  }
-
-
-  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(final Integer num) {
-    doPutsP(num, new Integer(NO_EXCEPTION), false);
-  }
-
-  protected static void doPuts(final Integer num, final Integer expectedResult) {
-    doPutsP(num, expectedResult, false);
-  }
-
-  protected static void doMultiUserPuts(final Integer num, final Integer numOfUsers,
-                                        final Integer[] expectedResults) {
-    if (numOfUsers != expectedResults.length) {
-      fail("SecurityTestUtil.doMultiUserPuts(): numOfUsers = " + numOfUsers
-          + ", but expected results " + expectedResults.length);
-    }
-    for (int i = 0; i < numOfUsers; i++) {
-      getLogWriter().info("PUT: MultiUser# " + i);
-      doPutsP(num, Integer.valueOf(i), expectedResults[i], false);
-    }
-  }
-
-  protected static void doGets(final Integer num) {
-    doGetsP(num, new Integer(NO_EXCEPTION), false);
-  }
-
-  protected static void doGets(final Integer num, final Integer expectedResult) {
-    doGetsP(num, expectedResult, false);
-  }
-
-  protected static void doMultiUserGetAll(final Integer numOfUsers, final Integer[] expectedResults) {
-    doMultiUserGetAll(numOfUsers, expectedResults, false);
-  }
-
-  protected static void doMultiUserGetAll(final Integer numOfUsers,
-                                          final Integer[] expectedResults, final 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);
-    }
-  }
-
-  protected static void doMultiUserGets(final Integer num, final Integer numOfUsers,
-                                        final Integer[] expectedResults) {
-    if (numOfUsers != expectedResults.length) {
-      fail("SecurityTestUtil.doMultiUserGets(): numOfUsers = " + numOfUsers
-          + ", but expected results " + expectedResults.length);
-    }
-    for (int i = 0; i < numOfUsers; i++) {
-      getLogWriter().info("GET: MultiUser# " + i);
-      doGetsP(num, Integer.valueOf(i), expectedResults[i], false);
-    }
-  }
-
-  protected static void doMultiUserRegionDestroys(final Integer numOfUsers,
-                                                  final 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]);
-    }
-  }
-
-  protected static void doMultiUserDestroys(final Integer num, final Integer numOfUsers,
-                                            final 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);
-    }
-  }
-
-  protected static void doMultiUserInvalidates(final Integer num, final Integer numOfUsers,
-                                               final Integer[] expectedResults) {
-    if (numOfUsers != expectedResults.length) {
-      fail("SecurityTestUtil.doMultiUserInvalidates(): numOfUsers = " + numOfUsers
-          + ", but expected results " + expectedResults.length);
-    }
-    for (int i = 0; i < numOfUsers; i++) {
-      getLogWriter().info("INVALIDATE: MultiUser# " + i);
-      doInvalidatesP(num, Integer.valueOf(i), expectedResults[i], false);
-    }
-  }
-
-  protected static void doMultiUserContainsKeys(final Integer num, final Integer numOfUsers,
-                                                final Integer[] expectedResults, final 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(final Integer numOfUsers,
-                                           final Integer[] expectedResults, final 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(final Integer numOfUsers, final Function function,
-                                      final Integer[] expectedResults, final Object[] results, final 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");
-      }
-    }
-  }
-
-  protected static void doMultiUserQueryExecute(final Integer numOfUsers,
-                                                final Integer[] expectedResults, final 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(final Integer num) {
-    doLocalGetsP(num.intValue(), false);
-  }
-
-  protected static void doNPuts(final Integer num) {
-    doPutsP(num, new Integer(NO_EXCEPTION), true);
-  }
-
-  protected static void doNPuts(final Integer num, final Integer expectedResult) {
-    doPutsP(num, expectedResult, true);
-  }
-
-  protected static void doNGets(final Integer num) {
-    doGetsP(num, new Integer(NO_EXCEPTION), true);
-  }
-
-  protected static void doNGets(final Integer num, final Integer expectedResult) {
-    doGetsP(num, expectedResult, true);
-  }
-
-  protected static void doNLocalGets(final Integer num) {
-    doLocalGetsP(num.intValue(), true);
-  }
-
-  protected static void doSimpleGet(final 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()");
-        }
-      }
-    }
-  }
-
-  protected static void doSimplePut(final 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()");
-        }
-      }
-    }
-  }
-
-  // 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);
-    if (cache != null && !cache.isClosed()) {
-      DistributedSystem sys = cache.getDistributedSystem();
-      cache.close();
-      sys.disconnect();
-      cache = null;
-    }
-    DistributedTestCase.disconnectFromDS();
-  }
-
-  protected static void closeCache(final Boolean keepAlive) {
-    removeExpectedExceptions(ignoredExceptions);
-    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(final String poolName) {
-    DynamicRegionFactory.get().open(new DynamicRegionFactory.Config(null, poolName, false, true));
-  }
-
-  private static void addJavaProperties(final 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(final 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 doPutsP(final Integer num, final Integer expectedResult,
-                              final boolean newVals) {
-    doPutsP(num, Integer.valueOf(0), expectedResult, newVals);
-  }
-
-  private static void doPutsP(final Integer num, final Integer multiUserIndex,
-                              final Integer expectedResult, final 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);
-      }
-      assertNotNull(region);
-    }
-    catch (Exception ex) {
-      if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        getLogWriter().info("Got expected exception when doing puts: " + ex);
-      }
-      else {
-        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]);
-        }
-        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() == NO_AVAILABLE_SERVERS) {
-          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)) {
-          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) {
-          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) {
-          getLogWriter().info("Got expected exception when doing puts: " + ex);
-        }
-        else {
-          fail("Got unexpected exception when doing puts", ex);
-        }
-      }
-    }
-  }
-
-  private static HashMap getSSLFields(final Object obj, final 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;
-          }
-        }
-        if (isInstance) {
-          resultFields.put(field, fieldObj);
-        }
-      }
-      catch (IllegalAccessException ex) {
-        getLogWriter().warning("Exception while getting SSL fields.", ex);
-      }
-    }
-    return resultFields;
-  }
-
-  private static void makeNullSSLFields(final Object obj, final 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);
-      }
-    }
-  }
-
-  // Deal with javax SSL properties
-  private static void makeNullStaticField(final 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(final Integer multiUserIndex,
-                                      final Integer expectedResult, final Integer expectedValue) {
-    Region region = null;
-    try {
-      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 query: " + ex);
-      } else {
-        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(final Integer multiUserIndex,
-                                         final Function function, Integer expectedResult, final Object expectedValue,
-                                         final String method) {
-    Region region = null;
-    try {
-      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 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(final Integer multiUserIndex,
-                                 final Integer expectedResult, final Integer expectedValue) {
-    Region region = null;
-    try {
-      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 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() == NO_AVAILABLE_SERVERS) {
-        getLogWriter().info(
-                "Got expected NoAvailableServers when doing queries: "
-                        + ex.getCause());
-      } else {
-        fail("Got unexpected exception when doing queries", ex);
-      }
-    } catch (ServerConnectivityException ex) {
-      if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-              && (ex.getCause() instanceof NotAuthorizedException)) {
-        getLogWriter().info(
-                "Got expected NotAuthorizedException when doing queries: "
-                        + ex.getCause());
-      } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        getLogWriter().info("Got expected exception when doing queries: " + ex);
-      } else {
-        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) {
-        getLogWriter().info("Got expected exception when doing queries: " + ex);
-      } else {
-        fail("Got unexpected exception when doing queries", ex);
-      }
-    }
-  }
-
-  private static void doContainsKeysP(final Integer num, final Integer multiUserIndex,
-                                      final Integer expectedResult, final boolean newVals, final boolean expectedValue) {
-
-    assertTrue(num.intValue() <= KEYS.length);
-    Region region = null;
-    try {
-      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 doing containsKey: " + ex);
-      }
-      else {
-        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]);
-        if (expectedResult.intValue() != NO_EXCEPTION) {
-          fail("Expected a NotAuthorizedException while doing containsKey");
-        }
-      }
-      catch(NoAvailableServersException ex) {
-        if(expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
-          getLogWriter().info(
-                  "Got expected NoAvailableServers when doing containsKey: "
-                          + ex.getCause());
-          continue;
-        }
-        else {
-          fail("Got unexpected exception when doing containsKey", ex);
-        }
-      }
-      catch (ServerConnectivityException ex) {
-        if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-                && (ex.getCause() instanceof NotAuthorizedException)) {
-          getLogWriter().info(
-                  "Got expected NotAuthorizedException when doing containsKey: "
-                          + ex.getCause());
-          continue;
-        }
-        else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          getLogWriter().info("Got expected exception when doing containsKey: " + ex);
-        }
-        else {
-          fail("Got unexpected exception when doing containsKey", ex);
-        }
-      }
-      catch (Exception ex) {
-        if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          getLogWriter().info("Got expected exception when doing containsKey: " + ex);
-        }
-        else {
-          fail("Got unexpected exception when doing containsKey", ex);
-        }
-      }
-      assertEquals(expectedValue, result);
-    }
-  }
-
-  private static void doInvalidatesP(final Integer num, final Integer multiUserIndex,
-                                     final Integer expectedResult, final boolean newVals) {
-    assertTrue(num.intValue() <= KEYS.length);
-    Region region = null;
-    try {
-      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 doing invalidates: " + ex);
-      }
-      else {
-        fail("Got unexpected exception when doing invalidates", ex);
-      }
-    }
-    for (int index = 0; index < num.intValue(); ++index) {
-      try {
-        region.invalidate(KEYS[index]);
-        if (expectedResult.intValue() != NO_EXCEPTION) {
-          fail("Expected a NotAuthorizedException while doing invalidates");
-        }
-      }
-      catch(NoAvailableServersException ex) {
-        if(expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
-          getLogWriter().info(
-                  "Got expected NoAvailableServers when doing invalidates: "
-                          + ex.getCause());
-          continue;
-        }
-        else {
-          fail("Got unexpected exception when doing invalidates", ex);
-        }
-      }
-      catch (ServerConnectivityException ex) {
-        if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-                && (ex.getCause() instanceof NotAuthorizedException)) {
-          getLogWriter().info(
-                  "Got expected NotAuthorizedException when doing invalidates: "
-                          + ex.getCause());
-          continue;
-        }
-        else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          getLogWriter().info("Got expected exception when doing invalidates: " + ex);
-        }
-        else {
-          fail("Got unexpected exception when doing invalidates", ex);
-        }
-      }
-      catch (Exception ex) {
-        if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          getLogWriter().info("Got expected exception when doing invalidates: " + ex);
-        }
-        else {
-          fail("Got unexpected exception when doing invalidates", ex);
-        }
-      }
-    }
-  }
-
-  private static void doDestroysP(final Integer num, final Integer multiUserIndex,
-                                  final Integer expectedResult, final boolean newVals) {
-    assertTrue(num.intValue() <= KEYS.length);
-    Region region = null;
-    try {
-      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 doing destroys: " + ex);
-      }
-      else {
-        fail("Got unexpected exception when doing destroys", ex);
-      }
-    }
-    for (int index = 0; index < num.intValue(); ++index) {
-      try {
-        region.destroy(KEYS[index]);
-        if (expectedResult.intValue() != NO_EXCEPTION) {
-          fail("Expected a NotAuthorizedException while doing destroys");
-        }
-      }
-      catch(NoAvailableServersException ex) {
-        if(expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
-          getLogWriter().info(
-                  "Got expected NoAvailableServers when doing destroys: "
-                          + ex.getCause());
-          continue;
-        }
-        else {
-          fail("Got unexpected exception when doing destroys", ex);
-        }
-      }
-      catch (ServerConnectivityException ex) {
-        if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-                && (ex.getCause() instanceof NotAuthorizedException)) {
-          getLogWriter().info(
-                  "Got expected NotAuthorizedException when doing destroys: "
-                          + ex.getCause());
-          continue;
-        }
-        else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          getLogWriter().info("Got expected exception when doing destroys: " + ex);
-        }
-        else {
-          fail("Got unexpected exception when doing destroys", ex);
-        }
-      }
-      catch (Exception ex) {
-        if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          getLogWriter().info("Got expected exception when doing destroys: " + ex);
-        }
-        else {
-          fail("Got unexpected exception when doing destroys", ex);
-        }
-      }
-    }
-  }
-
-  private static void doRegionDestroysP(final Integer multiuserIndex,
-                                        final Integer expectedResult) {
-    Region region = null;
-    try {
-      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 doing region destroy: " + ex);
-      } else {
-        fail("Got unexpected exception when doing region destroy", ex);
-      }
-    }
-
-    try {
-      region.destroyRegion();
-      if (expectedResult.intValue() != NO_EXCEPTION) {
-        fail("Expected a NotAuthorizedException while doing region destroy");
-      }
-      if (multiUserAuthMode) {
-        region = proxyCaches[multiuserIndex].getRegion(REGION_NAME);
-      } else {
-        region = getCache().getRegion(REGION_NAME);
-      }
-      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 region destroy", ex);
-      }
-    } catch (ServerConnectivityException ex) {
-      if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-              && (ex.getCause() instanceof NotAuthorizedException)) {
-        getLogWriter().info(
-                "Got expected NotAuthorizedException when doing region destroy: "
-                        + ex.getCause());
-      } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        getLogWriter().info(
-                "Got expected exception when doing region destroy: " + ex);
-      } else {
-        fail("Got unexpected exception when doing region destroy", ex);
-      }
-    } catch (Exception ex) {
-      if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        getLogWriter().info(
-                "Got expected exception when doing region destroy: " + ex);
-      } else {
-        fail("Got unexpected exception when doing region destroy", ex);
-      }
-    }
-  }
-
-  private static void doLocalGetsP(final int num, final 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(final Integer multiUserIndex,
-                                final Integer expectedResult, final boolean useTX) {
-    Region region = null;
-    try {
-      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 doing getAll: " + ex);
-      }
-      else {
-        fail("Got unexpected exception when doing getAll", ex);
-      }
-    }
-    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"));
-      }
-    } catch (NoAvailableServersException ex) {
-      if (expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
-        getLogWriter().info(
-                "Got expected NoAvailableServers when doing getAll: "
-                        + ex.getCause());
-      } else {
-        fail("Got unexpected exception when doing getAll", ex);
-      }
-    } catch (ServerConnectivityException ex) {
-      if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-              && (ex.getCause() instanceof NotAuthorizedException)) {
-        getLogWriter().info(
-                "Got expected NotAuthorizedException when doing getAll: "
-                        + ex.getCause());
-      } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        getLogWriter().info("Got expected exception when doing getAll: " + ex);
-      } else {
-        fail("Got unexpected exception when doing getAll", ex);
-      }
-    } catch (Exception ex) {
-      if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        getLogWriter().info("Got expected exception when doing getAll: " + ex);
-      } else {
-        fail("Got unexpected exception when doing getAll", ex);
-      }
-    }
-  }
-
-  private static void doGetsP(final Integer num, final Integer expectedResult,
-                              final boolean newVals) {
-    doGetsP(num, Integer.valueOf(0), expectedResult, newVals);
-  }
-
-  private static void doGetsP(final Integer num, final Integer multiUserIndex,
-                              final Integer expectedResult, final boolean newVals) {
-    assertTrue(num.intValue() <= KEYS.length);
-    Region region = null;
-    try {
-      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 doing gets: " + ex);
-      }
-      else {
-        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]);
-        }
-        catch (Exception ex) {
-        }
-        value = region.get(KEYS[index]);
-        if (expectedResult.intValue() != NO_EXCEPTION) {
-          fail("Expected a NotAuthorizedException while doing gets");
-        }
-      }
-      catch(NoAvailableServersException ex) {
-        if(expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
-          getLogWriter().info(
-                  "Got expected NoAvailableServers when doing gets: "
-                          + ex.getCause());
-          continue;
-        }
-        else {
-          fail("Got unexpected exception when doing gets", ex);
-        }
-      }
-      catch (ServerConnectivityException ex) {
-        if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-                && (ex.getCause() instanceof NotAuthorizedException)) {
-          getLogWriter().info(
-                  "Got expected NotAuthorizedException when doing gets: "
-                          + ex.getCause());
-          continue;
-        }
-        else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          getLogWriter().info("Got expected exception when doing gets: " + ex);
-        }
-        else {
-          fail("Got unexpected exception when doing gets", ex);
-        }
-      }
-      catch (Exception ex) {
-        if (expectedResult.intValue() == OTHER_EXCEPTION) {
-          getLogWriter().info("Got expected exception when doing gets: " + ex);
-        }
-        else {
-          fail("Got unexpected exception when doing gets", ex);
-        }
-      }
-      assertNotNull(value);
-      if (newVals) {
-        assertEquals(NVALUES[index], value);
-      }
-      else {
-        assertEquals(VALUES[index], value);
-      }
-    }
-  }
-
-  // ----------------------------- member methods -----------------------------
-
-  public DistributedSystem createSystem(final Properties sysProps, final Properties javaProps) {
-    closeCache();
-    clearStaticSSLContext();
-    setJavaProps(javaProps);
-
-    DistributedSystem dsys = distributedTestCase.getSystem(sysProps);
-    assertNotNull(dsys);
-    addIgnoredExceptions(ignoredExceptions);
-    return dsys;
-  }
-
-  private void openCache() {
-    assertNotNull(distributedTestCase.basicGetSystem());
-    assertTrue(distributedTestCase.basicGetSystem().isConnected());
-    cache = CacheFactory.create(distributedTestCase.basicGetSystem());
-    assertNotNull(cache);
-  }
-
-  // ------------------------------- inner classes ----------------------------
-
-  private 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;
-    }
-
-    /**
-     * For test purpose, to make sure
-     * the object is not deserialized
-     */
-    @Override
-    public void fromData(PdxReader in) {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void toData(PdxWriter out) {
-      out.writeLong("Id", Id);
-      out.writeString("fname", fname);
-      out.writeString("lname", lname);
-    }
-  }
-}


[5/7] incubator-geode git commit: Rename getter with side effect

Posted by kl...@apache.org.
Rename getter with side effect


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

Branch: refs/heads/feature/GEODE-693
Commit: 31ca34d6ed5b40df38d2a6b8c633bf96f65bb31e
Parents: 310698c
Author: Kirk Lund <kl...@apache.org>
Authored: Tue Mar 29 12:27:21 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue Mar 29 12:27:21 2016 -0700

----------------------------------------------------------------------
 .../security/ClientAuthenticationTestCase.java    | 18 +++++++++---------
 .../gemfire/security/SecurityTestUtils.java       |  2 +-
 .../gemfire/security/MultiuserAPIDUnitTest.java   |  2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/31ca34d6/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
index ea3d941..191ea3e 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestCase.java
@@ -87,7 +87,7 @@ public abstract class ClientAuthenticationTestCase extends JUnit4DistributedTest
     // Start the servers
     int locPort1 = getLocatorPort();
     int locPort2 = getLocatorPort();
-    String locString = getLocatorString();
+    String locString = getAndClearLocatorString();
 
     int port1 = server1.invoke(() -> createCacheServer(locPort1, locString, authenticator, extraProps, javaProps));
     int port2 = server2.invoke(() -> createCacheServer(locPort2, locString, authenticator, extraProps, javaProps));
@@ -133,7 +133,7 @@ public abstract class ClientAuthenticationTestCase extends JUnit4DistributedTest
     // Start the servers
     int locPort1 = getLocatorPort();
     int locPort2 = getLocatorPort();
-    String locString = getLocatorString();
+    String locString = getAndClearLocatorString();
 
     int port1 = createServer1(extraProps, javaProps, authenticator, locPort1, locString);
     int port2 = server2.invoke(() -> createCacheServer(locPort2, locString, authenticator, extraProps, javaProps));
@@ -176,7 +176,7 @@ public abstract class ClientAuthenticationTestCase extends JUnit4DistributedTest
     // Start the servers
     int locPort1 = getLocatorPort();
     int locPort2 = getLocatorPort();
-    String locString = getLocatorString();
+    String locString = getAndClearLocatorString();
 
     int port1 = createServer1(extraProps, javaProps, authenticator, locPort1, locString);
     int port2 = server2.invoke(() -> createCacheServer(locPort2, locString, authenticator, extraProps, javaProps));
@@ -212,7 +212,7 @@ public abstract class ClientAuthenticationTestCase extends JUnit4DistributedTest
 
     // Start the server
     int locPort1 = getLocatorPort();
-    String locString = getLocatorString();
+    String locString = getAndClearLocatorString();
 
     int port1 = createServer1(extraProps, javaProps, authenticator, locPort1, locString);
     Properties credentials = gen.getValidCredentials(1);
@@ -233,7 +233,7 @@ public abstract class ClientAuthenticationTestCase extends JUnit4DistributedTest
     // Start the servers
     int locPort1 = getLocatorPort();
     int locPort2 = getLocatorPort();
-    String locString = getLocatorString();
+    String locString = getAndClearLocatorString();
 
     int port1 = createServer1(extraProps, javaProps, authenticator, locPort1, locString);
     int port2 = server2.invoke(() -> createCacheServer(locPort2, locString, authenticator, extraProps, javaProps));
@@ -272,7 +272,7 @@ public abstract class ClientAuthenticationTestCase extends JUnit4DistributedTest
 
     // Start the server with invalid authenticator
     int locPort1 = getLocatorPort();
-    String locString = getLocatorString();
+    String locString = getAndClearLocatorString();
 
     int port1 = server1.invoke(() -> createCacheServer(locPort1, locString, "com.gemstone.gemfire.none", extraProps, javaProps));
 
@@ -305,7 +305,7 @@ public abstract class ClientAuthenticationTestCase extends JUnit4DistributedTest
     // Start the servers with no authenticator
     int locPort1 = getLocatorPort();
     int locPort2 = getLocatorPort();
-    String locString = getLocatorString();
+    String locString = getAndClearLocatorString();
 
     int port1 = server1.invoke(() -> createCacheServer(locPort1, locString, null, extraProps, javaProps));
     int port2 = server2.invoke(() -> createCacheServer(locPort2, locString, null, extraProps, javaProps));
@@ -343,7 +343,7 @@ public abstract class ClientAuthenticationTestCase extends JUnit4DistributedTest
     // Start the first server
     int locPort1 = getLocatorPort();
     int locPort2 = getLocatorPort();
-    String locString = getLocatorString();
+    String locString = getAndClearLocatorString();
 
     int port1 = server1.invoke(() -> createCacheServer(locPort1, locString, authenticator, extraProps, javaProps));
 
@@ -419,7 +419,7 @@ public abstract class ClientAuthenticationTestCase extends JUnit4DistributedTest
     // Start the first server
     int locPort1 = getLocatorPort();
     int locPort2 = getLocatorPort();
-    String locString = getLocatorString();
+    String locString = getAndClearLocatorString();
 
     int port1 = server1.invoke(() -> createCacheServer(locPort1, locString, authenticator, extraProps, javaProps));
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/31ca34d6/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java b/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
index 4474279..ce53b02 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
@@ -180,7 +180,7 @@ public final class SecurityTestUtils {
    * 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.
    */
-  protected static String getLocatorString() { // TODO: rename
+  protected static String getAndClearLocatorString() {
     String locString = locatorString;
     locatorString = null;
     return locString;

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/31ca34d6/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 bdff2c2..9e04f5f 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
@@ -272,7 +272,7 @@ public class MultiUserAPIDUnitTest extends ClientAuthorizationTestCase {
     // Start the servers
     int locPort1 = SecurityTestUtils.getLocatorPort();
     int locPort2 = SecurityTestUtils.getLocatorPort();
-    String locString = SecurityTestUtils.getLocatorString();
+    String locString = SecurityTestUtils.getAndClearLocatorString();
 
     int port1 = server1.invoke(() -> createCacheServer(locPort1, locString, authenticator, extraProps, javaProps));
     int port2 = server2.invoke(() -> createCacheServer(locPort2, locString, authenticator, extraProps, javaProps));


[7/7] incubator-geode git commit: Cleanup

Posted by kl...@apache.org.
Cleanup


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

Branch: refs/heads/feature/GEODE-693
Commit: e93932aabb5580e2fe343df79d883a71b9e5bd63
Parents: 31ca34d
Author: Kirk Lund <kl...@apache.org>
Authored: Tue Mar 29 16:53:12 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Tue Mar 29 16:53:12 2016 -0700

----------------------------------------------------------------------
 .../gemfire/internal/cache/EntriesMap.java      |    5 +-
 .../gemfire/internal/util/Callable.java         |   47 -
 .../cli/ClasspathScanLoadHelperJUnitTest.java   |   85 +-
 .../security/ClientAuthenticationTestUtils.java |   32 +-
 .../security/ClientAuthorizationDUnitTest.java  |    4 +-
 .../security/ClientAuthorizationTestCase.java   |  146 ++-
 .../security/ClientMultiUserAuthzDUnitTest.java |   60 +-
 .../DeltaClientPostAuthorizationDUnitTest.java  |   16 +-
 .../gemfire/security/SecurityTestUtils.java     | 1130 ++++++++----------
 .../ClientAuthorizationTwoDUnitTest.java        |    2 +-
 .../ClientPostAuthorizationDUnitTest.java       |    5 +-
 11 files changed, 676 insertions(+), 856 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e93932aa/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntriesMap.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntriesMap.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntriesMap.java
index 74697ea..257458f 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntriesMap.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/internal/cache/EntriesMap.java
@@ -20,10 +20,9 @@ package com.gemstone.gemfire.internal.cache;
 import java.util.*;
 import com.gemstone.gemfire.cache.*;
 import com.gemstone.gemfire.internal.InternalStatisticsDisabledException;
-import com.gemstone.gemfire.internal.util.Callable;
-//import com.gemstone.gemfire.util.concurrent.ConcurrentMap;
+
+import java.util.concurrent.Callable;
 import java.util.concurrent.ConcurrentMap;
-//import com.gemstone.gemfire.util.concurrent.locks.*;
 import com.gemstone.gemfire.distributed.internal.DM;
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e93932aa/geode-core/src/main/java/com/gemstone/gemfire/internal/util/Callable.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/internal/util/Callable.java b/geode-core/src/main/java/com/gemstone/gemfire/internal/util/Callable.java
deleted file mode 100755
index 7799224..0000000
--- a/geode-core/src/main/java/com/gemstone/gemfire/internal/util/Callable.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain. Use, modify, and
- * redistribute this code in any way without acknowledgement.
- */
-
-package com.gemstone.gemfire.internal.util;
-
-/**
- * A task that returns a result and may throw an exception.
- * Implementors define a single method with no arguments called
- * <tt>call</tt>.
- *
- * <p>The <tt>Callable</tt> interface is similar to {@link
- * java.lang.Runnable}, in that both are designed for classes whose
- * instances are potentially executed by another thread.  A
- * <tt>Runnable</tt>, however, does not return a result and cannot
- * throw a checked exception.
- *
- *
- * @version based on JSR166 Callable version 1.6.
- */
-public interface Callable {
-    /**
-     * Computes a result, or throws an exception if unable to do so.
-     *
-     * @return computed result
-     * @throws Exception if unable to compute a result
-     */
-    Object call() throws Exception;
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e93932aa/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/ClasspathScanLoadHelperJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/ClasspathScanLoadHelperJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/ClasspathScanLoadHelperJUnitTest.java
index 4476cd6..79a0f09 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/ClasspathScanLoadHelperJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/ClasspathScanLoadHelperJUnitTest.java
@@ -16,14 +16,12 @@
  */
 package com.gemstone.gemfire.management.internal.cli;
 
+import static org.junit.Assert.*;
+
 import java.io.IOException;
 import java.util.Set;
 
-import org.junit.experimental.categories.Category;
-
-import junit.framework.TestCase;
-
-import com.gemstone.gemfire.internal.util.Callable;
+import com.gemstone.gemfire.internal.util.Versionable;
 import com.gemstone.gemfire.management.internal.cli.domain.AbstractImpl;
 import com.gemstone.gemfire.management.internal.cli.domain.Impl1;
 import com.gemstone.gemfire.management.internal.cli.domain.Impl12;
@@ -31,61 +29,52 @@ import com.gemstone.gemfire.management.internal.cli.domain.Interface1;
 import com.gemstone.gemfire.management.internal.cli.domain.Interface2;
 import com.gemstone.gemfire.management.internal.cli.util.ClasspathScanLoadHelper;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
-/**
- */
 @Category(UnitTest.class)
-public class ClasspathScanLoadHelperJUnitTest  extends TestCase{
+public class ClasspathScanLoadHelperJUnitTest {
   
   private static final String PACKAGE_NAME = "com.gemstone.gemfire.management.internal.cli.domain";
   private static final String WRONG_PACKAGE_NAME = "com.gemstone.gemfire.management.internal.cli.domain1";
   private static final Class<?> INTERFACE1 = Interface1.class;
-  private static final Class<?> NO_IMPL_INTERFACE = Callable.class;
+  private static final Class<?> NO_IMPL_INTERFACE = Versionable.class;
   private static final Class<?> INTERFACE2 = Interface2.class;
   private static final Class<?> IMPL1 = Impl1.class;
   private static final Class<?> IMPL2 = Impl12.class;
   private static final Class<?> ABSTRACT_IMPL = AbstractImpl.class;
   
+  @Test
+  public void testLoadAndGet() throws Exception {
+    Set<Class<?>> classLoaded = ClasspathScanLoadHelper.loadAndGet(PACKAGE_NAME, INTERFACE1, true);
+    assertEquals(2, classLoaded.size());
+    assertTrue(classLoaded.contains(IMPL1));
+    assertTrue(classLoaded.contains(IMPL2));
+    //impl1 and impl12
+
+    classLoaded = ClasspathScanLoadHelper.loadAndGet(PACKAGE_NAME, INTERFACE1, false);
+    assertEquals(4, classLoaded.size());
+    assertTrue(classLoaded.contains(IMPL1));
+    assertTrue(classLoaded.contains(IMPL2));
+    assertTrue(classLoaded.contains(ABSTRACT_IMPL));
+    assertTrue(classLoaded.contains(INTERFACE1));
+
+    classLoaded = ClasspathScanLoadHelper.loadAndGet(PACKAGE_NAME, INTERFACE2, false);
+    assertEquals(2, classLoaded.size());
+    assertTrue(classLoaded.contains(IMPL2));
+    assertTrue(classLoaded.contains(INTERFACE2));
+
+    classLoaded = ClasspathScanLoadHelper.loadAndGet(PACKAGE_NAME, INTERFACE2, true);
+    assertEquals(1, classLoaded.size());
+    assertTrue(classLoaded.contains(IMPL2));
+
+    classLoaded = ClasspathScanLoadHelper.loadAndGet(WRONG_PACKAGE_NAME, INTERFACE2, true);
+    assertEquals(0, classLoaded.size());
 
-  public void testloadAndGet(){
+    classLoaded = ClasspathScanLoadHelper.loadAndGet(PACKAGE_NAME, NO_IMPL_INTERFACE, true);
+    assertEquals(0, classLoaded.size());
 
-    try {
-      Set<Class<?>> classLoaded = ClasspathScanLoadHelper.loadAndGet(PACKAGE_NAME, INTERFACE1, true);
-      assertEquals(2, classLoaded.size());
-      assertTrue(classLoaded.contains(IMPL1));
-      assertTrue(classLoaded.contains(IMPL2));
-      //impl1 and impl12
-      
-      classLoaded = ClasspathScanLoadHelper.loadAndGet(PACKAGE_NAME, INTERFACE1, false);
-      assertEquals(4, classLoaded.size());
-      assertTrue(classLoaded.contains(IMPL1));
-      assertTrue(classLoaded.contains(IMPL2));
-      assertTrue(classLoaded.contains(ABSTRACT_IMPL));
-      assertTrue(classLoaded.contains(INTERFACE1));
-      
-      classLoaded = ClasspathScanLoadHelper.loadAndGet(PACKAGE_NAME, INTERFACE2, false);
-      assertEquals(2, classLoaded.size());      
-      assertTrue(classLoaded.contains(IMPL2));      
-      assertTrue(classLoaded.contains(INTERFACE2));
-      
-      classLoaded = ClasspathScanLoadHelper.loadAndGet(PACKAGE_NAME, INTERFACE2, true);      
-      assertEquals(1, classLoaded.size());      
-      assertTrue(classLoaded.contains(IMPL2));
-      
-      classLoaded = ClasspathScanLoadHelper.loadAndGet(WRONG_PACKAGE_NAME, INTERFACE2, true);
-      assertEquals(0, classLoaded.size());      
-      
-      classLoaded = ClasspathScanLoadHelper.loadAndGet(PACKAGE_NAME, NO_IMPL_INTERFACE, true);
-      assertEquals(0, classLoaded.size());
-      
-      classLoaded = ClasspathScanLoadHelper.loadAndGet(WRONG_PACKAGE_NAME, NO_IMPL_INTERFACE, true);
-      assertEquals(0, classLoaded.size());
-      
-      
-    } catch (ClassNotFoundException e) {
-      fail("Error loading class" + e);
-    } catch (IOException e) {
-      fail("Error loading class" + e);
-    }   
+    classLoaded = ClasspathScanLoadHelper.loadAndGet(WRONG_PACKAGE_NAME, NO_IMPL_INTERFACE, true);
+    assertEquals(0, classLoaded.size());
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e93932aa/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestUtils.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestUtils.java
index dc78a5a..89a0a15 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestUtils.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthenticationTestUtils.java
@@ -16,13 +16,13 @@
  */
 package com.gemstone.gemfire.security;
 
+import static com.gemstone.gemfire.distributed.internal.DistributionConfig.*;
 import static com.gemstone.gemfire.security.SecurityTestUtils.*;
 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
@@ -32,7 +32,7 @@ public abstract class ClientAuthenticationTestUtils {
   protected ClientAuthenticationTestUtils() {
   }
 
-  protected static Integer createCacheServer(int dsPort, String locatorString, String authenticator, Properties extraProps, Properties javaProps) {
+  protected static Integer createCacheServer(final int locatorPort, final String locatorString, final String authenticator, final Properties extraProps, final Properties javaProps) {
     Properties authProps;
     if (extraProps == null) {
       authProps = new Properties();
@@ -41,13 +41,13 @@ public abstract class ClientAuthenticationTestUtils {
     }
 
     if (authenticator != null) {
-      authProps.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator);
+      authProps.setProperty(SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator);
     }
 
-    return SecurityTestUtils.createCacheServer(authProps, javaProps, dsPort, locatorString, 0, NO_EXCEPTION);
+    return SecurityTestUtils.createCacheServer(authProps, javaProps, locatorPort, locatorString, 0, NO_EXCEPTION);
   }
 
-  protected static void createCacheServer(int dsPort, String locatorString, int serverPort, String authenticator, Properties extraProps, Properties javaProps) {
+  protected static void createCacheServer(final int locatorPort, final String locatorString, final int serverPort, final String authenticator, final Properties extraProps, final Properties javaProps) {
     Properties authProps;
     if (extraProps == null) {
       authProps = new Properties();
@@ -56,32 +56,32 @@ public abstract class ClientAuthenticationTestUtils {
     }
 
     if (authenticator != null) {
-      authProps.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator);
+      authProps.setProperty(SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator);
     }
-    SecurityTestUtils.createCacheServer(authProps, javaProps, dsPort, locatorString, serverPort, NO_EXCEPTION);
+    SecurityTestUtils.createCacheServer(authProps, javaProps, locatorPort, locatorString, serverPort, NO_EXCEPTION);
   }
 
-  protected static void createCacheClient(String authInit, Properties authProps, Properties javaProps, int[] ports, int numConnections, boolean multiUserMode, boolean subscriptionEnabled, int expectedResult) {
+  protected static void createCacheClient(final String authInit, final Properties authProps, final Properties javaProps, final int[] ports, final int numConnections, final boolean multiUserMode, final boolean subscriptionEnabled, final int expectedResult) {
     SecurityTestUtils.createCacheClient(authInit, authProps, javaProps, ports, numConnections, false, multiUserMode, subscriptionEnabled, expectedResult);
   }
 
-  protected static void createCacheClient(String authInit, Properties authProps, Properties javaProps, int[] ports, int numConnections, boolean multiUserMode, int expectedResult) {
+  protected static void createCacheClient(final String authInit, final Properties authProps, final Properties javaProps, final int[] ports, final int numConnections, final boolean multiUserMode, final int expectedResult) {
     createCacheClient(authInit, authProps, javaProps, ports, numConnections, multiUserMode, true, expectedResult);
   }
 
-  protected 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);
+  protected static void createCacheClient(final String authInit, final Properties authProps, final Properties javaProps, final int port1, final int numConnections, final int expectedResult) {
+    createCacheClient(authInit, authProps, javaProps, new int[] { port1 }, numConnections, false, true, expectedResult);
   }
 
-  protected 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);
+  protected static void createCacheClient(final String authInit, final Properties authProps, final Properties javaProps, final int port1, final int port2, final int numConnections, final int expectedResult) {
+    createCacheClient(authInit, authProps, javaProps, port1, port2, numConnections, false, expectedResult);
   }
 
-  protected 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);
+  protected static void createCacheClient(final String authInit, final Properties authProps, final Properties javaProps, final int port1, final int port2, final int numConnections, final boolean multiUserMode, final int expectedResult) {
+    createCacheClient(authInit, authProps, javaProps, port1, port2, numConnections, multiUserMode, true, expectedResult);
   }
 
-  protected static void createCacheClient(String authInit, Properties authProps, Properties javaProps, int port1, int port2, int numConnections, boolean multiUserMode, boolean subscriptionEnabled, int expectedResult) {
+  protected static void createCacheClient(final String authInit, final Properties authProps, final Properties javaProps, final int port1, final int port2, final int numConnections, final boolean multiUserMode, final boolean subscriptionEnabled, final int expectedResult) {
     createCacheClient(authInit, authProps, javaProps, new int[] { port1, port2 }, numConnections, multiUserMode, subscriptionEnabled, expectedResult);
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e93932aa/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 33a32ff..eeb2c39 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
@@ -393,7 +393,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestCase {
   @Test
   public void testAllOpsWithFailover() throws InterruptedException {
     addIgnoredException("Read timed out");
-    runOpsWithFailover(allOpsForAllOpsWithFailover(), "testAllOpsWithFailover");
+    runOpsWithFailOver(allOpsForAllOpsWithFailover(), "testAllOpsWithFailover");
   }
 
   private OperationWithAction[] unregisterOpsForTestUnregisterInterestWithFailover() {
@@ -563,7 +563,7 @@ public class ClientAuthorizationDUnitTest extends ClientAuthorizationTestCase {
         Properties opCredentials = null;
         String currentRegionName = '/' + regionName;
         if ((opFlags & OpFlags.USE_SUBREGION) > 0) {
-          currentRegionName += ('/' + subregionName);
+          currentRegionName += ('/' + SUBREGION_NAME);
         }
         String credentialsTypeStr;
         OperationCode authOpCode = currentOp.getAuthzOperationCode();

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e93932aa/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
index be3de47..088dec4 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTestCase.java
@@ -18,6 +18,7 @@
  */
 package com.gemstone.gemfire.security;
 
+import static com.gemstone.gemfire.distributed.internal.DistributionConfig.*;
 import static com.gemstone.gemfire.internal.AvailablePort.*;
 import static com.gemstone.gemfire.security.SecurityTestUtils.*;
 import static com.gemstone.gemfire.test.dunit.Assert.*;
@@ -34,6 +35,7 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Random;
 import java.util.Set;
+import java.util.concurrent.Callable;
 
 import com.gemstone.gemfire.cache.DynamicRegionFactory;
 import com.gemstone.gemfire.cache.InterestResultPolicy;
@@ -53,11 +55,9 @@ import com.gemstone.gemfire.cache.query.QueryInvocationTargetException;
 import com.gemstone.gemfire.cache.query.QueryService;
 import com.gemstone.gemfire.cache.query.SelectResults;
 import com.gemstone.gemfire.cache.query.Struct;
-import com.gemstone.gemfire.distributed.internal.DistributionConfig;
 import com.gemstone.gemfire.internal.AvailablePort.Keeper;
 import com.gemstone.gemfire.internal.cache.AbstractRegionEntry;
 import com.gemstone.gemfire.internal.cache.LocalRegion;
-import com.gemstone.gemfire.internal.util.Callable;
 import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
 import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator.ClassCode;
 import com.gemstone.gemfire.security.generator.CredentialGenerator;
@@ -73,7 +73,7 @@ import com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;
  * 
  * @since 5.5
  */
-public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
+public abstract class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
 
   private static final int PAUSE = 5 * 1000;
 
@@ -82,8 +82,8 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
   protected static VM client1 = null;
   protected static VM client2 = null;
 
-  protected static final String regionName = REGION_NAME;
-  protected static final String subregionName = "AuthSubregion";
+  protected static final String regionName = REGION_NAME; // TODO: remove
+  protected static final String SUBREGION_NAME = "AuthSubregion";
 
   private static final String[] serverIgnoredExceptions = {
       "Connection refused",
@@ -182,29 +182,29 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
   protected void postTearDownClientAuthorizationTestBase() throws Exception {
   }
 
-  protected static Properties buildProperties(String authenticator, String accessor, boolean isAccessorPP, Properties extraAuthProps, Properties extraAuthzProps) {
+  protected static Properties buildProperties(final String authenticator, final String accessor, final boolean isAccessorPP, final Properties extraAuthProps, final Properties extraAuthzProps) {
     Properties authProps = new Properties();
     if (authenticator != null) {
-      authProps.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator);
+      authProps.setProperty(SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator);
     }
     if (accessor != null) {
       if (isAccessorPP) {
-        authProps.setProperty(DistributionConfig.SECURITY_CLIENT_ACCESSOR_PP_NAME, accessor);
+        authProps.setProperty(SECURITY_CLIENT_ACCESSOR_PP_NAME, accessor);
       } else {
-        authProps.setProperty(DistributionConfig.SECURITY_CLIENT_ACCESSOR_NAME, accessor);
+        authProps.setProperty(SECURITY_CLIENT_ACCESSOR_NAME, accessor);
       }
     }
     return concatProperties(new Properties[] { authProps, extraAuthProps, extraAuthzProps });
   }
 
-  protected static Integer createCacheServer(int locatorPort, Properties authProps, Properties javaProps) {
+  protected static Integer createCacheServer(int locatorPort, final Properties authProps, final Properties javaProps) {
     if (locatorPort == 0) {
       locatorPort = getRandomAvailablePort(SOCKET);
     }
     return SecurityTestUtils.createCacheServer(authProps, javaProps, locatorPort, null, 0, true, NO_EXCEPTION);
   }
 
-  protected static int createCacheServer(int locatorPort, int serverPort, Properties authProps, Properties javaProps) {
+  protected static int createCacheServer(int locatorPort, final int serverPort, final Properties authProps, final Properties javaProps) {
     if (locatorPort == 0) {
       locatorPort = getRandomAvailablePort(SOCKET);
     }
@@ -216,18 +216,18 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
   }
 
   protected static Region getSubregion() {
-    return getCache().getRegion(regionName + '/' + subregionName);
+    return getCache().getRegion(regionName + '/' + SUBREGION_NAME);
   }
 
-  private static Region createSubregion(Region region) {
+  private static Region createSubregion(final Region region) {
     Region subregion = getSubregion();
     if (subregion == null) {
-      subregion = region.createSubregion(subregionName, region.getAttributes());
+      subregion = region.createSubregion(SUBREGION_NAME, region.getAttributes());
     }
     return subregion;
   }
 
-  protected static String indicesToString(int[] indices) {
+  protected static String indicesToString(final int[] indices) {
     String str = "";
     if (indices != null && indices.length > 0) {
       str += indices[0];
@@ -239,10 +239,10 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
     return str;
   }
 
-  protected static void doOp(Byte opCode, int[] indices, Integer flagsI, Integer expectedResult) throws InterruptedException {
-    OperationCode op = OperationCode.fromOrdinal(opCode.byteValue());
+  protected static void doOp(final byte opCode, final int[] indices, final int flagsI, final int expectedResult) throws InterruptedException {
+    OperationCode op = OperationCode.fromOrdinal(opCode);
     boolean operationOmitted = false;
-    final int flags = flagsI.intValue();
+    final int flags = flagsI;
     Region region = getRegion();
 
     if ((flags & OpFlags.USE_SUBREGION) > 0) {
@@ -252,22 +252,14 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
       if ((flags & OpFlags.NO_CREATE_SUBREGION) > 0) {
         if ((flags & OpFlags.CHECK_NOREGION) > 0) {
           // Wait for some time for DRF update to come
-          waitForCondition(new Callable() {
-            public Object call() throws Exception {
-              return Boolean.valueOf(getSubregion() == null);
-            }
-          });
+          waitForCondition(() -> getSubregion() == null);
           subregion = getSubregion();
           assertNull(subregion);
           return;
 
         } else {
           // Wait for some time for DRF update to come
-          waitForCondition(new Callable() {
-            public Object call() throws Exception {
-              return Boolean.valueOf(getSubregion() != null);
-            }
-          });
+          waitForCondition(() -> getSubregion() != null);
           subregion = getSubregion();
           assertNotNull(subregion);
         }
@@ -281,11 +273,7 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
 
     } else if ((flags & OpFlags.CHECK_NOREGION) > 0) {
       // Wait for some time for region destroy update to come
-      waitForCondition(new Callable() {
-        public Object call() throws Exception {
-          return Boolean.valueOf(getRegion() == null);
-        }
-      });
+      waitForCondition(() -> getRegion() == null);
       region = getRegion();
       assertNull(region);
       return;
@@ -371,27 +359,28 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
           }
 
           if ((flags & OpFlags.LOCAL_OP) > 0) {
-            Callable cond = new Callable() {
+            Callable<Boolean> condition = new Callable<Boolean>() {
               private Region region;
 
               @Override
-              public Object call() throws Exception {
+              public Boolean call() throws Exception {
                 Object value = getLocalValue(region, key);
-                return Boolean.valueOf((flags & OpFlags.CHECK_FAIL) > 0 ? !expectedVal.equals(value) : expectedVal.equals(value));
+                return (flags & OpFlags.CHECK_FAIL) > 0 ? !expectedVal.equals(value) : expectedVal.equals(value);
               }
 
-              public Callable init(Region region) {
+              public Callable<Boolean> init(Region region) {
                 this.region = region;
                 return this;
               }
             }.init(region);
+            waitForCondition(condition);
 
-            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);
@@ -660,8 +649,8 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
           // Create region on server using the DynamicRegionFactory
           // Assume it has been already initialized
           DynamicRegionFactory drf = DynamicRegionFactory.get();
-          Region subregion = drf.createDynamicRegion(regionName, subregionName);
-          assertEquals('/' + regionName + '/' + subregionName, subregion.getFullPath());
+          Region subregion = drf.createDynamicRegion(regionName, SUBREGION_NAME);
+          assertEquals('/' + regionName + '/' + SUBREGION_NAME, subregion.getFullPath());
 
         } else if (op.isRegionDestroy()) {
           breakLoop = true;
@@ -686,7 +675,7 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
           fail("doOp: Unhandled operation " + op);
         }
 
-        if (expectedResult.intValue() != NO_EXCEPTION) {
+        if (expectedResult != NO_EXCEPTION) {
           if (!operationOmitted && !op.isUnregisterInterest()) {
             fail("Expected an exception while performing operation op =" + op + "flags = " + OpFlags.description(flags));
           }
@@ -695,10 +684,10 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
       } catch (Exception ex) {
         exceptionOccured = true;
         if ((ex instanceof ServerConnectivityException || ex instanceof QueryInvocationTargetException || ex instanceof CqException)
-            && (expectedResult.intValue() == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
+            && (expectedResult == 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() == OTHER_EXCEPTION) {
+        } else if (expectedResult == OTHER_EXCEPTION) {
           System.out.println("doOp: Got expected exception when doing operation: " + ex.toString());
           continue;
         } else {
@@ -706,15 +695,15 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
         }
       }
     }
-    if (!exceptionOccured && !operationOmitted && expectedResult.intValue() != NO_EXCEPTION) {
+    if (!exceptionOccured && !operationOmitted && expectedResult != 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) throws InterruptedException {
-    for (Iterator opIter = opBlock.iterator(); opIter.hasNext();) {
+  protected void executeOpBlock(final List<OperationWithAction> opBlock, final int port1, final int port2, final String authInit, final Properties extraAuthProps, final Properties extraAuthzProps, final TestCredentialGenerator credentialGenerator, final Random random) throws InterruptedException {
+    for (Iterator<OperationWithAction> opIter = opBlock.iterator(); opIter.hasNext();) {
       // Start client with valid credentials as specified in OperationWithAction
-      OperationWithAction currentOp = (OperationWithAction)opIter.next();
+      OperationWithAction currentOp = opIter.next();
       OperationCode opCode = currentOp.getOperationCode();
       int opFlags = currentOp.getFlags();
       int clientNum = currentOp.getClientNum();
@@ -739,23 +728,23 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
       System.out.println("executeOpBlock: performing operation number [" + currentOp.getOpNum() + "]: " + currentOp);
       if ((opFlags & OpFlags.USE_OLDCONN) == 0) {
         Properties opCredentials;
-        int newRnd = rnd.nextInt(100) + 1;
+        int newRnd = random.nextInt(100) + 1;
         String currentRegionName = '/' + regionName;
         if ((opFlags & OpFlags.USE_SUBREGION) > 0) {
-          currentRegionName += ('/' + subregionName);
+          currentRegionName += ('/' + SUBREGION_NAME);
         }
 
         String credentialsTypeStr;
         OperationCode authOpCode = currentOp.getAuthzOperationCode();
         int[] indices = currentOp.getIndices();
-        CredentialGenerator cGen = gen.getCredentialGenerator();
+        CredentialGenerator cGen = credentialGenerator.getCredentialGenerator();
         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);
+          opCredentials = credentialGenerator.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);
+          opCredentials = credentialGenerator.getAllowedCredentials(new OperationCode[] { opCode, authOpCode }, new String[] { currentRegionName }, indices, newRnd);
           credentialsTypeStr = " authorized " + authOpCode;
         }
 
@@ -782,7 +771,7 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
 
       // Perform the operation from selected client
       if (useThisVM) {
-        doOp(new Byte(opCode.toOrdinal()), currentOp.getIndices(), new Integer(opFlags), new Integer(expectedResult));
+        doOp(opCode.toOrdinal(), currentOp.getIndices(), new Integer(opFlags), new Integer(expectedResult));
       } else {
         byte ordinal = opCode.toOrdinal();
         int[] indices = currentOp.getIndices();
@@ -799,8 +788,8 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
     return authzGen;
   }
 
-  protected List getDummyGeneratorCombos() {
-    List generators = new ArrayList();
+  protected List<AuthzCredentialGenerator> getDummyGeneratorCombos() {
+    List<AuthzCredentialGenerator> generators = new ArrayList<>();
     Iterator authzCodeIter = AuthzCredentialGenerator.ClassCode.getAll().iterator();
 
     while (authzCodeIter.hasNext()) {
@@ -820,7 +809,7 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
     return generators;
   }
 
-  protected void runOpsWithFailover(OperationWithAction[] opCodes, String testName) throws InterruptedException {
+  protected void runOpsWithFailOver(final OperationWithAction[] opCodes, final String testName) throws InterruptedException {
     AuthzCredentialGenerator gen = getXmlAuthzGenerator();
     CredentialGenerator cGen = gen.getCredentialGenerator();
     Properties extraAuthProps = cGen.getSystemProperties();
@@ -861,16 +850,21 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
         if (opBlock.size() > 0) {
           locator1PortKeeper.release();
           port1Keeper.release();
+
           // Start the first server and execute the operation block
           server1.invoke(() -> ClientAuthorizationTestCase.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(() -> ClientAuthorizationTestCase.createCacheServer(locator2Port, port2, serverProps, javaProps ));
             server1.invoke(() -> closeCache());
+
             executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
           }
           opBlock.clear();
@@ -892,7 +886,7 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
    */
   private static class AuthzCqListener implements CqListener {
 
-    private List eventList;
+    private List<CqEvent> eventList;
     private int numCreates;
     private int numUpdates;
     private int numDestroys;
@@ -900,7 +894,7 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
     private int numErrors;
 
     public AuthzCqListener() {
-      this.eventList = new ArrayList();
+      this.eventList = new ArrayList<>();
       reset();
     }
 
@@ -911,7 +905,7 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
       this.numErrors = 0;
     }
 
-    public void onEvent(CqEvent aCqEvent) {
+    public void onEvent(final CqEvent aCqEvent) {
       Operation op = aCqEvent.getBaseOperation();
       if (op.isCreate()) {
         ++this.numCreates;
@@ -925,7 +919,7 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
       eventList.add(aCqEvent);
     }
 
-    public void onError(CqEvent aCqEvent) {
+    public void onError(final CqEvent aCqEvent) {
       ++this.numErrors;
     }
 
@@ -953,13 +947,12 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
       return this.numErrors;
     }
 
-    public void checkPuts(String[] vals, int[] indices) {
+    public void checkPuts(final String[] vals, final int[] indices) {
       for (int indexIndex = 0; indexIndex < indices.length; ++indexIndex) {
         int index = indices[indexIndex];
-        Iterator eventIter = this.eventList.iterator();
         boolean foundKey = false;
 
-        while (eventIter.hasNext()) {
+        for (Iterator<CqEvent> eventIter = this.eventList.iterator(); eventIter.hasNext();) {
           CqEvent event = (CqEvent)eventIter.next();
           if (KEYS[index].equals(event.getKey())) {
             assertEquals(vals[index], event.getNewValue());
@@ -1155,8 +1148,7 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
     private int clientNum;
 
     /**
-     * Bitwise or'd {@link OpFlags} integer to change/specify the behaviour of
-     * the operations.
+     * Bitwise or'd {@link OpFlags} integer to change/specify the behaviour of the operations.
      */
     private int flags;
 
@@ -1171,14 +1163,12 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
     private int opNum;
 
     /**
-     * Indicates end of an operation block which can be used for testing with
-     * failover
+     * Indicates end of an operation block which can be used for testing with failover
      */
     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
+     * 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);
 
@@ -1189,7 +1179,7 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
       }
     }
 
-    public OperationWithAction(OperationCode opCode) {
+    public OperationWithAction(final OperationCode opCode) {
       this.opCode = opCode;
       this.authzOpCode = opCode;
       this.clientNum = 1;
@@ -1198,7 +1188,7 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
       this.opNum = 0;
     }
 
-    public OperationWithAction(OperationCode opCode, int clientNum) {
+    public OperationWithAction(final OperationCode opCode, final int clientNum) {
       this.opCode = opCode;
       this.authzOpCode = opCode;
       this.clientNum = clientNum;
@@ -1207,7 +1197,7 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
       this.opNum = 0;
     }
 
-    public OperationWithAction(OperationCode opCode, int clientNum, int flags, int numOps) {
+    public OperationWithAction(final OperationCode opCode, final int clientNum, final int flags, final int numOps) {
       this.opCode = opCode;
       this.authzOpCode = opCode;
       this.clientNum = clientNum;
@@ -1216,7 +1206,7 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
       this.opNum = 0;
     }
 
-    public OperationWithAction(OperationCode opCode, OperationCode deniedOpCode, int clientNum, int flags, int numOps) {
+    public OperationWithAction(final OperationCode opCode, final OperationCode deniedOpCode, final int clientNum, final int flags, final int numOps) {
       this.opCode = opCode;
       this.authzOpCode = deniedOpCode;
       this.clientNum = clientNum;
@@ -1225,7 +1215,7 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
       this.opNum = 0;
     }
 
-    public OperationWithAction(OperationCode opCode, int clientNum, int flags, int[] indices) {
+    public OperationWithAction(final OperationCode opCode, final int clientNum, final int flags, final int[] indices) {
       this.opCode = opCode;
       this.authzOpCode = opCode;
       this.clientNum = clientNum;
@@ -1234,7 +1224,7 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
       this.opNum = 0;
     }
 
-    public OperationWithAction(OperationCode opCode, OperationCode deniedOpCode, int clientNum, int flags, int[] indices) {
+    public OperationWithAction(final OperationCode opCode, final OperationCode deniedOpCode, final int clientNum, final int flags, final int[] indices) {
       this.opCode = opCode;
       this.authzOpCode = deniedOpCode;
       this.clientNum = clientNum;
@@ -1314,15 +1304,15 @@ public class ClientAuthorizationTestCase extends JUnit4DistributedTestCase {
 
     private AuthzCredentialGenerator authzGen;
 
-    public TestAuthzCredentialGenerator(AuthzCredentialGenerator authzGen) {
+    public TestAuthzCredentialGenerator(final AuthzCredentialGenerator authzGen) {
       this.authzGen = authzGen;
     }
 
-    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) {
       return this.authzGen.getAllowedCredentials(opCodes, regionNames, num);
     }
 
-    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) {
       return this.authzGen.getDisallowedCredentials(opCodes, regionNames, num);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e93932aa/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 0830104..441d52c 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
@@ -53,8 +53,8 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestCase {
    */
   @Test
   public void testOps1() throws Exception {
-    for (Iterator iter = getDummyGeneratorCombos().iterator(); iter.hasNext();) {
-      AuthzCredentialGenerator gen = (AuthzCredentialGenerator)iter.next();
+    for (Iterator<AuthzCredentialGenerator> iter = getDummyGeneratorCombos().iterator(); iter.hasNext();) {
+      AuthzCredentialGenerator gen = iter.next();
       CredentialGenerator cGen = gen.getCredentialGenerator();
       Properties extraAuthProps = cGen.getSystemProperties();
       Properties javaProps = cGen.getJavaProperties();
@@ -155,30 +155,30 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestCase {
     server2.invoke(() -> PRClientServerTestBase.registerFunction(function));
 
     // Perform some put operations before verifying queries
-    client1.invoke(() -> doMultiUserPuts(4, 2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
-    client1.invoke(() -> doMultiUserQueries(2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, 4));
-    client1.invoke(() -> doMultiUserQueryExecute(2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, 4));
+    client1.invoke(() -> doMultiUserPuts(4, 2, new int[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
+    client1.invoke(() -> doMultiUserQueries(2, new int[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, 4));
+    client1.invoke(() -> doMultiUserQueryExecute(2, new int[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, 4));
 
     // Verify that the FE succeeds/fails
-    client2.invoke(() ->doMultiUserFE(2, function, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, new Object[] {null, null}, false));
+    client2.invoke(() ->doMultiUserFE(2, function, new int[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, false));
 
     // Failover
     server1.invoke(() -> closeCache());
     Thread.sleep(2000);
 
-    client1.invoke(() -> doMultiUserPuts(4, 2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
+    client1.invoke(() -> doMultiUserPuts(4, 2, new int[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
 
-    client1.invoke(() -> doMultiUserQueries(2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, 4));
-    client1.invoke(() -> doMultiUserQueryExecute(2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, 4));
+    client1.invoke(() -> doMultiUserQueries(2, new int[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, 4));
+    client1.invoke(() -> doMultiUserQueryExecute(2, new int[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, 4));
 
     // Verify that the FE succeeds/fails
-    client2.invoke(() -> doMultiUserFE(2, function, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, new Object[] {null, null}, true));
+    client2.invoke(() -> doMultiUserFE(2, function, new int[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, true));
   }
 
   @Test
   public void testOpsWithClientsInDifferentModes() throws Exception {
-    for (Iterator iter = getDummyGeneratorCombos().iterator(); iter.hasNext();) {
-      AuthzCredentialGenerator gen = (AuthzCredentialGenerator)iter.next();
+    for (Iterator<AuthzCredentialGenerator> iter = getDummyGeneratorCombos().iterator(); iter.hasNext();) {
+      AuthzCredentialGenerator gen = iter.next();
       CredentialGenerator cGen = gen.getCredentialGenerator();
       Properties extraAuthProps = cGen.getSystemProperties();
       Properties javaProps = cGen.getJavaProperties();
@@ -270,15 +270,15 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestCase {
 
   private void verifyPutsGets(final boolean isMultiuser, final boolean opAllowed) throws Exception {
     // Perform some put operations from client1
-    client1.invoke(() -> doMultiUserPuts(2, 2, new Integer[] { NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
+    client1.invoke(() -> doMultiUserPuts(2, 2, new int[] { NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
 
     // Verify that the gets succeed/fail
     if (isMultiuser) {
-      client2.invoke(() -> doMultiUserGets(2, 2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
+      client2.invoke(() -> doMultiUserGets(2, 2, new int[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
 
     } else {
       int expectedResult = (opAllowed) ? NO_EXCEPTION : NOTAUTHZ_EXCEPTION;
-      client2.invoke(() -> doMultiUserGets(1, 1, new Integer[] {expectedResult}));
+      client2.invoke(() -> doMultiUserGets(1, 1, new int[] {expectedResult}));
     }
   }
 
@@ -286,18 +286,18 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestCase {
     verifyContainsKeyDestroys(true, false /* unused */);
   }
 
-  private void verifyContainsKeyDestroys(final boolean isMultiuser, final boolean opAllowed) throws Exception {
+  private void verifyContainsKeyDestroys(final boolean isMultiUser, final boolean opAllowed) throws Exception {
     // Do puts before verifying containsKey
-    client1.invoke(() -> doMultiUserPuts(2, 2, new Integer[] {NO_EXCEPTION, NO_EXCEPTION}));
-    client1.invoke(() -> doMultiUserContainsKeys(1, 2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, new Boolean[] {true, false}));
+    client1.invoke(() -> doMultiUserPuts(2, 2, new int[] {NO_EXCEPTION, NO_EXCEPTION}));
+    client1.invoke(() -> doMultiUserContainsKeys(1, 2, new int[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, new boolean[] {true, false}));
 
     // Verify that the destroys succeed/fail
-    if (isMultiuser) {
-      client2.invoke(() -> doMultiUserDestroys(2, 2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
+    if (isMultiUser) {
+      client2.invoke(() -> doMultiUserDestroys(2, 2, new int[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
 
     } else {
       int expectedResult = (opAllowed) ? NO_EXCEPTION : NOTAUTHZ_EXCEPTION;
-      client2.invoke(() -> doMultiUserDestroys(1, 1, new Integer[] {expectedResult}));
+      client2.invoke(() -> doMultiUserDestroys(1, 1, new int[] {expectedResult}));
     }
   }
 
@@ -305,32 +305,32 @@ public class ClientMultiUserAuthzDUnitTest extends ClientAuthorizationTestCase {
     verifyContainsKeyInvalidates(true, false /* unused */);
   }
 
-  private void verifyContainsKeyInvalidates(final boolean isMultiuser, final boolean opAllowed) throws Exception {
+  private void verifyContainsKeyInvalidates(final boolean isMultiUser, final boolean opAllowed) throws Exception {
     // Do puts before verifying containsKey
-    client1.invoke(() -> doMultiUserPuts(2, 2, new Integer[] {NO_EXCEPTION, NO_EXCEPTION}));
-    client1.invoke(() -> doMultiUserContainsKeys(1, 2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, new Boolean[] {true, false}));
+    client1.invoke(() -> doMultiUserPuts(2, 2, new int[] {NO_EXCEPTION, NO_EXCEPTION}));
+    client1.invoke(() -> doMultiUserContainsKeys(1, 2, new int[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, new boolean[] {true, false}));
 
     // Verify that the invalidates succeed/fail
-    if (isMultiuser) {
-      client2.invoke(() -> doMultiUserInvalidates(2, 2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
+    if (isMultiUser) {
+      client2.invoke(() -> doMultiUserInvalidates(2, 2, new int[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
 
     } else {
       int expectedResult = (opAllowed) ? NO_EXCEPTION : NOTAUTHZ_EXCEPTION;
-      client2.invoke(() -> doMultiUserInvalidates(1, 1, new Integer[] {expectedResult}));
+      client2.invoke(() -> doMultiUserInvalidates(1, 1, new int[] {expectedResult}));
     }
   }
 
   private void verifyGetAllInTX() {
     server1.invoke(() -> doPuts());
-    client1.invoke(() -> doMultiUserGetAll(2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, true/*use TX*/));
+    client1.invoke(() -> doMultiUserGetAll(2, new int[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}, true/*use TX*/));
   }
 
   private void verifyGetAllRegionDestroys() {
     server1.invoke(() -> doPuts());
-    client1.invoke(() -> doMultiUserGetAll(2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
+    client1.invoke(() -> doMultiUserGetAll(2, new int[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
 
     // Verify that the region destroys succeed/fail
-    client2.invoke(() -> doMultiUserRegionDestroys(2, new Integer[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
+    client2.invoke(() -> doMultiUserRegionDestroys(2, new int[] {NO_EXCEPTION, NOTAUTHZ_EXCEPTION}));
   }
 
   private void doPuts() {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e93932aa/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 56d712f..222ea00 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
@@ -123,10 +123,10 @@ public class DeltaClientPostAuthorizationDUnitTest extends ClientAuthorizationTe
   }
 
   @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();) {
+  protected final void executeOpBlock(final List<OperationWithAction> opBlock, final int port1, final int port2, final String authInit, final Properties extraAuthProps, final Properties extraAuthzProps, final TestCredentialGenerator credentialGenerator, final Random random) throws InterruptedException {
+    for (Iterator<OperationWithAction> opIter = opBlock.iterator(); opIter.hasNext();) {
       // Start client with valid credentials as specified in OperationWithAction
-      OperationWithAction currentOp = (OperationWithAction)opIter.next();
+      OperationWithAction currentOp = opIter.next();
       OperationCode opCode = currentOp.getOperationCode();
       int opFlags = currentOp.getFlags();
       int clientNum = currentOp.getClientNum();
@@ -152,24 +152,24 @@ public class DeltaClientPostAuthorizationDUnitTest extends ClientAuthorizationTe
 
       if ((opFlags & OpFlags.USE_OLDCONN) == 0) {
         Properties opCredentials;
-        int newRnd = rnd.nextInt(100) + 1;
+        int newRnd = random.nextInt(100) + 1;
         String currentRegionName = '/' + regionName;
         if ((opFlags & OpFlags.USE_SUBREGION) > 0) {
-          currentRegionName += ('/' + subregionName);
+          currentRegionName += ('/' + SUBREGION_NAME);
         }
 
         String credentialsTypeStr;
         OperationCode authOpCode = currentOp.getAuthzOperationCode();
         int[] indices = currentOp.getIndices();
-        CredentialGenerator cGen = gen.getCredentialGenerator();
+        CredentialGenerator cGen = credentialGenerator.getCredentialGenerator();
         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);
+          opCredentials = credentialGenerator.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);
+          opCredentials = credentialGenerator.getAllowedCredentials(new OperationCode[] {opCode, authOpCode }, new String[] { currentRegionName }, indices, newRnd);
           credentialsTypeStr = " authorized " + authOpCode;
         }
 


[6/7] incubator-geode git commit: Cleanup

Posted by kl...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e93932aa/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java b/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
index ce53b02..663a17d 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/security/SecurityTestUtils.java
@@ -42,6 +42,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
+import java.util.concurrent.Callable;
 import javax.net.ServerSocketFactory;
 import javax.net.SocketFactory;
 import javax.net.ssl.KeyManager;
@@ -78,7 +79,6 @@ import com.gemstone.gemfire.cache.query.SelectResults;
 import com.gemstone.gemfire.cache.server.CacheServer;
 import com.gemstone.gemfire.distributed.DistributedSystem;
 import com.gemstone.gemfire.distributed.Locator;
-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;
@@ -165,7 +165,7 @@ public final class SecurityTestUtils {
     DynamicRegionFactory.get().open(new DynamicRegionFactory.Config(null, null, false, true));
   }
 
-  protected static Integer getLocatorPort() {
+  protected static int getLocatorPort() {
     int locatorPort = getRandomAvailablePort(SOCKET);
     String addr = getIPLiteral();
     if (locatorString == null) {
@@ -200,8 +200,8 @@ public final class SecurityTestUtils {
     SecurityTestUtils.ignoredExceptions = expectedExceptions;
   }
 
-  protected static int createCacheServer(final Properties authProps, final Properties javaProps, final int dsPort, final String locatorString, final int serverPort, final int expectedResult) {
-    return createCacheServer(authProps, javaProps, dsPort, locatorString, serverPort, false, expectedResult);
+  protected static int createCacheServer(final Properties authProps, final Properties javaProps, final int locatorPort, final String locatorString, final int serverPort, final int expectedResult) {
+    return createCacheServer(authProps, javaProps, locatorPort, locatorString, serverPort, false, expectedResult);
   }
 
   protected static int createCacheServer(Properties authProps, final Properties javaProps, final int locatorPort, final String locatorString, final int serverPort, final boolean setupDynamicRegionFactory, final int expectedResult) {
@@ -216,6 +216,7 @@ public final class SecurityTestUtils {
       authProps.setProperty("locators", "localhost["+getDUnitLocatorPort()+"]");
     }
     authProps.setProperty(SECURITY_LOG_LEVEL_NAME, "finest");
+
     getLogWriter().info("Set the server properties to: " + authProps);
     getLogWriter().info("Set the java properties to: " + javaProps);
 
@@ -225,54 +226,53 @@ public final class SecurityTestUtils {
       if (expectedResult != NO_EXCEPTION) {
         fail("Expected a security exception when starting peer");
       }
-    }
-    catch (AuthenticationRequiredException ex) {
+
+    } catch (AuthenticationRequiredException ex) {
       if (expectedResult == AUTHREQ_EXCEPTION) {
         getLogWriter().info("Got expected exception when starting peer: " + ex);
         return 0;
-      }
-      else {
+      } else {
         fail("Got unexpected exception when starting peer", ex);
       }
-    }
-    catch (AuthenticationFailedException ex) {
+
+    } catch (AuthenticationFailedException ex) {
       if (expectedResult == AUTHFAIL_EXCEPTION) {
         getLogWriter().info("Got expected exception when starting peer: " + ex);
         return 0;
-      }
-      else {
+      } else {
         fail("Got unexpected exception when starting peer", ex);
       }
-    }
-    catch (Exception ex) {
+
+    } catch (Exception ex) {
       fail("Got unexpected exception when starting peer", ex);
     }
 
     if (setupDynamicRegionFactory) {
       initDynamicRegionFactory();
     }
+
     tmpInstance.openCache();
+
     AttributesFactory factory = new AttributesFactory();
     factory.setScope(Scope.DISTRIBUTED_ACK);
     factory.setDataPolicy(DataPolicy.REPLICATE);
+
     RegionAttributes attrs = factory.create();
+
     cache.createRegion(REGION_NAME, attrs);
-    int port;
-    if (serverPort <= 0) {
-      port = 0;
-    }
-    else {
-      port = serverPort;
-    }
+
+    int port = serverPort <= 0 ? 0 : serverPort;
+
     CacheServer server1 = cache.addCacheServer();
+
     server1.setPort(port);
     server1.setNotifyBySubscription(true);
     try {
       server1.start();
-    }
-    catch (Exception ex) {
+    } catch (Exception ex) {
       fail("Got unexpected exception when starting CacheServer", ex);
     }
+
     return server1.getPort();
   }
 
@@ -292,23 +292,14 @@ public final class SecurityTestUtils {
   }
 
   // 4
-  protected static void createCacheClient(final String authInitModule,
-                                          final Properties authProps, final Properties javaProps, final int[] ports,
-                                          final int numConnections, final boolean setupDynamicRegionFactory,
-                                          final boolean multiUserMode, final int expectedResult) {
-    createCacheClient(authInitModule, authProps, javaProps, ports,
-        numConnections, setupDynamicRegionFactory, multiUserMode, Boolean.TRUE,
-        expectedResult);
+  protected static void createCacheClient(final String authInitModule, final Properties authProps, final Properties javaProps, final int[] ports, final int numConnections, final boolean setupDynamicRegionFactory, final boolean multiUserMode, final int expectedResult) {
+    createCacheClient(authInitModule, authProps, javaProps, ports, numConnections, setupDynamicRegionFactory, multiUserMode, true, expectedResult);
   }
 
   // 5
-  protected static void createCacheClient(final String authInitModule,
-                                          Properties authProps, final Properties javaProps, int[] ports,
-                                          final int numConnections, final boolean setupDynamicRegionFactory,
-                                          final boolean multiUserMode, final boolean subscriptionEnabled,
-                                          final int expectedResult) {
+  protected static void createCacheClient(final String authInitModule, Properties authProps, final Properties javaProps, int[] ports, final int numConnections, final boolean setupDynamicRegionFactory, final boolean multiUserMode, final boolean subscriptionEnabled, final int expectedResult) {
+    multiUserAuthMode = multiUserMode;
 
-    multiUserAuthMode = Boolean.valueOf(multiUserMode);
     if (authProps == null) {
       authProps = new Properties();
     }
@@ -317,13 +308,14 @@ public final class SecurityTestUtils {
     authProps.setProperty(SECURITY_LOG_LEVEL_NAME, "finest");
     // TODO (ashetkar) Add " && (!multiUserAuthMode)" below.
     if (authInitModule != null) {
-      authProps.setProperty(SECURITY_CLIENT_AUTH_INIT_NAME,
-          authInitModule);
+      authProps.setProperty(SECURITY_CLIENT_AUTH_INIT_NAME, authInitModule);
     }
 
     SecurityTestUtils tmpInstance = new SecurityTestUtils("temp");
     tmpInstance.createSystem(authProps, javaProps);
+
     AttributesFactory factory = new AttributesFactory();
+
     int[] portsI = new int[ports.length];
     for(int z=0;z<ports.length;z++) {
       portsI[z] = ports[z];
@@ -332,21 +324,20 @@ public final class SecurityTestUtils {
     try {
       PoolFactory poolFactory = PoolManager.createFactory();
       poolFactory.setRetryAttempts(200);
+
       if (multiUserAuthMode) {
         poolFactory.setMultiuserAuthentication(multiUserAuthMode);
-        // [sumedh] Why is this false here only to be overridden in
-        // ClientServerTestCase.configureConnectionPoolWithNameAndFactory below?
-        // Actually setting it to false causes MultiuserAPIDUnitTest to fail.
+        // [sumedh] Why is this false here only to be overridden in ClientServerTestCase.configureConnectionPoolWithNameAndFactory below?
+        // Actually setting it to false causes MultiUserAPIDUnitTest to fail.
         //poolFactory.setSubscriptionEnabled(false);
       }
-      pool = configureConnectionPoolWithNameAndFactory(factory,
-          getIPLiteral(), portsI, subscriptionEnabled, 0,
-          numConnections, null, null,
-          poolFactory);
+
+      pool = configureConnectionPoolWithNameAndFactory(factory, getIPLiteral(), portsI, subscriptionEnabled, 0, numConnections, null, null, poolFactory);
 
       if (setupDynamicRegionFactory) {
         initClientDynamicRegionFactory(pool.getName());
       }
+
       tmpInstance.openCache();
       try {
         getLogWriter().info("multi-user mode " + multiUserAuthMode);
@@ -354,11 +345,11 @@ public final class SecurityTestUtils {
         if (!multiUserAuthMode) {
           fail("Expected a UnsupportedOperationException but got none in single-user mode");
         }
+
       } catch (UnsupportedOperationException uoe) {
         if (!multiUserAuthMode) {
           getLogWriter().info("Got expected UnsupportedOperationException in single-user mode");
-        }
-        else {
+        } else {
           fail("Got unexpected exception in multi-user mode ", uoe);
         }
       }
@@ -367,96 +358,82 @@ public final class SecurityTestUtils {
       if (multiUserAuthMode) {
         factory.setDataPolicy(DataPolicy.EMPTY);
       }
+
       RegionAttributes attrs = factory.create();
+
       cache.createRegion(REGION_NAME, attrs);
 
-      if (expectedResult != NO_EXCEPTION
-          && expectedResult != 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 == AUTHREQ_EXCEPTION
-          || expectedResult == NOFORCE_AUTHREQ_EXCEPTION) {
-        getLogWriter().info(
-            "Got expected exception when starting client: " + ex);
-      }
-      else {
+
+    } catch (AuthenticationRequiredException ex) {
+      if (expectedResult == AUTHREQ_EXCEPTION || expectedResult == NOFORCE_AUTHREQ_EXCEPTION) {
+        getLogWriter().info( "Got expected exception when starting client: " + ex);
+      } else {
         fail("Got unexpected exception when starting client", ex);
       }
-    }
-    catch (AuthenticationFailedException ex) {
+
+    } catch (AuthenticationFailedException ex) {
       if (expectedResult == AUTHFAIL_EXCEPTION) {
-        getLogWriter().info(
-            "Got expected exception when starting client: " + ex);
-      }
-      else {
+        getLogWriter().info("Got expected exception when starting client: " + ex);
+      } else {
         fail("Got unexpected exception when starting client", ex);
       }
-    }
-    catch (ServerRefusedConnectionException ex) {
+
+    } catch (ServerRefusedConnectionException ex) {
       if (expectedResult == CONNREFUSED_EXCEPTION) {
-        getLogWriter().info(
-            "Got expected exception when starting client: " + ex);
-      }
-      else {
+        getLogWriter().info("Got expected exception when starting client: " + ex);
+      } else {
         fail("Got unexpected exception when starting client", ex);
       }
-    }
-    catch (Exception ex) {
+
+    } catch (Exception ex) {
       fail("Got unexpected exception when starting client", ex);
     }
   }
 
-  protected static void createCacheClientForMultiUserMode(final int numOfUsers,
-                                                          final String authInitModule, final Properties[] authProps, final Properties javaProps,
-                                                          final int[] ports, final int numConnections,
-                                                          final boolean setupDynamicRegionFactory, final int expectedResult) {
-    createCacheClientForMultiUserMode(numOfUsers, authInitModule, authProps,
-        javaProps, ports, numConnections, setupDynamicRegionFactory, null,
-        expectedResult);
+  protected static void createCacheClientForMultiUserMode(final int numOfUsers, final String authInitModule, final Properties[] authProps, final Properties javaProps, final int[] ports, final int numConnections, final boolean setupDynamicRegionFactory, final int expectedResult) {
+    createCacheClientForMultiUserMode(numOfUsers, authInitModule, authProps, javaProps, ports, numConnections, setupDynamicRegionFactory, null, expectedResult);
   }
 
-  protected static void createCacheClientForMultiUserMode(final int numOfUsers,
-                                                          final String authInitModule, final Properties[] authProps, final Properties javaProps,
-                                                          final int[] ports, final int numConnections,
-                                                          final boolean setupDynamicRegionFactory, final String durableClientId,
-                                                          final int expectedResult) {
-
+  protected static void createCacheClientForMultiUserMode(final int numOfUsers, final String authInitModule, final Properties[] authProps, final Properties javaProps, final int[] ports, final int numConnections, final boolean setupDynamicRegionFactory, final String durableClientId, final int expectedResult) {
     if (numOfUsers < 1) {
       fail("Number of users cannot be less than one");
     }
+
     multiUserAuthMode = true;
+
     if (numOfUsers != authProps.length) {
-      fail("Number of authProps provided does not match with numOfUsers specified, "
-          + authProps.length);
+      fail("Number of authProps provided does not match with numOfUsers specified, " + authProps.length);
     }
+
     if (authProps[0] == null) {
       authProps[0] = new Properties();
     }
     authProps[0].setProperty(MCAST_PORT_NAME, "0");
     authProps[0].setProperty(LOCATORS_NAME, "");
-    authProps[0].setProperty(SECURITY_LOG_LEVEL_NAME,
-        "finest");
+    authProps[0].setProperty(SECURITY_LOG_LEVEL_NAME, "finest");
+
     Properties props = new Properties();
+
     if (authInitModule != null) {
-      authProps[0].setProperty(
-          SECURITY_CLIENT_AUTH_INIT_NAME, authInitModule);
-      props.setProperty(SECURITY_CLIENT_AUTH_INIT_NAME,
-          authInitModule);
+      authProps[0].setProperty(SECURITY_CLIENT_AUTH_INIT_NAME, authInitModule);
+      props.setProperty(SECURITY_CLIENT_AUTH_INIT_NAME, authInitModule);
     }
+
     if (durableClientId != null) {
-      props.setProperty(DURABLE_CLIENT_ID_NAME,
-          durableClientId);
-      props.setProperty(DURABLE_CLIENT_TIMEOUT_NAME, String
-          .valueOf(DEFAULT_DURABLE_CLIENT_TIMEOUT));
+      props.setProperty(DURABLE_CLIENT_ID_NAME, durableClientId);
+      props.setProperty(DURABLE_CLIENT_TIMEOUT_NAME, String.valueOf(DEFAULT_DURABLE_CLIENT_TIMEOUT));
     }
 
     SecurityTestUtils tmpInstance = new SecurityTestUtils("temp");
     tmpInstance.createSystem(props, javaProps);
+
     AttributesFactory factory = new AttributesFactory();
+
     int[] portsI = new int[ports.length];
     for(int z=0;z<ports.length;z++) {
       portsI[z] = ports[z];
@@ -464,18 +441,18 @@ public final class SecurityTestUtils {
    
     try {
       tmpInstance.openCache();
+
       PoolFactory poolFactory = PoolManager.createFactory();
       poolFactory.setRetryAttempts(200);
       poolFactory.setMultiuserAuthentication(multiUserAuthMode);
       poolFactory.setSubscriptionEnabled(true);
-      pool = configureConnectionPoolWithNameAndFactory(factory,
-          getIPLiteral(), portsI, true, 1,
-          numConnections, null, null,
-          poolFactory);
+
+      pool = configureConnectionPoolWithNameAndFactory(factory, getIPLiteral(), portsI, true, 1, numConnections, null, null, poolFactory);
 
       if (setupDynamicRegionFactory) {
         initClientDynamicRegionFactory(pool.getName());
       }
+
       proxyCaches = new ProxyCache[numOfUsers];
       for (int i=0; i<numOfUsers; i++) {
         proxyCaches[i] = (ProxyCache)((PoolImpl) pool).createAuthenticatedCacheView(authProps[i]);
@@ -484,44 +461,37 @@ public final class SecurityTestUtils {
       factory.setScope(Scope.LOCAL);
       factory.setDataPolicy(DataPolicy.EMPTY);
       RegionAttributes attrs = factory.create();
+
       cache.createRegion(REGION_NAME, attrs);
 
-      if (expectedResult != NO_EXCEPTION
-          && expectedResult != 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 == AUTHREQ_EXCEPTION
-          || expectedResult == NOFORCE_AUTHREQ_EXCEPTION) {
-        getLogWriter().info(
-            "Got expected exception when starting client: " + ex);
-      }
-      else {
+
+    } catch (AuthenticationRequiredException ex) {
+      if (expectedResult == AUTHREQ_EXCEPTION || expectedResult == NOFORCE_AUTHREQ_EXCEPTION) {
+        getLogWriter().info("Got expected exception when starting client: " + ex);
+      } else {
         fail("Got unexpected exception when starting client", ex);
       }
-    }
-    catch (AuthenticationFailedException ex) {
+
+    } catch (AuthenticationFailedException ex) {
       if (expectedResult == AUTHFAIL_EXCEPTION) {
-        getLogWriter().info(
-            "Got expected exception when starting client: " + ex);
-      }
-      else {
+        getLogWriter().info("Got expected exception when starting client: " + ex);
+      } else {
         fail("Got unexpected exception when starting client", ex);
       }
-    }
-    catch (ServerRefusedConnectionException ex) {
+
+    } catch (ServerRefusedConnectionException ex) {
       if (expectedResult == CONNREFUSED_EXCEPTION) {
-        getLogWriter().info(
-            "Got expected exception when starting client: " + ex);
-      }
-      else {
+        getLogWriter().info("Got expected exception when starting client: " + ex);
+      } else {
         fail("Got unexpected exception when starting client", ex);
       }
-    }
-    catch (Exception ex) {
+
+    } catch (Exception ex) {
       fail("Got unexpected exception when starting client", ex);
     }
   }
@@ -529,45 +499,46 @@ public final class SecurityTestUtils {
   protected static void createProxyCache(final int[] userIndices, final Properties[] props) {
     int j = 0;
     for (int i : userIndices) {
-      proxyCaches[i] = (ProxyCache)((PoolImpl) pool)
-          .createAuthenticatedCacheView(props[j]);
+      proxyCaches[i] = (ProxyCache)((PoolImpl) pool).createAuthenticatedCacheView(props[j]);
       j++;
     }
   }
 
-  protected static void startLocator(final String name, Integer port, final Object extraProps,
-                                     final Object javaProps, final String[] expectedExceptions) {
-    File logFile = new File(name + "-locator" + port.intValue() + ".log");
+  protected static void startLocator(final String name, int port, final Properties extraProps, final Properties javaProps, final String[] expectedExceptions) {
     try {
       Properties authProps = new Properties();
+
       if (extraProps != null) {
-        authProps.putAll((Properties)extraProps);
+        authProps.putAll(extraProps);
       }
       authProps.setProperty(MCAST_PORT_NAME, "0");
-      authProps.setProperty(LOCATORS_NAME, 
-                            getIPLiteral() + "[" + port + "]");
+      authProps.setProperty(LOCATORS_NAME, getIPLiteral() + "[" + port + "]");
       authProps.setProperty(ENABLE_CLUSTER_CONFIGURATION_NAME, "false");
+
       clearStaticSSLContext();
-      setJavaProps((Properties)javaProps);
+
+      setJavaProps(javaProps);
+
+      File logFile = new File(name + "-locator" + port + ".log");
       FileOutputStream logOut = new FileOutputStream(logFile);
       PrintStream logStream = new PrintStream(logOut);
       addIgnoredExceptions(expectedExceptions);
       logStream.flush();
-      locator = Locator.startLocatorAndDS(port.intValue(), logFile, null,
-          authProps);
-    }
-    catch (IOException ex) {
-      fail("While starting locator on port " + port.intValue(), ex);
+
+      locator = Locator.startLocatorAndDS(port, logFile, null, authProps);
+
+    } catch (IOException ex) {
+      fail("While starting locator on port " + port, ex);
     }
   }
 
-  protected static void stopLocator(final Integer port, final String[] expectedExceptions) {
+  protected static void stopLocator(final int port, final String[] expectedExceptions) {
     try {
       locator.stop();
       removeExpectedExceptions(expectedExceptions);
-    }
-    catch (Exception ex) {
-      fail("While stopping locator on port " + port.intValue(), ex);
+
+    } catch (Exception ex) {
+      fail("While stopping locator on port " + port, ex);
     }
   }
 
@@ -575,24 +546,22 @@ public final class SecurityTestUtils {
     return cache;
   }
 
-  // Some useful region methods used by security tests
-
-  protected static void waitForCondition(final Callable cond) {
-    waitForCondition(cond, 100, 120);
+  protected static void waitForCondition(final Callable<Boolean> condition) {
+    waitForCondition(condition, 100, 120);
   }
 
-  protected static void waitForCondition(final Callable cond, final int sleepMillis,
-                                         final int numTries) {
+  protected static void waitForCondition(final Callable<Boolean> condition, final int sleepMillis, final int numTries) {
     WaitCriterion ev = new WaitCriterion() {
+      @Override
       public boolean done() {
         try {
-          return ((Boolean)cond.call()).booleanValue();
-        }
-        catch (Exception e) {
+          return condition.call();
+        } catch (Exception e) {
           fail("Unexpected exception", e);
         }
         return false; // NOTREACHED
       }
+      @Override
       public String description() {
         return null;
       }
@@ -611,197 +580,184 @@ public final class SecurityTestUtils {
     }
   }
 
-
   protected static void doPutAllP() throws Exception {
     Region region = getCache().getRegion(REGION_NAME);
     assertNotNull(region);
-    Map map = new LinkedHashMap();
+
+    Map<String, Employee> map = new LinkedHashMap<>();
     map.put("1010L", new Employee(1010L, "John", "Doe"));
+
     region.putAll(map);
   }
   
-  protected static void doPuts(final Integer num) {
-    doPutsP(num, new Integer(NO_EXCEPTION), false);
+  protected static void doPuts(final int num) {
+    doPutsP(num, NO_EXCEPTION, false);
   }
 
-  protected static void doPuts(final Integer num, final Integer expectedResult) {
+  protected static void doPuts(final int num, final int expectedResult) {
     doPutsP(num, expectedResult, false);
   }
 
-  protected static void doMultiUserPuts(final Integer num, final Integer numOfUsers,
-                                        final Integer[] expectedResults) {
+  protected static void doMultiUserPuts(final int num, final int numOfUsers, final int[] expectedResults) {
     if (numOfUsers != expectedResults.length) {
-      fail("SecurityTestUtils.doMultiUserPuts(): numOfUsers = " + numOfUsers
-          + ", but expected results " + expectedResults.length);
+      fail("SecurityTestUtils.doMultiUserPuts(): numOfUsers = " + numOfUsers + ", but expected results " + expectedResults.length);
     }
+
     for (int i = 0; i < numOfUsers; i++) {
       getLogWriter().info("PUT: MultiUser# " + i);
-      doPutsP(num, Integer.valueOf(i), expectedResults[i], false);
+      doPutsP(num, i, expectedResults[i], false);
     }
   }
 
-  protected static void doGets(final Integer num) {
-    doGetsP(num, new Integer(NO_EXCEPTION), false);
+  protected static void doGets(final int num) {
+    doGetsP(num, NO_EXCEPTION, false);
   }
 
-  protected static void doGets(final Integer num, final Integer expectedResult) {
+  protected static void doGets(final int num, final int expectedResult) {
     doGetsP(num, expectedResult, false);
   }
 
-  protected static void doMultiUserGetAll(final Integer numOfUsers, final Integer[] expectedResults) {
+  protected static void doMultiUserGetAll(final int numOfUsers, final int[] expectedResults) {
     doMultiUserGetAll(numOfUsers, expectedResults, false);
   }
 
-  protected static void doMultiUserGetAll(final Integer numOfUsers,
-                                          final Integer[] expectedResults, final boolean useTX) {
+  protected static void doMultiUserGetAll(final int numOfUsers, final int[] expectedResults, final boolean useTX) {
     if (numOfUsers != expectedResults.length) {
-      fail("SecurityTestUtils.doMultiUserGetAll(): numOfUsers = " + numOfUsers
-          + ", but expected results " + expectedResults.length);
+      fail("SecurityTestUtils.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);
+      getLogWriter().info("GET_ALL" + (useTX ? " in TX" : "") + ": MultiUser# " + i);
+      doGetAllP(i, expectedResults[i], useTX);
     }
   }
 
-  protected static void doMultiUserGets(final Integer num, final Integer numOfUsers,
-                                        final Integer[] expectedResults) {
+  protected static void doMultiUserGets(final int num, final int numOfUsers, final int[] expectedResults) {
     if (numOfUsers != expectedResults.length) {
-      fail("SecurityTestUtils.doMultiUserGets(): numOfUsers = " + numOfUsers
-          + ", but expected results " + expectedResults.length);
+      fail("SecurityTestUtils.doMultiUserGets(): numOfUsers = " + numOfUsers + ", but expected results " + expectedResults.length);
     }
+
     for (int i = 0; i < numOfUsers; i++) {
       getLogWriter().info("GET: MultiUser# " + i);
-      doGetsP(num, Integer.valueOf(i), expectedResults[i], false);
+      doGetsP(num, i, expectedResults[i], false);
     }
   }
 
-  protected static void doMultiUserRegionDestroys(final Integer numOfUsers,
-                                                  final Integer[] expectedResults) {
+  protected static void doMultiUserRegionDestroys(final int numOfUsers, final int[] expectedResults) {
     if (numOfUsers != expectedResults.length) {
-      fail("SecurityTestUtils.doMultiUserRegionDestroys(): numOfUsers = " + numOfUsers
-          + ", but expected results " + expectedResults.length);
+      fail("SecurityTestUtils.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]);
+      doRegionDestroysP(i, expectedResults[i]);
     }
   }
 
-  protected static void doMultiUserDestroys(final Integer num, final Integer numOfUsers,
-                                            final Integer[] expectedResults) {
+  protected static void doMultiUserDestroys(final int num, final int numOfUsers, final int[] expectedResults) {
     if (numOfUsers != expectedResults.length) {
-      fail("SecurityTestUtils.doMultiUserDestroys(): numOfUsers = " + numOfUsers
-          + ", but expected results " + expectedResults.length);
+      fail("SecurityTestUtils.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);
+      doDestroysP(num, i, expectedResults[i]);
     }
   }
 
-  protected static void doMultiUserInvalidates(final Integer num, final Integer numOfUsers,
-                                               final Integer[] expectedResults) {
+  protected static void doMultiUserInvalidates(final int num, final int numOfUsers, final int[] expectedResults) {
     if (numOfUsers != expectedResults.length) {
-      fail("SecurityTestUtils.doMultiUserInvalidates(): numOfUsers = " + numOfUsers
-          + ", but expected results " + expectedResults.length);
+      fail("SecurityTestUtils.doMultiUserInvalidates(): numOfUsers = " + numOfUsers + ", but expected results " + expectedResults.length);
     }
+
     for (int i = 0; i < numOfUsers; i++) {
       getLogWriter().info("INVALIDATE: MultiUser# " + i);
-      doInvalidatesP(num, Integer.valueOf(i), expectedResults[i], false);
+      doInvalidatesP(num, i, expectedResults[i]);
     }
   }
 
-  protected static void doMultiUserContainsKeys(final Integer num, final Integer numOfUsers,
-                                                final Integer[] expectedResults, final Boolean[] results) {
+  protected static void doMultiUserContainsKeys(final int num, final int numOfUsers, final int[] expectedResults, final boolean[] results) {
     if (numOfUsers != expectedResults.length) {
-      fail("SecurityTestUtils.doMultiUserContainsKeys(): numOfUsers = " + numOfUsers
-          + ", but #expected results " + expectedResults.length);
+      fail("SecurityTestUtils.doMultiUserContainsKeys(): numOfUsers = " + numOfUsers + ", but #expected results " + expectedResults.length);
     }
+
     if (numOfUsers != results.length) {
-      fail("SecurityTestUtils.doMultiUserContainsKeys(): numOfUsers = " + numOfUsers
-          + ", but #expected output " + results.length);
+      fail("SecurityTestUtils.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]);
+      doContainsKeysP(num, i, expectedResults[i], results[i]);
     }
   }
 
-  protected static void doMultiUserQueries(final Integer numOfUsers,
-                                           final Integer[] expectedResults, final Integer valueSize) {
+  protected static void doMultiUserQueries(final int numOfUsers, final int[] expectedResults, final int valueSize) {
     if (numOfUsers != expectedResults.length) {
-      fail("SecurityTestUtils.doMultiUserQueries(): numOfUsers = " + numOfUsers
-          + ", but #expected results " + expectedResults.length);
+      fail("SecurityTestUtils.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);
+      doQueriesP(i, expectedResults[i], valueSize);
     }
   }
 
-  protected static void doMultiUserFE(final Integer numOfUsers, final Function function,
-                                      final Integer[] expectedResults, final Object[] results, final Boolean isFailoverCase) {
+  protected static void doMultiUserFE(final int numOfUsers, final Function function, final int[] expectedResults, final boolean isFailOverCase) {
     if (numOfUsers != expectedResults.length) {
-      fail("SecurityTestUtils.doMultiUserFE(): numOfUsers = " + numOfUsers
-          + ", but #expected results " + expectedResults.length);
-    }
-    if (numOfUsers != results.length) {
-      fail("SecurityTestUtils.doMultiUserFE(): numOfUsers = " + numOfUsers
-          + ", but #expected output " + results.length);
+      fail("SecurityTestUtils.doMultiUserFE(): numOfUsers = " + numOfUsers + ", but #expected results " + expectedResults.length);
     }
+
     for (int i = 0; i < numOfUsers; i++) {
       getLogWriter().info("FunctionExecute:onRegion MultiUser# " + i);
-      doFunctionExecuteP(Integer.valueOf(i), function, expectedResults[i], results[i], "region");
+      doFunctionExecuteP(i, function, expectedResults[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");
+      doFunctionExecuteP(i, function, expectedResults[i], "server");
     }
-    if (!isFailoverCase) {
+
+    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");
+        doFunctionExecuteP(i, function, expectedResults[i], "servers");
       }
     }
   }
 
-  protected static void doMultiUserQueryExecute(final Integer numOfUsers,
-                                                final Integer[] expectedResults, final Integer result) {
+  protected static void doMultiUserQueryExecute(final int numOfUsers, final int[] expectedResults, final int result) {
     if (numOfUsers != expectedResults.length) {
-      fail("SecurityTestUtils.doMultiUserFE(): numOfUsers = " + numOfUsers
-          + ", but #expected results " + expectedResults.length);
+      fail("SecurityTestUtils.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);
+      doQueryExecuteP(i, expectedResults[i], result);
     }
   }
 
-  protected static void doLocalGets(final Integer num) {
-    doLocalGetsP(num.intValue(), false);
+  protected static void doLocalGets(final int num) {
+    doLocalGetsP(num, false);
   }
 
-  protected static void doNPuts(final Integer num) {
-    doPutsP(num, new Integer(NO_EXCEPTION), true);
+  protected static void doNPuts(final int num) {
+    doPutsP(num, NO_EXCEPTION, true);
   }
 
-  protected static void doNPuts(final Integer num, final Integer expectedResult) {
+  protected static void doNPuts(final int num, final int expectedResult) {
     doPutsP(num, expectedResult, true);
   }
 
-  protected static void doNGets(final Integer num) {
-    doGetsP(num, new Integer(NO_EXCEPTION), true);
+  protected static void doNGets(final int num) {
+    doGetsP(num, NO_EXCEPTION, true);
   }
 
-  protected static void doNGets(final Integer num, final Integer expectedResult) {
+  protected static void doNGets(final int num, final int expectedResult) {
     doGetsP(num, expectedResult, true);
   }
 
-  protected static void doNLocalGets(final Integer num) {
-    doLocalGetsP(num.intValue(), true);
+  protected static void doNLocalGets(final int num) {
+    doLocalGetsP(num, true);
   }
 
   protected static void doSimpleGet(final String expectedResult) {
@@ -811,14 +767,12 @@ public final class SecurityTestUtils {
         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()");
+          fail("Expected " + expectedResult + " but found " + e.getClass().getSimpleName() + " in doSimpleGet()");
         } else {
-          getLogWriter().fine(
-              "Got expected " + e.getClass().getSimpleName()
-                  + " in doSimpleGet()");
+          getLogWriter().fine("Got expected " + e.getClass().getSimpleName() + " in doSimpleGet()");
         }
       }
     }
@@ -831,75 +785,75 @@ public final class SecurityTestUtils {
         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);
+          fail("Expected " + expectedResult + " but found " + e.getClass().getSimpleName() + " in doSimplePut()", e);
         } else {
-          getLogWriter().fine(
-              "Got expected " + e.getClass().getSimpleName()
-                  + " in doSimplePut()");
+          getLogWriter().fine("Got expected " + e.getClass().getSimpleName() + " in doSimplePut()");
         }
       }
     }
   }
 
-  // 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.
+  /**
+   * 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 });
+
+    // Get the class of this and use reflection to blank out any static SSLContext objects inside
+    Map<Field, Object> contextMap = getSSLFields(defaultServerFact, new Class[] { SSLContext.class, SSLContextSpi.class });
     makeNullSSLFields(defaultServerFact, contextMap);
-    Iterator contextObjsIter = contextMap.values().iterator();
-    while (contextObjsIter.hasNext()) {
+
+    for (Iterator contextObjsIter = contextMap.values().iterator(); contextObjsIter.hasNext();) {
       Object contextObj = contextObjsIter.next();
-      Map contextObjsMap = getSSLFields(contextObj, new Class[] {
-          TrustManager.class, KeyManager.class, TrustManager[].class,
-          KeyManager[].class });
+      Map<Field, Object> 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 });
+    contextMap = getSSLFields(defaultFact, new Class[] { SSLContext.class, SSLContextSpi.class });
     makeNullSSLFields(defaultFact, contextMap);
-    contextObjsIter = contextMap.values().iterator();
-    while (contextObjsIter.hasNext()) {
+
+    for (Iterator contextObjsIter = contextMap.values().iterator(); contextObjsIter.hasNext();) {
       Object contextObj = contextObjsIter.next();
-      Map contextObjsMap = getSSLFields(contextObj, new Class[] {
-          TrustManager.class, KeyManager.class, TrustManager[].class,
-          KeyManager[].class });
+      Map<Field, Object> 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);
+
     if (cache != null && !cache.isClosed()) {
       DistributedSystem sys = cache.getDistributedSystem();
       cache.close();
       sys.disconnect();
       cache = null;
     }
+
     DistributedTestCase.disconnectFromDS();
   }
 
   protected static void closeCache(final Boolean keepAlive) {
     removeExpectedExceptions(ignoredExceptions);
+
     if (cache != null && !cache.isClosed()) {
       DistributedSystem sys = cache.getDistributedSystem();
       cache.close(keepAlive);
       sys.disconnect();
       cache = null;
     }
+
     DistributedTestCase.disconnectFromDS();
   }
 
@@ -911,8 +865,7 @@ public final class SecurityTestUtils {
 
   private static void addJavaProperties(final Properties javaProps) {
     if (javaProps != null) {
-      Iterator iter = javaProps.entrySet().iterator();
-      while (iter.hasNext()) {
+      for (Iterator iter = javaProps.entrySet().iterator(); iter.hasNext();) {
         Map.Entry entry = (Map.Entry)iter.next();
         System.setProperty((String)entry.getKey(), (String)entry.getValue());
       }
@@ -922,178 +875,166 @@ public final class SecurityTestUtils {
   private static void removeJavaProperties(final Properties javaProps) {
     if (javaProps != null) {
       Properties props = System.getProperties();
-      Iterator iter = javaProps.keySet().iterator();
-      while (iter.hasNext()) {
+
+      for (Iterator iter = javaProps.keySet().iterator(); iter.hasNext();) {
         props.remove(iter.next());
       }
+
       System.setProperties(props);
     }
   }
 
-  private static void doPutsP(final Integer num, final Integer expectedResult,
-                              final boolean newVals) {
-    doPutsP(num, Integer.valueOf(0), expectedResult, newVals);
+  private static void doPutsP(final int num, final int expectedResult, final boolean newVals) {
+    doPutsP(num, 0, expectedResult, newVals);
   }
 
-  private static void doPutsP(final Integer num, final Integer multiUserIndex,
-                              final Integer expectedResult, final boolean newVals) {
-    assertTrue(num.intValue() <= KEYS.length);
+  private static void doPutsP(final int num, final int multiUserIndex, final int expectedResult, final boolean newVals) {
+    assertTrue(num <= KEYS.length);
     Region region = null;
+
     try {
       if (multiUserAuthMode) {
         region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
         regionRef = region;
-      }
-      else {
+      } else {
         region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
-    }
-    catch (Exception ex) {
-      if (expectedResult.intValue() == OTHER_EXCEPTION) {
+
+    } catch (Exception ex) {
+      if (expectedResult == OTHER_EXCEPTION) {
         getLogWriter().info("Got expected exception when doing puts: " + ex);
-      }
-      else {
+      } else {
         fail("Got unexpected exception when doing puts", ex);
       }
     }
-    for (int index = 0; index < num.intValue(); ++index) {
+
+    for (int index = 0; index < num; ++index) {
       try {
         if (newVals) {
           region.put(KEYS[index], NVALUES[index]);
-        }
-        else {
+        } else {
           region.put(KEYS[index], VALUES[index]);
         }
-        if (expectedResult.intValue() != NO_EXCEPTION) {
+        if (expectedResult != NO_EXCEPTION) {
           fail("Expected a NotAuthorizedException while doing puts");
         }
-      }
-      catch(NoAvailableServersException ex) {
-        if(expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
-          getLogWriter().info(
-                  "Got expected NoAvailableServers when doing puts: "
-                          + ex.getCause());
+
+      } catch(NoAvailableServersException ex) {
+        if(expectedResult == NO_AVAILABLE_SERVERS) {
+          getLogWriter().info("Got expected NoAvailableServers when doing puts: " + ex.getCause());
           continue;
-        }
-        else {
+        } else {
           fail("Got unexpected exception when doing puts", ex);
         }
-      }
-      catch (ServerConnectivityException ex) {
-        if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-                && (ex.getCause() instanceof NotAuthorizedException)) {
-          getLogWriter().info(
-                  "Got expected NotAuthorizedException when doing puts: "
-                          + ex.getCause());
+
+      } catch (ServerConnectivityException ex) {
+        if ((expectedResult == NOTAUTHZ_EXCEPTION) && (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());
+
+        if ((expectedResult == 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());
+
+        if ((expectedResult == AUTHFAIL_EXCEPTION) && (ex.getCause() instanceof AuthenticationFailedException)) {
+          getLogWriter().info("Got expected AuthenticationFailedException when doing puts: " + ex.getCause());
           continue;
-        }
-        else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        } else if (expectedResult == OTHER_EXCEPTION) {
           getLogWriter().info("Got expected exception when doing puts: " + ex);
-        }
-        else {
+        } else {
           fail("Got unexpected exception when doing puts", ex);
         }
-      }
-      catch (Exception ex) {
-        if (expectedResult.intValue() == OTHER_EXCEPTION) {
+
+      } catch (Exception ex) {
+        if (expectedResult == OTHER_EXCEPTION) {
           getLogWriter().info("Got expected exception when doing puts: " + ex);
-        }
-        else {
+        } else {
           fail("Got unexpected exception when doing puts", ex);
         }
       }
     }
   }
 
-  private static HashMap getSSLFields(final Object obj, final Class[] classes) {
-    HashMap resultFields = new HashMap();
+  private static Map<Field, Object> getSSLFields(final Object obj, final Class[] classes) {
+    Map<Field, Object> 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;
           }
         }
+
         if (isInstance) {
           resultFields.put(field, fieldObj);
         }
-      }
-      catch (IllegalAccessException ex) {
+
+      } catch (IllegalAccessException ex) {
         getLogWriter().warning("Exception while getting SSL fields.", ex);
       }
     }
     return resultFields;
   }
 
-  private static void makeNullSSLFields(final Object obj, final Map fieldMap) {
-    Iterator fieldIter = fieldMap.entrySet().iterator();
-    while (fieldIter.hasNext()) {
-      Map.Entry entry = (Map.Entry)fieldIter.next();
-      Field field = (Field)entry.getKey();
+  private static void makeNullSSLFields(final Object obj, final Map<Field, Object> fieldMap) {
+    for (Iterator<Map.Entry<Field, Object>> fieldIter = fieldMap.entrySet().iterator(); fieldIter.hasNext();) {
+      Map.Entry<Field, Object> entry = fieldIter.next();
+      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) {
+
+      } catch (IllegalAccessException ex) {
         getLogWriter().warning("Exception while clearing SSL fields.", ex);
       }
     }
   }
 
-  // Deal with javax SSL properties
-  private static void makeNullStaticField(final Class cls) {
-    Field[] fields = cls.getDeclaredFields();
+  /**
+   * Deal with javax SSL properties
+   */
+  private static void makeNullStaticField(final Class sslClass) {
+    Field[] fields = sslClass.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))) {
+
+          } else if (sslClass.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);
+
+      } 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(final Integer multiUserIndex,
-                                      final Integer expectedResult, final Integer expectedValue) {
+  private static void doQueryExecuteP(final int multiUserIndex, final int expectedResult, final int expectedValue) {
     Region region = null;
     try {
       if (multiUserAuthMode) {
@@ -1102,61 +1043,57 @@ public final class SecurityTestUtils {
         region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
+
     } catch (Exception ex) {
-      if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        getLogWriter().info(
-                "Got expected exception when executing query: " + ex);
+      if (expectedResult == OTHER_EXCEPTION) {
+        getLogWriter().info("Got expected exception when executing query: " + ex);
       } else {
         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 {
+      } else {
         region.getCache().getQueryService().newQuery(queryString);
       }
+
       SelectResults result = (SelectResults)query.execute();
-      if (expectedResult.intValue() != NO_EXCEPTION) {
+      if (expectedResult != NO_EXCEPTION) {
         fail("Expected a NotAuthorizedException while executing function");
       }
-      assertEquals(expectedValue.intValue(), result.asList().size());
+      assertEquals(expectedValue, result.asList().size());
+
     } catch (NoAvailableServersException ex) {
-      if (expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
-        getLogWriter().info(
-                "Got expected NoAvailableServers when executing query: "
-                        + ex.getCause());
+      if (expectedResult == 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);
+      if ((expectedResult == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
+        getLogWriter().info("Got expected NotAuthorizedException when executing query: " + ex.getCause());
+      } else if (expectedResult == 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);
+      if (expectedResult == OTHER_EXCEPTION) {
+        getLogWriter().info("Got expected exception when executing query: " + ex);
       } else {
         fail("Got unexpected exception when executing query", ex);
       }
     }
   }
 
-  private static void doFunctionExecuteP(final Integer multiUserIndex,
-                                         final Function function, Integer expectedResult, final Object expectedValue,
-                                         final String method) {
+  private static void doFunctionExecuteP(final int multiUserIndex, final Function function, int expectedResult, final String method) {
     Region region = null;
     try {
       if (multiUserAuthMode) {
@@ -1165,25 +1102,29 @@ public final class SecurityTestUtils {
         region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
+
     } catch (Exception ex) {
-      if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        getLogWriter().info(
-                "Got expected exception when executing function: " + ex);
+      if (expectedResult == 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]);
@@ -1191,56 +1132,48 @@ public final class SecurityTestUtils {
           execution = FunctionService.onServers(pool);
         }
       }
+
       execution.execute(function.getId());
-      if (expectedResult.intValue() != NO_EXCEPTION) {
+      if (expectedResult != NO_EXCEPTION) {
         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());
+      if (expectedResult == 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);
+      if ((expectedResult == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
+        getLogWriter().info("Got expected NotAuthorizedException when executing function: " + ex.getCause());
+      } else if (expectedResult == 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);
+      // if NOTAUTHZ_EXCEPTION AND (cause is NotAuthorizedException OR (cause is ServerOperationException AND cause.cause is NotAuthorizedException))
+      if (expectedResult == NOTAUTHZ_EXCEPTION && (ex.getCause() instanceof NotAuthorizedException || (ex.getCause() instanceof ServerOperationException && ex.getCause().getCause() instanceof NotAuthorizedException)) ) {
+        getLogWriter().info("Got expected NotAuthorizedException when executing function: " + ex.getCause());
+      } else if (expectedResult == 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);
+      if (expectedResult == OTHER_EXCEPTION) {
+        getLogWriter().info("Got expected exception when executing function: " + ex);
       } else {
         fail("Got unexpected exception when executing function", ex);
       }
     }
   }
 
-  private static void doQueriesP(final Integer multiUserIndex,
-                                 final Integer expectedResult, final Integer expectedValue) {
+  private static void doQueriesP(final int multiUserIndex, final int expectedResult, final int expectedValue) {
     Region region = null;
     try {
       if (multiUserAuthMode) {
@@ -1249,53 +1182,51 @@ public final class SecurityTestUtils {
         region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
+
     } catch (Exception ex) {
-      if (expectedResult.intValue() == OTHER_EXCEPTION) {
+      if (expectedResult == 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) {
+      assertEquals(expectedValue, resultSet.size());
+      if (expectedResult != NO_EXCEPTION) {
         fail("Expected a NotAuthorizedException while doing queries");
       }
+
     } catch (NoAvailableServersException ex) {
-      if (expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
-        getLogWriter().info(
-                "Got expected NoAvailableServers when doing queries: "
-                        + ex.getCause());
+      if (expectedResult == NO_AVAILABLE_SERVERS) {
+        getLogWriter().info("Got expected NoAvailableServers when doing queries: " + ex.getCause());
       } else {
         fail("Got unexpected exception when doing queries", ex);
       }
+
     } catch (ServerConnectivityException ex) {
-      if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-              && (ex.getCause() instanceof NotAuthorizedException)) {
-        getLogWriter().info(
-                "Got expected NotAuthorizedException when doing queries: "
-                        + ex.getCause());
-      } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+      if ((expectedResult == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
+        getLogWriter().info("Got expected NotAuthorizedException when doing queries: " + ex.getCause());
+      } else if (expectedResult == OTHER_EXCEPTION) {
         getLogWriter().info("Got expected exception when doing queries: " + ex);
       } else {
         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) {
+      if ((expectedResult == NOTAUTHZ_EXCEPTION) && (qite.getCause() instanceof NotAuthorizedException)) {
+        getLogWriter().info("Got expected NotAuthorizedException when doing queries: " + qite.getCause());
+      } else if (expectedResult == 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) {
+      if (expectedResult == OTHER_EXCEPTION) {
         getLogWriter().info("Got expected exception when doing queries: " + ex);
       } else {
         fail("Got unexpected exception when doing queries", ex);
@@ -1303,218 +1234,188 @@ public final class SecurityTestUtils {
     }
   }
 
-  private static void doContainsKeysP(final Integer num, final Integer multiUserIndex,
-                                      final Integer expectedResult, final boolean newVals, final boolean expectedValue) {
+  private static void doContainsKeysP(final int num, final int multiUserIndex, final int expectedResult, final boolean expectedValue) {
+    assertTrue(num <= KEYS.length);
 
-    assertTrue(num.intValue() <= KEYS.length);
     Region region = null;
     try {
       if (multiUserAuthMode) {
         region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
-      }
-      else {
+      } else {
         region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
-    }
-    catch (Exception ex) {
-      if (expectedResult.intValue() == OTHER_EXCEPTION) {
+
+    } catch (Exception ex) {
+      if (expectedResult == OTHER_EXCEPTION) {
         getLogWriter().info("Got expected exception when doing containsKey: " + ex);
-      }
-      else {
+      } else {
         fail("Got unexpected exception when doing containsKey", ex);
       }
     }
-    for (int index = 0; index < num.intValue(); ++index) {
+
+    for (int index = 0; index < num; ++index) {
       boolean result = false;
+
       try {
         result = region.containsKeyOnServer(KEYS[index]);
-        if (expectedResult.intValue() != NO_EXCEPTION) {
+        if (expectedResult != NO_EXCEPTION) {
           fail("Expected a NotAuthorizedException while doing containsKey");
         }
-      }
-      catch(NoAvailableServersException ex) {
-        if(expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
-          getLogWriter().info(
-                  "Got expected NoAvailableServers when doing containsKey: "
-                          + ex.getCause());
+
+      } catch(NoAvailableServersException ex) {
+        if(expectedResult == NO_AVAILABLE_SERVERS) {
+          getLogWriter().info("Got expected NoAvailableServers when doing containsKey: " + ex.getCause());
           continue;
-        }
-        else {
+        } else {
           fail("Got unexpected exception when doing containsKey", ex);
         }
-      }
-      catch (ServerConnectivityException ex) {
-        if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-                && (ex.getCause() instanceof NotAuthorizedException)) {
-          getLogWriter().info(
-                  "Got expected NotAuthorizedException when doing containsKey: "
-                          + ex.getCause());
+
+      } catch (ServerConnectivityException ex) {
+        if ((expectedResult == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
+          getLogWriter().info("Got expected NotAuthorizedException when doing containsKey: " + ex.getCause());
           continue;
-        }
-        else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        } else if (expectedResult == OTHER_EXCEPTION) {
           getLogWriter().info("Got expected exception when doing containsKey: " + ex);
-        }
-        else {
+        } else {
           fail("Got unexpected exception when doing containsKey", ex);
         }
-      }
-      catch (Exception ex) {
-        if (expectedResult.intValue() == OTHER_EXCEPTION) {
+
+      } catch (Exception ex) {
+        if (expectedResult == OTHER_EXCEPTION) {
           getLogWriter().info("Got expected exception when doing containsKey: " + ex);
-        }
-        else {
+        } else {
           fail("Got unexpected exception when doing containsKey", ex);
         }
       }
+
       assertEquals(expectedValue, result);
     }
   }
 
-  private static void doInvalidatesP(final Integer num, final Integer multiUserIndex,
-                                     final Integer expectedResult, final boolean newVals) {
-    assertTrue(num.intValue() <= KEYS.length);
+  private static void doInvalidatesP(final int num, final int multiUserIndex, final int expectedResult) {
+    assertTrue(num <= KEYS.length);
+
     Region region = null;
     try {
       if (multiUserAuthMode) {
         region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
-      }
-      else {
+      } else {
         region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
-    }
-    catch (Exception ex) {
-      if (expectedResult.intValue() == OTHER_EXCEPTION) {
+
+    } catch (Exception ex) {
+      if (expectedResult == OTHER_EXCEPTION) {
         getLogWriter().info("Got expected exception when doing invalidates: " + ex);
-      }
-      else {
+      } else {
         fail("Got unexpected exception when doing invalidates", ex);
       }
     }
-    for (int index = 0; index < num.intValue(); ++index) {
+
+    for (int index = 0; index < num; ++index) {
       try {
         region.invalidate(KEYS[index]);
-        if (expectedResult.intValue() != NO_EXCEPTION) {
+        if (expectedResult != NO_EXCEPTION) {
           fail("Expected a NotAuthorizedException while doing invalidates");
         }
-      }
-      catch(NoAvailableServersException ex) {
-        if(expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
-          getLogWriter().info(
-                  "Got expected NoAvailableServers when doing invalidates: "
-                          + ex.getCause());
+
+      } catch(NoAvailableServersException ex) {
+        if (expectedResult == NO_AVAILABLE_SERVERS) {
+          getLogWriter().info("Got expected NoAvailableServers when doing invalidates: " + ex.getCause());
           continue;
-        }
-        else {
+        } else {
           fail("Got unexpected exception when doing invalidates", ex);
         }
-      }
-      catch (ServerConnectivityException ex) {
-        if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-                && (ex.getCause() instanceof NotAuthorizedException)) {
-          getLogWriter().info(
-                  "Got expected NotAuthorizedException when doing invalidates: "
-                          + ex.getCause());
+
+      } catch (ServerConnectivityException ex) {
+        if ((expectedResult == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
+          getLogWriter().info("Got expected NotAuthorizedException when doing invalidates: " + ex.getCause());
           continue;
-        }
-        else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        } else if (expectedResult == OTHER_EXCEPTION) {
           getLogWriter().info("Got expected exception when doing invalidates: " + ex);
-        }
-        else {
+        } else {
           fail("Got unexpected exception when doing invalidates", ex);
         }
-      }
-      catch (Exception ex) {
-        if (expectedResult.intValue() == OTHER_EXCEPTION) {
+
+      } catch (Exception ex) {
+        if (expectedResult == OTHER_EXCEPTION) {
           getLogWriter().info("Got expected exception when doing invalidates: " + ex);
-        }
-        else {
+        } else {
           fail("Got unexpected exception when doing invalidates", ex);
         }
       }
     }
   }
 
-  private static void doDestroysP(final Integer num, final Integer multiUserIndex,
-                                  final Integer expectedResult, final boolean newVals) {
-    assertTrue(num.intValue() <= KEYS.length);
+  private static void doDestroysP(final int num, final int multiUserIndex, final int expectedResult) {
+    assertTrue(num <= KEYS.length);
+
     Region region = null;
     try {
       if (multiUserAuthMode) {
         region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
-      }
-      else {
+      } else {
         region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
-    }
-    catch (Exception ex) {
-      if (expectedResult.intValue() == OTHER_EXCEPTION) {
+
+    } catch (Exception ex) {
+      if (expectedResult == OTHER_EXCEPTION) {
         getLogWriter().info("Got expected exception when doing destroys: " + ex);
-      }
-      else {
+      } else {
         fail("Got unexpected exception when doing destroys", ex);
       }
     }
-    for (int index = 0; index < num.intValue(); ++index) {
+
+    for (int index = 0; index < num; ++index) {
       try {
         region.destroy(KEYS[index]);
-        if (expectedResult.intValue() != NO_EXCEPTION) {
+        if (expectedResult != NO_EXCEPTION) {
           fail("Expected a NotAuthorizedException while doing destroys");
         }
-      }
-      catch(NoAvailableServersException ex) {
-        if(expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
-          getLogWriter().info(
-                  "Got expected NoAvailableServers when doing destroys: "
-                          + ex.getCause());
+
+      } catch(NoAvailableServersException ex) {
+        if(expectedResult == NO_AVAILABLE_SERVERS) {
+          getLogWriter().info("Got expected NoAvailableServers when doing destroys: " + ex.getCause());
           continue;
-        }
-        else {
+        } else {
           fail("Got unexpected exception when doing destroys", ex);
         }
-      }
-      catch (ServerConnectivityException ex) {
-        if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-                && (ex.getCause() instanceof NotAuthorizedException)) {
-          getLogWriter().info(
-                  "Got expected NotAuthorizedException when doing destroys: "
-                          + ex.getCause());
+
+      } catch (ServerConnectivityException ex) {
+        if ((expectedResult == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
+          getLogWriter().info("Got expected NotAuthorizedException when doing destroys: " + ex.getCause());
           continue;
-        }
-        else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        } else if (expectedResult == OTHER_EXCEPTION) {
           getLogWriter().info("Got expected exception when doing destroys: " + ex);
-        }
-        else {
+        } else {
           fail("Got unexpected exception when doing destroys", ex);
         }
-      }
-      catch (Exception ex) {
-        if (expectedResult.intValue() == OTHER_EXCEPTION) {
+
+      } catch (Exception ex) {
+        if (expectedResult == OTHER_EXCEPTION) {
           getLogWriter().info("Got expected exception when doing destroys: " + ex);
-        }
-        else {
+        } else {
           fail("Got unexpected exception when doing destroys", ex);
         }
       }
     }
   }
 
-  private static void doRegionDestroysP(final Integer multiuserIndex,
-                                        final Integer expectedResult) {
+  private static void doRegionDestroysP(final int multiUserIndex, final int 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) {
-        getLogWriter().info(
-                "Got expected exception when doing region destroy: " + ex);
+      if (expectedResult == OTHER_EXCEPTION) {
+        getLogWriter().info("Got expected exception when doing region destroy: " + ex);
       } else {
         fail("Got unexpected exception when doing region destroy", ex);
       }
@@ -1522,39 +1423,36 @@ public final class SecurityTestUtils {
 
     try {
       region.destroyRegion();
-      if (expectedResult.intValue() != NO_EXCEPTION) {
+      if (expectedResult != NO_EXCEPTION) {
         fail("Expected a NotAuthorizedException while doing region destroy");
       }
+
       if (multiUserAuthMode) {
-        region = proxyCaches[multiuserIndex].getRegion(REGION_NAME);
+        region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
       } else {
         region = getCache().getRegion(REGION_NAME);
       }
       assertNull(region);
+
     } catch (NoAvailableServersException ex) {
-      if (expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
-        getLogWriter().info(
-                "Got expected NoAvailableServers when doing region destroy: "
-                        + ex.getCause());
+      if (expectedResult == NO_AVAILABLE_SERVERS) {
+        getLogWriter().info("Got expected NoAvailableServers when doing region destroy: " + ex.getCause());
       } else {
         fail("Got unexpected exception when doing region destroy", ex);
       }
+
     } catch (ServerConnectivityException ex) {
-      if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-              && (ex.getCause() instanceof NotAuthorizedException)) {
-        getLogWriter().info(
-                "Got expected NotAuthorizedException when doing region destroy: "
-                        + ex.getCause());
-      } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        getLogWriter().info(
-                "Got expected exception when doing region destroy: " + ex);
+      if ((expectedResult == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
+        getLogWriter().info("Got expected NotAuthorizedException when doing region destroy: " + ex.getCause());
+      } else if (expectedResult == OTHER_EXCEPTION) {
+        getLogWriter().info("Got expected exception when doing region destroy: " + ex);
       } else {
         fail("Got unexpected exception when doing region destroy", ex);
       }
+
     } catch (Exception ex) {
-      if (expectedResult.intValue() == OTHER_EXCEPTION) {
-        getLogWriter().info(
-                "Got expected exception when doing region destroy: " + ex);
+      if (expectedResult == OTHER_EXCEPTION) {
+        getLogWriter().info("Got expected exception when doing region destroy: " + ex);
       } else {
         fail("Got unexpected exception when doing region destroy", ex);
       }
@@ -1563,22 +1461,21 @@ public final class SecurityTestUtils {
 
   private static void doLocalGetsP(final int num, final 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);
+      waitForCondition(() -> expectedVal.equals(getLocalValue(region, key)), 1000, 30 / num);
     }
+
     for (int index = 0; index < num; ++index) {
       Region.Entry entry = region.getEntry(KEYS[index]);
       assertNotNull(entry);
@@ -1586,68 +1483,70 @@ public final class SecurityTestUtils {
     }
   }
 
-  private static void doGetAllP(final Integer multiUserIndex,
-                                final Integer expectedResult, final boolean useTX) {
+  private static void doGetAllP(final int multiUserIndex, final int expectedResult, final 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) {
-      if (expectedResult.intValue() == OTHER_EXCEPTION) {
+
+    } catch (Exception ex) {
+      if (expectedResult == OTHER_EXCEPTION) {
         getLogWriter().info("Got expected exception when doing getAll: " + ex);
-      }
-      else {
+      } else {
         fail("Got unexpected exception when doing getAll", ex);
       }
     }
+
     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)) {
+
+      if ((expectedResult == NOTAUTHZ_EXCEPTION)) {
         assertEquals(0, entries.size());
-      } else if ((expectedResult.intValue() == NO_EXCEPTION)) {
+      } else if ((expectedResult == NO_EXCEPTION)) {
         assertEquals(2, entries.size());
         assertEquals("value1", entries.get("key1"));
         assertEquals("value2", entries.get("key2"));
       }
+
     } catch (NoAvailableServersException ex) {
-      if (expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
-        getLogWriter().info(
-                "Got expected NoAvailableServers when doing getAll: "
-                        + ex.getCause());
+      if (expectedResult == NO_AVAILABLE_SERVERS) {
+        getLogWriter().info("Got expected NoAvailableServers when doing getAll: " + ex.getCause());
       } else {
         fail("Got unexpected exception when doing getAll", ex);
       }
+
     } catch (ServerConnectivityException ex) {
-      if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-              && (ex.getCause() instanceof NotAuthorizedException)) {
-        getLogWriter().info(
-                "Got expected NotAuthorizedException when doing getAll: "
-                        + ex.getCause());
-      } else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+      if ((expectedResult == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
+        getLogWriter().info("Got expected NotAuthorizedException when doing getAll: " + ex.getCause());
+      } else if (expectedResult == OTHER_EXCEPTION) {
         getLogWriter().info("Got expected exception when doing getAll: " + ex);
       } else {
         fail("Got unexpected exception when doing getAll", ex);
       }
+
     } catch (Exception ex) {
-      if (expectedResult.intValue() == OTHER_EXCEPTION) {
+      if (expectedResult == OTHER_EXCEPTION) {
         getLogWriter().info("Got expected exception when doing getAll: " + ex);
       } else {
         fail("Got unexpected exception when doing getAll", ex);
@@ -1655,84 +1554,75 @@ public final class SecurityTestUtils {
     }
   }
 
-  private static void doGetsP(final Integer num, final Integer expectedResult,
-                              final boolean newVals) {
-    doGetsP(num, Integer.valueOf(0), expectedResult, newVals);
+  private static void doGetsP(final int num, final int expectedResult, final boolean newVals) {
+    doGetsP(num, 0, expectedResult, newVals);
   }
 
-  private static void doGetsP(final Integer num, final Integer multiUserIndex,
-                              final Integer expectedResult, final boolean newVals) {
-    assertTrue(num.intValue() <= KEYS.length);
+  private static void doGetsP(final int num, final int multiUserIndex, final int expectedResult, final boolean newVals) {
+    assertTrue(num <= KEYS.length);
+
     Region region = null;
     try {
       if (multiUserAuthMode) {
         region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
-      }
-      else {
+      } else {
         region = getCache().getRegion(REGION_NAME);
       }
       assertNotNull(region);
-    }
-    catch (Exception ex) {
-      if (expectedResult.intValue() == OTHER_EXCEPTION) {
+
+    } catch (Exception ex) {
+      if (expectedResult == OTHER_EXCEPTION) {
         getLogWriter().info("Got expected exception when doing gets: " + ex);
-      }
-      else {
+      } else {
         fail("Got unexpected exception when doing gets", ex);
       }
     }
-    for (int index = 0; index < num.intValue(); ++index) {
+
+    for (int index = 0; index < num; ++index) {
       Object value = null;
       try {
+
         try {
           region.localInvalidate(KEYS[index]);
+        } catch (Exception ex) {
         }
-        catch (Exception ex) {
-        }
+
         value = region.get(KEYS[index]);
-        if (expectedResult.intValue() != NO_EXCEPTION) {
+        if (expectedResult != NO_EXCEPTION) {
           fail("Expected a NotAuthorizedException while doing gets");
         }
-      }
-      catch(NoAvailableServersException ex) {
-        if(expectedResult.intValue() == NO_AVAILABLE_SERVERS) {
-          getLogWriter().info(
-                  "Got expected NoAvailableServers when doing gets: "
-                          + ex.getCause());
+
+      } catch(NoAvailableServersException ex) {
+        if(expectedResult == NO_AVAILABLE_SERVERS) {
+          getLogWriter().info("Got expected NoAvailableServers when doing gets: " + ex.getCause());
           continue;
-        }
-        else {
+        } else {
           fail("Got unexpected exception when doing gets", ex);
         }
-      }
-      catch (ServerConnectivityException ex) {
-        if ((expectedResult.intValue() == NOTAUTHZ_EXCEPTION)
-                && (ex.getCause() instanceof NotAuthorizedException)) {
-          getLogWriter().info(
-                  "Got expected NotAuthorizedException when doing gets: "
-                          + ex.getCause());
+
+      } catch (ServerConnectivityException ex) {
+        if ((expectedResult == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
+          getLogWriter().info("Got expected NotAuthorizedException when doing gets: " + ex.getCause());
           continue;
-        }
-        else if (expectedResult.intValue() == OTHER_EXCEPTION) {
+        } else if (expectedResult == OTHER_EXCEPTION) {
           getLogWriter().info("Got expected exception when doing gets: " + ex);
-        }
-        else {
+        } else {
           fail("Got unexpected exception when doing gets", ex);
         }
-      }
-      catch (Exception ex) {
-        if (expectedResult.intValue() == OTHER_EXCEPTION) {
+
+      } catch (Exception ex) {
+        if (expectedResult == OTHER_EXCEPTION) {
           getLogWriter().info("Got expected exception when doing gets: " + ex);
-        }
-        else {
+        } else {
           fail("Got unexpected exception when doing gets", ex);
         }
       }
+
       assertNotNull(value);
+
       if (newVals) {
         assertEquals(NVALUES[index], value);
-      }
-      else {
+      } else {
         assertEquals(VALUES[index], value);
       }
     }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e93932aa/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 64ab4ee..e2950c2 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
@@ -54,7 +54,7 @@ public class ClientAuthorizationTwoDUnitTest extends ClientAuthorizationTestCase
 
   @Test
   public void testAllOpsWithFailover2() throws Exception {
-    runOpsWithFailover(allOps(), "testAllOpsWithFailover2");
+    runOpsWithFailOver(allOps(), "testAllOpsWithFailover2");
   }
 
   private OperationWithAction[] allOps() {

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/e93932aa/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 d84cd43..ce03ac6 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
@@ -54,9 +54,8 @@ public class ClientPostAuthorizationDUnitTest extends ClientAuthorizationTestCas
   public void testAllPostOps() throws Exception {
     OperationWithAction[] allOps = allOpsForTestAllPostOps();
 
-    for (Iterator iter = getDummyGeneratorCombos().iterator(); iter.hasNext();) {
-
-      AuthzCredentialGenerator gen = (AuthzCredentialGenerator)iter.next();
+    for (Iterator<AuthzCredentialGenerator> iter = getDummyGeneratorCombos().iterator(); iter.hasNext();) {
+      AuthzCredentialGenerator gen = iter.next();
       CredentialGenerator cGen = gen.getCredentialGenerator();
       Properties extraAuthProps = cGen.getSystemProperties();
       Properties javaProps = cGen.getJavaProperties();