Search in sources :

Example 46 with CqException

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);
}
Also used : PoolFactory(org.apache.geode.cache.client.PoolFactory) CacheSerializableRunnable(org.apache.geode.cache30.CacheSerializableRunnable) CacheException(org.apache.geode.cache.CacheException) VM(org.apache.geode.test.dunit.VM) Host(org.apache.geode.test.dunit.Host) CqExistsException(org.apache.geode.cache.query.CqExistsException) CqException(org.apache.geode.cache.query.CqException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) RegionNotFoundException(org.apache.geode.cache.query.RegionNotFoundException) CacheException(org.apache.geode.cache.CacheException) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) Test(org.junit.Test)

Aggregations

CqException (org.apache.geode.cache.query.CqException)46 CacheException (org.apache.geode.cache.CacheException)20 RegionNotFoundException (org.apache.geode.cache.query.RegionNotFoundException)20 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)20 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)16 Test (org.junit.Test)16 CqExistsException (org.apache.geode.cache.query.CqExistsException)15 QueryService (org.apache.geode.cache.query.QueryService)14 CqClosedException (org.apache.geode.cache.query.CqClosedException)12 ClientSubscriptionTest (org.apache.geode.test.junit.categories.ClientSubscriptionTest)9 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)9 IOException (java.io.IOException)8 List (java.util.List)8 CqQuery (org.apache.geode.cache.query.CqQuery)8 DefaultQueryService (org.apache.geode.cache.query.internal.DefaultQueryService)8 CqService (org.apache.geode.cache.query.internal.cq.CqService)8 Set (java.util.Set)7 CqAttributesFactory (org.apache.geode.cache.query.CqAttributesFactory)7 QueryException (org.apache.geode.cache.query.QueryException)7 InternalCqQuery (org.apache.geode.cache.query.internal.cq.InternalCqQuery)7