use of org.apache.geode.cache.client.ClientCacheFactory in project geode by apache.
the class OnGroupsFunctionExecutionDUnitTest method testClientServerException.
@Test
public void testClientServerException() {
Host host = Host.getHost(0);
VM server0 = host.getVM(0);
VM server1 = host.getVM(1);
VM server2 = host.getVM(2);
VM client = host.getVM(3);
VM locator = Host.getLocator();
final String regionName = getName();
initVM(server0, "mg,g0", regionName, true);
initVM(server1, "g1", regionName, true);
initVM(server2, "g0,g1,g2", regionName, true);
final int locatorPort = getLocatorPort(locator);
final String hostName = host.getHostName();
client.invoke(new SerializableCallable() {
@Override
public Object call() throws Exception {
try {
Cache c = CacheFactory.getAnyInstance();
c.close();
} catch (CacheClosedException cce) {
}
disconnectFromDS();
LogWriterUtils.getLogWriter().fine("SWAP:creating client cache");
ClientCacheFactory ccf = new ClientCacheFactory();
ccf.addPoolLocator(hostName, locatorPort);
ccf.setPoolServerGroup("mg");
ccf.set(LOG_LEVEL, LogWriterUtils.getDUnitLogLevel());
ClientCache c = ccf.create();
IgnoredException expected = IgnoredException.addIgnoredException("No member found");
try {
InternalFunctionService.onServers(c, "no such group").execute(new OnGroupsFunction()).getResult();
fail("expected exception not thrown");
} catch (FunctionException e) {
} finally {
expected.remove();
}
IgnoredException.addIgnoredException("NullPointerException");
Execution e = InternalFunctionService.onServers(c, "mg");
ArrayList<String> args = new ArrayList<String>();
args.add("runtime");
e = e.setArguments(args);
try {
e.execute(new OnGroupsExceptionFunction()).getResult();
fail("expected exception not thrown");
} catch (FunctionException ex) {
assertTrue(ex.getCause() instanceof NullPointerException);
}
Execution e1 = InternalFunctionService.onServers(c, "g1");
e1 = e1.setArguments(args);
try {
e1.execute(new OnGroupsExceptionFunction()).getResult();
fail("expected exception not thrown");
} catch (FunctionException ex) {
assertTrue(ex.getCause() instanceof NullPointerException);
}
// only one member
Execution e2 = InternalFunctionService.onServers(c, "g1");
args.add("g2");
e2 = e2.setArguments(args);
try {
e2.execute(new OnGroupsExceptionFunction()).getResult();
fail("expected exception not thrown");
} catch (FunctionException ex) {
assertTrue(ex.getCause() instanceof NullPointerException);
}
return null;
}
});
}
use of org.apache.geode.cache.client.ClientCacheFactory in project geode by apache.
the class MainWithChildrenRollingFileHandlerDUnitTest method testGeode2874_nameWithoutExtensionDoesNotThrowOnMemberRestart.
@Test
public void testGeode2874_nameWithoutExtensionDoesNotThrowOnMemberRestart() throws Exception {
MemberVM<Locator> locatorVM = locatorServerStartupRule.startLocatorVM(0);
ClientCacheFactory clientCacheFactory = new ClientCacheFactory();
clientCacheFactory.addPoolLocator(InetAddress.getLocalHost().toString(), locatorVM.getPort());
clientCacheFactory.set(LOG_FILE, "nameWithoutExtension");
ClientCache clientCache = clientCacheFactory.create();
clientCache.close();
ClientCache clientCache2 = clientCacheFactory.create();
}
Aggregations