use of org.apache.geode.cache.client.NoAvailableServersException in project geode by apache.
the class SecurityTestUtils method doContainsKeysP.
private static void doContainsKeysP(final int num, final int multiUserIndex, final int expectedResult, final boolean expectedValue) {
assertTrue(num <= KEYS.length);
Region region = null;
try {
if (multiUserAuthMode) {
region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
} else {
region = getCache().getRegion(REGION_NAME);
}
assertNotNull(region);
} catch (Exception ex) {
if (expectedResult == OTHER_EXCEPTION) {
getLogWriter().info("Got expected exception when doing containsKey: " + ex);
} else {
fail("Got unexpected exception when doing containsKey", ex);
}
}
for (int index = 0; index < num; ++index) {
boolean result = false;
try {
result = region.containsKeyOnServer(KEYS[index]);
if (expectedResult != NO_EXCEPTION) {
fail("Expected a NotAuthorizedException while doing containsKey");
}
} catch (NoAvailableServersException ex) {
if (expectedResult == NO_AVAILABLE_SERVERS) {
getLogWriter().info("Got expected NoAvailableServers when doing containsKey: " + ex.getCause());
continue;
} else {
fail("Got unexpected exception when doing containsKey", ex);
}
} catch (ServerConnectivityException ex) {
if ((expectedResult == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
getLogWriter().info("Got expected NotAuthorizedException when doing containsKey: " + ex.getCause());
continue;
} else if (expectedResult == OTHER_EXCEPTION) {
getLogWriter().info("Got expected exception when doing containsKey: " + ex);
} else {
fail("Got unexpected exception when doing containsKey", ex);
}
} catch (Exception ex) {
if (expectedResult == OTHER_EXCEPTION) {
getLogWriter().info("Got expected exception when doing containsKey: " + ex);
} else {
fail("Got unexpected exception when doing containsKey", ex);
}
}
assertEquals(expectedValue, result);
}
}
use of org.apache.geode.cache.client.NoAvailableServersException in project geode by apache.
the class SecurityTestUtils method doGetAllP.
private static void doGetAllP(final int multiUserIndex, final int expectedResult, final boolean useTX) {
Region region = null;
try {
if (multiUserAuthMode) {
region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
} else {
region = getCache().getRegion(REGION_NAME);
}
assertNotNull(region);
} catch (Exception ex) {
if (expectedResult == OTHER_EXCEPTION) {
getLogWriter().info("Got expected exception when doing getAll: " + ex);
} else {
fail("Got unexpected exception when doing getAll", ex);
}
}
try {
List keys = new ArrayList();
keys.add("key1");
keys.add("key2");
if (useTX) {
getCache().getCacheTransactionManager().begin();
}
Map entries = region.getAll(keys);
// Also check getEntry()
region.getEntry("key1");
if (useTX) {
getCache().getCacheTransactionManager().commit();
}
assertNotNull(entries);
if ((expectedResult == NOTAUTHZ_EXCEPTION)) {
assertEquals(0, entries.size());
} else if ((expectedResult == NO_EXCEPTION)) {
assertEquals(2, entries.size());
assertEquals("value1", entries.get("key1"));
assertEquals("value2", entries.get("key2"));
}
} catch (NoAvailableServersException ex) {
if (expectedResult == NO_AVAILABLE_SERVERS) {
getLogWriter().info("Got expected NoAvailableServers when doing getAll: " + ex.getCause());
} else {
fail("Got unexpected exception when doing getAll", ex);
}
} catch (ServerConnectivityException ex) {
if ((expectedResult == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
getLogWriter().info("Got expected NotAuthorizedException when doing getAll: " + ex.getCause());
} else if (expectedResult == OTHER_EXCEPTION) {
getLogWriter().info("Got expected exception when doing getAll: " + ex);
} else {
fail("Got unexpected exception when doing getAll", ex);
}
} catch (Exception ex) {
if (expectedResult == OTHER_EXCEPTION) {
getLogWriter().info("Got expected exception when doing getAll: " + ex);
} else {
fail("Got unexpected exception when doing getAll", ex);
}
}
}
use of org.apache.geode.cache.client.NoAvailableServersException in project geode by apache.
the class SecurityTestUtils method doDestroysP.
private static void doDestroysP(final int num, final int multiUserIndex, final int expectedResult) {
assertTrue(num <= KEYS.length);
Region region = null;
try {
if (multiUserAuthMode) {
region = proxyCaches[multiUserIndex].getRegion(REGION_NAME);
} else {
region = getCache().getRegion(REGION_NAME);
}
assertNotNull(region);
} catch (Exception ex) {
if (expectedResult == OTHER_EXCEPTION) {
getLogWriter().info("Got expected exception when doing destroys: " + ex);
} else {
fail("Got unexpected exception when doing destroys", ex);
}
}
for (int index = 0; index < num; ++index) {
try {
region.destroy(KEYS[index]);
if (expectedResult != NO_EXCEPTION) {
fail("Expected a NotAuthorizedException while doing destroys");
}
} catch (NoAvailableServersException ex) {
if (expectedResult == NO_AVAILABLE_SERVERS) {
getLogWriter().info("Got expected NoAvailableServers when doing destroys: " + ex.getCause());
continue;
} else {
fail("Got unexpected exception when doing destroys", ex);
}
} catch (ServerConnectivityException ex) {
if ((expectedResult == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
getLogWriter().info("Got expected NotAuthorizedException when doing destroys: " + ex.getCause());
continue;
} else if (expectedResult == OTHER_EXCEPTION) {
getLogWriter().info("Got expected exception when doing destroys: " + ex);
} else {
fail("Got unexpected exception when doing destroys", ex);
}
} catch (Exception ex) {
if (expectedResult == OTHER_EXCEPTION) {
getLogWriter().info("Got expected exception when doing destroys: " + ex);
} else {
fail("Got unexpected exception when doing destroys", ex);
}
}
}
}
use of org.apache.geode.cache.client.NoAvailableServersException in project geode by apache.
the class SecurityTestUtils method doPutsP.
private static void doPutsP(final int num, final int multiUserIndex, final int expectedResult, final boolean newVals) {
assertTrue(num <= KEYS.length);
Region region = getRegion(multiUserIndex, expectedResult);
for (int index = 0; index < num; ++index) {
try {
if (newVals) {
region.put(KEYS[index], NVALUES[index]);
} else {
region.put(KEYS[index], VALUES[index]);
}
if (expectedResult != NO_EXCEPTION) {
fail("Expected a NotAuthorizedException while doing puts");
}
} catch (NoAvailableServersException ex) {
if (expectedResult == NO_AVAILABLE_SERVERS) {
getLogWriter().info("Got expected NoAvailableServers when doing puts: " + ex.getCause());
continue;
} else {
fail("Got unexpected exception when doing puts", ex);
}
} catch (ServerConnectivityException ex) {
if ((expectedResult == NOTAUTHZ_EXCEPTION) && (ex.getCause() instanceof NotAuthorizedException)) {
getLogWriter().info("Got expected NotAuthorizedException when doing puts: " + ex.getCause());
continue;
}
if ((expectedResult == AUTHREQ_EXCEPTION) && (ex.getCause() instanceof AuthenticationRequiredException)) {
getLogWriter().info("Got expected AuthenticationRequiredException when doing puts: " + ex.getCause());
continue;
}
if ((expectedResult == AUTHFAIL_EXCEPTION) && (ex.getCause() instanceof AuthenticationFailedException)) {
getLogWriter().info("Got expected AuthenticationFailedException when doing puts: " + ex.getCause());
continue;
} else if (expectedResult == OTHER_EXCEPTION) {
getLogWriter().info("Got expected exception when doing puts: " + ex);
} else {
fail("Got unexpected exception when doing puts", ex);
}
} catch (Exception ex) {
if (expectedResult == OTHER_EXCEPTION) {
getLogWriter().info("Got expected exception when doing puts: " + ex);
} else {
fail("Got unexpected exception when doing puts", ex);
}
}
}
}
Aggregations