use of org.apache.geode.cache.query.CqException in project geode by apache.
the class CqDataUsingPoolDUnitTest method testCQWithEstablishCallBackConnection.
/**
* Test for CQ with establishCallBackConnection.
*/
@Test
public void testCQWithEstablishCallBackConnection() throws Exception {
final Host host = Host.getHost(0);
VM server1 = host.getVM(0);
VM client = host.getVM(1);
cqDUnitTest.createServer(server1, 0, false, MirrorType.KEYS_VALUES);
final int port1 = server1.invoke(() -> CqQueryUsingPoolDUnitTest.getCacheServerPort());
final String serverHost = NetworkUtils.getServerHostName(server1.getHost());
final String poolName = "testCQWithEstablishCallBackConnection";
client.invoke(new CacheSerializableRunnable("createPool :" + poolName) {
@Override
public void run2() throws CacheException {
// Create Cache.
getCache();
PoolFactory cpf = PoolManager.createFactory();
cpf.setSubscriptionEnabled(false);
cpf.addServer(serverHost, port1);
cpf.create(poolName);
}
});
// Create CQs.
cqDUnitTest.createCQ(client, poolName, "testCQWithEstablishCallBackConnection_0", cqDUnitTest.cqs[0]);
// This should fail.
try {
cqDUnitTest.executeCQ(client, "testCQWithEstablishCallBackConnection_0", false, "CqException");
fail("Test should have failed with connection with establishCallBackConnection not found.");
} catch (Exception expected) {
// Expected.
}
// Close.
cqDUnitTest.closeClient(client);
cqDUnitTest.closeServer(server1);
}
Aggregations