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 <[email protected]> Authored: Tue Mar 29 16:53:12 2016 -0700 Committer: Kirk Lund <[email protected]> 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; }
