You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/03/29 00:48:38 UTC
[4/8] incubator-geode git commit: Tests are passing
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java
index 270d0a7..724fa72 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthorizationTwoDUnitTest.java
@@ -16,9 +16,10 @@
*/
package com.gemstone.gemfire.security;
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.test.dunit.IgnoredException.*;
+
import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.IgnoredException;
import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -39,26 +40,20 @@ public class ClientAuthorizationTwoDUnitTest extends ClientAuthorizationTestBase
@Override
public final void postSetUpClientAuthorizationTestBase() throws Exception {
- IgnoredException.addIgnoredException("Read timed out");
- IgnoredException.addIgnoredException("Connection reset");
- IgnoredException.addIgnoredException("SocketTimeoutException");
- IgnoredException.addIgnoredException("ServerConnectivityException");
- IgnoredException.addIgnoredException("Socket Closed");
+ addIgnoredException("Read timed out");
+ addIgnoredException("Connection reset");
+ addIgnoredException("SocketTimeoutException");
+ addIgnoredException("ServerConnectivityException");
+ addIgnoredException("Socket Closed");
}
@Override
public final void preTearDownClientAuthorizationTestBase() throws Exception {
- // close the clients first
- client1.invoke(() -> SecurityTestUtil.closeCache());
- client2.invoke(() -> SecurityTestUtil.closeCache());
- SecurityTestUtil.closeCache();
- // then close the servers
- server1.invoke(() -> SecurityTestUtil.closeCache());
- server2.invoke(() -> SecurityTestUtil.closeCache());
+ closeCache();
}
@Test
- public void testAllOpsWithFailover2() {
+ public void testAllOpsWithFailover2() throws Exception {
runOpsWithFailover(allOps(), "testAllOpsWithFailover2");
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
index 8ef10c1..2a1fa7b 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientAuthzObjectModDUnitTest.java
@@ -16,6 +16,10 @@
*/
package com.gemstone.gemfire.security;
+import static com.gemstone.gemfire.internal.AvailablePort.*;
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@@ -25,7 +29,6 @@ import com.gemstone.gemfire.DataSerializable;
import com.gemstone.gemfire.Instantiator;
import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
import com.gemstone.gemfire.distributed.internal.DistributionConfig;
-import com.gemstone.gemfire.internal.AvailablePort;
import com.gemstone.gemfire.internal.security.FilterPostAuthorization;
import com.gemstone.gemfire.internal.security.FilterPreAuthorization;
import com.gemstone.gemfire.internal.security.ObjectWithAuthz;
@@ -33,8 +36,6 @@ import com.gemstone.gemfire.security.generator.CredentialGenerator;
import com.gemstone.gemfire.security.generator.DummyAuthzCredentialGenerator;
import com.gemstone.gemfire.security.generator.DummyCredentialGenerator;
import com.gemstone.gemfire.security.templates.UserPasswordAuthInit;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import org.junit.Test;
@@ -78,7 +79,7 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase {
}
@Test
- public void testAllOpsObjectModWithFailover() {
+ public void testAllOpsObjectModWithFailover() throws Exception {
OperationWithAction[] allOps = allOps();
TestPostCredentialGenerator tgen = new TestPostCredentialGenerator();
@@ -90,16 +91,17 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase {
String authInit = credentialGenerator.getAuthInit();
String authenticator = credentialGenerator.getAuthenticator();
- LogWriterUtils.getLogWriter().info("testPutsGetsObjectModWithFailover: Using authinit: " + authInit);
- LogWriterUtils.getLogWriter().info("testPutsGetsObjectModWithFailover: Using authenticator: " + authenticator);
- LogWriterUtils.getLogWriter().info("testPutsGetsObjectModWithFailover: Using pre-operation accessor: " + preAccessor);
- LogWriterUtils.getLogWriter().info("testPutsGetsObjectModWithFailover: Using post-operation accessor: " + postAccessor);
+ getLogWriter().info("testPutsGetsObjectModWithFailover: Using authinit: " + authInit);
+ getLogWriter().info("testPutsGetsObjectModWithFailover: Using authenticator: " + authenticator);
+ getLogWriter().info("testPutsGetsObjectModWithFailover: Using pre-operation accessor: " + preAccessor);
+ getLogWriter().info("testPutsGetsObjectModWithFailover: Using post-operation accessor: " + postAccessor);
// Start servers with all required properties
Properties serverProps = buildProperties(authenticator, extraProps, preAccessor, postAccessor);
+
// Get ports for the servers
- Integer port1 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
- Integer port2 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+ int port1 = getRandomAvailablePort(SOCKET);
+ int port2 =getRandomAvailablePort(SOCKET);
// Perform all the ops on the clients
List opBlock = new ArrayList();
@@ -112,13 +114,13 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase {
// End of current operation block; execute all the operations on the servers with failover
if (opBlock.size() > 0) {
// Start the first server and execute the operation block
- server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port1, serverProps, javaProps ));
- server2.invoke(() -> SecurityTestUtil.closeCache());
+ server1.invoke(() -> createCacheServer(getLocatorPort(), port1, serverProps, javaProps ));
+ server2.invoke(() -> closeCache());
executeOpBlock(opBlock, port1, port2, authInit, extraProps, null, tgen, rnd);
if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
// Failover to the second server and run the block again
- server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port2, serverProps, javaProps ));
- server1.invoke(() -> SecurityTestUtil.closeCache());
+ server2.invoke(() -> createCacheServer(getLocatorPort(), port2, serverProps, javaProps ));
+ server1.invoke(() -> closeCache());
executeOpBlock(opBlock, port1, port2, authInit, extraProps, null, tgen, rnd);
}
opBlock.clear();
@@ -209,7 +211,7 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase {
}
- private Properties buildProperties(String authenticator, Properties extraProps, String preAccessor, String postAccessor) {
+ private Properties buildProperties(final String authenticator, final Properties extraProps, final String preAccessor, final String postAccessor) {
Properties authProps = new Properties();
if (authenticator != null) {
authProps.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator);
@@ -232,7 +234,7 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase {
this(ObjectWithAuthz.class, ObjectWithAuthz.CLASSID);
}
- public MyInstantiator(Class clazz, int classId) {
+ public MyInstantiator(final Class clazz, final int classId) {
super(clazz, classId);
}
@@ -248,7 +250,7 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase {
}
@Override
- public Properties getAllowedCredentials(OperationCode[] opCodes, String[] regionNames, int[] keyIndices, int num) {
+ public Properties getAllowedCredentials(final OperationCode[] opCodes, final String[] regionNames, final int[] keyIndices, final int num) {
int userIndex = 1;
byte role = DummyAuthzCredentialGenerator.getRequiredRole(opCodes);
if (role == DummyAuthzCredentialGenerator.READER_ROLE) {
@@ -261,7 +263,7 @@ public class ClientAuthzObjectModDUnitTest extends ClientAuthorizationTestBase {
}
@Override
- public Properties getDisallowedCredentials(OperationCode[] opCodes, String[] regionNames, int[] keyIndices, int num) {
+ public Properties getDisallowedCredentials(final OperationCode[] opCodes, final String[] regionNames, final int[] keyIndices, final int num) {
int userIndex = 0;
for (int index = 0; index < keyIndices.length; ++index) {
if (keyIndices[index] != index) {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
index 6bca85f..8d3876f 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientCQPostAuthorizationDUnitTest.java
@@ -16,7 +16,12 @@
*/
package com.gemstone.gemfire.security;
+import static com.gemstone.gemfire.internal.AvailablePort.*;
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
import static com.gemstone.gemfire.test.dunit.Assert.*;
+import static com.gemstone.gemfire.test.dunit.Invoke.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
+import static com.gemstone.gemfire.test.dunit.Wait.*;
import java.util.Collection;
import java.util.HashMap;
@@ -39,17 +44,10 @@ import com.gemstone.gemfire.cache.query.cq.dunit.CqQueryTestListener;
import com.gemstone.gemfire.cache.query.internal.cq.ClientCQImpl;
import com.gemstone.gemfire.cache.query.internal.cq.CqService;
import com.gemstone.gemfire.cache.query.internal.cq.InternalCqQuery;
-import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
-import com.gemstone.gemfire.internal.AvailablePort;
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
-import com.gemstone.gemfire.internal.logging.InternalLogWriter;
import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
import com.gemstone.gemfire.security.generator.CredentialGenerator;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.Invoke;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
import com.gemstone.gemfire.test.dunit.SerializableRunnable;
-import com.gemstone.gemfire.test.dunit.Wait;
import com.gemstone.gemfire.test.dunit.WaitCriterion;
import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import org.junit.Test;
@@ -61,30 +59,26 @@ import org.junit.experimental.categories.Category;
@Category(DistributedTest.class)
public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestBase {
- private Map<String, String> cqNameToQueryStrings = new HashMap<String, String>();
+ private Map<String, String> cqNameToQueryStrings = new HashMap<>();
@Override
protected final void preSetUpClientAuthorizationTestBase() throws Exception {
getSystem();
- Invoke.invokeInEveryVM(new SerializableRunnable("getSystem") {
+ invokeInEveryVM(new SerializableRunnable("getSystem") {
public void run() {
getSystem();
}
});
- }
-
- @Override
- protected final void postSetUpClientAuthorizationTestBase() throws Exception {
this.cqNameToQueryStrings.put("CQ_0", "SELECT * FROM ");
this.cqNameToQueryStrings.put("CQ_1", "SELECT * FROM ");
}
@Override
public final void preTearDownClientAuthorizationTestBase() throws Exception {
- client1.invoke(() -> SecurityTestUtil.closeCache());
- client2.invoke(() -> SecurityTestUtil.closeCache());
- server1.invoke(() -> SecurityTestUtil.closeCache());
- server2.invoke(() -> SecurityTestUtil.closeCache());
+ client1.invoke(() -> closeCache());
+ client2.invoke(() -> closeCache());
+ server1.invoke(() -> closeCache());
+ server2.invoke(() -> closeCache());
this.cqNameToQueryStrings.clear();
}
@@ -97,7 +91,7 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
* Client2 does some operations on the region which satisfies both the CQs
* Validate that listeners for both the CQs are invoked.
*/
- doStartUp(Integer.valueOf(2), Integer.valueOf(5), new Boolean[] {true, true});
+ doStartUp(2, 5, new boolean[] {true, true}, false);
}
@Test
@@ -109,7 +103,7 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
* Client2 does some operations on the region which satisfies both the CQs
* Validate that listeners for none of the CQs are invoked.
*/
- doStartUp(Integer.valueOf(2), Integer.valueOf(5), new Boolean[] {false, false});
+ doStartUp(2, 5, new boolean[] {false, false}, false);
}
@Test
@@ -122,7 +116,7 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
* Client2 does some operations on the region which satisfies both the CQs
* Validate that listener for User1's CQ is invoked but that for User2's CQ is not invoked.
*/
- doStartUp(Integer.valueOf(2), Integer.valueOf(5), new Boolean[] {true, false});
+ doStartUp(2, 5, new boolean[] {true, false}, false);
}
@Test
@@ -137,14 +131,10 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
* Client2 does some operations on the region which satisfies both the CQs
* Validate that listeners for both the CQs are get updates.
*/
- doStartUp(Integer.valueOf(2), Integer.valueOf(5), new Boolean[] {true, true}, Boolean.TRUE);
- }
-
- private void doStartUp(Integer numOfUsers, Integer numOfPuts, Boolean[] postAuthzAllowed) throws Exception {
- doStartUp(numOfUsers, numOfPuts, postAuthzAllowed, Boolean.FALSE /* failover */);
+ doStartUp(2, 5, new boolean[] {true, true}, true);
}
- private void doStartUp(Integer numOfUsers, Integer numOfPuts, Boolean[] postAuthzAllowed, Boolean failover) throws Exception {
+ private void doStartUp(final int numOfUsers, final int numOfPuts, final boolean[] postAuthzAllowed, final boolean failover) throws Exception {
AuthzCredentialGenerator authzGenerator = getXmlAuthzGenerator();
CredentialGenerator credentialGenerator = authzGenerator.getCredentialGenerator();
Properties extraAuthProps = credentialGenerator.getSystemProperties();
@@ -170,78 +160,78 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
Properties[] authProps = new Properties[numOfUsers];
for (int i = 0; i < numOfUsers; i++) {
int rand = rnd.nextInt(100) + 1;
+
if (postAuthzAllowed[i]) {
- opCredentials = tgen.getAllowedCredentials(new OperationCode[] {OperationCode.EXECUTE_CQ, OperationCode.GET}, /* For callback, GET should be allowed */ new String[] {regionName}, indices, rand);
+ // For callback, GET should be allowed
+ opCredentials = tgen.getAllowedCredentials(new OperationCode[] {OperationCode.EXECUTE_CQ, OperationCode.GET}, new String[] {REGION_NAME}, indices, rand);
} else {
- opCredentials = tgen.getDisallowedCredentials(new OperationCode[] { OperationCode.GET}, /* For callback, GET should be disallowed */ new String[] {regionName}, indices, rand);
+ // For callback, GET should be disallowed
+ opCredentials = tgen.getDisallowedCredentials(new OperationCode[] { OperationCode.GET}, new String[] {REGION_NAME}, indices, rand);
}
- authProps[i] = SecurityTestUtil.concatProperties(new Properties[] {opCredentials, extraAuthProps, extraAuthzProps});
+
+ authProps[i] = concatProperties(new Properties[] {opCredentials, extraAuthProps, extraAuthzProps});
}
// Get ports for the servers
- Integer port1 = Integer.valueOf(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
- Integer port2 = Integer.valueOf(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
- Integer locatorPort = Integer.valueOf(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+ int port1 = getRandomAvailablePort(SOCKET);
+ int port2 = getRandomAvailablePort(SOCKET);
+ int locatorPort = getRandomAvailablePort(SOCKET);
// Close down any running servers
- server1.invoke(() -> SecurityTestUtil.closeCache());
- server2.invoke(() -> SecurityTestUtil.closeCache());
+ server1.invoke(() -> closeCache());
+ server2.invoke(() -> closeCache());
server1.invoke(() -> createServerCache(serverProps, javaProps, locatorPort, port1));
- client1.invoke(() -> createClientCache(javaProps2, authInit, authProps, new Integer[] {port1, port2}, numOfUsers, postAuthzAllowed));
- client2.invoke(() -> createClientCache(javaProps2, authInit, authProps, new Integer[] {port1, port2}, numOfUsers, postAuthzAllowed));
+ client1.invoke(() -> createClientCache(javaProps2, authInit, authProps, new int[] {port1, port2}, numOfUsers, postAuthzAllowed));
+ client2.invoke(() -> createClientCache(javaProps2, authInit, authProps, new int[] {port1, port2}, numOfUsers, postAuthzAllowed));
client1.invoke(() -> createCQ(numOfUsers));
- client1.invoke(() -> executeCQ(numOfUsers, new Boolean[] {false, false}, numOfPuts, new String[numOfUsers], postAuthzAllowed));
+ client1.invoke(() -> executeCQ(numOfUsers, new boolean[] {false, false}, numOfPuts, new String[numOfUsers], postAuthzAllowed));
- client2.invoke(() -> doPuts(numOfPuts, Boolean.TRUE/* put last key */));
+ client2.invoke(() -> doPuts(numOfPuts, true/* put last key */));
if (!postAuthzAllowed[0]) {
// There is no point waiting as no user is authorized to receive cq events.
try {Thread.sleep(1000);} catch (InterruptedException ie) {} // TODO: replace with Awaitility
} else {
- client1.invoke(() -> waitForLastKey(Integer.valueOf(0)));
+ client1.invoke(() -> waitForLastKey(0));
if (postAuthzAllowed[1]) {
- client1.invoke(() -> waitForLastKey(Integer.valueOf(1)));
+ client1.invoke(() -> waitForLastKey(1));
}
}
client1.invoke(() -> checkCQListeners(numOfUsers, postAuthzAllowed, numOfPuts + 1/* last key */, 0, !failover));
+
if (failover) {
server2.invoke(() -> createServerCache(serverProps, javaProps, locatorPort, port2));
- server1.invoke(() -> SecurityTestUtil.closeCache());
+ server1.invoke(() -> closeCache());
// Allow time for client1 to register its CQs on server2
- server2.invoke(() -> allowCQsToRegister(Integer.valueOf(2)));
+ server2.invoke(() -> allowCQsToRegister(2));
- client2.invoke(() -> doPuts(numOfPuts, Boolean.TRUE/* put last key */));
- client1.invoke(() -> waitForLastKeyUpdate(Integer.valueOf(0)));
- client1.invoke(() -> checkCQListeners(numOfUsers, postAuthzAllowed, numOfPuts + 1/* last key */, numOfPuts + 1/* last key */, Boolean.TRUE));
+ client2.invoke(() -> doPuts(numOfPuts, true/* put last key */));
+ client1.invoke(() -> waitForLastKeyUpdate(0));
+ client1.invoke(() -> checkCQListeners(numOfUsers, postAuthzAllowed, numOfPuts + 1/* last key */, numOfPuts + 1/* last key */, true));
}
}
- private void createServerCache(Properties serverProps, Properties javaProps, Integer serverPort) {
- Integer locatorPort = Integer.valueOf(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
- SecurityTestUtil.createCacheServer((Properties)serverProps, javaProps, locatorPort, null, serverPort, Boolean.TRUE, Integer.valueOf(SecurityTestUtil.NO_EXCEPTION));
- }
-
- private void createServerCache(Properties serverProps, Properties javaProps, Integer locatorPort, Integer serverPort) {
- SecurityTestUtil.createCacheServer((Properties)serverProps, javaProps, locatorPort, null, serverPort, Boolean.TRUE, Integer.valueOf(SecurityTestUtil.NO_EXCEPTION));
+ private void createServerCache(final Properties serverProps, final Properties javaProps, final int locatorPort, final int serverPort) {
+ SecurityTestUtil.createCacheServer(serverProps, javaProps, locatorPort, null, serverPort, true, NO_EXCEPTION);
}
- private void createClientCache(Properties javaProps, String authInit, Properties[] authProps, Integer ports[], Integer numOfUsers, Boolean[] postAuthzAllowed) {
- SecurityTestUtil.createCacheClientForMultiUserMode(numOfUsers, authInit, authProps, javaProps, ports, null, Boolean.FALSE, SecurityTestUtil.NO_EXCEPTION);
+ private void createClientCache(final Properties javaProps, final String authInit, final Properties[] authProps, final int ports[], final int numOfUsers, final boolean[] postAuthzAllowed) {
+ createCacheClientForMultiUserMode(numOfUsers, authInit, authProps, javaProps, ports, 0, false, NO_EXCEPTION);
}
- private void createCQ(Integer num) throws CqException, CqExistsException {
+ private void createCQ(final int num) throws CqException, CqExistsException {
for (int i = 0; i < num; i++) {
- QueryService cqService = SecurityTestUtil.proxyCaches[i].getQueryService();
+ QueryService cqService = getProxyCaches(i).getQueryService();
String cqName = "CQ_" + i;
- String queryStr = cqNameToQueryStrings.get(cqName) + SecurityTestUtil.proxyCaches[i].getRegion(regionName).getFullPath();
+ String queryStr = cqNameToQueryStrings.get(cqName) + getProxyCaches(i).getRegion(REGION_NAME).getFullPath();
// Create CQ Attributes.
CqAttributesFactory cqf = new CqAttributesFactory();
- CqListener[] cqListeners = {new CqQueryTestListener(LogWriterUtils.getLogWriter())};
+ CqListener[] cqListeners = {new CqQueryTestListener(getLogWriter())};
((CqQueryTestListener)cqListeners[0]).cqName = cqName;
cqf.initCqListeners(cqListeners);
@@ -253,27 +243,24 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
}
}
- private void executeCQ(Integer num, Boolean[] initialResults, Integer expectedResultsSize, String[] expectedErr, Boolean[] postAuthzAllowed) throws RegionNotFoundException {
- InternalLogWriter logWriter = InternalDistributedSystem.getStaticInternalLogWriter();
-
+ private void executeCQ(final int num, final boolean[] initialResults, final int expectedResultsSize, final String[] expectedErr, final boolean[] postAuthzAllowed) throws RegionNotFoundException, CqException {
for (int i = 0; i < num; i++) {
try {
if (expectedErr[i] != null) {
- logWriter.info("<ExpectedException action=add>" + expectedErr[i] + "</ExpectedException>");
+ getLogWriter().info("<ExpectedException action=add>" + expectedErr[i] + "</ExpectedException>");
}
CqQuery cq1 = null;
String cqName = "CQ_" + i;
- String queryStr = cqNameToQueryStrings.get(cqName) + SecurityTestUtil.proxyCaches[i].getRegion(regionName).getFullPath();
- QueryService cqService = SecurityTestUtil.proxyCaches[i].getQueryService();
+ //String queryStr = cqNameToQueryStrings.get(cqName) + getProxyCaches(i).getRegion(REGION_NAME).getFullPath();
+ QueryService cqService = getProxyCaches(i).getQueryService();
// Get CqQuery object.
cq1 = cqService.getCq(cqName);
if (cq1 == null) {
- LogWriterUtils.getLogWriter().info(
- "Failed to get CqQuery object for CQ name: " + cqName);
+ getLogWriter().info("Failed to get CqQuery object for CQ name: " + cqName);
fail("Failed to get CQ " + cqName);
} else {
- LogWriterUtils.getLogWriter().info("Obtained CQ, CQ name: " + cq1.getName());
+ getLogWriter().info("Obtained CQ, CQ name: " + cq1.getName());
assertTrue("newCq() state mismatch", cq1.getState().isStopped());
}
@@ -284,16 +271,17 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
cqResults = cq1.executeWithInitialResults();
} catch (CqException ce) {
if (ce.getCause() instanceof NotAuthorizedException && !postAuthzAllowed[i]) {
- LogWriterUtils.getLogWriter().info("Got expected exception for CQ " + cqName);
+ getLogWriter().info("Got expected exception for CQ " + cqName);
} else {
- LogWriterUtils.getLogWriter().info("CqService is: " + cqService);
+ getLogWriter().info("CqService is: " + cqService);
throw new AssertionError("Failed to execute CQ " + cqName, ce);
}
}
- LogWriterUtils.getLogWriter().info("initial result size = " + cqResults.size());
+
+ getLogWriter().info("initial result size = " + cqResults.size());
assertTrue("executeWithInitialResults() state mismatch", cq1.getState().isRunning());
if (expectedResultsSize >= 0) {
- assertEquals("unexpected results size", expectedResultsSize.intValue(), cqResults.size());
+ assertEquals("unexpected results size", expectedResultsSize, cqResults.size());
}
} else {
@@ -302,34 +290,24 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
cq1.execute();
} catch (CqException ce) {
if (ce.getCause() instanceof NotAuthorizedException && !postAuthzAllowed[i]) {
- LogWriterUtils.getLogWriter().info("Got expected exception for CQ " + cqName);
+ getLogWriter().info("Got expected exception for CQ " + cqName);
} else {
- LogWriterUtils.getLogWriter().info("CqService is: " + cqService);
- ce.printStackTrace();
- throw new AssertionError("Failed to execute CQ " + cqName, ce);
- }
-
- } catch (Exception ex) {
- AssertionError err = new AssertionError("Failed to execute CQ "
- + cqName);
- err.initCause(ex);
- if (expectedErr == null) {
- LogWriterUtils.getLogWriter().info("CqService is: " + cqService, err);
+ throw ce;
}
- throw err;
}
+
assertTrue("execute() state mismatch", cq1.getState().isRunning() == postAuthzAllowed[i]);
}
} finally {
if (expectedErr[i] != null) {
- logWriter.info("<ExpectedException action=remove>" + expectedErr[i] + "</ExpectedException>");
+ getLogWriter().info("<ExpectedException action=remove>" + expectedErr[i] + "</ExpectedException>");
}
}
}
}
- private void doPuts(Integer num, Boolean putLastKey) {
- Region region = SecurityTestUtil.proxyCaches[0].getRegion(regionName);
+ private void doPuts(final int num, final boolean putLastKey) {
+ Region region = getProxyCaches(0).getRegion(REGION_NAME);
for (int i = 0; i < num; i++) {
region.put("CQ_key"+i, "CQ_value"+i);
}
@@ -338,28 +316,24 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
}
}
- private void putLastKey() {
- Region region = GemFireCacheImpl.getInstance().getRegion(regionName);
- region.put("LAST_KEY", "LAST_KEY");
- }
-
- private void waitForLastKey(Integer cqIndex) {
+ private void waitForLastKey(final int cqIndex) {
String cqName = "CQ_" + cqIndex;
- QueryService qService = SecurityTestUtil.proxyCaches[cqIndex].getQueryService();
+ QueryService qService = SecurityTestUtil.getProxyCaches(cqIndex).getQueryService();
ClientCQImpl cqQuery = (ClientCQImpl)qService.getCq(cqName);
((CqQueryTestListener)cqQuery.getCqListeners()[0]).waitForCreated("LAST_KEY");
}
- private void waitForLastKeyUpdate(Integer cqIndex) {
+ private void waitForLastKeyUpdate(final int cqIndex) {
String cqName = "CQ_" + cqIndex;
- QueryService qService = SecurityTestUtil.proxyCaches[cqIndex].getQueryService();
+ QueryService qService = getProxyCaches(cqIndex).getQueryService();
ClientCQImpl cqQuery = (ClientCQImpl)qService.getCq(cqName);
((CqQueryTestListener)cqQuery.getCqListeners()[0]).waitForUpdated("LAST_KEY");
}
- private void allowCQsToRegister(Integer number) {
+ private void allowCQsToRegister(final int number) {
final int num = number;
WaitCriterion wc = new WaitCriterion() {
+ @Override
public boolean done() {
CqService cqService = GemFireCacheImpl.getInstance().getCqService();
cqService.start();
@@ -370,24 +344,24 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
return false;
}
}
-
+ @Override
public String description() {
return num + "Waited for " + num + " CQs to be registered on this server.";
}
};
- Wait.waitForCriterion(wc, 60 * 1000, 100, false);
+ waitForCriterion(wc, 60 * 1000, 100, false);
}
- private void checkCQListeners(Integer numOfUsers, Boolean[] expectedListenerInvocation, Integer createEventsSize, Integer updateEventsSize, Boolean closeCache) {
+ private boolean checkCQListeners(final int numOfUsers, final boolean[] expectedListenerInvocation, final int createEventsSize, final int updateEventsSize, final boolean closeCache) {
for (int i = 0; i < numOfUsers; i++) {
String cqName = "CQ_" + i;
- QueryService qService = SecurityTestUtil.proxyCaches[i].getQueryService();
+ QueryService qService = getProxyCaches(i).getQueryService();
ClientCQImpl cqQuery = (ClientCQImpl)qService.getCq(cqName);
if (expectedListenerInvocation[i]) {
for (CqListener listener : cqQuery.getCqListeners()) {
- assertEquals(createEventsSize.intValue(), ((CqQueryTestListener)listener).getCreateEventCount());
- assertEquals(updateEventsSize.intValue(), ((CqQueryTestListener)listener).getUpdateEventCount());
+ assertEquals(createEventsSize, ((CqQueryTestListener)listener).getCreateEventCount());
+ assertEquals(updateEventsSize, ((CqQueryTestListener)listener).getUpdateEventCount());
}
} else {
for (CqListener listener : cqQuery.getCqListeners()) {
@@ -395,8 +369,9 @@ public class ClientCQPostAuthorizationDUnitTest extends ClientAuthorizationTestB
}
}
if (closeCache) {
- SecurityTestUtil.proxyCaches[i].close();
+ getProxyCaches(i).close();
}
}
+ return true;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
index 931a53e..b234741 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/ClientPostAuthorizationDUnitTest.java
@@ -16,6 +16,9 @@
*/
package com.gemstone.gemfire.security;
+import static com.gemstone.gemfire.security.SecurityTestUtil.*;
+import static com.gemstone.gemfire.test.dunit.LogWriterUtils.*;
+
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -26,8 +29,6 @@ import com.gemstone.gemfire.cache.operations.OperationContext.OperationCode;
import com.gemstone.gemfire.internal.AvailablePort;
import com.gemstone.gemfire.security.generator.AuthzCredentialGenerator;
import com.gemstone.gemfire.security.generator.CredentialGenerator;
-import com.gemstone.gemfire.test.dunit.Host;
-import com.gemstone.gemfire.test.dunit.LogWriterUtils;
import com.gemstone.gemfire.test.junit.Retry;
import com.gemstone.gemfire.test.junit.categories.DistributedTest;
import com.gemstone.gemfire.test.junit.rules.RetryRule;
@@ -43,26 +44,14 @@ import org.junit.experimental.categories.Category;
* @since 5.5
*/
@Category(DistributedTest.class)
-public class ClientPostAuthorizationDUnitTest extends
- ClientAuthorizationTestBase {
+public class ClientPostAuthorizationDUnitTest extends ClientAuthorizationTestBase {
@Rule
public RetryRule retryRule = new RetryRule();
- @Override
- public final void preTearDownClientAuthorizationTestBase() throws Exception {
- // close the clients first
- client1.invoke(() -> SecurityTestUtil.closeCache());
- client2.invoke(() -> SecurityTestUtil.closeCache());
- SecurityTestUtil.closeCache();
- // then close the servers
- server1.invoke(() -> SecurityTestUtil.closeCache());
- server2.invoke(() -> SecurityTestUtil.closeCache());
- }
-
@Test
@Retry(2)
- public void testAllPostOps() {
+ public void testAllPostOps() throws Exception {
OperationWithAction[] allOps = allOpsForTestAllPostOps();
for (Iterator iter = getDummyGeneratorCombos().iterator(); iter.hasNext();) {
@@ -77,41 +66,39 @@ public class ClientPostAuthorizationDUnitTest extends
String accessor = gen.getAuthorizationCallback();
TestAuthzCredentialGenerator tgen = new TestAuthzCredentialGenerator(gen);
- LogWriterUtils.getLogWriter().info("testAllPostOps: Using authinit: " + authInit);
- LogWriterUtils.getLogWriter().info("testAllPostOps: Using authenticator: " + authenticator);
- LogWriterUtils.getLogWriter().info("testAllPostOps: Using accessor: " + accessor);
+ getLogWriter().info("testAllPostOps: Using authinit: " + authInit);
+ getLogWriter().info("testAllPostOps: Using authenticator: " + authenticator);
+ getLogWriter().info("testAllPostOps: Using accessor: " + accessor);
// Start servers with all required properties
Properties serverProps = buildProperties(authenticator, accessor, true, extraAuthProps, extraAuthzProps);
// Get ports for the servers
- Integer port1 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
- Integer port2 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+ Integer port1 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+ Integer port2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
// Close down any running servers
- server1.invoke(() -> SecurityTestUtil.closeCache());
- server2.invoke(() -> SecurityTestUtil.closeCache());
+ server1.invoke(() -> closeCache());
+ server2.invoke(() -> closeCache());
// Perform all the ops on the clients
List opBlock = new ArrayList();
Random rnd = new Random();
for (int opNum = 0; opNum < allOps.length; ++opNum) {
- // Start client with valid credentials as specified in
- // OperationWithAction
+ // Start client with valid credentials as specified in OperationWithAction
OperationWithAction currentOp = allOps[opNum];
if (currentOp.equals(OperationWithAction.OPBLOCK_END) || currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
- // End of current operation block; execute all the operations
- // on the servers with failover
+ // End of current operation block; execute all the operations on the servers with failover
if (opBlock.size() > 0) {
// Start the first server and execute the operation block
- server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port1, serverProps, javaProps ));
- server2.invoke(() -> SecurityTestUtil.closeCache());
+ server1.invoke(() -> createCacheServer(getLocatorPort(), port1, serverProps, javaProps ));
+ server2.invoke(() -> closeCache());
executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
// Failover to the second server and run the block again
- server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port2, serverProps, javaProps ));
- server1.invoke(() -> SecurityTestUtil.closeCache());
+ server2.invoke(() -> createCacheServer(SecurityTestUtil.getLocatorPort(), port2, serverProps, javaProps ));
+ server1.invoke(() -> closeCache());
executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
}
opBlock.clear();
@@ -126,11 +113,13 @@ public class ClientPostAuthorizationDUnitTest extends
}
@Test
- public void testAllOpsNotifications() {
+ public void testAllOpsNotifications() throws Exception {
OperationWithAction[] allOps = allOpsForTestAllOpsNotifications();
AuthzCredentialGenerator authzGenerator = getXmlAuthzGenerator();
- LogWriterUtils.getLogWriter().info("Executing opblocks with credential generator " + authzGenerator);
+
+ getLogWriter().info("Executing opblocks with credential generator " + authzGenerator);
+
CredentialGenerator credentialGenerator = authzGenerator.getCredentialGenerator();
Properties extraAuthProps = credentialGenerator.getSystemProperties();
Properties javaProps = credentialGenerator.getJavaProperties();
@@ -140,36 +129,34 @@ public class ClientPostAuthorizationDUnitTest extends
String accessor = authzGenerator.getAuthorizationCallback();
TestAuthzCredentialGenerator tgen = new TestAuthzCredentialGenerator(authzGenerator);
- LogWriterUtils.getLogWriter().info("testAllOpsNotifications: Using authinit: " + authInit);
- LogWriterUtils.getLogWriter().info("testAllOpsNotifications: Using authenticator: " + authenticator);
- LogWriterUtils.getLogWriter().info("testAllOpsNotifications: Using accessor: " + accessor);
+ getLogWriter().info("testAllOpsNotifications: Using authinit: " + authInit);
+ getLogWriter().info("testAllOpsNotifications: Using authenticator: " + authenticator);
+ getLogWriter().info("testAllOpsNotifications: Using accessor: " + accessor);
// Start servers with all required properties
Properties serverProps = buildProperties(authenticator, accessor, true, extraAuthProps, extraAuthzProps);
// Get ports for the servers
- Integer port1 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
- Integer port2 = new Integer(AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET));
+ Integer port1 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
+ Integer port2 = AvailablePort.getRandomAvailablePort(AvailablePort.SOCKET);
// Perform all the ops on the clients
List opBlock = new ArrayList();
Random rnd = new Random();
for (int opNum = 0; opNum < allOps.length; ++opNum) {
- // Start client with valid credentials as specified in
- // OperationWithAction
+ // Start client with valid credentials as specified in OperationWithAction
OperationWithAction currentOp = allOps[opNum];
if (currentOp.equals(OperationWithAction.OPBLOCK_END) || currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
- // End of current operation block; execute all the operations
- // on the servers with failover
+ // End of current operation block; execute all the operations on the servers with failover
if (opBlock.size() > 0) {
// Start the first server and execute the operation block
- server1.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port1, serverProps, javaProps ));
- server2.invoke(() -> SecurityTestUtil.closeCache());
+ server1.invoke(() -> createCacheServer(getLocatorPort(), port1, serverProps, javaProps ));
+ server2.invoke(() -> closeCache());
executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
if (!currentOp.equals(OperationWithAction.OPBLOCK_NO_FAILOVER)) {
// Failover to the second server and run the block again
- server2.invoke(() -> ClientAuthorizationTestBase.createCacheServer(SecurityTestUtil.getLocatorPort(), port2, serverProps, javaProps ));
- server1.invoke(() -> SecurityTestUtil.closeCache());
+ server2.invoke(() -> createCacheServer(getLocatorPort(), port2, serverProps, javaProps ));
+ server1.invoke(() -> closeCache());
executeOpBlock(opBlock, port1, port2, authInit, extraAuthProps, extraAuthzProps, tgen, rnd);
}
opBlock.clear();
@@ -189,8 +176,7 @@ public class ClientPostAuthorizationDUnitTest extends
new OperationWithAction(OperationCode.GET, 2, OpFlags.CHECK_NOKEY, 4),
new OperationWithAction(OperationCode.GET, 3, OpFlags.CHECK_NOKEY | OpFlags.CHECK_NOTAUTHZ, 4),
- // OPBLOCK_END indicates end of an operation block that needs to
- // be executed on each server when doing failover
+ // OPBLOCK_END indicates end of an operation block that needs to be executed on each server when doing failover
OperationWithAction.OPBLOCK_END,
// Test UPDATE and verify with a GET
@@ -219,59 +205,40 @@ public class ClientPostAuthorizationDUnitTest extends
new OperationWithAction(OperationCode.EXECUTE_CQ, 2, OpFlags.NONE, 8),
new OperationWithAction(OperationCode.EXECUTE_CQ, 3, OpFlags.CHECK_NOTAUTHZ, 8),
- OperationWithAction.OPBLOCK_END };
+ OperationWithAction.OPBLOCK_END
+ };
}
private OperationWithAction[] allOpsForTestAllOpsNotifications() {
return new OperationWithAction[]{
// Test CREATE and verify with a GET
- new OperationWithAction(OperationCode.REGISTER_INTEREST,
- OperationCode.GET, 2, OpFlags.USE_REGEX
- | OpFlags.REGISTER_POLICY_NONE, 8),
- new OperationWithAction(OperationCode.REGISTER_INTEREST,
- OperationCode.GET, 3, OpFlags.USE_REGEX
- | OpFlags.REGISTER_POLICY_NONE | OpFlags.USE_NOTAUTHZ, 8),
+ new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 2, OpFlags.USE_REGEX | OpFlags.REGISTER_POLICY_NONE, 8),
+ new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 3, OpFlags.USE_REGEX | OpFlags.REGISTER_POLICY_NONE | OpFlags.USE_NOTAUTHZ, 8),
new OperationWithAction(OperationCode.PUT),
- new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
- | OpFlags.LOCAL_OP, 4),
- new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
- | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 4),
+ new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 4),
+ new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 4),
- // OPBLOCK_END indicates end of an operation block that needs to
- // be executed on each server when doing failover
+ // OPBLOCK_END indicates end of an operation block that needs to be executed on each server when doing failover
OperationWithAction.OPBLOCK_END,
// Test UPDATE and verify with a GET
- new OperationWithAction(OperationCode.REGISTER_INTEREST,
- OperationCode.GET, 2, OpFlags.USE_REGEX
- | OpFlags.REGISTER_POLICY_NONE, 8),
- new OperationWithAction(OperationCode.REGISTER_INTEREST,
- OperationCode.GET, 3, OpFlags.USE_REGEX
- | OpFlags.REGISTER_POLICY_NONE | OpFlags.USE_NOTAUTHZ, 8),
- new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN
- | OpFlags.USE_NEWVAL, 4),
- new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
- | OpFlags.LOCAL_OP | OpFlags.USE_NEWVAL, 4),
- new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
- | OpFlags.LOCAL_OP | OpFlags.USE_NEWVAL | OpFlags.CHECK_FAIL, 4),
+ new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 2, OpFlags.USE_REGEX | OpFlags.REGISTER_POLICY_NONE, 8),
+ new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 3, OpFlags.USE_REGEX | OpFlags.REGISTER_POLICY_NONE | OpFlags.USE_NOTAUTHZ, 8),
+ new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN | OpFlags.USE_NEWVAL, 4),
+ new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.USE_NEWVAL, 4),
+ new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.USE_NEWVAL | OpFlags.CHECK_FAIL, 4),
OperationWithAction.OPBLOCK_END,
// Test DESTROY and verify with GET that KEYS should not exist
new OperationWithAction(OperationCode.PUT, 3, OpFlags.NONE, 8),
- new OperationWithAction(OperationCode.REGISTER_INTEREST,
- OperationCode.GET, 2, OpFlags.USE_REGEX, 8),
- new OperationWithAction(OperationCode.REGISTER_INTEREST, 3,
- OpFlags.USE_REGEX | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 8),
- // registerInterest now clears the KEYS, so a dummy put to add
- // those KEYS back for the case when updates should not come
+ new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 2, OpFlags.USE_REGEX, 8),
+ new OperationWithAction(OperationCode.REGISTER_INTEREST, 3, OpFlags.USE_REGEX | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 8),
+ // registerInterest now clears the KEYS, so a dummy put to add those KEYS back for the case when updates should not come
new OperationWithAction(OperationCode.PUT, 3, OpFlags.USE_OLDCONN, 8),
- new OperationWithAction(OperationCode.DESTROY, 1, OpFlags.USE_OLDCONN,
- 4),
- new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
- | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 4),
- new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
- | OpFlags.LOCAL_OP, 4),
+ new OperationWithAction(OperationCode.DESTROY, 1, OpFlags.USE_OLDCONN, 4),
+ new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 4),
+ new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 4),
// Repopulate the region
new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN, 8),
@@ -279,75 +246,46 @@ public class ClientPostAuthorizationDUnitTest extends
// Do REGION_CLEAR and check with GET
new OperationWithAction(OperationCode.PUT, 3, OpFlags.NONE, 8),
- new OperationWithAction(OperationCode.REGISTER_INTEREST,
- OperationCode.GET, 2, OpFlags.USE_ALL_KEYS, 1),
- new OperationWithAction(OperationCode.REGISTER_INTEREST, 3,
- OpFlags.USE_ALL_KEYS | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 1),
- // registerInterest now clears the KEYS, so a dummy put to add
- // those KEYS back for the case when updates should not come
+ new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 2, OpFlags.USE_ALL_KEYS, 1),
+ new OperationWithAction(OperationCode.REGISTER_INTEREST, 3, OpFlags.USE_ALL_KEYS | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 1),
+ // registerInterest now clears the KEYS, so a dummy put to add those KEYS back for the case when updates should not come
new OperationWithAction(OperationCode.PUT, 3, OpFlags.USE_OLDCONN, 8),
- new OperationWithAction(OperationCode.REGION_CLEAR, 1,
- OpFlags.USE_OLDCONN, 1),
- new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
- | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 8),
- new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
- | OpFlags.LOCAL_OP, 8),
+ new OperationWithAction(OperationCode.REGION_CLEAR, 1, OpFlags.USE_OLDCONN, 1),
+ new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.CHECK_FAIL, 8),
+ new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 8),
// Repopulate the region
new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN, 8),
OperationWithAction.OPBLOCK_END,
// Do REGION_CREATE and check with CREATE/GET
- new OperationWithAction(OperationCode.REGISTER_INTEREST,
- OperationCode.GET, 2, OpFlags.USE_ALL_KEYS | OpFlags.ENABLE_DRF, 1),
- new OperationWithAction(OperationCode.REGISTER_INTEREST,
- OperationCode.GET, 3, OpFlags.USE_ALL_KEYS | OpFlags.ENABLE_DRF
- | OpFlags.USE_NOTAUTHZ | OpFlags.REGISTER_POLICY_NONE, 1),
- new OperationWithAction(OperationCode.REGION_CREATE, 1,
- OpFlags.ENABLE_DRF, 1),
- new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN
- | OpFlags.USE_SUBREGION, 4),
- new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
- | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION
- | OpFlags.NO_CREATE_SUBREGION, 4),
- new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
- | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION
- | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
+ new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 2, OpFlags.USE_ALL_KEYS | OpFlags.ENABLE_DRF, 1),
+ new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 3, OpFlags.USE_ALL_KEYS | OpFlags.ENABLE_DRF | OpFlags.USE_NOTAUTHZ | OpFlags.REGISTER_POLICY_NONE, 1),
+ new OperationWithAction(OperationCode.REGION_CREATE, 1, OpFlags.ENABLE_DRF, 1),
+ new OperationWithAction(OperationCode.PUT, 1, OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION, 4),
+ new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION | OpFlags.NO_CREATE_SUBREGION, 4),
+ new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
// Do REGION_DESTROY of the sub-region and check with GET
- new OperationWithAction(OperationCode.REGION_DESTROY, 1,
- OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION, 1),
- new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
- | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION
- | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
- new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
- | OpFlags.USE_SUBREGION | OpFlags.CHECK_NOKEY
- | OpFlags.CHECK_EXCEPTION, 4),
- new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
- | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION
- | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
- new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
- | OpFlags.USE_SUBREGION | OpFlags.CHECK_NOKEY
- | OpFlags.CHECK_EXCEPTION, 4),
+ new OperationWithAction(OperationCode.REGION_DESTROY, 1, OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION, 1),
+ new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
+ new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION | OpFlags.CHECK_NOKEY | OpFlags.CHECK_EXCEPTION, 4),
+ new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.USE_SUBREGION | OpFlags.NO_CREATE_SUBREGION | OpFlags.CHECK_NOREGION, 4),
+ new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.USE_SUBREGION | OpFlags.CHECK_NOKEY | OpFlags.CHECK_EXCEPTION, 4),
OperationWithAction.OPBLOCK_END,
// Do REGION_DESTROY of the region and check with GET
new OperationWithAction(OperationCode.PUT, 3, OpFlags.NONE, 8),
- new OperationWithAction(OperationCode.REGISTER_INTEREST,
- OperationCode.GET, 2, OpFlags.USE_ALL_KEYS, 1),
- new OperationWithAction(OperationCode.REGISTER_INTEREST, 3,
- OpFlags.USE_ALL_KEYS | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 1),
- // registerInterest now clears the KEYS, so a dummy put to add
- // those KEYS back for the case when updates should not come
+ new OperationWithAction(OperationCode.REGISTER_INTEREST, OperationCode.GET, 2, OpFlags.USE_ALL_KEYS, 1),
+ new OperationWithAction(OperationCode.REGISTER_INTEREST, 3, OpFlags.USE_ALL_KEYS | OpFlags.USE_OLDCONN | OpFlags.REGISTER_POLICY_NONE, 1),
+ // registerInterest now clears the KEYS, so a dummy put to add those KEYS back for the case when updates should not come
new OperationWithAction(OperationCode.PUT, 3, OpFlags.USE_OLDCONN, 8),
- new OperationWithAction(OperationCode.REGION_DESTROY, 1, OpFlags.NONE,
- 1),
- new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN
- | OpFlags.LOCAL_OP | OpFlags.CHECK_NOREGION, 4),
- new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN
- | OpFlags.LOCAL_OP, 4),
-
- OperationWithAction.OPBLOCK_NO_FAILOVER};
+ new OperationWithAction(OperationCode.REGION_DESTROY, 1, OpFlags.NONE, 1),
+ new OperationWithAction(OperationCode.GET, 2, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP | OpFlags.CHECK_NOREGION, 4),
+ new OperationWithAction(OperationCode.GET, 3, OpFlags.USE_OLDCONN | OpFlags.LOCAL_OP, 4),
+
+ OperationWithAction.OPBLOCK_NO_FAILOVER
+ };
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java
index 3cf8cac..931cc6d 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserAPIDUnitTest.java
@@ -106,7 +106,7 @@ public class MultiUserAPIDUnitTest extends ClientAuthorizationTestBase {
} else { // multiuser mode
Region realRegion = GemFireCacheImpl.getInstance().getRegion(SecurityTestUtil.REGION_NAME);
- Region proxyRegion = SecurityTestUtil.proxyCaches[0].getRegion(SecurityTestUtil.REGION_NAME);
+ Region proxyRegion = SecurityTestUtil.getProxyCaches(0).getRegion(SecurityTestUtil.REGION_NAME);
Pool pool = PoolManagerImpl.getPMI().find("testPool");
for (int i = 0; i <= 27; i++) {
@@ -235,15 +235,15 @@ public class MultiUserAPIDUnitTest extends ClientAuthorizationTestBase {
// expect an exception, fail otherwise.
case 23:
op = "ProxyQueryService().getIndexes()";
- SecurityTestUtil.proxyCaches[0].getQueryService().getIndexes(null);
+ SecurityTestUtil.getProxyCaches(0).getQueryService().getIndexes(null);
break;
case 24:
op = "ProxyQueryService().createIndex()";
- SecurityTestUtil.proxyCaches[0].getQueryService().createIndex(null, null, null );
+ SecurityTestUtil.getProxyCaches(0).getQueryService().createIndex(null, null, null );
break;
case 25:
op = "ProxyQueryService().removeIndexes()";
- SecurityTestUtil.proxyCaches[0].getQueryService().removeIndexes();
+ SecurityTestUtil.getProxyCaches(0).getQueryService().removeIndexes();
break;
case 26:
op = "ProxyRegion.localDestroy()";
@@ -280,40 +280,44 @@ public class MultiUserAPIDUnitTest extends ClientAuthorizationTestBase {
getLogWriter().info("testValidCredentials: Using authinit: " + authInit);
// Start the servers
- Integer locPort1 = SecurityTestUtil.getLocatorPort();
- Integer locPort2 = SecurityTestUtil.getLocatorPort();
+ int locPort1 = SecurityTestUtil.getLocatorPort();
+ int locPort2 = SecurityTestUtil.getLocatorPort();
String locString = SecurityTestUtil.getLocatorString();
- Integer port1 = (Integer)server1.invoke(() -> createCacheServer(locPort1, locString, authenticator, extraProps, javaProps));
- Integer port2 = (Integer)server2.invoke(() -> createCacheServer(locPort2, locString, authenticator, extraProps, javaProps));
+
+ int port1 = server1.invoke(() -> createCacheServer(locPort1, locString, authenticator, extraProps, javaProps));
+ int port2 = server2.invoke(() -> createCacheServer(locPort2, locString, authenticator, extraProps, javaProps));
// Start the clients with valid credentials
Properties credentials1 = gen.getValidCredentials(1);
Properties javaProps1 = gen.getJavaProperties();
getLogWriter().info("testValidCredentials: For first client credentials: " + credentials1 + " : " + javaProps1);
+
Properties credentials2 = gen.getValidCredentials(2);
Properties javaProps2 = gen.getJavaProperties();
getLogWriter().info("testValidCredentials: For second client credentials: " + credentials2 + " : " + javaProps2);
- client1.invoke(() -> createCacheClient(authInit, credentials1, javaProps1, port1, port2, null, multiUser, new Integer(SecurityTestUtil.NO_EXCEPTION)));
+
+ client1.invoke(() -> createCacheClient(authInit, credentials1, javaProps1, port1, port2, 0, multiUser, NO_EXCEPTION));
}
- private Integer createCacheServer(Object dsPort, Object locatorString, Object authenticator, Object extraProps, Object javaProps) {
+ private Integer createCacheServer(int dsPort, String locatorString, String authenticator, Properties extraProps, Properties javaProps) {
Properties authProps = new Properties();
if (extraProps != null) {
- authProps.putAll((Properties)extraProps);
+ authProps.putAll(extraProps);
}
if (authenticator != null) {
authProps.setProperty(DistributionConfig.SECURITY_CLIENT_AUTHENTICATOR_NAME, authenticator.toString());
}
- return SecurityTestUtil.createCacheServer(authProps, javaProps, (Integer)dsPort, (String)locatorString, null, new Integer(SecurityTestUtil.NO_EXCEPTION));
+ return SecurityTestUtil.createCacheServer(authProps, javaProps, dsPort, locatorString, 0, NO_EXCEPTION);
}
- private void createCacheClient(Object authInit, Object authProps, Object javaProps, Integer port1, Integer port2, Object numConnections, Boolean multiUserMode, Integer expectedResult) {
- createCacheClient(authInit, (Properties)authProps, (Properties)javaProps, new Integer[] {port1, port2}, numConnections, multiUserMode, expectedResult);
+ // a
+ protected static void createCacheClient(String authInit, Properties authProps, Properties javaProps, int[] ports, int numConnections, boolean multiUserMode, int expectedResult) {
+ SecurityTestUtil.createCacheClient(authInit, authProps, javaProps, ports, numConnections, multiUserMode, expectedResult); // invokes SecurityTestUtil 2
}
- private void createCacheClient(Object authInit, Properties authProps, Properties javaProps, Integer[] ports, Object numConnections, Boolean multiUserMode, Integer expectedResult) {
- String authInitStr = (authInit == null ? null : authInit.toString());
- SecurityTestUtil.createCacheClient(authInitStr, authProps, javaProps, ports, numConnections, multiUserMode.toString(), expectedResult);
+ // b
+ private void createCacheClient(String authInit, Properties authProps, Properties javaProps, int port1, int port2, int numConnections, boolean multiUserMode, int expectedResult) {
+ createCacheClient(authInit, authProps, javaProps, new int[] {port1, port2}, numConnections, multiUserMode, expectedResult); // invokes a
}
}
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/4f6a5311/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java
index 9c32a77..c425969 100644
--- a/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java
+++ b/geode-cq/src/test/java/com/gemstone/gemfire/security/MultiuserDurableCQAuthzDUnitTest.java
@@ -88,9 +88,9 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
* 7. Confirm that the users receive the events which were enqueued at server while they were away.
* 8. Same for ProxyCache.close()
*/
- Integer numOfUsers = 2;
- Integer numOfPuts = 5;
- Boolean[] postAuthzAllowed = new Boolean[] {Boolean.TRUE, Boolean.TRUE};
+ int numOfUsers = 2;
+ int numOfPuts = 5;
+ boolean[] postAuthzAllowed = new boolean[] {true, true};
doTest(numOfUsers, numOfPuts, postAuthzAllowed, getXmlAuthzGenerator(), null);
}
@@ -107,9 +107,9 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
* 7. Observer the behaviour.
* 8. Same for ProxyCache.close(false)
*/
- Integer numOfUsers = 2;
- Integer numOfPuts = 5;
- Boolean[] postAuthzAllowed = new Boolean[] {Boolean.TRUE, Boolean.TRUE};
+ int numOfUsers = 2;
+ int numOfPuts = 5;
+ boolean[] postAuthzAllowed = new boolean[] {true, true};
doTest(numOfUsers, numOfPuts, postAuthzAllowed, getXmlAuthzGenerator(), Boolean.TRUE);
}
@@ -126,14 +126,14 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
* 7. Observer the behaviour.
* 8. Same for ProxyCache.close(true)
*/
- Integer numOfUsers = 2;
- Integer numOfPuts = 5;
- Boolean[] postAuthzAllowed = new Boolean[] {Boolean.TRUE, Boolean.TRUE};
+ int numOfUsers = 2;
+ int numOfPuts = 5;
+ boolean[] postAuthzAllowed = new boolean[] {true, true};
doTest(numOfUsers, numOfPuts, postAuthzAllowed, getXmlAuthzGenerator(), Boolean.FALSE);
}
- private void doTest(Integer numOfUsers, Integer numOfPuts, Boolean[] postAuthzAllowed, AuthzCredentialGenerator authzGenerator, Boolean keepAlive) throws Exception {
+ private void doTest(int numOfUsers, int numOfPuts, boolean[] postAuthzAllowed, final AuthzCredentialGenerator authzGenerator, final Boolean keepAlive) throws Exception {
CredentialGenerator credentialGenerator = authzGenerator.getCredentialGenerator();
Properties extraAuthProps = credentialGenerator.getSystemProperties();
Properties javaProps = credentialGenerator.getJavaProperties();
@@ -198,10 +198,10 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
server2.invoke(() -> SecurityTestUtil.closeCache());
server1.invoke(() -> createServerCache(serverProps, javaProps, locatorPort, port1));
- client1.invoke(() -> createClientCache(javaProps2, authInit, authProps, new Integer[] {port1, port2}, numOfUsers, durableClientId, postAuthzAllowed));
+ client1.invoke(() -> createClientCache(javaProps2, authInit, authProps, new int[] {port1, port2}, numOfUsers, durableClientId, postAuthzAllowed));
client1.invoke(() -> createCQ(numOfUsers, Boolean.TRUE));
- client1.invoke(() -> executeCQ(numOfUsers, new Boolean[] {false, false}, numOfPuts, new String[numOfUsers]));
+ client1.invoke(() -> executeCQ(numOfUsers, new boolean[] {false, false}, numOfPuts, new String[numOfUsers]));
client1.invoke(() -> readyForEvents());
if (keepAlive == null) {
@@ -212,9 +212,9 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
server1.invoke(() -> doPuts(numOfPuts, Boolean.TRUE/* put last key */));
- client1.invoke(() -> createClientCache(javaProps2, authInit, authProps, new Integer[] {port1, port2}, numOfUsers, durableClientId, postAuthzAllowed));
+ client1.invoke(() -> createClientCache(javaProps2, authInit, authProps, new int[] {port1, port2}, numOfUsers, durableClientId, postAuthzAllowed));
client1.invoke(() -> createCQ(numOfUsers, Boolean.TRUE));
- client1.invoke(() ->executeCQ(numOfUsers, new Boolean[] {false, false}, numOfPuts, new String[numOfUsers]));
+ client1.invoke(() ->executeCQ(numOfUsers, new boolean[] {false, false}, numOfPuts, new String[numOfUsers]));
client1.invoke(() -> readyForEvents());
if (!postAuthzAllowed[0] || keepAlive == null || !keepAlive) {
@@ -226,10 +226,10 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
Integer numOfCreates = keepAlive == null ? 0 : (keepAlive ? numOfPuts + 1/* last key */ : 0);
client1.invoke(() -> checkCQListeners(numOfUsers, postAuthzAllowed, numOfCreates, 0));
- client1.invoke(() -> proxyCacheClose(new Integer[] {0, 1}, keepAlive));
+ client1.invoke(() -> proxyCacheClose(new int[] {0, 1}, keepAlive));
client1.invoke(() -> SecurityTestUtil.createProxyCache(new Integer[] {0, 1}, authProps));
client1.invoke(() -> createCQ(numOfUsers, Boolean.TRUE));
- client1.invoke(() -> executeCQ(numOfUsers, new Boolean[] {false, false}, numOfPuts, new String[numOfUsers]));
+ client1.invoke(() -> executeCQ(numOfUsers, new boolean[] {false, false}, numOfPuts, new String[numOfUsers]));
server1.invoke(() -> doPuts(numOfPuts, Boolean.TRUE/* put last key */));
@@ -245,30 +245,30 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
}
private void createServerCache(Properties serverProps, Properties javaProps, Integer locatorPort, Integer serverPort) {
- SecurityTestUtil.createCacheServer((Properties)serverProps, javaProps, locatorPort, null, serverPort, Boolean.TRUE, new Integer(SecurityTestUtil.NO_EXCEPTION));
+ SecurityTestUtil.createCacheServer((Properties)serverProps, javaProps, locatorPort, null, serverPort, true, NO_EXCEPTION);
}
- private void createClientCache(Properties javaProps, String authInit, Properties[] authProps, Integer ports[], Integer numOfUsers, Boolean[] postAuthzAllowed) {
- SecurityTestUtil.createCacheClientForMultiUserMode(numOfUsers, authInit, authProps, javaProps, ports, null, Boolean.FALSE, SecurityTestUtil.NO_EXCEPTION);
+ private void createClientCache(Properties javaProps, String authInit, Properties[] authProps, int ports[], int numOfUsers, boolean[] postAuthzAllowed) {
+ SecurityTestUtil.createCacheClientForMultiUserMode(numOfUsers, authInit, authProps, javaProps, ports, 0, false, NO_EXCEPTION);
}
private void readyForEvents() {
GemFireCacheImpl.getInstance().readyForEvents();
}
- private void createClientCache(Properties javaProps, String authInit, Properties[] authProps, Integer ports[], Integer numOfUsers, String durableId, Boolean[] postAuthzAllowed) {
- SecurityTestUtil.createCacheClientForMultiUserMode(numOfUsers, authInit, authProps, javaProps, ports, null, Boolean.FALSE, durableId, SecurityTestUtil.NO_EXCEPTION);
+ private void createClientCache(Properties javaProps, String authInit, Properties[] authProps, int ports[], int numOfUsers, String durableId, boolean[] postAuthzAllowed) {
+ SecurityTestUtil.createCacheClientForMultiUserMode(numOfUsers, authInit, authProps, javaProps, ports, 0, false, durableId, NO_EXCEPTION);
}
private void createCQ(Integer num) throws CqException, CqExistsException {
createCQ(num, false);
}
- private void createCQ(Integer num, Boolean isDurable) throws CqException, CqExistsException {
+ private void createCQ(int num, boolean isDurable) throws CqException, CqExistsException {
for (int i = 0; i < num; i++) {
- QueryService cqService = SecurityTestUtil.proxyCaches[i].getQueryService();
+ QueryService cqService = SecurityTestUtil.getProxyCaches(i).getQueryService();
String cqName = "CQ_" + i;
- String queryStr = cqNameToQueryStrings.get(cqName) + SecurityTestUtil.proxyCaches[i].getRegion(regionName).getFullPath();
+ String queryStr = cqNameToQueryStrings.get(cqName) + SecurityTestUtil.getProxyCaches(i).getRegion(regionName).getFullPath();
// Create CQ Attributes.
CqAttributesFactory cqf = new CqAttributesFactory();
@@ -284,7 +284,7 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
}
}
- private void executeCQ(Integer num, Boolean[] initialResults, Integer expectedResultsSize, String[] expectedErr) throws CqException, RegionNotFoundException {
+ private void executeCQ(int num, boolean[] initialResults, int expectedResultsSize, String[] expectedErr) throws CqException, RegionNotFoundException {
InternalLogWriter logWriter = InternalDistributedSystem.getStaticInternalLogWriter();
for (int i = 0; i < num; i++) {
@@ -295,8 +295,8 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
CqQuery cq1 = null;
String cqName = "CQ_" + i;
- String queryStr = cqNameToQueryStrings.get(cqName) + SecurityTestUtil.proxyCaches[i].getRegion(regionName).getFullPath();
- QueryService cqService = SecurityTestUtil.proxyCaches[i].getQueryService();
+ String queryStr = cqNameToQueryStrings.get(cqName) + SecurityTestUtil.getProxyCaches(i).getRegion(regionName).getFullPath();
+ QueryService cqService = SecurityTestUtil.getProxyCaches(i).getQueryService();
// Get CqQuery object.
cq1 = cqService.getCq(cqName);
@@ -318,8 +318,7 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
assertTrue("executeWithInitialResults() state mismatch", cq1
.getState().isRunning());
if (expectedResultsSize >= 0) {
- assertEquals("unexpected results size", expectedResultsSize
- .intValue(), cqResults.size());
+ assertEquals("unexpected results size", expectedResultsSize, cqResults.size());
}
} else {
@@ -350,9 +349,9 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
region.put("LAST_KEY", "LAST_KEY");
}
- private void waitForLastKey(Integer cqIndex, Boolean isCreate) {
+ private void waitForLastKey(int cqIndex, boolean isCreate) {
String cqName = "CQ_" + cqIndex;
- QueryService qService = SecurityTestUtil.proxyCaches[cqIndex].getQueryService();
+ QueryService qService = SecurityTestUtil.getProxyCaches(cqIndex).getQueryService();
ClientCQImpl cqQuery = (ClientCQImpl)qService.getCq(cqName);
if (isCreate) {
((CqQueryTestListener)cqQuery.getCqListeners()[cqIndex]).waitForCreated("LAST_KEY");
@@ -361,16 +360,16 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
}
}
- private void checkCQListeners(Integer numOfUsers,Boolean[] expectedListenerInvocation, Integer createEventsSize, Integer updateEventsSize) {
+ private void checkCQListeners(int numOfUsers, boolean[] expectedListenerInvocation, int createEventsSize, int updateEventsSize) {
for (int i = 0; i < numOfUsers; i++) {
String cqName = "CQ_" + i;
- QueryService qService = SecurityTestUtil.proxyCaches[i].getQueryService();
+ QueryService qService = SecurityTestUtil.getProxyCaches(i).getQueryService();
ClientCQImpl cqQuery = (ClientCQImpl)qService.getCq(cqName);
if (expectedListenerInvocation[i]) {
for (CqListener listener : cqQuery.getCqListeners()) {
- assertEquals(createEventsSize.intValue(), ((CqQueryTestListener)listener).getCreateEventCount());
- assertEquals(updateEventsSize.intValue(), ((CqQueryTestListener)listener).getUpdateEventCount());
+ assertEquals(createEventsSize, ((CqQueryTestListener)listener).getCreateEventCount());
+ assertEquals(updateEventsSize, ((CqQueryTestListener)listener).getUpdateEventCount());
}
} else {
@@ -381,19 +380,19 @@ public class MultiUserDurableCQAuthzDUnitTest extends ClientAuthorizationTestBas
}
}
- private void proxyCacheClose(Integer[] userIndices) {
+ private void proxyCacheClose(int[] userIndices) {
proxyCacheClose(userIndices, null);
}
- private void proxyCacheClose(Integer[] userIndices, Boolean keepAliveFlags) {
+ private void proxyCacheClose(int[] userIndices, Boolean keepAliveFlags) {
if (keepAliveFlags != null) {
for (int i : userIndices) {
- SecurityTestUtil.proxyCaches[i].close(keepAliveFlags);
+ SecurityTestUtil.getProxyCaches(i).close(keepAliveFlags);
}
} else {
for (int i : userIndices) {
- SecurityTestUtil.proxyCaches[i].close();
+ SecurityTestUtil.getProxyCaches(i).close();
}
}
}