Search in sources :

Example 11 with CqQueryTestListener

use of org.apache.geode.cache.query.cq.dunit.CqQueryTestListener in project geode by apache.

the class CQListGIIDUnitTest method createCQ.

/* Register CQs */
public static void createCQ(String cqName, String queryStr) {
    org.apache.geode.test.dunit.LogWriterUtils.getLogWriter().info("### Create CQ. ###" + cqName);
    // Get CQ Service.
    QueryService cqService = null;
    try {
        cqService = cache.getQueryService();
    } catch (Exception cqe) {
        Assert.fail("Failed to getCQService.", cqe);
    }
    // Create CQ Attributes.
    CqAttributesFactory cqf = new CqAttributesFactory();
    CqListener[] cqListeners = { new CqQueryTestListener(org.apache.geode.test.dunit.LogWriterUtils.getLogWriter()) };
    ((CqQueryTestListener) cqListeners[0]).cqName = cqName;
    cqf.initCqListeners(cqListeners);
    CqAttributes cqa = cqf.create();
    // Create CQ.
    try {
        CqQuery cq1 = cqService.newCq(cqName, queryStr, cqa);
        assertTrue("newCq() state mismatch", cq1.getState().isStopped());
    } catch (Exception ex) {
        fail("Failed to create CQ " + cqName + " . ", ex);
    }
}
Also used : CqQueryTestListener(org.apache.geode.cache.query.cq.dunit.CqQueryTestListener) QueryService(org.apache.geode.cache.query.QueryService) CqAttributes(org.apache.geode.cache.query.CqAttributes) CqListener(org.apache.geode.cache.query.CqListener) CqAttributesFactory(org.apache.geode.cache.query.CqAttributesFactory) CqQuery(org.apache.geode.cache.query.CqQuery) IOException(java.io.IOException) CacheException(org.apache.geode.cache.CacheException)

Aggregations

CqQueryTestListener (org.apache.geode.cache.query.cq.dunit.CqQueryTestListener)11 QueryService (org.apache.geode.cache.query.QueryService)10 CqAttributes (org.apache.geode.cache.query.CqAttributes)7 CqListener (org.apache.geode.cache.query.CqListener)7 CqQuery (org.apache.geode.cache.query.CqQuery)7 CqAttributesFactory (org.apache.geode.cache.query.CqAttributesFactory)6 CacheException (org.apache.geode.cache.CacheException)5 IOException (java.io.IOException)3 Region (org.apache.geode.cache.Region)3 SelectResults (org.apache.geode.cache.query.SelectResults)3 Struct (org.apache.geode.cache.query.Struct)3 TestObject (org.apache.geode.cache.query.dunit.PdxQueryCQTestBase.TestObject)3 ClientCQImpl (org.apache.geode.cache.query.internal.cq.ClientCQImpl)3 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)3 Host (org.apache.geode.test.dunit.Host)3 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)3 VM (org.apache.geode.test.dunit.VM)3 ClientSubscriptionTest (org.apache.geode.test.junit.categories.ClientSubscriptionTest)3 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)3 SerializationTest (org.apache.geode.test.junit.categories.SerializationTest)3